Class CachedIdentityAuthorizeCallback
- All Implemented Interfaces:
Callback,ExtendedCallback
A callback that is capable of perform authorization based on the identities managed by an IdentityCache.
This callback can be used in two ways:
- As an alternative to
AuthorizeCallback. As a result, the identity (if successfully authorized) will be cached - To perform a lookup in the cache and authorize the cached identity locally
- Author:
- Pedro Igor
-
Constructor Summary
ConstructorsConstructorDescriptionCachedIdentityAuthorizeCallback(String name, IdentityCache identityCache) Creates a new instance to authenticate, authorize and cache the identity associated with the givenname.CachedIdentityAuthorizeCallback(Principal principal, Function<SecurityDomain, IdentityCache> identityCache, boolean localCache) Creates a new instance to authenticate, authorize and cache the identity associated with the givenprincipal.CachedIdentityAuthorizeCallback(Principal principal, IdentityCache identityCache) Creates a new instance to authenticate, authorize and cache the identity associated with the givenprincipal.CachedIdentityAuthorizeCallback(Principal principal, IdentityCache identityCache, boolean localCache) Creates a new instance to authenticate, authorize and cache the identity associated with the givenprincipal.CachedIdentityAuthorizeCallback(Function<SecurityDomain, IdentityCache> identityCache, boolean localCache) Creates a new instance in order to authorize identities managed by the givenidentityCache.CachedIdentityAuthorizeCallback(IdentityCache identityCache) Creates a new instance in order to authorize identities managed by the givenidentityCache.CachedIdentityAuthorizeCallback(IdentityCache identityCache, boolean localCache) Creates a new instance in order to authorize identities managed by the givenidentityCache. -
Method Summary
Modifier and TypeMethodDescriptionReturns the authorizationPrincipal.Returns a cachedSecurityIdentity, if present in the cache.Returns thePrincipalrepresenting the cached identity.booleanIndicates if a cached identity was successfully authorized.booleanIndicates if authorization decisions should be performed based on the givenIdentityCacheonly.booleanDetermine if this callback is optional.booleanDetermine if this callback is requesting information.voidsetAuthorized(SecurityIdentity securityIdentity) Authorizes and caches the givensecurityIdentity.voidsetSecurityDomain(SecurityDomain securityDomain) Set the currentSecurityDomainin order to obtain identities from the cache
-
Constructor Details
-
CachedIdentityAuthorizeCallback
Creates a new instance in order to authorize identities managed by the givenidentityCache.- Parameters:
identityCache- the identity cache
-
CachedIdentityAuthorizeCallback
Creates a new instance in order to authorize identities managed by the givenidentityCache.- Parameters:
identityCache- the identity cachelocalCache- if true, indicates that authorization should be based on the givenidentityCacheonly. In case the mechanism performing the authorization is wrapped by another one that provides a top-level cache (eg.: SSO), only the givenidentityCachewill be considered.
-
CachedIdentityAuthorizeCallback
public CachedIdentityAuthorizeCallback(Function<SecurityDomain, IdentityCache> identityCache, boolean localCache) Creates a new instance in order to authorize identities managed by the given
identityCache.This constructor can be used to perform caching operations (e.g.: put, get and remove) in the context of a
SecurityDomain.- Parameters:
identityCache- a function that creates anIdentityCachegiven aSecurityDomainlocalCache- if true, indicates that authorization should be based on the givenidentityCacheonly. In case the mechanism performing the authorization is wrapped by another one that provides a top-level cache (eg.: SSO), only the givenidentityCachewill be considered.
-
CachedIdentityAuthorizeCallback
Creates a new instance to authenticate, authorize and cache the identity associated with the givenname.By supplying a name authorizing the supplied name will be prioritised over restoring an identify from the cache
- Parameters:
name- the name associated with the identityidentityCache- the identity cache
-
CachedIdentityAuthorizeCallback
public CachedIdentityAuthorizeCallback(Principal principal, IdentityCache identityCache, boolean localCache) Creates a new instance to authenticate, authorize and cache the identity associated with the givenprincipal.By supplying a
Principalauthorizing the suppliedPrincipalwill be prioritised over restoring an identify from the cache- Parameters:
principal- the principal associated with the identityidentityCache- the identity cachelocalCache- if true, indicates that authorization should be based on the givenidentityCacheonly. In case the mechanism performing the authorization is wrapped by another one that provides a top-level cache (eg.: SSO), only the givenidentityCachewill be considered.
-
CachedIdentityAuthorizeCallback
Creates a new instance to authenticate, authorize and cache the identity associated with the givenprincipal.By supplying a
Principalauthorizing the suppliedPrincipalwill be prioritised over restoring an identify from the cache- Parameters:
principal- the principal associated with the identityidentityCache- the identity cache
-
CachedIdentityAuthorizeCallback
public CachedIdentityAuthorizeCallback(Principal principal, Function<SecurityDomain, IdentityCache> identityCache, boolean localCache) Creates a new instance to authenticate, authorize and cache the identity associated with the given
principal.This constructor can be used to perform caching operations (e.g.: put, get and remove) in the context of a
SecurityDomain.By supplying a
Principalauthorizing the suppliedPrincipalwill be prioritised over restoring an identify from the cache- Parameters:
principal- the principal associated with the identityidentityCache- a function that creates anIdentityCachegiven aSecurityDomainlocalCache- if true, indicates that authorization should be based on the givenidentityCacheonly. In case the mechanism performing the authorization is wrapped by another one that provides a top-level cache (eg.: SSO), only the givenidentityCachewill be considered.
-
-
Method Details
-
isAuthorized
public boolean isAuthorized()Indicates if a cached identity was successfully authorized.- Returns:
- true if the cached identity was successfully authorized. Otherwise, false
-
setAuthorized
Authorizes and caches the givensecurityIdentity.- Parameters:
securityIdentity- the identity to authorize and cache. If null, the corresponding identity will be removed from the cache
-
getPrincipal
Returns thePrincipalrepresenting the cached identity.- Returns:
- the principal (not
null)
-
getAuthorizationPrincipal
Returns the authorizationPrincipal.- Returns:
- the principal
-
getIdentity
Returns a cachedSecurityIdentity, if present in the cache.- Returns:
- the cached identity or null if there is no entry in the cache
-
isLocalCache
public boolean isLocalCache()Indicates if authorization decisions should be performed based on the givenIdentityCacheonly.- Returns:
- true indicating that authorization decisions should be performed based on the given
IdentityCacheonly. Otherwise, false
-
setSecurityDomain
Set the currentSecurityDomainin order to obtain identities from the cache- Parameters:
securityDomain- the current security domain
-
isOptional
public boolean isOptional()Description copied from interface:ExtendedCallbackDetermine if this callback is optional.- Specified by:
isOptionalin interfaceExtendedCallback- Returns:
trueif the callback is optional,falseif it is mandatory
-
needsInformation
public boolean needsInformation()Description copied from interface:ExtendedCallbackDetermine if this callback is requesting information.- Specified by:
needsInformationin interfaceExtendedCallback- Returns:
trueif the callback is requesting information,falseif it is only providing information
-