Java Code Examples for org.apache.neethi.Policy#getAlternatives()
The following examples show how to use
org.apache.neethi.Policy#getAlternatives() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecipientTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; RecipientToken recipientToken = new RecipientToken(consts, builder); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), recipientToken); /* * for the moment we will pick the first token specified in the policy */ break; } return recipientToken; }
Example 2
Source File: RecipientEncryptionTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; RecipientEncryptionToken recipientEncryptionToken = new RecipientEncryptionToken(consts, builder); recipientEncryptionToken.setOptional(PolicyConstants.isOptional(element)); recipientEncryptionToken.setIgnorable(PolicyConstants.isIgnorable(element)); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), recipientEncryptionToken); break; // TODO process all the token that must be set .. } return recipientEncryptionToken; }
Example 3
Source File: InitiatorEncryptionTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; InitiatorEncryptionToken initiatorToken = new InitiatorEncryptionToken(consts, builder); initiatorToken.setOptional(PolicyConstants.isOptional(element)); initiatorToken.setIgnorable(PolicyConstants.isIgnorable(element)); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), initiatorToken); break; // TODO process all the token that must be set .. } return initiatorToken; }
Example 4
Source File: AsymmetricBindingBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; AsymmetricBinding asymmetricBinding = new AsymmetricBinding(consts, builder); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); Iterator<List<Assertion>> iterator = policy.getAlternatives(); if (!iterator.hasNext()) { throw new IllegalArgumentException( "sp:AsymmetricBinding must specify at least one alternative" ); } processAlternative(iterator.next(), asymmetricBinding, consts); return asymmetricBinding; }
Example 5
Source File: InitiatorSignatureTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; InitiatorSignatureToken initiatorToken = new InitiatorSignatureToken(consts, builder); initiatorToken.setOptional(PolicyConstants.isOptional(element)); initiatorToken.setIgnorable(PolicyConstants.isIgnorable(element)); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), initiatorToken); break; // TODO process all the token that must be set .. } return initiatorToken; }
Example 6
Source File: ProtectionTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; ProtectionToken protectionToken = new ProtectionToken(consts, builder); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), protectionToken); break; // since there should be only one alternative .. } return protectionToken; }
Example 7
Source File: RecipientEncryptionTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; RecipientEncryptionToken recipientEncryptionToken = new RecipientEncryptionToken(consts, builder); recipientEncryptionToken.setOptional(PolicyConstants.isOptional(element)); recipientEncryptionToken.setIgnorable(PolicyConstants.isIgnorable(element)); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), recipientEncryptionToken); break; // TODO process all the token that must be set .. } return recipientEncryptionToken; }
Example 8
Source File: AsymmetricBindingBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; AsymmetricBinding asymmetricBinding = new AsymmetricBinding(consts, builder); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); Iterator<List<Assertion>> iterator = policy.getAlternatives(); if (!iterator.hasNext()) { throw new IllegalArgumentException( "sp:AsymmetricBinding must specify at least one alternative" ); } processAlternative(iterator.next(), asymmetricBinding, consts); return asymmetricBinding; }
Example 9
Source File: RecipientSignatureTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; RecipientSignatureToken recipientSignatureToken = new RecipientSignatureToken(consts, builder); recipientSignatureToken.setOptional(PolicyConstants.isOptional(element)); recipientSignatureToken.setIgnorable(PolicyConstants.isIgnorable(element)); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), recipientSignatureToken); break; // TODO process all the token that must be set .. } return recipientSignatureToken; }
Example 10
Source File: InitiatorTokenBuilder.java From steady with Apache License 2.0 | 6 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; InitiatorToken initiatorToken = new InitiatorToken(consts, builder); initiatorToken.setOptional(PolicyConstants.isOptional(element)); initiatorToken.setIgnorable(PolicyConstants.isIgnorable(element)); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), initiatorToken); break; // TODO process all the token that must be set .. } return initiatorToken; }
Example 11
Source File: EffectivePolicyImpl.java From cxf with Apache License 2.0 | 5 votes |
protected Collection<Assertion> getSupportedAlternatives(PolicyEngine engine, Policy p, Message m) { Collection<Assertion> alternatives = new ArrayList<>(); for (Iterator<List<Assertion>> it = p.getAlternatives(); it.hasNext();) { List<Assertion> alternative = it.next(); if (engine.supportsAlternative(alternative, null, m)) { alternatives.addAll(alternative); } } return alternatives; }
Example 12
Source File: AssertionInfoMap.java From cxf with Apache License 2.0 | 5 votes |
public List<List<Assertion>> checkEffectivePolicy(Policy policy) { List<List<Assertion>> validated = new ArrayList<>(4); List<QName> errors = new ArrayList<>(); Iterator<List<Assertion>> alternatives = policy.getAlternatives(); while (alternatives.hasNext()) { List<Assertion> pc = alternatives.next(); if (supportsAlternative(pc, errors)) { validated.add(pc); } } if (!validated.isEmpty()) { return validated; } Set<String> msgs = new LinkedHashSet<>(); for (QName name : errors) { Collection<AssertionInfo> ais = getAssertionInfo(name); boolean found = false; for (AssertionInfo ai : ais) { if (!ai.isAsserted()) { String s = name.toString(); if (ai.getErrorMessage() != null) { s += ": " + ai.getErrorMessage(); } msgs.add(s); found = true; } } if (!found) { msgs.add(name.toString()); } } StringBuilder error = new StringBuilder(); for (String msg : msgs) { error.append('\n').append(msg); } throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE, error.toString())); }
Example 13
Source File: AssertionInfoMap.java From cxf with Apache License 2.0 | 4 votes |
public boolean supportsAlternative(PolicyComponent assertion, List<QName> errors) { boolean pass = true; if (assertion instanceof PolicyAssertion) { PolicyAssertion a = (PolicyAssertion)assertion; if (!a.isAsserted(this) && !a.isOptional()) { errors.add(a.getName()); pass = false; } } else if (assertion instanceof Assertion) { Assertion ass = (Assertion)assertion; Collection<AssertionInfo> ail = getAssertionInfo(ass.getName()); boolean found = false; for (AssertionInfo ai : ail) { if (ai.getAssertion().equal(ass) || ai.getAssertion().equals(ass)) { found = true; if (!ai.isAsserted() && !ass.isOptional()) { errors.add(ass.getName()); pass = false; } } } if (!found) { errors.add(ass.getName()); return false; } } if (assertion instanceof PolicyContainingAssertion) { Policy p = ((PolicyContainingAssertion)assertion).getPolicy(); if (p != null) { Iterator<List<Assertion>> alternatives = p.getAlternatives(); while (alternatives.hasNext()) { List<Assertion> pc = alternatives.next(); for (Assertion p2 : pc) { pass &= supportsAlternative(p2, errors); } } } } return pass; }
Example 14
Source File: X509TokenBuilder.java From steady with Apache License 2.0 | 4 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; X509Token x509Token = new X509Token(consts); x509Token.setOptional(PolicyConstants.isOptional(element)); x509Token.setIgnorable(PolicyConstants.isIgnorable(element)); Element policyElement = DOMUtils.getFirstElement(element); if (policyElement == null && consts != SP11Constants.INSTANCE) { throw new IllegalArgumentException( "sp:X509Token/wsp:Policy must have a value" ); } // Process token inclusion String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken()); if (includeAttr != null) { SPConstants.IncludeTokenType inclusion = consts.getInclusionFromAttributeValue(includeAttr); x509Token.setInclusion(inclusion); } if (policyElement != null) { if (DOMUtils.getFirstChildWithName(policyElement, consts.getRequiredDerivedKeys()) != null) { x509Token.setDerivedKeys(true); } else if (DOMUtils.getFirstChildWithName(policyElement, SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS) != null) { x509Token.setImpliedDerivedKeys(true); } else if (DOMUtils.getFirstChildWithName(policyElement, SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) { x509Token.setExplicitDerivedKeys(true); } } Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), x509Token, consts); /* * since there should be only one alternative */ break; } return x509Token; }
Example 15
Source File: IssuedTokenBuilder.java From steady with Apache License 2.0 | 4 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; IssuedToken issuedToken = new IssuedToken(consts); issuedToken.setOptional(PolicyConstants.isOptional(element)); issuedToken.setIgnorable(PolicyConstants.isIgnorable(element)); String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken()); if (includeAttr != null) { issuedToken.setInclusion(consts.getInclusionFromAttributeValue(includeAttr)); } Element child = DOMUtils.getFirstElement(element); boolean foundPolicy = false; boolean foundRST = false; while (child != null) { String ln = child.getLocalName(); if (SPConstants.ISSUER.equals(ln)) { try { EndpointReferenceType epr = VersionTransformer.parseEndpointReference(child); issuedToken.setIssuerEpr(epr); } catch (JAXBException e) { throw new IllegalArgumentException(e); } } else if (SPConstants.REQUEST_SECURITY_TOKEN_TEMPLATE.equals(ln)) { foundRST = true; issuedToken.setRstTemplate(child); } else if (org.apache.neethi.Constants.ELEM_POLICY.equals(ln)) { foundPolicy = true; Policy policy = builder.getPolicy(child); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), issuedToken); break; // since there should be only one alternative .. } } else if (SPConstants.ISSUER_NAME.equals(ln)) { String issuerName = child.getNodeValue(); issuedToken.setIssuerName(issuerName); } child = DOMUtils.getNextElement(child); } if (!foundPolicy && consts != SP11Constants.INSTANCE) { throw new IllegalArgumentException( "sp:IssuedToken/wsp:Policy must have a value" ); } if (!foundRST) { throw new IllegalArgumentException( "sp:IssuedToken/sp:RequestSecurityTokenTemplate must have a value" ); } return issuedToken; }
Example 16
Source File: SupportingTokens12Builder.java From steady with Apache License 2.0 | 4 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) { QName name = DOMUtils.getElementQName(element); SupportingToken supportingToken = null; if (SP12Constants.SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SUPPORTING, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.ENDORSING_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_ENDORSING, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENDORSING, SP12Constants.INSTANCE, builder); } else if (SP12Constants.ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_ENCRYPTED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENCRYPTED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_ENDORSING_ENCRYPTED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENDORSING_ENCRYPTED, SP12Constants.INSTANCE, builder); } Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), supportingToken); /* * for the moment we will say there should be only one alternative */ break; } return supportingToken; }
Example 17
Source File: SupportingTokens12Builder.java From steady with Apache License 2.0 | 4 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) { QName name = DOMUtils.getElementQName(element); SupportingToken supportingToken = null; if (SP12Constants.SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SUPPORTING, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.ENDORSING_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_ENDORSING, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_ENDORSING_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENDORSING, SP12Constants.INSTANCE, builder); } else if (SP12Constants.ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_ENCRYPTED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENCRYPTED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.ENDORSING_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_ENDORSING_ENCRYPTED, SP12Constants.INSTANCE, builder); } else if (SP12Constants.SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS.equals(name)) { supportingToken = new SupportingToken( SupportTokenType.SUPPORTING_TOKEN_SIGNED_ENDORSING_ENCRYPTED, SP12Constants.INSTANCE, builder); } Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), supportingToken); /* * for the moment we will say there should be only one alternative */ break; } return supportingToken; }
Example 18
Source File: TransportTokenBuilder.java From steady with Apache License 2.0 | 4 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; TransportToken transportToken = new TransportToken(consts, builder); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { transportToken.setToken((Token)((iterator.next()).get(0))); break; // since there should be only one alternative } return transportToken; }
Example 19
Source File: X509TokenBuilder.java From steady with Apache License 2.0 | 4 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; X509Token x509Token = new X509Token(consts); x509Token.setOptional(PolicyConstants.isOptional(element)); x509Token.setIgnorable(PolicyConstants.isIgnorable(element)); Element policyElement = DOMUtils.getFirstElement(element); if (policyElement == null && consts != SP11Constants.INSTANCE) { throw new IllegalArgumentException( "sp:X509Token/wsp:Policy must have a value" ); } // Process token inclusion String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken()); if (includeAttr != null) { SPConstants.IncludeTokenType inclusion = consts.getInclusionFromAttributeValue(includeAttr); x509Token.setInclusion(inclusion); } if (policyElement != null) { if (DOMUtils.getFirstChildWithName(policyElement, consts.getRequiredDerivedKeys()) != null) { x509Token.setDerivedKeys(true); } else if (DOMUtils.getFirstChildWithName(policyElement, SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS) != null) { x509Token.setImpliedDerivedKeys(true); } else if (DOMUtils.getFirstChildWithName(policyElement, SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) { x509Token.setExplicitDerivedKeys(true); } } Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { processAlternative(iterator.next(), x509Token, consts); /* * since there should be only one alternative */ break; } return x509Token; }
Example 20
Source File: TransportTokenBuilder.java From steady with Apache License 2.0 | 4 votes |
public Assertion build(Element element, AssertionBuilderFactory factory) throws IllegalArgumentException { SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI()) ? SP11Constants.INSTANCE : SP12Constants.INSTANCE; TransportToken transportToken = new TransportToken(consts, builder); Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element)); policy = policy.normalize(builder.getPolicyRegistry(), false); for (Iterator<List<Assertion>> iterator = policy.getAlternatives(); iterator.hasNext();) { transportToken.setToken((Token)((iterator.next()).get(0))); break; // since there should be only one alternative } return transportToken; }