public boolean init ( String s1 ) { if ( s1 == null ) { Tr . error ( tc , "AUTH_FILTER_INIT_NULL_STRING" ) ; return false ; } //break up conditions around semicolon StringTokenizer st1 = new StringTokenizer ( s1 , ";" ) ; StringTokenizer st2 = null ; String s2 = null ; while ( st1 . hasMoreTokens ( ) ) { s2 = st1 . nextToken ( ) ; //break up individual condition based on its three parts st2 = new StringTokenizer ( s2 , "^=!<>%" ) ; //first token is the HTTP header name String key = st2 . nextToken ( ) ; if ( ! st2 . hasMoreTokens ( ) ) { Tr . error ( tc , "AUTH_FILTER_MALFORMED_CONDITION" , new Object [ ] { s1 , s2 , null } ) ; return false ; // if no second token we have a problem } //second token is the value String valueString = st2 . nextToken ( ) ; // between the tokens there is the operand String operand = s2 . substring ( key . length ( ) , s2 . length ( ) - valueString . length ( ) ) . trim ( ) ; //IP addresses are special boolean ipAddress = false ; if ( REMOTE_ADDRESS . equals ( key ) ) ipAddress = true ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Adding " + key + " " + operand + " " + valueString ) ; } //This is awful but existing api doesn't allow for an exception // So, I have the throw a runtimeexception if I can't parse the condition try { ICondition condition = makeConditionWithSymbolOperand ( key , operand , valueString , ipAddress ) ; filterCondition . add ( condition ) ; } catch ( FilterException e ) { throw new RuntimeException ( e ) ; } } return true ; }
Pass the filter string so the implementation can read any of the properties