Search in sources :

Example 1 with AssertionIDRef

use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.

the class AdviceImpl method toXMLString.

/**
    * Returns a String representation
    * @param includeNSPrefix Determines whether or not the namespace 
    *        qualifier is prepended to the Element when converted
    * @param declareNS Determines whether or not the namespace is 
    *        declared within the Element.
    * @return A String representation
    * @exception SAML2Exception if something is wrong during conversion
    */
public String toXMLString(boolean includeNSPrefix, boolean declareNS) throws SAML2Exception {
    StringBuffer sb = new StringBuffer(2000);
    String NS = "";
    String appendNS = "";
    if (declareNS) {
        NS = SAML2Constants.ASSERTION_DECLARE_STR;
    }
    if (includeNSPrefix) {
        appendNS = SAML2Constants.ASSERTION_PREFIX;
    }
    sb.append("<").append(appendNS).append(ADVICE_ELEMENT).append(NS).append(">\n");
    int length = 0;
    if (assertionIDRefs != null) {
        length = assertionIDRefs.size();
        for (int i = 0; i < length; i++) {
            AssertionIDRef assertionIDRef = (AssertionIDRef) assertionIDRefs.get(i);
            sb.append(assertionIDRef.toXMLString(includeNSPrefix, false));
        }
    }
    if (assertionURIRefs != null) {
        length = assertionURIRefs.size();
        for (int i = 0; i < length; i++) {
            String str = (String) assertionURIRefs.get(i);
            sb.append("<").append(appendNS).append(ASSERTION_URI_REF_ELEMENT).append(">").append(str).append("</").append(appendNS).append(ASSERTION_URI_REF_ELEMENT).append(">\n");
        }
    }
    if (assertions != null) {
        length = assertions.size();
        for (int i = 0; i < length; i++) {
            Assertion assertion = (Assertion) assertions.get(i);
            sb.append(assertion.toXMLString(includeNSPrefix, false));
        }
    }
    if (encryptedAssertions != null) {
        length = encryptedAssertions.size();
        for (int i = 0; i < length; i++) {
            EncryptedAssertion ea = (EncryptedAssertion) encryptedAssertions.get(i);
            sb.append(ea.toXMLString(includeNSPrefix, false));
        }
    }
    if (additionalInfo != null) {
        length = additionalInfo.size();
        for (int i = 0; i < length; i++) {
            String str = (String) additionalInfo.get(i);
            sb.append(str).append("\n");
        }
    }
    sb.append("</").append(appendNS).append(ADVICE_ELEMENT).append(">");
    return sb.toString();
}
Also used : AssertionIDRef(com.sun.identity.saml2.assertion.AssertionIDRef) EncryptedAssertion(com.sun.identity.saml2.assertion.EncryptedAssertion) EncryptedAssertion(com.sun.identity.saml2.assertion.EncryptedAssertion) Assertion(com.sun.identity.saml2.assertion.Assertion)

Example 2 with AssertionIDRef

use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.

the class AssertionIDRequestImpl method parseDOMChileElements.

/** 
     * Parses child elements of the Docuemnt Element for this object.
     * 
     * @param iter the child elements iterator.
     * @throws SAML2Exception if error parsing the Document Element.
     */
protected void parseDOMChileElements(ListIterator iter) throws SAML2Exception {
    super.parseDOMChileElements(iter);
    AssertionFactory aFactory = AssertionFactory.getInstance();
    while (iter.hasNext()) {
        Element childElement = (Element) iter.next();
        String localName = childElement.getLocalName();
        if (SAML2Constants.ASSERTION_ID_REF.equals(localName)) {
            AssertionIDRef assertionIDRef = aFactory.createAssertionIDRef(childElement);
            if (assertionIDRefs == null) {
                assertionIDRefs = new ArrayList();
            }
            assertionIDRefs.add(assertionIDRef);
        } else {
            iter.previous();
            break;
        }
    }
    if (assertionIDRefs == null) {
        throw new SAML2Exception(SAML2Utils.bundle.getString("schemaViolation"));
    }
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) AssertionFactory(com.sun.identity.saml2.assertion.AssertionFactory) AssertionIDRef(com.sun.identity.saml2.assertion.AssertionIDRef) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Example 3 with AssertionIDRef

use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.

the class AssertionIDRequestImpl method getXMLString.

protected void getXMLString(Set namespaces, StringBuffer attrs, StringBuffer childElements, boolean includeNSPrefix, boolean declareNS) throws SAML2Exception {
    validateData();
    if (declareNS) {
        namespaces.add(SAML2Constants.PROTOCOL_DECLARE_STR.trim());
        namespaces.add(SAML2Constants.ASSERTION_DECLARE_STR.trim());
    }
    super.getXMLString(namespaces, attrs, childElements, includeNSPrefix, declareNS);
    for (Iterator iter = assertionIDRefs.iterator(); iter.hasNext(); ) {
        AssertionIDRef assertionIDRef = (AssertionIDRef) iter.next();
        childElements.append(assertionIDRef.toXMLString(includeNSPrefix, declareNS)).append(SAML2Constants.NEWLINE);
    }
}
Also used : AssertionIDRef(com.sun.identity.saml2.assertion.AssertionIDRef) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator)

Example 4 with AssertionIDRef

use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.

the class AdviceImpl method makeImmutable.

/**
    * Makes the object immutable
    */
public void makeImmutable() {
    if (isMutable) {
        if (assertions != null) {
            int length = assertions.size();
            for (int i = 0; i < length; i++) {
                Assertion assertion = (Assertion) assertions.get(i);
                assertion.makeImmutable();
            }
            assertions = Collections.unmodifiableList(assertions);
        }
        if (encryptedAssertions != null) {
            encryptedAssertions = Collections.unmodifiableList(encryptedAssertions);
        }
        if (assertionIDRefs != null) {
            int length = assertionIDRefs.size();
            for (int i = 0; i < length; i++) {
                AssertionIDRef assertionIDRef = (AssertionIDRef) assertionIDRefs.get(i);
                assertionIDRef.makeImmutable();
            }
            assertionIDRefs = Collections.unmodifiableList(assertionIDRefs);
        }
        if (assertionURIRefs != null) {
            assertionURIRefs = Collections.unmodifiableList(assertionURIRefs);
        }
        if (additionalInfo != null) {
            additionalInfo = Collections.unmodifiableList(additionalInfo);
        }
        isMutable = false;
    }
}
Also used : AssertionIDRef(com.sun.identity.saml2.assertion.AssertionIDRef) EncryptedAssertion(com.sun.identity.saml2.assertion.EncryptedAssertion) Assertion(com.sun.identity.saml2.assertion.Assertion)

Example 5 with AssertionIDRef

use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.

the class AssertionIDRefImpl method parseElement.

private void parseElement(Element element) throws SAML2Exception {
    if (element == null) {
        SAML2Utils.debug.message("AssertionIDRefImpl.parseElement:" + " Input is null.");
        throw new SAML2Exception(SAML2Utils.bundle.getString("nullInput"));
    }
    String tag = element.getLocalName();
    if (!SAML2Constants.ASSERTION_ID_REF.equals(tag)) {
        SAML2Utils.debug.message("AssertionIDRefImpl.parseElement: " + "Element local name is not AssertionIDRef.");
        throw new SAML2Exception(SAML2Utils.bundle.getString("wrongInput"));
    }
    NodeList nodes = element.getChildNodes();
    int nodeCount = nodes.getLength();
    if (nodeCount > 0) {
        for (int i = 0; i < nodeCount; i++) {
            Node currentNode = nodes.item(i);
            if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
                if (SAML2Utils.debug.messageEnabled()) {
                    SAML2Utils.debug.message("AssertionIDRefImpl.parseElement: " + "AssertionIDRef can't have child element.");
                }
                throw new SAML2Exception(SAML2Utils.bundle.getString("wrongInput"));
            }
        }
    }
    value = XMLUtils.getElementValue(element);
    if ((value == null) || (value.trim().length() == 0)) {
        if (SAML2Utils.debug.messageEnabled()) {
            SAML2Utils.debug.message("AssertionIDRefImpl.parseElement: " + "AssertionIDRef value is null or empty.");
        }
        throw new SAML2Exception(SAML2Utils.bundle.getString("emptyElementValue"));
    }
    mutable = false;
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node)

Aggregations

AssertionIDRef (com.sun.identity.saml2.assertion.AssertionIDRef)5 Assertion (com.sun.identity.saml2.assertion.Assertion)3 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)3 EncryptedAssertion (com.sun.identity.saml2.assertion.EncryptedAssertion)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 AssertionFactory (com.sun.identity.saml2.assertion.AssertionFactory)1 Issuer (com.sun.identity.saml2.assertion.Issuer)1 RoleDescriptorType (com.sun.identity.saml2.jaxb.metadata.RoleDescriptorType)1 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)1 ProtocolFactory (com.sun.identity.saml2.protocol.ProtocolFactory)1 Response (com.sun.identity.saml2.protocol.Response)1 Status (com.sun.identity.saml2.protocol.Status)1 StatusCode (com.sun.identity.saml2.protocol.StatusCode)1 Date (java.util.Date)1 List (java.util.List)1 ListIterator (java.util.ListIterator)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 SAML2TokenRepositoryException (org.forgerock.openam.federation.saml2.SAML2TokenRepositoryException)1 Element (org.w3c.dom.Element)1