private < T > CompletionStage < T > regex ( final Http . RequestHeader requestHeader , final DeadboltHandler deadboltHandler , final Optional < String > content , final String [ ] values , final int valueIndex , final ConstraintMode mode , final boolean invert , final Function < Http . RequestHeader , CompletionStage < T > > pass , final TriFunction < Http . RequestHeader , DeadboltHandler , Optional < String > , CompletionStage < T > > fail , final ConstraintPoint constraintPoint ) { return CompletableFuture . completedFuture ( patternCache . apply ( values [ valueIndex ] ) ) . thenCombine ( getSubject ( requestHeader , deadboltHandler ) , ( patternValue , subject ) -> F . Tuple ( subject . _1 . isPresent ( ) ? analyzer . checkRegexPattern ( subject . _1 , Optional . ofNullable ( patternValue ) ) : invert , subject . _2 ) ) // this is a little clumsy - it means no subject + invert is still denied . thenCompose ( hasPassed -> ( invert ? ! hasPassed . _1 : hasPassed . _1 ) ? ( successCallAgain ( mode , values , valueIndex ) ? regex ( hasPassed . _2 , deadboltHandler , content , values , valueIndex + 1 , mode , invert , pass , fail , constraintPoint ) : pass ( hasPassed . _2 , deadboltHandler , pass , constraintPoint , "pattern - regex" ) ) : ( failCallAgain ( mode , values , valueIndex ) ? regex ( hasPassed . _2 , deadboltHandler , content , values , valueIndex + 1 , mode , invert , pass , fail , constraintPoint ) : fail . apply ( hasPassed . _2 , deadboltHandler , content ) ) ) ; }
Checks access to the resource based on the regex