- java.lang.Object
- 
- aeonics.entity.Entity
- 
- aeonics.manager.Manager.Type
- 
- aeonics.manager.Security
 
 
 
- 
- All Implemented Interfaces:
- Exportable,- Snapshotable
 
 public abstract class Security extends Manager.Type Manages the global security settings in the system and defines the common behavior of the different security requirements.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface aeonics.util.SnapshotableSnapshotable.SnapshotMode
 
- 
 - 
Constructor SummaryConstructors Constructor Description Security()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description User.Typeauthenticate(Provider.Type provider, Data context)Authenticate a user based on opaque authentication credentials.abstract Tokenauthenticate(java.lang.String token, boolean reset)Retreives a token instance based on a an opaque token value.abstract voidclearTokens(User.Type user)Revokes all tokens for the provided userabstract byte[]decrypt(java.lang.String value, byte[] key)Decrypts the given value to recover the original value that was encrypted withencrypt(String, String).java.lang.Stringdecrypt(java.lang.String value, java.lang.String key)Decrypts the given value to recover the original text that was encrypted withencrypt(String, String).abstract java.lang.Stringencrypt(byte[] value, byte[] key)Encrypts the given value with a strong symmetric key encryption method.java.lang.Stringencrypt(java.lang.String value, java.lang.String key)Encrypts the given value with a strong symmetric key encryption method.abstract TokengenerateToken(User.Type user, long validity, boolean exclusive, java.lang.String... scopes)Generates aTokenfor the provided user.static Securityget()Returns the current active instance of this manager type.booleangranted(User.Type user, java.lang.String scope, Data context)Checks if the user is granted usage of the specified scope with the given context.java.lang.Stringhash(byte[] value)Produces a strong cryptographic hash of the input value.abstract java.lang.Stringhash(byte[] value, byte[] salt)Produces a strong cryptographic hash of the input value.abstract java.lang.Stringhash(java.io.InputStream value)Produces a strong cryptographic hash of the target input data.java.lang.Stringhash(java.lang.String value)Produces a strong cryptographic hash of the input value.java.lang.Stringhash(java.lang.String value, java.lang.String salt)Produces a strong cryptographic hash of the input value.booleanisExplicitlyAllowed(User.Type user, java.lang.String scope, Data context)Evaluates if the user is explicitly allowed access.booleanisExplicitlyDenied(User.Type user, java.lang.String scope, Data context)Evaluates if the user is explicitly denied access.java.lang.Class<? extends Manager.Type>manager()Hardcoded manager typejava.util.List<Provider.Type>providers(java.lang.String user)Returns the list ofProviderthat may be able to authenticate the specified user.abstract java.lang.StringrandomHash()Produces a random meaningless and opaque hash.abstract voidrevokeToken(Token token)Revokes the provided token If the provided token is null, this method returns without doing anything.- 
Methods inherited from class aeonics.manager.Manager.Typecategory, internal, snapshotMode
 - 
Methods inherited from class aeonics.entity.EntityaddRelation, addRelation, addRelation, cast, clearRelation, config, context, countRelations, countRelations, defineRelation, equals, export, firstRelation, hashCode, hasRelation, id, internal, name, name, onCreate, onRemove, onUpdate, parameter, relations, relationships, removeRelation, snapshot, template, type, valueOf, valueOf
 
- 
 
- 
- 
- 
Method Detail- 
managerpublic final java.lang.Class<? extends Manager.Type> manager() Hardcoded manager type- Specified by:
- managerin class- Manager.Type
- Returns:
- the type of manager
 
 - 
getpublic static Security get() Returns the current active instance of this manager type.- Returns:
- the current active instance of this manager type
 
 - 
randomHashpublic abstract java.lang.String randomHash() Produces a random meaningless and opaque hash. The goal of this function is to serve as source of entropy to generate cryptographycally-sufficient long random string values.This is a good candidate to generate a Token.- Returns:
- a random hash in hex format
 
 - 
hashpublic abstract java.lang.String hash(java.io.InputStream value) Produces a strong cryptographic hash of the target input data. The hash is not salted. The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the input stream to hash
- Returns:
- the hashed value in hex format
 
 - 
hashpublic java.lang.String hash(java.lang.String value) Produces a strong cryptographic hash of the input value. The hash is not salted. Always prefer thehash(String, String)version. The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the input text to hash
- Returns:
- the hashed value in hex format
 
 - 
hashpublic java.lang.String hash(byte[] value) Produces a strong cryptographic hash of the input value. The hash is not salted. Always prefer thehash(String, String)version. The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the input text to hash
- Returns:
- the hashed value in hex format
 
 - 
hashpublic java.lang.String hash(java.lang.String value, java.lang.String salt)Produces a strong cryptographic hash of the input value. The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the input text to hash
- salt- the salt value (may be null but it is not recommended)
- Returns:
- the hashed value in hex format
 
 - 
hashpublic abstract java.lang.String hash(byte[] value, byte[] salt)Produces a strong cryptographic hash of the input value. The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the input text to hash
- salt- the salt value (may be null but it is not recommended)
- Returns:
- the hashed value in hex format
 
 - 
encryptpublic java.lang.String encrypt(java.lang.String value, java.lang.String key)Encrypts the given value with a strong symmetric key encryption method. Usedecrypt(String, String)to recover the original value. The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the input text to encrypt
- key- the symmetric key
- Returns:
- the encrypted value in base64 format
- Throws:
- java.lang.SecurityException- if any error happens during encryption. For security purpose, the cause of the exception is discarded.
 
 - 
encryptpublic abstract java.lang.String encrypt(byte[] value, byte[] key)Encrypts the given value with a strong symmetric key encryption method. Usedecrypt(String, byte[])to recover the original value. The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the input to encrypt
- key- the symmetric key
- Returns:
- the encrypted value in base64 format
- Throws:
- java.lang.SecurityException- if any error happens during encryption. For security purpose, the cause of the exception is discarded.
 
 - 
decryptpublic java.lang.String decrypt(java.lang.String value, java.lang.String key)Decrypts the given value to recover the original text that was encrypted withencrypt(String, String). The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the encrypted text to decrypt in base64 format
- key- the symmetric key
- Returns:
- the original text
- Throws:
- java.lang.SecurityException- if any error happens during decryption, including a key mismatch. For security purpose, the cause of the exception is discarded.
 
 - 
decryptpublic abstract byte[] decrypt(java.lang.String value, byte[] key)Decrypts the given value to recover the original value that was encrypted withencrypt(String, String). The underlying implementation is not enforced but the algorithm shall remain consistent to ensure backward compatibility over time.- Parameters:
- value- the encrypted value to decrypt in base64 format
- key- the symmetric key
- Returns:
- the original value
- Throws:
- java.lang.SecurityException- if any error happens during decryption, including a key mismatch. For security purpose, the cause of the exception is discarded.
 
 - 
providerspublic java.util.List<Provider.Type> providers(java.lang.String user) Returns the list ofProviderthat may be able to authenticate the specified user.This method is used to allow the user to choose an authentication provider. It is not guaranteed that all returned providers can successfully authenticate the user, this is more of an indication as per Provider.Type.supports(String).- Parameters:
- user- the user login
- Returns:
- the list of providers that can support authenticating the provided user
 
 - 
authenticatepublic User.Type authenticate(Provider.Type provider, Data context) Authenticate a user based on opaque authentication credentials. This is the prefered way to authenticate users.This method calls Provider.Type.authenticate(Data)on the selected provider.This method has the ability to intercept the authentication request and perform auditing, filtering or any other type of logic. - Parameters:
- provider- the target identity provider
- context- the authentication context that shall be used by the provider to authenticate the user
- Returns:
- the authenticated user instance or User.ANONYMOUSif no user matches
 
 - 
grantedpublic boolean granted(User.Type user, java.lang.String scope, Data context) Checks if the user is granted usage of the specified scope with the given context. The final decision is!isExplicitlyDenied(user, scope, context) && isExplicitlyAllowed(user, scope, context) TheUser.SYSTEMis always granted without checking.The scope and context are not defined and can be anything, the behavior will depend on applicable PolicyIn general, for the internal routing mechanics, the scope will be "topic" and the context will contain a Messageentity.- Parameters:
- user- the user, must not be null
- scope- the scope of interest, must not be null
- context- the context data to check against rules and policies, may be null
- Returns:
- true if the user is allowed given the scope and context
 
 - 
isExplicitlyDeniedpublic boolean isExplicitlyDenied(User.Type user, java.lang.String scope, Data context) Evaluates if the user is explicitly denied access. An explicit deny (return true) is different from a non-explicit deny (return false) in that the former says "I am strictly against it" and the latter is more "I do not have any objections".The scope and context are not defined and can be anything, the behavior will depend on applicable PolicyIn general, the scope will be "topic" and the context will contain a Messageentity.- Parameters:
- user- the user, must not be null
- scope- the scope of interest, must not be null
- context- the context data to check against rules and policies, may be null
- Returns:
- true if the user is explicitly denied given the scope and context
 
 - 
isExplicitlyAllowedpublic boolean isExplicitlyAllowed(User.Type user, java.lang.String scope, Data context) Evaluates if the user is explicitly allowed access. An explicit allow (return true) is different from a non-explicit allow (return false) in that the former says "Yes you can" and the latter is more "I don't know".The scope and context are not defined and can be anything, the behavior will depend on applicable PolicyIn general, the scope will be "topic" and the context will contain a Messageentity.- Parameters:
- user- the user, must not be null
- scope- the scope of interest, must not be null
- context- the context data to check against rules and policies, may be null
- Returns:
- true if the user is explicitly allowed given the scope and context
 
 - 
generateTokenpublic abstract Token generateToken(User.Type user, long validity, boolean exclusive, java.lang.String... scopes) Generates aTokenfor the provided user.- Parameters:
- user- the target user, must not be null and must not be- User.SYSTEMor- User.ANONYMOUS
- validity- the validity time in millisecond. A value- <= 0means valid forever.
- exclusive- whether or not other tokens for the same user should be revoked (regardless of the scopes)
- scopes- the list of scopes, must not be null or empty
- Returns:
- a token that can be used to uniquely identify the provided user, or null if the token could not be generated
 
 - 
authenticatepublic abstract Token authenticate(java.lang.String token, boolean reset) Retreives a token instance based on a an opaque token value.- Parameters:
- token- the token value, must not be null
- reset- whether or not to reset the optional time-based validity of this for this token
- Returns:
- the matching token instance or null if no token matches
 
 - 
revokeTokenpublic abstract void revokeToken(Token token) Revokes the provided token If the provided token is null, this method returns without doing anything.- Parameters:
- token- the token to revoke
 
 - 
clearTokenspublic abstract void clearTokens(User.Type user) Revokes all tokens for the provided user- Parameters:
- user- the target user, must not be null and must not be- User.SYSTEMor- User.ANONYMOUS
 
 
- 
 
-