|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openliberty.openaz.pep.PepRequestFactory
public class PepRequestFactory
The main entry point for building a PEP
The basic pattern is to as follows:
AzService azService = new org.openliberty.openaz.pdp.provider.SimpleConcreteService();
PepRequestFactory pep = new PepRequestFactory(CONTAINER,azService);
newPepRequest(String, String, String)
newPepRequest(Object, Object, Object)
newPepRequest(Object, Object, Object, Object)
newBulkPepRequest(Object, List, Object)
newBulkPepRequest(Object, List, List, Object)
newQueryPepRequest(Object, Object, String, org.openliberty.openaz.pep.PepRequest.QUERY_TYPE)
// Define an environment attribute
Date now = new Date();
// Define a collection of Subject attributes
HashMap subject = new HashMap();
subject.put(AzXacmlStrings.X_ATTR_SUBJECT_ID, "josh");
subject.put(AzXacmlStrings.X_ATTR_SUBJECT_AUTHN_LOC_AUTHENTICATION_METHOD, SAMPLE_SESSION_AUTH_METHOD);
// Define an array of action strings
String[] actions = new String[] { "read", "write", "delete", "read", "write", "delete" };
// Define a collection: of Permissions using
// the resourceNames and actions for each Permission
String resourceName = "file:\\\\toplevel";
ArrayList resourceActions = new ArrayList();
for (int i = 0; i < actions.length; i++) {
String resource = resourceName + "0" + new Integer(i);
resourceActions.add(new FilePermission(resource, actions[i]));
}
// Create the request object
try {
PepRequest req = pep.newBulkPepRequest(subject,resourceActions,now);
PepResponse resp = req.decide();
System.out.println(resp.allowed());
if (resp.allowed()) {
Map<String,Obligation> obligations = resp.getObligations();
Iterator<String> itObligationIds = obligations.keySet().iterator();
while (itObligationIds.hasNext()){
String obligationId = itObligationIds.next();
Obligation obligation = obligations.get(obligationId);
Map<String,String> oblAttrs = obligation.getStringValues();
System.out.println("ObligationId: " + obligationId +
"\nObligation Attributes: " + oblAttrs);
}
}
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_PROVIDER_NAME
|
Constructor Summary | |
---|---|
PepRequestFactory(java.lang.String name,
AzService azService)
Constructor of Pep Request Factory uses the DefaultDecisionHandler |
|
PepRequestFactory(java.lang.String name,
AzService azService,
java.util.List<PreDecisionHandler> preDecideHandlers,
DecisionHandler decideHandler,
java.util.List<PostDecisionHandler> postDecideHandlers)
Constructor that allows for the inclusion of custom PreDecisionHandler, DecisionHandler and PostDecsionHandler |
Method Summary | |
---|---|
ActionFactory |
getActionFactory()
|
java.lang.Object |
getActionObject(AzResourceActionAssociation azRaa)
|
AzService |
getAzService()
|
DecisionHandler |
getDecisionHandler()
|
EnvironmentFactory |
getEnvironmentFactory()
|
java.lang.String |
getName()
|
java.util.List<PostDecisionHandler> |
getPostDecisionHandlers()
|
java.util.List<PreDecisionHandler> |
getPreDecisionHandlers()
|
java.lang.String |
getProviderClassName()
|
ResourceFactory |
getResourceFactory()
|
java.lang.Object |
getResourceObject(AzResourceActionAssociation azRaa)
|
java.lang.Object |
getResourceObjectId(java.lang.Object resourceObject)
|
PepResponseFactory |
getResponseFactory()
|
SubjectFactory |
getSubjectFactory()
|
PepRequest |
newBulkPepRequest(java.lang.Object subjectObj,
java.util.List actionObjects,
java.util.List resourceObjects,
java.lang.Object environmentObj)
Create a PepRequest using objects, where a list of n action objects and a corresponding list of n resource objects are provided to represent n resource-action pairs. |
PepRequest |
newBulkPepRequest(java.lang.Object subjectObj,
java.util.List actionResourceObjects,
java.lang.Object environmentObj)
Create a PepRequest using objects, where a list of n action-resource objects are provided. |
PepRequest |
newPepRequest(java.lang.Object subjectObj,
java.lang.Object actionResourceObject,
java.lang.Object environmentObj)
Creates a PEP request using objects, but the action and the resource are both derived from the same object ex: Permission or HttpServletRequest |
PepRequest |
newPepRequest(java.lang.Object subjectObj,
java.lang.Object actionObj,
java.lang.Object resourceObj,
java.lang.Object environmentObj)
Create a PepRequest using objects |
PepRequest |
newPepRequest(java.lang.String subjectName,
java.lang.String actionId,
java.lang.String resourceId)
Create a PepRequest juts using Strings |
PepRequest |
newQueryPepRequest(java.lang.Object subjectObj,
java.lang.Object environmentObj,
java.lang.String scope,
PepRequest.QUERY_TYPE queryType)
Create a PepRequest using subject and environment objects, plus a "scope" String that represents a PDP policy-specific resource representation. |
void |
setActionFactory(ActionFactory actionFactory)
|
void |
setAzService(AzService azService)
|
void |
setEnvironmentFactory(EnvironmentFactory environmentFactory)
|
void |
setName(java.lang.String name)
|
void |
setProviderClassName(java.lang.String providerClassName)
|
void |
setResourceFactory(ResourceFactory resourceFactory)
|
void |
setResponseFactory(PepResponseFactory responseFactory)
|
void |
setSubjectFactory(SubjectFactory subjectFactory)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_PROVIDER_NAME
Constructor Detail |
---|
public PepRequestFactory(java.lang.String name, AzService azService, java.util.List<PreDecisionHandler> preDecideHandlers, DecisionHandler decideHandler, java.util.List<PostDecisionHandler> postDecideHandlers)
name
- The name of the PEP. This is used as the issuer of all of the attributes.azService
- A handle to the AzServicepreDecisionHandlers
- decisionHanlder
- postDecisionHandlers
- public PepRequestFactory(java.lang.String name, AzService azService)
name
- The name of the PEP. This is used as the issuer of all of the attributes.azService
- A handle to the AzServiceMethod Detail |
---|
public PepRequest newPepRequest(java.lang.String subjectName, java.lang.String actionId, java.lang.String resourceId) throws PepException
subjectName
- String representing the name of the subejct ex: JoshresourceId
- String representing the resource ex: file1234actionId
- String representing the action ex: read
PepException
- Indicates that there is some issue creating the PEPRequest
public PepRequest newPepRequest(java.lang.Object subjectObj, java.lang.Object actionObj, java.lang.Object resourceObj, java.lang.Object environmentObj) throws PepException
subjectObj
- Object representing the Subject
ex: javax.auth.security.SubjectactionObj
- Object representing the Action
ex: String (read)resourceObj
- Object representing the Resource
ex: String (file) or FileenvironmentObj
- Object representing the Environment
ex: Map containing attributes name and values
PepException
- if there is no JavObjectMapper
configured
for the objects passed into the factory.JavaObjectMapper
public PepRequest newPepRequest(java.lang.Object subjectObj, java.lang.Object actionResourceObject, java.lang.Object environmentObj) throws PepException
subjectObj
- Object representing the Subject
ex: javax.auth.security.SubjectactionResourceObject
- Object representing both the action and the
resource ex: FilePermission or HttpServletRequestenvironmentObj
- Object representing the Environment
ex: Map containing attributes name and values
PepException
- if there is no JavObjectMapper
configured
for the objects passed into the factory.JavaObjectMapper
public PepRequest newBulkPepRequest(java.lang.Object subjectObj, java.util.List actionObjects, java.util.List resourceObjects, java.lang.Object environmentObj) throws PepException
subjectObj
- Object representing the Subject
ex: javax.auth.security.Subjectlist
- of length n, of actionObj Objects representing the Actions
ex: String (read)list
- of length n, of resourceObj Objects representing the Resources
ex: String (file) or FileenvironmentObj
- Object representing the Environment
ex: Map containing attributes name and values
PepException
public PepRequest newBulkPepRequest(java.lang.Object subjectObj, java.util.List actionResourceObjects, java.lang.Object environmentObj) throws PepException
subjectObj
- Object representing the Subject
ex: javax.auth.security.Subjectlist
- of length n, of actionResourceObjects representing the
Action Resource pairs ex: String (read), String (file)environmentObj
- Object representing the Environment
ex: Map containing attributes name and values
PepException
public PepRequest newQueryPepRequest(java.lang.Object subjectObj, java.lang.Object environmentObj, java.lang.String scope, PepRequest.QUERY_TYPE queryType) throws PepException
- a list of Allowed ResourceAction pairs within scope - a list of Denied ResourceAction pairs within scope - or a list of full detailed results for all ResourceAction pairs within scope
subjectObj
- environmentObj
- scope
- a string containing a PDP policy-specific resource
representationqueryType
- an enum containing a choice of allowed, denied,
or full/verbose
PepException
public void setProviderClassName(java.lang.String providerClassName)
public java.lang.String getProviderClassName()
public java.lang.Object getResourceObjectId(java.lang.Object resourceObject)
public java.lang.Object getResourceObject(AzResourceActionAssociation azRaa)
public java.lang.Object getActionObject(AzResourceActionAssociation azRaa)
public void setName(java.lang.String name)
public java.lang.String getName()
public void setAzService(AzService azService)
public AzService getAzService()
public void setEnvironmentFactory(EnvironmentFactory environmentFactory)
public EnvironmentFactory getEnvironmentFactory()
public void setResourceFactory(ResourceFactory resourceFactory)
public ResourceFactory getResourceFactory()
public void setSubjectFactory(SubjectFactory subjectFactory)
public SubjectFactory getSubjectFactory()
public void setActionFactory(ActionFactory actionFactory)
public ActionFactory getActionFactory()
public void setResponseFactory(PepResponseFactory responseFactory)
public PepResponseFactory getResponseFactory()
public java.util.List<PreDecisionHandler> getPreDecisionHandlers()
public DecisionHandler getDecisionHandler()
public java.util.List<PostDecisionHandler> getPostDecisionHandlers()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |