public static Authentication build ( String crypt ) throws IllegalArgumentException { if ( crypt == null ) { return new PlainAuth ( null ) ; } String [ ] value = crypt . split ( ":" ) ; if ( value . length == 2 ) { String type = value [ 0 ] . trim ( ) ; String password = value [ 1 ] . trim ( ) ; if ( password != null && password . length ( ) > 0 ) { if ( "plain" . equals ( type ) ) { return new PlainAuth ( password ) ; } if ( "md5" . equals ( type ) ) { return new Md5Auth ( password ) ; } if ( "crc32" . equals ( type ) ) { return new Crc32Auth ( Long . parseLong ( password ) ) ; } } } throw new IllegalArgumentException ( "error password: " + crypt ) ; }
build an Authentication .