Class JwtServiceImpl
java.lang.Object
es.kukenan.smartfi.common.service.jwt.JwtServiceImpl
- All Implemented Interfaces:
JwtService,org.springframework.beans.factory.InitializingBean
@RefreshScope
@Component
public class JwtServiceImpl
extends Object
implements JwtService, org.springframework.beans.factory.InitializingBean
JWT services implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringJWT audience claim, used to validate received JWT.private static final StringAccess role claim property in the JWT.private static final StringChannel claim property in the JWT.private static final StringCompany Id claimp roperty in the JWT.private static final StringCompany identifier on db claim property im the JWT.private static final StringCustomer identifier claim property in the JWT.private static final StringDevice identifier claim property im the JWT.private static final StringSecurity level claim property in the JWT.private static final StringUsername claim property name in the JWT.private longJWT expiration amount.private ChronoUnitJWT expiration amount.private StringJWT issuer claim, used to validate received JWT.private StringJWT private key alias.private StringJWT private key password.private StringJWT private key store password.private StringJWT private key for token signing.private PublicKeyJWT Signing key (public part), used to verify JWT signatures.private StringJWT public key alias.private StringJWT private key password.private StringJWT public key for token validation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateJwtFromSpec(JwtBearerToken token) Create a new JWT.private JwtBearerTokenextractJwtDetails(String token) Extract claims details from the given JWT.getAud()Retrieve the audience sentence used to create and validate tokens.getIss()Retrieve the issuer used to create and validate tokens.voidModify the audience sentence used to create and validate tokens.voidModify the issuer used to create and validate tokens.Check if the given javascript web token is valid.
-
Field Details
-
CLAIM_USERNAME
Username claim property name in the JWT.- See Also:
-
CLAIM_SECURITY_LEVEL
Security level claim property in the JWT.- See Also:
-
CLAIM_ACCESS_ROLE
Access role claim property in the JWT.- See Also:
-
CLAIM_COMPANY_ID
Company Id claimp roperty in the JWT.- See Also:
-
CLAIM_CUSTOMER_ID
Customer identifier claim property in the JWT.- See Also:
-
CLAIM_CHANNEL
Channel claim property in the JWT.- See Also:
-
CLAIM_DEVICE_ID
Device identifier claim property im the JWT.- See Also:
-
CLAIM_COMPANY_IDENTIFIER
Company identifier on db claim property im the JWT.- See Also:
-
privateKeyStoreUrl
JWT private key for token signing. -
privateKeyAlias
JWT private key alias. -
privateKeyPassword
JWT private key password. -
privateKeyStorePassword
JWT private key store password. -
publicKeyStoreUrl
JWT public key for token validation. -
publicKeyAlias
JWT public key alias. -
publicKeyStorePassword
JWT private key password. -
iss
JWT issuer claim, used to validate received JWT. -
aud
JWT audience claim, used to validate received JWT. -
expirationAmount
@Value("${jwt.expiration.amount}") private long expirationAmountJWT expiration amount. -
expirationAmountUnit
JWT expiration amount. -
publicKey
JWT Signing key (public part), used to verify JWT signatures.
-
-
Constructor Details
-
JwtServiceImpl
public JwtServiceImpl()
-
-
Method Details
-
getAud
Retrieve the audience sentence used to create and validate tokens.- Returns:
- audience.
-
setAud
Modify the audience sentence used to create and validate tokens.- Parameters:
aud- the audience to set.
-
getIss
Retrieve the issuer used to create and validate tokens.- Returns:
- issuer.
-
setIss
Modify the issuer used to create and validate tokens.- Parameters:
iss- the issuer to set.
-
validateAuthentication
Description copied from interface:JwtServiceCheck if the given javascript web token is valid.- Specified by:
validateAuthenticationin interfaceJwtService- Parameters:
jwt- valid signed JWT.- Returns:
- a spring authentication token if valid, null in other case
-
createJwtFromSpec
Description copied from interface:JwtServiceCreate a new JWT.- Specified by:
createJwtFromSpecin interfaceJwtService- Parameters:
token- JWT details. The token ID, if missing, is generated (UUID).- Returns:
- a new signed JWT.
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
extractJwtDetails
Extract claims details from the given JWT.- Parameters:
token- a valid, signed, JWT.- Returns:
- a new object with the given JWT details.
-