当前位置: 首页>>代码示例>>Java>>正文


Java Evaluatable类代码示例

本文整理汇总了Java中org.herasaf.xacml.core.policy.Evaluatable的典型用法代码示例。如果您正苦于以下问题:Java Evaluatable类的具体用法?Java Evaluatable怎么用?Java Evaluatable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Evaluatable类属于org.herasaf.xacml.core.policy包,在下文中一共展示了Evaluatable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deployPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
void deployPolicies(PDP pdp, List<Evaluatable> policies,
                    XacmlRequestDto xacmlRequest, boolean isAudited) {
    try {
        final PolicyRetrievalPoint repo = pdp.getPolicyRepository();
        final UnorderedPolicyRepository repository = (UnorderedPolicyRepository) repo;
        repository.deploy(policies);
        if (isAudited) {
            for (final Evaluatable policy : policies) {
                auditPolicy(policy, xacmlRequest);
            }
        }
    } catch (AuditException | WritingException | IOException
            | DocumentAccessorException | DocumentXmlConverterException e) {
        log.error(e.getMessage(), e);
        undeployAllPolicies(pdp);
        throw new C2SAuditException(e.getMessage(), e);
    }
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:19,代码来源:PolicyDecisionPointServiceImpl.java

示例2: getPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Override
public List<Evaluatable> getPolicies(XacmlRequestDto xacmlRequest) throws NoPolicyFoundException, PolicyProviderException {
    ConsentListAndPatientDto consentListAndPatientDto = searchForFhirPatientAndFhirConsent(xacmlRequest);
    Patient fhirPatient = consentListAndPatientDto.getPatient();

    List<Consent> fhirConsentList = consentListAndPatientDto.getMatchingConsents();

    List<ConsentDto> consentDtoList = convertFhirConsentListToConsentDtoList(fhirConsentList, fhirPatient);
    List<PolicyDto> policyDtoList = convertConsentDtoListToXacmlPolicyDtoList(consentDtoList);

    PolicyContainerDto policyContainerDto = PolicyContainerDto.builder().policies(policyDtoList).build();

    Evaluatable policySet = xacmlPolicySetService.getPoliciesCombinedAsPolicySet(
            policyContainerDto,
            UUID.randomUUID().toString(),
            PolicyCombiningAlgIds.DENY_OVERRIDES.getUrn()
    );

    return Arrays.asList(policySet);
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:21,代码来源:FhirServerPolicyProviderImpl.java

示例3: validate

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
public static boolean validate(final byte[] policy) {
    boolean isValid = false;
    try {
        final String policyString = new String(policy,
                DOMUtils.DEFAULT_ENCODING);
        final Document policyDoc = DOMUtils.bytesToDocument(policy);
        final Evaluatable policyObj = PolicyMarshaller
                .unmarshal(new ByteArrayInputStream(policy));
        Assert.notNull(policyString);
        Assert.notNull(policyObj);
        Assert.notNull(policyDoc);
        isValid = true;
    } catch (final Exception e) {
        LOGGER.debug(e.getMessage(), e);
    }
    return isValid;
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:18,代码来源:PolicyValidationUtils.java

示例4: getPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Override
public List<Evaluatable> getPolicies(XacmlRequestDto xacmlRequest) throws NoPolicyFoundException, PolicyProviderException {

    final String mrn = xacmlRequest.getPatientId().getExtension();
    final String mrnDomain = xacmlRequest.getPatientId().getRoot();

    final String policyId = toPolicyId(mrn, mrnDomain,
            xacmlRequest.getRecipientNpi(),
            xacmlRequest.getIntermediaryNpi());

    // Get all policies from db
    final PolicyContainerDto policies = getPolicies(policyId);

    //PolicyDto policyDto = new PolicyDto();
    final Evaluatable policySet = xacmlPolicySetService.getPoliciesCombinedAsPolicySet(policies, UUID
                    .randomUUID().toString(),
            PolicyCombiningAlgIds.DENY_OVERRIDES.getUrn());

    return Arrays.asList(policySet);
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:21,代码来源:JdbcPolicyProviderImpl.java

示例5: testUndeployPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Test
public void testUndeployPolicies() {
	EvaluatableID id = policy.getId();
	List<EvaluatableID> ids = new LinkedList<EvaluatableID>();
	ids.add(id);
	pdp.deployPolicies(simplePDP, policies);
	assertEquals(
			"PERMIT",
			pdp.evaluateRequest(simplePDP, request,
					new LinkedList<Evaluatable>()).getPdpDecision());
	pdp.undeployPoliciesById(simplePDP, ids);
	assertEquals(
			"NOT_APPLICABLE",
			pdp.evaluateRequest(simplePDP, request,
					new LinkedList<Evaluatable>()).getPdpDecision());
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:17,代码来源:PolicyDecisionPointImplTest.java

示例6: undeployAllPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
private void undeployAllPolicies(PDP pdp) {
    final PolicyRepository repo = (PolicyRepository) pdp
            .getPolicyRepository();
    final List<Evaluatable> policies = new LinkedList<>(
            repo.getDeployment());
    for (final Evaluatable policy : policies) {
        repo.undeploy(policy.getId());
    }
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:10,代码来源:PolicyDecisionPointServiceImpl.java

示例7: auditPolicy

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
private void auditPolicy(Evaluatable policy, XacmlRequestDto xacmlRequest)
        throws WritingException, IOException, DocumentAccessorException,
        AuditException {
    final StringWriter writer = new StringWriter();
    PolicyMarshaller.marshal(policy, writer);

    Map<PredicateKey, String> predicateMap = null;

    if (auditClient.isPresent()) {
        predicateMap = auditClient.get()
                .createPredicateMap();
        final String policyString = writer.toString();
        writer.close();
        final NodeList policyIdNodeList = documentAccessor.getNodeList(
                documentXmlConverter.loadDocument(policyString), "//@PolicyId");
        Set<String> policyIdSet = null;
        if (policyIdNodeList.getLength() > 0) {
            policyIdSet = new HashSet<>();
            for (int i = 0; i < policyIdNodeList.getLength(); i++) {
                policyIdSet.add(policyIdNodeList.item(i).getNodeValue());
            }
        }
        predicateMap.put(ContextHandlerPredicateKey.XACML_POLICY, policyString);
        if (policyIdSet != null) {
            predicateMap.put(ContextHandlerPredicateKey.XACML_POLICY_ID, policyIdSet.toString());
        }
        auditClient.get().audit(this, xacmlRequest.getMessageId(), ContextHandlerAuditVerb.DEPLOY_POLICY,
                xacmlRequest.getPatientId().getExtension(), predicateMap);
    }
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:31,代码来源:PolicyDecisionPointServiceImpl.java

示例8: getPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Override
public List<Evaluatable> getPolicies(XacmlRequestDto xacmlRequest) {

    List<PolicyDto> policyDtoList = convertConsentDtoListToXacmlPolicyDtoList(xacmlRequest);

    PolicyContainerDto policyContainerDto = PolicyContainerDto.builder().policies(policyDtoList).build();

    Evaluatable policySet = xacmlPolicySetService.getPoliciesCombinedAsPolicySet(
            policyContainerDto,
            UUID.randomUUID().toString(),
            PolicyCombiningAlgIds.DENY_OVERRIDES.getUrn()
    );

    return Arrays.asList(policySet);
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:16,代码来源:PcmServicePolicyProviderImpl.java

示例9: getPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Override
public List<Evaluatable> getPolicies(XacmlRequestDto xacmlRequest) throws NoPolicyFoundException, PolicyProviderException {
    if (UNHANDLED_ERROR_PATIENT_ID.equals(xacmlRequest.getPatientId())) {
        throw new PolicyProviderException("Unhandled exception");
    } else if (PATIENT_ID.equals(xacmlRequest.getPatientId())) {
        try {
            final byte[] testXacmlBytes = Files.readAllBytes(Paths.get(new ClassPathResource("sampleXacmlTemplate.xml").getURI()));
            final PolicyDto policyDto = new PolicyDto();
            policyDto.setId("consentReferenceId");
            policyDto.setPolicy(testXacmlBytes);
            final PolicyContainerDto policyContainerDto = PolicyContainerDto.builder().policies(Collections.singletonList(policyDto)).build();


            final Evaluatable policySet = xacmlPolicySetService.getPoliciesCombinedAsPolicySet(
                    policyContainerDto,
                    UUID.randomUUID().toString(),
                    PolicyCombiningAlgIds.DENY_OVERRIDES.getUrn()
            );

            return Arrays.asList(policySet);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    } else {
        throw new NoPolicyFoundException("Test request content doesn't match.\nExpected: " + PATIENT_ID + "\nActual: " + xacmlRequest.getPatientId());
    }
}
 
开发者ID:bhits,项目名称:context-handler,代码行数:28,代码来源:PolicyProviderStub.java

示例10: evaluateRequest

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的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);
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:9,代码来源:PolicyDecisionPointImpl.java

示例11: getPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Override
public List<Evaluatable> getPolicies(String patientUniqueId) {
	List<Evaluatable> policies = new LinkedList<Evaluatable>();
	List<String> policiesString = new LinkedList<String>();
	try {
		// Retrieve policy documents
		AdhocQueryResponse response = xdsbRegistry.registryStoredQuery(
				patientUniqueId, null, XdsbDocumentType.PRIVACY_CONSENT,
				true);

		// Extract doc.request from query response
		RetrieveDocumentSetRequest retrieveDocumentSetRequest = xdsbRegistry
				.extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest(response);

		// Retrieve all policies
		RetrieveDocumentSetResponse retrieveDocumentSetResponse = xdsbRepository
				.retrieveDocumentSet(retrieveDocumentSetRequest);

		// Add policy documents to a string list
		for (DocumentResponse docResponse : retrieveDocumentSetResponse
				.getDocumentResponse()) {
			String docString = new String(docResponse.getDocument());
			docString = docString.replace(
					"<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "");
			policiesString.add(docString);
		}

		// Wrap policies in a policy set
		String policySet = makePolicySet(policiesString);

		// Unmarshall policy set as an Evaluatable and add to policy list
		Evaluatable policy = unmarshal(new ByteArrayInputStream(policySet.getBytes()));
		policies.add(policy);
	} catch (Throwable t) {
		logger.error(t.getMessage(), t);
		throw new DS4PException(
				"Consent files cannot be queried/retrieved from XDS.b");
	}
	return policies;
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:41,代码来源:PolicyDecisionPointImplDataXdsb.java

示例12: testGetPolicies

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Test
//unable to mock static class
public void testGetPolicies() throws Exception, Throwable {
	PolicyDecisionPointImplDataXdsb sut=spy(policyDecisionPointImplDataXdsb);
	byte[] xacmlPolicy="<Policy xmlns=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\"  PolicyId=\"a07478e8-3642-42ff-980e-911e26ec3f47\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable\">\r\n   <Description>This is a reference policy [email protected]</Description>\r\n   <Target></Target>\r\n   <Rule Effect=\"Permit\" RuleId=\"primary-group-rule\">\r\n      <Target>\r\n         <Resources>\r\n            <Resource>\r\n               <ResourceMatch MatchId=\"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match\">\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">[email protected]</AttributeValue>\r\n                  <ResourceAttributeDesignator AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></ResourceAttributeDesignator>\r\n               </ResourceMatch>\r\n            </Resource>\r\n         </Resources>\r\n         <Actions>\r\n            <Action>\r\n               <ActionMatch MatchId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">write</AttributeValue>\r\n                  <ActionAttributeDesignator AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></ActionAttributeDesignator>\r\n               </ActionMatch>\r\n            </Action>\r\n         </Actions>\r\n      </Target>\r\n      <Condition>\r\n         <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:and\">\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:or\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1568797520</AttributeValue>\r\n               </Apply>\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1083949036</AttributeValue>\r\n               </Apply>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:or\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1285969170</AttributeValue>\r\n               </Apply>\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1346575297</AttributeValue>\r\n               </Apply>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:or\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"gov.samhsa.consent2share.purpose-of-use-code\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TREAT</AttributeValue>\r\n               </Apply>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                  <ActionAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></ActionAttributeDesignator>\r\n               </Apply>\r\n               <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">write</AttributeValue>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-greater-than-or-equal\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-one-and-only\">\r\n                  <EnvironmentAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\"></EnvironmentAttributeDesignator>\r\n               </Apply>\r\n               <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\">2013-06-12T00:00:00-04:00</AttributeValue>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-less-than-or-equal\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-one-and-only\">\r\n                  <EnvironmentAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\"></EnvironmentAttributeDesignator>\r\n               </Apply>\r\n               <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\">2013-07-18T00:00:00-04:00</AttributeValue>\r\n            </Apply>\r\n         </Apply>\r\n      </Condition>\r\n   </Rule>\r\n   \r\n   <Rule Effect=\"Deny\" RuleId=\"Deny-the-else\"/>\r\n   \r\n   <Obligations>\r\n   \t\t<Obligation ObligationId=\"urn:samhsa:names:tc:consent2share:1.0:obligation:redact-document-section-code\" FulfillOn=\"Permit\">\r\n   \t\t\t<AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:3.0:example:attribute:text\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">47420-5</AttributeAssignment>\r\n   \t\t</Obligation>\r\n   \t\t\r\n   \t\t<Obligation ObligationId=\"urn:samhsa:names:tc:consent2share:1.0:obligation:redact-sensitivity-code\" FulfillOn=\"Permit\">\r\n         <AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:3.0:example:attribute:text\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">ETH</AttributeAssignment>\r\n      </Obligation>\r\n   </Obligations>\r\n   \r\n   \r\n   \r\n   \r\n</Policy>    ".getBytes();
	RetrieveDocumentSetResponse retrieveDocumentSetResponse
		=mock(RetrieveDocumentSetResponse.class);
	RetrieveDocumentSetRequest retrieveDocumentSetRequest
		=mock(RetrieveDocumentSetRequest.class);
	AdhocQueryResponse response
		=mock(AdhocQueryResponse.class);
	DocumentResponse docResponse1=mock(DocumentResponse.class);
	DocumentResponse docResponse2=mock(DocumentResponse.class);
	List<RetrieveDocumentSetResponse.DocumentResponse> policyDocuments=new ArrayList<RetrieveDocumentSetResponse.DocumentResponse>();
	policyDocuments.add(docResponse1);
	policyDocuments.add(docResponse2);
	Evaluatable evaluatable=mock(Evaluatable.class);
	doReturn(evaluatable).when(sut).unmarshal(any(InputStream.class));
	when(xdsbRegistry.registryStoredQuery("1", null, 
			XdsbDocumentType.PRIVACY_CONSENT,true)).thenReturn(response);
	when(xdsbRegistry.extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest(response)).thenReturn(retrieveDocumentSetRequest);
	when(xdsbRepository.retrieveDocumentSet(retrieveDocumentSetRequest)).thenReturn(retrieveDocumentSetResponse);
	when(retrieveDocumentSetResponse.getDocumentResponse()).thenReturn(policyDocuments);
	when(docResponse2.getDocument()).thenReturn(xacmlPolicy);
	when(docResponse1.getDocument()).thenReturn(xacmlPolicy);
	
	sut.getPolicies("1");
	
	verify(xdsbRegistry,times(1)).extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest(response);
	verify(xdsbRepository,times(1)).retrieveDocumentSet(retrieveDocumentSetRequest);
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:32,代码来源:PolicyDecisionPointImplDataXdsbTest.java

示例13: testGetPoliciesWhenDocumentCannotBeFound

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Test(expected=DS4PException.class)
public void testGetPoliciesWhenDocumentCannotBeFound() throws Exception, Throwable{
	PolicyDecisionPointImplDataXdsb sut=spy(policyDecisionPointImplDataXdsb);
	byte[] xacmlPolicy="<Policy xmlns=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\"  PolicyId=\"a07478e8-3642-42ff-980e-911e26ec3f47\" RuleCombiningAlgId=\"urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable\">\r\n   <Description>This is a reference policy [email protected]</Description>\r\n   <Target></Target>\r\n   <Rule Effect=\"Permit\" RuleId=\"primary-group-rule\">\r\n      <Target>\r\n         <Resources>\r\n            <Resource>\r\n               <ResourceMatch MatchId=\"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match\">\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">[email protected]</AttributeValue>\r\n                  <ResourceAttributeDesignator AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></ResourceAttributeDesignator>\r\n               </ResourceMatch>\r\n            </Resource>\r\n         </Resources>\r\n         <Actions>\r\n            <Action>\r\n               <ActionMatch MatchId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">write</AttributeValue>\r\n                  <ActionAttributeDesignator AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></ActionAttributeDesignator>\r\n               </ActionMatch>\r\n            </Action>\r\n         </Actions>\r\n      </Target>\r\n      <Condition>\r\n         <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:and\">\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:or\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1568797520</AttributeValue>\r\n               </Apply>\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1083949036</AttributeValue>\r\n               </Apply>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:or\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1285969170</AttributeValue>\r\n               </Apply>\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">1346575297</AttributeValue>\r\n               </Apply>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:or\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n                  <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                     <SubjectAttributeDesignator MustBePresent=\"false\" AttributeId=\"gov.samhsa.consent2share.purpose-of-use-code\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></SubjectAttributeDesignator>\r\n                  </Apply>\r\n                  <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">TREAT</AttributeValue>\r\n               </Apply>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-equal\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only\">\r\n                  <ActionAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" DataType=\"http://www.w3.org/2001/XMLSchema#string\"></ActionAttributeDesignator>\r\n               </Apply>\r\n               <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#string\">write</AttributeValue>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-greater-than-or-equal\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-one-and-only\">\r\n                  <EnvironmentAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\"></EnvironmentAttributeDesignator>\r\n               </Apply>\r\n               <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\">2013-06-12T00:00:00-04:00</AttributeValue>\r\n            </Apply>\r\n            <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-less-than-or-equal\">\r\n               <Apply FunctionId=\"urn:oasis:names:tc:xacml:1.0:function:dateTime-one-and-only\">\r\n                  <EnvironmentAttributeDesignator MustBePresent=\"false\" AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\"></EnvironmentAttributeDesignator>\r\n               </Apply>\r\n               <AttributeValue DataType=\"http://www.w3.org/2001/XMLSchema#dateTime\">2013-07-18T00:00:00-04:00</AttributeValue>\r\n            </Apply>\r\n         </Apply>\r\n      </Condition>\r\n   </Rule>\r\n   \r\n   <Rule Effect=\"Deny\" RuleId=\"Deny-the-else\"/>\r\n   \r\n   <Obligations>\r\n   \t\t<Obligation ObligationId=\"urn:samhsa:names:tc:consent2share:1.0:obligation:redact-document-section-code\" FulfillOn=\"Permit\">\r\n   \t\t\t<AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:3.0:example:attribute:text\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">47420-5</AttributeAssignment>\r\n   \t\t</Obligation>\r\n   \t\t\r\n   \t\t<Obligation ObligationId=\"urn:samhsa:names:tc:consent2share:1.0:obligation:redact-sensitivity-code\" FulfillOn=\"Permit\">\r\n         <AttributeAssignment AttributeId=\"urn:oasis:names:tc:xacml:3.0:example:attribute:text\" DataType=\"http://www.w3.org/2001/XMLSchema#string\">ETH</AttributeAssignment>\r\n      </Obligation>\r\n   </Obligations>\r\n   \r\n   \r\n   \r\n   \r\n</Policy>    ".getBytes();
	RetrieveDocumentSetResponse retrieveDocumentSetResponse
		=mock(RetrieveDocumentSetResponse.class);
	RetrieveDocumentSetRequest retrieveDocumentSetRequest
		=mock(RetrieveDocumentSetRequest.class);
	AdhocQueryResponse response
		=mock(AdhocQueryResponse.class);
	DocumentResponse docResponse1=mock(DocumentResponse.class);
	DocumentResponse docResponse2=mock(DocumentResponse.class);
	List<RetrieveDocumentSetResponse.DocumentResponse> policyDocuments=new ArrayList<RetrieveDocumentSetResponse.DocumentResponse>();
	policyDocuments.add(docResponse1);
	policyDocuments.add(docResponse2);
	Evaluatable evaluatable=mock(Evaluatable.class);
	doReturn(evaluatable).when(sut).unmarshal(any(InputStream.class));
	when(xdsbRegistry.registryStoredQuery("1", null, 
			XdsbDocumentType.PRIVACY_CONSENT,true)).thenReturn(response);
	doThrow(new IOException()).when(xdsbRegistry).extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest(response);
	when(xdsbRepository.retrieveDocumentSet(retrieveDocumentSetRequest)).thenReturn(retrieveDocumentSetResponse);
	when(retrieveDocumentSetResponse.getDocumentResponse()).thenReturn(policyDocuments);
	when(docResponse2.getDocument()).thenReturn(xacmlPolicy);
	when(docResponse1.getDocument()).thenReturn(xacmlPolicy);
	
	sut.getPolicies("1");
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:28,代码来源:PolicyDecisionPointImplDataXdsbTest.java

示例14: testDeployPoliciesListOfEvaluatable_NOT_APPLICABLE

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Test
public void testDeployPoliciesListOfEvaluatable_NOT_APPLICABLE() {
	// Arrange
	LinkedList<Evaluatable> emptyPolicyList = new LinkedList<Evaluatable>();

	// Act
	String decision = pdp.evaluateRequest(request, emptyPolicyList)
			.getPdpDecision();

	// Assert
	assertEquals("NOT_APPLICABLE", decision);
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:13,代码来源:PolicyDecisionPointImplTest.java

示例15: testUndeployPolicy

import org.herasaf.xacml.core.policy.Evaluatable; //导入依赖的package包/类
@Test
public void testUndeployPolicy() {
	pdp.deployPolicies(simplePDP, policies);
	pdp.undeployPolicy(simplePDP, policy);
	assertEquals(
			"NOT_APPLICABLE",
			pdp.evaluateRequest(simplePDP, request,
					new LinkedList<Evaluatable>()).getPdpDecision());
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:10,代码来源:PolicyDecisionPointImplTest.java


注:本文中的org.herasaf.xacml.core.policy.Evaluatable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。