MyPresentationPolicy { public boolean isSatisfiedBy(PresentationTokenDescription ptd, TokenManager tk, KeyManager km) { if (!ptd.getPolicyUID().equals(policy.getPolicyUID())) { logger.warning("Different policyUIDs."); return false; } if (!messageEquals(ptd.getMessage(), policy.getMessage())) { logger.warning("Messages don't match."); return false; } if (!pseudonymListEquals(ptd.getPseudonym(), policy.getPseudonym())) { logger.warning("Pseudonyms don't match"); return false; } if (!credentialsEquals(ptd.getCredential(), policy.getCredential(), km)) { logger.warning("Credentials don't match"); return false; } if (!predicatesEquals(ptd.getAttributePredicate(), policy.getAttributePredicate())) { logger.warning("Predicates don't match."); return false; } if (!verifierDrivenRevocationListEquals(ptd.getVerifierDrivenRevocation(), policy.getVerifierDrivenRevocation())) { logger.warning("Verifier Driven Revocation don't match"); return false; } if(policy.isAllowSimpleProof() == false && ptd.isUsesSimpleProof()){ logger.warning("Policy does not allow simple proofs."); return false; } if(ptd.isUsesSimpleProof() && ! checkIfSimpleProofAdmissible()) { logger.warning("Policy is too complex for simple proof flag."); } if (tk != null) { return checkEstablishedPseudonyms(ptd, tk); } else { return true; } } MyPresentationPolicy(PresentationPolicy policy); PresentationPolicy getPolicy(); boolean isSatisfiedBy(PresentationTokenDescription ptd, TokenManager tk, KeyManager km); URI getPolicyUri(); List<ArrayList<MyCredentialDescription>> findCredentialAssignment(String username, 
      CredentialManager credentialManager, KeyManager km); List<ArrayList<PseudonymWithMetadata>> findPseudonymAssignment(
    List<List<PseudonymWithMetadata>> pseudonymChoice,
    List<MyCredentialDescription> credAssign); boolean filterSecrets(List<ArrayList<PseudonymWithMetadata>> pseudonymAssignment,
      List<MyCredentialDescription> credAssign); PresentationTokenDescription generateTokenDescription(
      ArrayList<MyCredentialDescription> assignment, ContextGenerator contextGenerator); List<List<MyInspectableAttribute>> computeInspectorChoice(KeyManager keyManager); List<List<PseudonymWithMetadata>> computePseudonymChoice(String username, 
      CredentialManager credentialManager, ContextGenerator contextGenerator,
      EvidenceGenerationOrchestration evidenceOrchestration); Message getMessage(); void updateIssuerToRevocationInformationUidMap(Map<URI, URI> toUpdate);  }
@Test public void testIsSatisfiedByEmpty() throws Exception { PresentationTokenDescription pt = (PresentationTokenDescription) XmlUtils.getObjectFromXML(getClass().getResourceAsStream( "/eu/abc4trust/sampleXml/presentationTokens/emptyPolicy.xml"), true); PresentationPolicyAlternatives ppa = (PresentationPolicyAlternatives) XmlUtils.getObjectFromXML(getClass().getResourceAsStream( "/eu/abc4trust/sampleXml/presentationPolicies/emptyPolicy.xml"), true); MyPresentationPolicy mypp = new MyPresentationPolicy(ppa.getPresentationPolicy().get(0)); assertTrue(mypp.isSatisfiedBy(pt, null, null)); }
@Test public void testIsSatisfiedBy() throws Exception { PresentationToken pt = (PresentationToken) XmlUtils.getObjectFromXML(getClass().getResourceAsStream( "/eu/abc4trust/sampleXml/presentationTokens/presentationTokenHotelOption1.xml"), true); PresentationTokenDescription ptd = pt.getPresentationTokenDescription(); PresentationPolicyAlternatives ppa = (PresentationPolicyAlternatives) XmlUtils.getObjectFromXML(getClass().getResourceAsStream( "/eu/abc4trust/sampleXml/presentationPolicies/presentationPolicyAlternativesHotel.xml"), true); MyPresentationPolicy mypp = new MyPresentationPolicy(ppa.getPresentationPolicy().get(0)); assertTrue(mypp.isSatisfiedBy(ptd, null, null)); }