Package org.keycloak.authorization
Class AuthorizationProvider
java.lang.Object
org.keycloak.authorization.AuthorizationProvider
- All Implemented Interfaces:
Provider
The main contract here is the creation of PermissionEvaluator instances. Usually
an application has a single AuthorizationProvider instance and threads servicing client requests obtain PermissionEvaluator
from the evaluators() method.
The internal state of a AuthorizationProvider is immutable. This internal state includes all of the metadata
used during the evaluation of policies.
Once created, PermissionEvaluator instances can be obtained from the evaluators() method:
List permissionsToEvaluate = getPermissions(); // the permissions to evaluate
EvaluationContext evaluationContext = createEvaluationContext(); // the context with runtime environment information
PermissionEvaluator evaluator = authorization.evaluators().from(permissionsToEvaluate, context);
evaluator.evaluate(new Decision() {
public void onDecision(Evaluation evaluation) {
// do something on grant
}
});
- Author:
- Pedro Igor
-
Constructor Summary
ConstructorsConstructorDescriptionAuthorizationProvider(KeycloakSession session, RealmModel realm, PolicyEvaluator policyEvaluator) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Returns aEvaluatorsinstance from wherePolicyEvaluatorinstances can be obtained.No cache sits in front of thisgetPolicyEvaluator(ResourceServer resourceServer) <P extends PolicyProvider>
PgetProvider(String type) Returns aPolicyProviderFactorygiven atype.Returns the registeredPolicyProviderFactory.getProviderFactory(String type) Returns aPolicyProviderFactorygiven atype.getRealm()Cache sits in front of this Returns aStoreFactory.
-
Constructor Details
-
AuthorizationProvider
public AuthorizationProvider(KeycloakSession session, RealmModel realm, PolicyEvaluator policyEvaluator)
-
-
Method Details
-
evaluators
Returns aEvaluatorsinstance from wherePolicyEvaluatorinstances can be obtained.- Returns:
- a
Evaluatorsinstance
-
getStoreFactory
Cache sits in front of this Returns aStoreFactory.- Returns:
- the
StoreFactory
-
getLocalStoreFactory
No cache sits in front of this- Returns:
-
getProviderFactoriesStream
Returns the registeredPolicyProviderFactory.- Returns:
- a
Streamcontaining all registeredPolicyProviderFactory
-
getProviderFactory
Returns aPolicyProviderFactorygiven atype.- Parameters:
type- the type of the policy provider- Returns:
- a
PolicyProviderFactorywith the giventype
-
getProvider
Returns aPolicyProviderFactorygiven atype.- Type Parameters:
P- the expected type of the provider- Parameters:
type- the type of the policy provider- Returns:
- a
PolicyProviderwith the giventype
-
getKeycloakSession
-
getRealm
-
getPolicyEvaluator
-
close
public void close()
-