Class KnoxService
java.lang.Object
org.apache.nifi.web.security.knox.KnoxService
KnoxService is a service for managing the Apache Knox SSO.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate KnoxConfigurationprivate Stringprivate static final org.slf4j.Loggerprivate com.nimbusds.jose.JWSVerifier -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExtracts the authentication from the token and verify it.Returns the Knox Url.booleanReturns whether Knox support is enabled.private booleanvalidateAudience(com.nimbusds.jwt.SignedJWT jwtToken) Validate the jwt audience.private booleanvalidateExpiration(com.nimbusds.jwt.SignedJWT jwtToken) Validate the jwt expiration.private booleanvalidateSignature(com.nimbusds.jwt.SignedJWT jwtToken) Validate the jwt signature.private booleanvalidateToken(com.nimbusds.jwt.SignedJWT jwtToken) Validate the specified jwt.
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
configuration
-
verifier
private com.nimbusds.jose.JWSVerifier verifier -
knoxUrl
-
audiences
-
-
Constructor Details
-
KnoxService
Creates a new KnoxService.- Parameters:
configuration- knox configuration
-
-
Method Details
-
isKnoxEnabled
public boolean isKnoxEnabled()Returns whether Knox support is enabled.- Returns:
- whether Knox support is enabled
-
getKnoxUrl
Returns the Knox Url.- Returns:
- knox url
-
getAuthenticationFromToken
public String getAuthenticationFromToken(String jwt) throws ParseException, com.nimbusds.jose.JOSEException Extracts the authentication from the token and verify it.- Parameters:
jwt- signed jwt string- Returns:
- the user authentication
- Throws:
ParseException- if the payload of the jwt doesn't represent a valid json object and a jwt claims setcom.nimbusds.jose.JOSEException- if the JWS object couldn't be verified
-
validateToken
private boolean validateToken(com.nimbusds.jwt.SignedJWT jwtToken) throws com.nimbusds.jose.JOSEException, ParseException Validate the specified jwt.- Parameters:
jwtToken- knox jwt- Returns:
- whether this jwt is valid
- Throws:
com.nimbusds.jose.JOSEException- if the jws object couldn't be verifiedParseException- if the payload of the jwt doesn't represent a valid json object and a jwt claims set
-
validateSignature
private boolean validateSignature(com.nimbusds.jwt.SignedJWT jwtToken) throws com.nimbusds.jose.JOSEException Validate the jwt signature.- Parameters:
jwtToken- knox jwt- Returns:
- whether this jwt signature is valid
- Throws:
com.nimbusds.jose.JOSEException- if the jws object couldn't be verified
-
validateAudience
Validate the jwt audience.- Parameters:
jwtToken- knox jwt- Returns:
- whether this jwt audience is valid
- Throws:
ParseException- if the payload of the jwt doesn't represent a valid json object and a jwt claims set
-
validateExpiration
Validate the jwt expiration.- Parameters:
jwtToken- knox jwt- Returns:
- whether this jwt is not expired
- Throws:
ParseException- if the payload of the jwt doesn't represent a valid json object and a jwt claims set
-