Package com.jalios.jcms.security
Class JwtManager
- java.lang.Object
 - 
- com.jalios.jcms.security.JwtManager
 
 
- 
- All Implemented Interfaces:
 JPropertiesListener
public class JwtManager extends java.lang.Object implements JPropertiesListener
 
- 
- 
Field Summary
- 
Fields inherited from interface com.jalios.util.JPropertiesListener
REVISION 
 - 
 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jose4j.jwt.JwtClaimsgenerateDefaultClaims(Member mbr, java.lang.String issuer, float expiration)generate default claimsorg.jose4j.jwt.JwtClaimsgenerateDefaultClaims(Member mbr, java.lang.String issuer, float expiration, java.lang.String url, java.lang.Integer prefixLength, java.util.List<java.lang.String> methodList, java.lang.String ipMask)generate default claimsjava.lang.StringgenerateToken(java.security.PrivateKey key, Member mbr, java.lang.String issuer, float expiration, java.lang.String url, java.lang.Integer prefixLength, java.util.List<java.lang.String> methodList, java.lang.String ipMask)generate default claimsjava.lang.StringgenerateToken(org.jose4j.jwt.JwtClaims claims, java.io.File privateKeyFile, java.lang.String password)Generate a Jwt tokenjava.lang.StringgenerateToken(org.jose4j.jwt.JwtClaims claims, java.security.PrivateKey key)Generate a Jwt tokenjava.lang.StringgenerateToken(org.jose4j.jwt.JwtClaims claims, java.security.PrivateKey key, java.security.PublicKey receiverKey)Generate a encrypted Jwt tokenstatic JwtManagergetInstance()voidpropertiesChange(JProperties properties)Invoked after properties have been modified in JCMS and save on disk.org.jose4j.jwt.JwtClaimsreadToken(java.lang.String token, java.security.PublicKey key)Read a token against the provided publicKey 
 - 
 
- 
- 
Method Detail
- 
getInstance
public static JwtManager getInstance()
 
- 
propertiesChange
public void propertiesChange(JProperties properties)
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
public org.jose4j.jwt.JwtClaims readToken(java.lang.String token, java.security.PublicKey key)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 java.lang.String generateToken(org.jose4j.jwt.JwtClaims claims, java.io.File privateKeyFile, java.lang.String password) throws org.jose4j.lang.JoseExceptionGenerate 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 java.lang.String generateToken(org.jose4j.jwt.JwtClaims claims, java.security.PrivateKey key) throws org.jose4j.lang.JoseExceptionGenerate 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 java.lang.String generateToken(java.security.PrivateKey key, Member mbr, java.lang.String issuer, float expiration, java.lang.String url, java.lang.Integer prefixLength, java.util.List<java.lang.String> methodList, java.lang.String ipMask) throws org.jose4j.lang.JoseExceptiongenerate 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:
 - he JWT token
 - Throws:
 org.jose4j.lang.JoseException- thrown if the token cannot be generated
 
- 
generateToken
public java.lang.String generateToken(org.jose4j.jwt.JwtClaims claims, java.security.PrivateKey key, java.security.PublicKey receiverKey) throws org.jose4j.lang.JoseExceptionGenerate a 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
public org.jose4j.jwt.JwtClaims generateDefaultClaims(Member mbr, java.lang.String issuer, float expiration)
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, java.lang.String issuer, float expiration, java.lang.String url, java.lang.Integer prefixLength, java.util.List<java.lang.String> methodList, java.lang.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 
 
 - 
 
 -