Package com.jalios.jcms.security
Class JwtManager
java.lang.Object
com.jalios.jcms.security.JwtManager
- All Implemented Interfaces:
JPropertiesListener
-
Method Summary
Modifier and TypeMethodDescriptionorg.jose4j.jwt.JwtClaimsgenerateDefaultClaims(Member mbr, String issuer, float expiration) generate default claimsorg.jose4j.jwt.JwtClaimsgenerateDefaultClaims(Member mbr, String issuer, float expiration, String url, Integer prefixLength, List<String> methodList, String ipMask) Generate default claimsorg.jose4j.jwt.JwtClaimsgenerateDefaultClaims(Member mbr, String issuer, String url, AccessTokenOptions options) Generated the default JWT claims for the specified optionsorg.jose4j.jwt.JwtClaimsgenerateDefaultClaims(String mbrLoginOrId, String issuer, String url, AccessTokenOptions options) Generated the default JWT claims for the specified optionsgenerateToken(PrivateKey key, Member mbr, String issuer, float expiration, String url, Integer prefixLength, List<String> methodList, String ipMask) Generate a JWT token using default claims.generateToken(org.jose4j.jwt.JwtClaims claims, File privateKeyFile, String password) Generate a JWT tokengenerateToken(org.jose4j.jwt.JwtClaims claims, PrivateKey key) Generate a JWT tokengenerateToken(org.jose4j.jwt.JwtClaims claims, PrivateKey key, PublicKey receiverKey) Generate an encrypted JWT tokenstatic JwtManagervoidpropertiesChange(JProperties properties) Invoked after properties have been modified in JCMS and save on disk.org.jose4j.jwt.JwtClaimsRead a token against the provided publicKey
-
Method Details
-
getInstance
-
propertiesChange
Description copied from interface:JPropertiesListenerInvoked after properties have been modified in JCMS and save on disk.You cannot alter the value received in parameters.
Note that properties parameter may be null, a limited set of site properties, or all site properties.
To check that a property has been modified, reload the "current" property instead using
channel.getPropertiesorchannel.getProperty.- Specified by:
propertiesChangein interfaceJPropertiesListener- Parameters:
properties- the properties which have been submitted to change
-
readToken
Read a token against the provided publicKey- Parameters:
token- the JWT tokenkey- the public Key- Returns:
- the
JwtClaimsis token can be read and if it 's valid, null otherwise
-
generateToken
public String generateToken(org.jose4j.jwt.JwtClaims claims, File privateKeyFile, String password) throws org.jose4j.lang.JoseException Generate a JWT token- Parameters:
claims- the claimsprivateKeyFile- thePrivateKeyfile to encrypt withpassword- the password of thePrivateKey- Returns:
- the JWT token
- Throws:
org.jose4j.lang.JoseException- thrown if the token cannot be generated
-
generateToken
public String generateToken(org.jose4j.jwt.JwtClaims claims, PrivateKey key) throws org.jose4j.lang.JoseException Generate a JWT token- Parameters:
claims- the claimskey- thePrivateKeyfile to encrypt with- Returns:
- the JWT token
- Throws:
org.jose4j.lang.JoseException- thrown if the token cannot be generated
-
generateToken
public String generateToken(PrivateKey key, Member mbr, String issuer, float expiration, String url, Integer prefixLength, List<String> methodList, String ipMask) throws org.jose4j.lang.JoseException Generate a JWT token using default claims.- Parameters:
key- thePrivateKeyfile to encrypt withmbr- theMemberas subjectissuer- the issuer of the JWT Claimsexpiration- the expiration duration in minutesurl- the url to checkprefixLength- the length of the prefixmethodList- theListof authorized (not null and non empty if the check must be done)ipMask- the ipMask (a regex) id the ip check must be done- Returns:
- the JWT token
- Throws:
org.jose4j.lang.JoseException- thrown if the token cannot be generated
-
generateToken
public String generateToken(org.jose4j.jwt.JwtClaims claims, PrivateKey key, PublicKey receiverKey) throws org.jose4j.lang.JoseException Generate an encrypted JWT token- Parameters:
claims- the claimskey- thePrivateKeyfile to encrypt withreceiverKey- thePublicKeyof the receiver- Returns:
- the JWT token
- Throws:
org.jose4j.lang.JoseException- thrown if the token cannot be generated
-
generateDefaultClaims
generate default claims- Parameters:
mbr- theMemberas subjectissuer- the issuer of the JWT Claimsexpiration- the expiration duration in minutes- Returns:
- the
JwtClaims
-
generateDefaultClaims
public org.jose4j.jwt.JwtClaims generateDefaultClaims(Member mbr, String issuer, float expiration, String url, Integer prefixLength, List<String> methodList, String ipMask) Generate default claims- Parameters:
mbr- theMemberas subjectissuer- the issuer of the JWT Claimsexpiration- the expiration duration in minutesurl- the url to checkprefixLength- the length of the prefixmethodList- theListof authorized (not null and non empty if the check must be done)ipMask- (a regex) id the ip check must be done- Returns:
- the
JwtClaims
-
generateDefaultClaims
public org.jose4j.jwt.JwtClaims generateDefaultClaims(Member mbr, String issuer, String url, AccessTokenOptions options) Generated the default JWT claims for the specified options- Parameters:
mbr- theMemberas subjectissuer- the issuer of the JWT Claims (usually the channel name)url- the url to checkoptions- the token options MUST NOT be null- Returns:
- a new JwtClaims
- Since:
- 10.0.8 / JCMS-4770
-
generateDefaultClaims
public org.jose4j.jwt.JwtClaims generateDefaultClaims(String mbrLoginOrId, String issuer, String url, AccessTokenOptions options) Generated the default JWT claims for the specified options- Parameters:
mbrLoginOrId- theMemberlogin or id, used as Claims subject, must not be null nor emptyissuer- the issuer of the JWT Claims (usually the channel name)url- the url to checkoptions- the token options MUST NOT be null- Returns:
- a new JwtClaims
- Since:
- 10.0.8 / JCMS-10606
-