public Set < Auth > createAuthsFromString ( String authInfo ) { if ( "" . equals ( authInfo ) || authInfo == null ) return Collections . emptySet ( ) ; String [ ] parts = authInfo . split ( "," ) ; final Set < Auth > auths = new HashSet < Auth > ( ) ; try { for ( String auth : parts ) { StringTokenizer tokenizer = new StringTokenizer ( auth , ":" ) ; while ( tokenizer . hasMoreTokens ( ) ) { auths . add ( new Auth ( tokenizer . nextToken ( ) , tokenizer . nextToken ( ) , tokenizer . nextToken ( ) , tokenizer . nextToken ( ) ) ) ; } } return auths ; } catch ( NoSuchElementException e ) { final StringBuilder b = new StringBuilder ( ) ; for ( String auth : parts ) { b . append ( auth ) ; } throw new IllegalArgumentException ( "Auth configuration is configured wrongly:" + b . toString ( ) , e ) ; } }
Create a auth object from a String looking like .