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 Details

    • CLAIM_USERNAME

      private static final String CLAIM_USERNAME
      Username claim property name in the JWT.
      See Also:
    • CLAIM_SECURITY_LEVEL

      private static final String CLAIM_SECURITY_LEVEL
      Security level claim property in the JWT.
      See Also:
    • CLAIM_ACCESS_ROLE

      private static final String CLAIM_ACCESS_ROLE
      Access role claim property in the JWT.
      See Also:
    • CLAIM_COMPANY_ID

      private static final String CLAIM_COMPANY_ID
      Company Id claimp roperty in the JWT.
      See Also:
    • CLAIM_CUSTOMER_ID

      private static final String CLAIM_CUSTOMER_ID
      Customer identifier claim property in the JWT.
      See Also:
    • CLAIM_CHANNEL

      private static final String CLAIM_CHANNEL
      Channel claim property in the JWT.
      See Also:
    • CLAIM_DEVICE_ID

      private static final String CLAIM_DEVICE_ID
      Device identifier claim property im the JWT.
      See Also:
    • CLAIM_COMPANY_IDENTIFIER

      private static final String CLAIM_COMPANY_IDENTIFIER
      Company identifier on db claim property im the JWT.
      See Also:
    • privateKeyStoreUrl

      @Value("${jwt.keystores.private.store}") private String privateKeyStoreUrl
      JWT private key for token signing.
    • privateKeyAlias

      @Value("${jwt.keystores.private.keyalias}") private String privateKeyAlias
      JWT private key alias.
    • privateKeyPassword

      @Value("${jwt.keystores.private.keypass}") private String privateKeyPassword
      JWT private key password.
    • privateKeyStorePassword

      @Value("${jwt.keystores.private.storepass}") private String privateKeyStorePassword
      JWT private key store password.
    • publicKeyStoreUrl

      @Value("${jwt.keystores.public.store}") private String publicKeyStoreUrl
      JWT public key for token validation.
    • publicKeyAlias

      @Value("${jwt.keystores.public.keyalias}") private String publicKeyAlias
      JWT public key alias.
    • publicKeyStorePassword

      @Value("${jwt.keystores.public.storepass}") private String publicKeyStorePassword
      JWT private key password.
    • iss

      @Value("${jwt.claims.iss}") private String iss
      JWT issuer claim, used to validate received JWT.
    • aud

      @Value("${jwt.claims.aud}") private String aud
      JWT audience claim, used to validate received JWT.
    • expirationAmount

      @Value("${jwt.expiration.amount}") private long expirationAmount
      JWT expiration amount.
    • expirationAmountUnit

      @Value("${jwt.expiration.amount-unit}") private ChronoUnit expirationAmountUnit
      JWT expiration amount.
    • publicKey

      private PublicKey publicKey
      JWT Signing key (public part), used to verify JWT signatures.
  • Constructor Details

    • JwtServiceImpl

      public JwtServiceImpl()
  • Method Details

    • getAud

      public String getAud()
      Retrieve the audience sentence used to create and validate tokens.
      Returns:
      audience.
    • setAud

      public void setAud(String aud)
      Modify the audience sentence used to create and validate tokens.
      Parameters:
      aud - the audience to set.
    • getIss

      public String getIss()
      Retrieve the issuer used to create and validate tokens.
      Returns:
      issuer.
    • setIss

      public void setIss(String iss)
      Modify the issuer used to create and validate tokens.
      Parameters:
      iss - the issuer to set.
    • validateAuthentication

      public WalletAuthenticationJwtImpl validateAuthentication(String jwt)
      Description copied from interface: JwtService
      Check if the given javascript web token is valid.
      Specified by:
      validateAuthentication in interface JwtService
      Parameters:
      jwt - valid signed JWT.
      Returns:
      a spring authentication token if valid, null in other case
    • createJwtFromSpec

      public String createJwtFromSpec(JwtBearerToken token)
      Description copied from interface: JwtService
      Create a new JWT.
      Specified by:
      createJwtFromSpec in interface JwtService
      Parameters:
      token - JWT details. The token ID, if missing, is generated (UUID).
      Returns:
      a new signed JWT.
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • extractJwtDetails

      private JwtBearerToken extractJwtDetails(String token)
      Extract claims details from the given JWT.
      Parameters:
      token - a valid, signed, JWT.
      Returns:
      a new object with the given JWT details.