@ SuppressWarnings ( "PMD.AvoidLiteralsInIfCondition" ) public Token getAuthorizationToken ( final ContainerRequest request ) { String authorizationString = request . getHeaderString ( "Authorization" ) ; if ( authorizationString != null && ! "" . equals ( authorizationString ) ) { authorizationString = authorizationString . trim ( ) ; final String [ ] components = authorizationString . split ( "\\s" ) ; if ( components . length != 2 ) { throw new NotAuthorizedException ( authenticationType ) ; } final String scheme = components [ 0 ] ; if ( ! authenticationType . equalsIgnoreCase ( scheme ) ) { throw new NotAuthorizedException ( authenticationType ) ; } final String tokenString = components [ 1 ] ; return Token . fromString ( tokenString ) ; } return null ; }
Extract a Fernet token from an RFC6750 Authorization header .