public String authenticateBASIC ( final HttpServletRequest request ) { LOG . debug ( "authenticateBASIC" ) ; boolean valid = false ; String userID = null ; String password = null ; try { final String authHeader = request . getHeader ( "Authorization" ) ; if ( authHeader != null ) { final StringTokenizer st = new StringTokenizer ( authHeader ) ; if ( st . hasMoreTokens ( ) ) { final String basic = st . nextToken ( ) ; if ( basic . equalsIgnoreCase ( "Basic" ) ) { final String credentials = st . nextToken ( ) ; final String userPass = new String ( Base64 . decodeBase64 ( credentials . getBytes ( ) ) ) ; final int p = userPass . indexOf ( ":" ) ; if ( p != - 1 ) { userID = userPass . substring ( 0 , p ) ; password = userPass . substring ( p + 1 ) ; // Validate the User. valid = validateUser ( userID , password ) ; } } } } } catch ( final Exception e ) { LOG . debug ( "An error occured while processing Basic authentication" , e ) ; } if ( valid ) { // For now assume userID as userName return userID ; } return null ; }
BASIC authentication .