public class PolicyRuntimeImpl extends java.lang.Object implements PolicyRuntime
Following is an illustration of how policy change notifications from policy admin are handled in policy runtime:
[========================= Policy Abstract Layer ==========================][==== Policy Provider Layer ======]
------------------- -------------------------- --------------------- -----------------------
| PolicyRuntimeImpl | | JournalEventListenerImpl | | CallbackHandlerImpl | | PolicyRuntimeProvider |
------------------- -------------------------- --------------------- -----------------------
| | | (OES/XML)
| | | |
--------^--------------------------->| | |
1.Journal event notification - J1 | | |
| (from Policy Admin) | | |
| | | |
|<---------------------------| | 2. notify about j1 3. < ( transform to p1| |----------------------------^--------------------------^------------------------>|
| 4. Notify about P1 (invoke provider.handlePolicyChangeEvent()) |\
| | | | )> 5. Kick off policy refresh
| | | |/ OES XML
| | | | | |
| | | | asynchronous synchronous
| | | |\ | |
| | | | ) 6. Do policy refresh
| | | |/
| | |<------------------------| | 7. notify change uptake completion. <--------------------------^--------------------------| 8. invoke handlepolicychangeuptakecompletion() 9. <( \| runtime event listeners < pre>------------------------|>---------------------------|>PolicyRuntimeFactory| Constructor and Description |
|---|
PolicyRuntimeImpl(PolicyRuntimeProvider provider,
java.util.Map<java.lang.String,java.lang.Object> properties) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPolicyChangeEventListener(PolicyChangeEventListener listener)
Adds the specified event listener to receive policy runtime change events.
|
OAuthClient |
createClient(OAuthClientImpl clientMetadata) |
java.util.List<PolicyChangeEvent> |
getAllPolicyChangeEvents()
Returns all the policy change events.
|
java.util.List<PolicyChangeEvent> |
getAllPolicyChangeEvents(long fromChangeVersion)
Returns all the policy change events starting from the
input change version to the latest version.
|
RuntimeAuthnScheme |
getAuthnScheme(java.lang.String schemeName)
Returns
RuntimeAuthnScheme for the given scheme name. |
OAuthClient |
getClient(java.lang.String clientId,
java.lang.String domainName) |
java.lang.String |
getHostIdentifier(java.lang.String host,
int port)
Returns Host Identifier associated with a host and port.
|
OAuthIdentityDomain |
getIdentityDomain(java.lang.String domainName) |
PolicyChangeEvent |
getLatestPolicyChangeEvent()
Returns the latest policy change event.
|
PolicyChangeEvent |
getPolicyChangeEvent(long changeVersion)
Returns the policy change event associated with the input change version.
|
OAuthResourceServer |
getResource(java.lang.String resourceServerName,
OAuthIdentityDomain domain) |
OAuthResourceServer |
getResource(java.lang.String resourceId,
java.lang.String domainName) |
ServerDiagnosticsDataInfo |
getServerDiagnostics(boolean verbose) |
long |
getStoreVersionInUse()
Returns the policy store version currently in use.
|
void |
handlePolicyChangeEvent(PolicyChangeEvent event)
Handles policy change event.
|
void |
handlePolicyChangeUptakeCompletion(long policyStoreVersion)
Handles the provider callback for policy change uptake completion notification.
|
AccessResult |
isAuthorized(AccessRequest request)
Determines if a given Subject is permitted to access a RuntimeResource.
|
java.lang.Boolean |
isPolicyCacheValid()
returns true if cache has been initialized otherwise return false.
|
AccessResult |
isResourceProtected(AccessRequest request)
Determines if a given RuntimeResource is protected with an authentication policy,
if so, it evaluates the policy and returns the evaluation result,the authentication scheme
specified for the resource, and any responses specified in the authentication policy.
|
AccessResult |
isSessionValid(AccessRequest request)
Determines if a given user session is valid for the access request.
|
AccessResult |
isTokenRequestAuthorized(AccessRequest request)
Determines if a given Subject is permitted to request a token that will
be used to access RuntimeResource.
|
PolicyCacheRefreshResponse |
refreshPolicyCacheOnDemand(java.lang.String desiredVersion) |
void |
removePolicyChangeEventListener(PolicyChangeEventListener listener)
Removes the specified policy runtime change event listener.
|
void |
shutdown()
Shutdown hook for cleaning up
|
PolicyCacheWriteResponse |
writePolicyCacheToFile() |
public PolicyRuntimeImpl(PolicyRuntimeProvider provider,
java.util.Map<java.lang.String,java.lang.Object> properties)
throws PolicyEvaluationException
PolicyEvaluationExceptionpublic AccessResult isResourceProtected(AccessRequest request) throws PolicyEvaluationException
isResourceProtected in interface PolicyRuntimerequest - AccessRequest containing resource (required), identity (optional), and access context (optional).PolicyEvaluationException - stores root cause for failure.public AccessResult isAuthorized(AccessRequest request) throws PolicyEvaluationException
isAuthorized in interface PolicyRuntimerequest - AccessRequest containing resource (required), identity (required), and access context (optional).PolicyEvaluationException - stores root cause for failure.public AccessResult isSessionValid(AccessRequest request) throws PolicyEvaluationException
isSessionValid in interface PolicyRuntimerequest - AccessRequest containing resource (required), and access context (required, should contain session)PolicyEvaluationExceptionpublic AccessResult isTokenRequestAuthorized(AccessRequest request) throws PolicyEvaluationException
isTokenRequestAuthorized in interface PolicyRuntimerequest - access requestPolicyEvaluationExceptionpublic RuntimeAuthnScheme getAuthnScheme(java.lang.String schemeName) throws PolicyEvaluationException
RuntimeAuthnScheme for the given scheme name.getAuthnScheme in interface PolicyRuntimePolicyEvaluationExceptionpublic java.lang.String getHostIdentifier(java.lang.String host,
int port)
throws PolicyEvaluationException
getHostIdentifier in interface PolicyRuntimehost - - hostnameport - - for preferred hosts port value is 0PolicyEvaluationExceptionpublic PolicyChangeEvent getPolicyChangeEvent(long changeVersion)
throws PolicyEvaluationException
getPolicyChangeEvent in interface PolicyRuntimePolicyEvaluationExceptionpublic PolicyChangeEvent getLatestPolicyChangeEvent()
throws PolicyEvaluationException
getLatestPolicyChangeEvent in interface PolicyRuntimePolicyEvaluationExceptionpublic java.util.List<PolicyChangeEvent> getAllPolicyChangeEvents()
throws PolicyEvaluationException
getAllPolicyChangeEvents in interface PolicyRuntimePolicyEvaluationExceptionpublic java.util.List<PolicyChangeEvent> getAllPolicyChangeEvents(long fromChangeVersion)
throws PolicyEvaluationException
getAllPolicyChangeEvents in interface PolicyRuntimePolicyEvaluationExceptionpublic void addPolicyChangeEventListener(PolicyChangeEventListener listener)
throws PolicyEvaluationException
addPolicyChangeEventListener in interface PolicyRuntimePolicyEvaluationExceptionpublic void removePolicyChangeEventListener(PolicyChangeEventListener listener)
throws PolicyEvaluationException
removePolicyChangeEventListener in interface PolicyRuntimePolicyEvaluationExceptionpublic void handlePolicyChangeEvent(PolicyChangeEvent event)
throws PolicyEvaluationException
event - policy change eventPolicyEvaluationExceptionpublic void handlePolicyChangeUptakeCompletion(long policyStoreVersion)
public long getStoreVersionInUse()
throws PolicyEvaluationException
getStoreVersionInUse in interface PolicyRuntimePolicyEvaluationExceptionpublic OAuthClient getClient(java.lang.String clientId,
java.lang.String domainName)
throws PolicyEvaluationException
getClient in interface PolicyRuntimePolicyEvaluationExceptionpublic OAuthClient createClient(OAuthClientImpl clientMetadata)
throws PolicyEvaluationException
createClient in interface PolicyRuntimePolicyEvaluationExceptionpublic OAuthResourceServer getResource(java.lang.String resourceId,
java.lang.String domainName)
throws PolicyEvaluationException
getResource in interface PolicyRuntimePolicyEvaluationExceptionpublic OAuthIdentityDomain getIdentityDomain(java.lang.String domainName)
throws PolicyEvaluationException
getIdentityDomain in interface PolicyRuntimePolicyEvaluationExceptionpublic OAuthResourceServer getResource(java.lang.String resourceServerName,
OAuthIdentityDomain domain)
throws PolicyEvaluationException
getResource in interface PolicyRuntimePolicyEvaluationExceptionpublic ServerDiagnosticsDataInfo getServerDiagnostics(boolean verbose)
getServerDiagnostics in interface PolicyRuntimeverbose - Boolean parameter when set to true provides additional information such
Application domains and their IDs. The number of application domains displayed is controlled
by the VerboseMaxSize configuration parameter the defauly value of which is 50.public PolicyCacheRefreshResponse refreshPolicyCacheOnDemand(java.lang.String desiredVersion)
refreshPolicyCacheOnDemand in interface PolicyRuntimedesiredVersion - Cache version which it desire for the server to sync to.
This can be null or empty string, in that case cache will be refreshed to latest version.
If this is provided and provided version is incorrect or not available in persistent store,
then cache will be refreshed to latest version available in the store.public PolicyCacheWriteResponse writePolicyCacheToFile()
writePolicyCacheToFile in interface PolicyRuntimepublic void shutdown()
throws PolicyEvaluationException
PolicyRuntimeshutdown in interface PolicyRuntimePolicyEvaluationExceptionpublic java.lang.Boolean isPolicyCacheValid()
PolicyRuntimeisPolicyCacheValid in interface PolicyRuntime