- java.lang.Object
-
- jakarta.security.jacc.PolicyFactory
-
public abstract class PolicyFactory extends java.lang.Object
Abstract factory and finder class for obtaining the instance of the class that implements the PolicyFactory of a provider. The factory will be used to instantiate Policy objects.- See Also:
Policy
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FACTORY_NAME
private static PolicyFactory
policyFactory
private PolicyFactory
wrapped
-
Constructor Summary
Constructors Constructor Description PolicyFactory()
Default constructor for if no wrapping is neededPolicyFactory(PolicyFactory wrapped)
If this factory has been decorated, the implementation doing the decorating should push the implementation being wrapped to this constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Policy
getPolicy()
This method is used to obtain an instance of the provider specific class that implements thePolicy
interface that corresponds to policy context within the provider.abstract Policy
getPolicy(java.lang.String contextId)
This method is used to obtain an instance of the provider specific class that implements thePolicy
interface that corresponds to policy context within the provider.static PolicyFactory
getPolicyFactory()
Get the system-wide PolicyFactory implementation.PolicyFactory
getWrapped()
If this factory has been decorated, the implementation doing the decorating may override this method to provide access to the implementation being wrapped.void
setPolicy(Policy policy)
Set the context Policy implementation.abstract void
setPolicy(java.lang.String contextId, Policy policy)
Set the context Policy implementation.static void
setPolicyFactory(PolicyFactory policyFactory)
Set the system-wide PolicyFactory implementation.
-
-
-
Field Detail
-
FACTORY_NAME
public static final java.lang.String FACTORY_NAME
- See Also:
- Constant Field Values
-
policyFactory
private static volatile PolicyFactory policyFactory
-
wrapped
private PolicyFactory wrapped
-
-
Constructor Detail
-
PolicyFactory
public PolicyFactory()
Default constructor for if no wrapping is needed
-
PolicyFactory
public PolicyFactory(PolicyFactory wrapped)
If this factory has been decorated, the implementation doing the decorating should push the implementation being wrapped to this constructor. ThegetWrapped()
will then return the implementation being wrapped.- Parameters:
wrapped
- The implementation being wrapped.
-
-
Method Detail
-
getPolicyFactory
public static PolicyFactory getPolicyFactory()
Get the system-wide PolicyFactory implementation.The name of the factory implementation class is obtained from the value of the system property,
This value can also be retrieved from the fieldjakarta.security.jacc.PolicyFactory.provider
PolicyFactory.FACTORY_NAME
.- Returns:
- the system-wide singleton instance of the provider specific PolicyFactory implementation class.
- Throws:
java.lang.SecurityException
- If an exception was thrown during the class loading, or construction of the default PolicyFactory implementation class; in which case the SecurityException will contain the root Exception as its cause.
-
setPolicyFactory
public static void setPolicyFactory(PolicyFactory policyFactory)
Set the system-wide PolicyFactory implementation.If an implementation was set previously, it will be replaced.
- Parameters:
policyFactory
- The PolicyFactory instance, which may be null.
-
getWrapped
public PolicyFactory getWrapped()
If this factory has been decorated, the implementation doing the decorating may override this method to provide access to the implementation being wrapped.
-
getPolicy
public Policy getPolicy()
This method is used to obtain an instance of the provider specific class that implements thePolicy
interface that corresponds to policy context within the provider. The policy context is identified by the value of the policy context identifier associated with the thread on which the accessor is called.For a given determined value of the policy context identifier, this method must always return the same instance of
Policy
and there must be at most one actual instance of aPolicy
with a given policy context identifier (during a process context).This method should be logically identical to calling
getPolicy(String)
with as input the value returned fromPolicyContext.getContextID()
.- Returns:
- an Object that implements the
Policy
interface corresponding to the identified policy context, or a null if such an Object is not present.
-
setPolicy
public void setPolicy(Policy policy)
Set the context Policy implementation.If an implementation was set previously, it will be replaced.
This method should be logically identical to calling
setPolicy(String, Policy)
with as input for the first parameter the value returned fromPolicyContext.getContextID()
.- Parameters:
policy
- The policy instance, which may be null.
-
getPolicy
public abstract Policy getPolicy(java.lang.String contextId)
This method is used to obtain an instance of the provider specific class that implements thePolicy
interface that corresponds to policy context within the provider. The policy context is identified by the value of the policy context identifier associated with the thread on which the accessor is called.For a given determined value of the policy context identifier, this method must always return the same instance of
Policy
and there must be at most one actual instance of aPolicy
with a given policy context identifier (during a process context).- Parameters:
contextId
- A String identifying the policy context whosePolicy
interface is to be returned. The value passed to this parameter can be null, which corresponds to the system-wide defaultPolicy
instance.- Returns:
- an Object that implements the
Policy
interface corresponding to the identified policy context, or a null if such an Object is not present.
-
setPolicy
public abstract void setPolicy(java.lang.String contextId, Policy policy)
Set the context Policy implementation.If an implementation was set previously, it will be replaced.
-
-