本文整理汇总了Java中org.herasaf.xacml.core.context.impl.RequestType类的典型用法代码示例。如果您正苦于以下问题:Java RequestType类的具体用法?Java RequestType怎么用?Java RequestType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestType类属于org.herasaf.xacml.core.context.impl包,在下文中一共展示了RequestType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processDownstreamUsageRequest
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
/**
* Process Downstream usage request in string format
* @param subjectId
* @param resourceName
* @return
*/
public List<PIIType> processDownstreamUsageRequest(String subjectId, String resourceName){
RequestType request = PDPRequest.createXacmlRequest(subjectId, resourceName);
ResponseType response;
List<PIIType> piis = new ArrayList<PIIType>();
response = pdp.evaluate(request);
List<ResultType> results = response.getResult();
for(ResultType result : results){
if(result.getStatus().getStatusCode().getValue() == StatusCodeType.STATUS_OK){
if(result.getDecision() == DecisionType.PERMIT){
PIIType pii = piiDao.findObject(PIIType.class, Long.parseLong(result.getResourceId()));
eventHandler.firePersonalDataSent(pii, subjectId);
loggerHandler.logDownstreamUsage(pii, subjectId);
piis.add(pii);
}
}
}
return piis;
}
示例2: testFindApplicableRule
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
@Test
public void testFindApplicableRule() throws WritingException, SyntaxException, org.herasaf.xacml.core.SyntaxException, ProcessingException, MissingAttributeException, JAXBException, IOException {
PDPRequest req = readPolicy("/accessControlUtilsTest/demo_policy.xml", "dummy");
RequestType request = req.createXacmlRequest("http://www.example.org/names#user_name");
PolicyType policy1 = (PolicyType) unmarshallerPrime.unmarshal(
getClass().getResourceAsStream("/accessControlUtilsTest/demo_preferences.xml"));
PolicyType policy2 = (PolicyType) unmarshallerPrime.unmarshal(
getClass().getResourceAsStream("/accessControlUtilsTest/test_applicable_policy.xml"));
List<Object> policySetOrPolicy = new LinkedList<Object>();// preferenceGroup from file
policySetOrPolicy.add(policy1);
RuleType rule = accessControlUtils.findApplicableRule(policySetOrPolicy, request);
Assert.assertEquals("#username", rule.getRuleId());
policySetOrPolicy.clear();
policySetOrPolicy.add(policy2);
request = req.createXacmlRequest("http://www.w3.org/2006/vcard/ns#email");
rule = accessControlUtils.findApplicableRule(policySetOrPolicy, request);
Assert.assertEquals("#loginPreferences", rule.getRuleId());
}
示例3: evaluateRequest
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
@Override
public XacmlResponseDto evaluateRequest(XacmlRequestDto xacmlRequest){
log.info("evaluateRequest invoked");
final RequestType request = requestGenerator.generateRequest(xacmlRequest);
log.debug(createPDPRequestLogMessage(request));
return managePoliciesAndEvaluateRequest(request, xacmlRequest);
}
示例4: managePoliciesAndEvaluateRequest
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
private synchronized XacmlResponseDto managePoliciesAndEvaluateRequest(
RequestType request, XacmlRequestDto xacmlRequest)
throws C2SAuditException, NoPolicyFoundException,
PolicyProviderException {
PDP pdp = getSimplePDP();
deployPolicies(pdp, xacmlRequest);
return managePoliciesAndEvaluateRequest(pdp, request);
}
示例5: createPDPRequestLogMessage
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
private String createPDPRequestLogMessage(RequestType request) {
final String logMsgPrefix = "PDP Request: ";
final String errMsg = "Failed during marshalling PDP Request";
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
RequestMarshaller.marshal(request, baos);
return new StringBuilder().append(logMsgPrefix).append(new String(baos.toByteArray())).toString();
} catch (Exception e) {
log.error(new StringBuilder().append(errMsg).append(" : ").append(e.getMessage()).toString());
}
return logMsgPrefix + errMsg;
}
示例6: generateRequest
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
public RequestType generateRequest(XacmlRequestDto xacmlRequest) {
RequestType requestType = null;
final String request = generateRequestString(xacmlRequest);
final InputStream is = new ByteArrayInputStream(request.getBytes());
try {
requestType = unmarshalRequest(is);
} catch (final SyntaxException e) {
logger.debug(e.getMessage(), e);
}
return requestType;
}
示例7: generateRequest
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
/**
* Generate request.
*
* @param recepientSubjectNPI the recepient subject npi
* @param intermediarySubjectNPI the intermediary subject npi
* @param purposeOfUse the purpose of use
* @param patientId the patient id
* @return the request type
*/
public RequestType generateRequest(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId){
RequestType requestType=null;
String request=generateRequestString (recepientSubjectNPI, intermediarySubjectNPI, purposeOfUse, patientId);
InputStream is =new ByteArrayInputStream(request.getBytes());
try {
// Need call SimplePDPFactory.getSimplePDP() to use RequestMarshaller from herasaf
requestType=unmarshalRequest(is);
} catch (SyntaxException e) {
LOGGER.debug(e.toString(),e);
}
return requestType;
}
示例8: evaluateRequest
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
@Override
public XacmlResponse evaluateRequest(PDP pdp, RequestType request,
String patientUniqueId) {
LOGGER.info("evaluateRequest invoked");
List<Evaluatable> deployedPolicies = deployPolicies(pdp,
patientUniqueId);
return managePoliciesAndEvaluateRequest(pdp, request, deployedPolicies);
}
示例9: testGenerateRequest
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
@Test
public void testGenerateRequest() throws SyntaxException{
RequestGenerator sut=spy(requestGenerator);
RequestType request=mock(RequestType.class);
doReturn(request).when(sut).unmarshalRequest(any(InputStream.class));
when(sut.getDate()).thenReturn("2013-12-23T14:48:07-0500");
sut.generateRequest("123", "456", "TREAT", "789");
verify (sut,times(1)).unmarshalRequest(any(InputStream.class));
}
示例10: checkAccess
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
/**
* Access control:
* Check the target elements of the policySetOrPolicy with HERAS against the request. *
*
* @param policySetOrPolicy - a list of PolicyType or PolicySetType objects from PPL
* @param request - the XACML request
* @return the decision (PERMIT, DENY, INDETERMINATE, NOT_APPLICABLE)
* @throws WritingException
* @throws SyntaxException
* @throws com.sap.research.primelife.exceptions.SyntaxException
* @throws JAXBException
*/
public DecisionType checkAccess(List<Object> policySetOrPolicy, RequestType request)
throws WritingException, SyntaxException, com.sap.research.primelife.exceptions.SyntaxException, JAXBException{
// we evaluate request against policy repository associated with the PII
SimplePDPFactory.useDefaultInitializers();
PDP simplePDP = SimplePDPFactory.getSimplePDP();
PolicyRepository repo = simplePDP.getPolicyRepository();
// initialize policy repository
for (Object obj : policySetOrPolicy) {
Evaluatable evaluatable = null;
if (obj instanceof PolicySetType) {
evaluatable = ConverterFunctions.convertToHerasPolicySet(
(PolicySetType) obj);
}
else if (obj instanceof PolicyType) {
evaluatable = ConverterFunctions.convertToHerasPolicy(
(PolicyType) obj);
}
else if (obj instanceof eu.primelife.ppl.policy.xacml.impl.PolicyType) {
evaluatable = ConverterFunctions.convertToHerasPolicy((eu.primelife.ppl.policy.xacml.impl.PolicyType) obj);
}
repo.deploy(evaluatable);
}
ResponseCtx responseCtx = simplePDP.evaluate(new RequestCtx(request));
DecisionType decision = responseCtx.getResponse().getResults().get(0).getDecision();
return decision;
}
示例11: matchTarget
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
/**
* Converts Target element from PPL schema to HERAS schema and matches
* it against the request using HERAS {@link TargetMatcher}.
*
* @param request HERAS request
* @param target Target element in PPL schema format
*
* @return result of matching (true if the target is applicable)
* @throws JAXBException
*/
private static boolean matchTarget(RequestType request, TargetType target)
throws WritingException,
com.sap.research.primelife.exceptions.SyntaxException,
FileNotFoundException, SyntaxException, ProcessingException,
MissingAttributeException, JAXBException {
//converting the target from PPL TargetType to HERAS TargetType
org.herasaf.xacml.core.policy.impl.TargetType herasTarget = ConverterFunctions.fromPPLTargetToHerasTarget(target);
return targetMatcher.match(request, herasTarget, new RequestInformation(null));
}
示例12: evaluate
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
/**
* @param XACML request
* @return XACML reponse
* @throws JAXBException
* @throws org.herasaf.xacml.core.SyntaxException
* @throws WritingException
* @throws org.herasaf.xacml.core.SyntaxException
* @throws MissingAttributeException
* @throws ProcessingException
* @throws FileNotFoundException
* @throws Exception
*/
public ResponseType evaluate(RequestType request) {
String name;
ResponseType response = new ResponseType();
List<ResultType> resultList = new ArrayList<ResultType>();
response.setResult(resultList);
try{
name = (String)(request.getResources().get(0).getAttributes().get(0).getAttributeValues().get(0).getContent().get(0));
if(name == null){
resultList.add(generateResultMissingAttribute());
return response;
}
}catch(RuntimeException e){
resultList.add(generateResultMissingAttribute());
return response;
}
// Get the requested Piis
List<PIIType> piiList = piiQueryStategy.executeQuery(name);
if(piiList == null || piiList.size() == 0){
LOGGER.info("No Pii found");
return null;
}
// Foreach Pii
for(PIIType pii : piiList){
evaluate(request, resultList, pii);
}
return response;
}
示例13: testEvaluateWithRequestNoResource
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
@Test
public void testEvaluateWithRequestNoResource(){
RequestType requestWithoutResource= this.createXacmlRequestWithNoResource("[email protected]");
ResponseType response = pdp.evaluate(requestWithoutResource);
// PDP should have no interaction with IPIIQueryStrategy or IPolicyQueryStrategy
verifyZeroInteractions(mPiiQueryStrategy);
verifyZeroInteractions(mPolicyQueryStrategy);
// PDP should return a Response containing one single Result with StatusCode to MISSING_ATTRIBUTE
assertEquals(1, response.getResult().size());
assertEquals(StatusCodeType.STATUS_MISSING_ATTRIBUTE, response.getResult().get(0).getStatus().getStatusCode().getValue());
assertEquals(DecisionType.NOT_APPLICABLE, response.getResult().get(0).getDecision());
}
示例14: testEvaluateWithRequestMatching0Pii
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
@Test
public void testEvaluateWithRequestMatching0Pii(){
// The resource will match n Piis
when(mPiiQueryStrategy.executeQuery("file.ext")).thenReturn(new ArrayList<PIIType>());
RequestType request = this.createXacmlRequest("[email protected]", "file.ext");
ResponseType response = pdp.evaluate(request);
// PDP should have call IPIIQueryStrategy to retrieve 0 Piis
verify(mPiiQueryStrategy).executeQuery("file.ext");
// PDP should have no interaction with IPolicyQueryStrategy
verifyZeroInteractions(mPolicyQueryStrategy);
// PDP should return null
assertNull("The PDP response should be null", response);
}
示例15: createXacmlRequestWithNoResource
import org.herasaf.xacml.core.context.impl.RequestType; //导入依赖的package包/类
private RequestType createXacmlRequestWithNoResource(String subjectId) {
ObjectFactory ofHerasContext = new ObjectFactory();
//create the request query
RequestType request = ofHerasContext.createRequestType();
//create the Subject
SubjectType subjectEmail = ofHerasContext.createSubjectType();
org.herasaf.xacml.core.context.impl.AttributeType attributeEmail = ofHerasContext.createAttributeType();
AttributeValueType attributeValue = ofHerasContext.createAttributeValueType();
StringDataTypeAttribute stringDataType = new StringDataTypeAttribute();
attributeEmail.setAttributeId("http://www.primelife.eu/ppl/email");
attributeEmail.setDataType(stringDataType);
attributeValue.getContent().add(subjectId);
attributeEmail.getAttributeValues().add(attributeValue);
subjectEmail.getAttributes().add(attributeEmail);
request.getSubjects().add(subjectEmail);
// create "read" action
AttributeValueType attributeValueAction = ofHerasContext.createAttributeValueType();
attributeValueAction.getContent().add("read");
org.herasaf.xacml.core.context.impl.AttributeType attributeAction = ofHerasContext.createAttributeType();
attributeAction.setAttributeId("urn:oasis:names:tc:xacml:1.0:action:action-id");
attributeAction.setDataType(new StringDataTypeAttribute());
attributeAction.getAttributeValues().add(attributeValueAction);
ActionType action = ofHerasContext.createActionType();
action.getAttributes().add(attributeAction);
request.setAction(action);
// create empty environment
request.setEnvironment(new EnvironmentType());
return request;
}