private String [ ] toNameConfigPair ( String token ) throws ConfigurationException { String [ ] pair = token . split ( "\\[" , 2 ) ; String name = StringUtils . clean ( pair [ 0 ] ) ; if ( name == null ) { throw new IllegalArgumentException ( "Filter name not found for filter chain definition token: " + token ) ; } String config = null ; if ( pair . length == 2 ) { config = StringUtils . clean ( pair [ 1 ] ) ; //if there was an open bracket, it assumed there is a closing bracket, so strip it too: config = config . substring ( 0 , config . length ( ) - 1 ) ; config = StringUtils . clean ( config ) ; //backwards compatibility prior to implementing SHIRO-205: //prior to SHIRO-205 being implemented, it was common for end-users to quote the config inside brackets //if that config required commas. We need to strip those quotes to get to the interior quoted definition //to ensure any existing quoted definitions still function for end users: if ( config != null && config . startsWith ( "\"" ) && config . endsWith ( "\"" ) ) { String stripped = config . substring ( 1 , config . length ( ) - 1 ) ; stripped = StringUtils . clean ( stripped ) ; //if the stripped value does not have any internal quotes, we can assume that the entire config was //quoted and we can use the stripped value. if ( stripped != null && stripped . indexOf ( ' ' ) == - 1 ) { config = stripped ; } //else: //the remaining config does have internal quotes, so we need to assume that each comma delimited //pair might be quoted, in which case we need the leading and trailing quotes that we stripped //So we ignore the stripped value. } } return new String [ ] { name , config } ; }
This method is copied from the same method in Shiro in class DefaultFilterChainManager .