public static Result parse ( String pAuthInfo ) { StringTokenizer stok = new StringTokenizer ( pAuthInfo ) ; String method = stok . nextToken ( ) ; if ( ! HttpServletRequest . BASIC_AUTH . equalsIgnoreCase ( method ) ) { throw new IllegalArgumentException ( "Only BasicAuthentication is supported" ) ; } String b64Auth = stok . nextToken ( ) ; String auth = new String ( Base64Util . decode ( b64Auth ) ) ; int p = auth . indexOf ( ' ' ) ; String user ; String password ; boolean valid ; if ( p != - 1 ) { user = auth . substring ( 0 , p ) ; password = auth . substring ( p + 1 ) ; valid = true ; } else { valid = false ; user = null ; password = null ; } return new Result ( method , user , password , valid ) ; }
Parse the HTTP authorization header