Java Code Examples for org.opensaml.xml.io.UnmarshallingException

The following examples show how to use org.opensaml.xml.io.UnmarshallingException. These examples are extracted from open source projects. 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
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    EntityDescriptor entityDescriptor = (EntityDescriptor) parentSAMLObject;

    if (childSAMLObject instanceof Extensions) {
        entityDescriptor.setExtensions((Extensions) childSAMLObject);
    } else if (childSAMLObject instanceof Signature) {
        entityDescriptor.setSignature((Signature) childSAMLObject);
    } else if (childSAMLObject instanceof RoleDescriptor) {
        entityDescriptor.getRoleDescriptors().add((RoleDescriptor) childSAMLObject);
    } else if (childSAMLObject instanceof AffiliationDescriptor) {
        entityDescriptor.setAffiliationDescriptor((AffiliationDescriptor) childSAMLObject);
    } else if (childSAMLObject instanceof Organization) {
        entityDescriptor.setOrganization((Organization) childSAMLObject);
    } else if (childSAMLObject instanceof ContactPerson) {
        entityDescriptor.getContactPersons().add((ContactPerson) childSAMLObject);
    } else if (childSAMLObject instanceof AdditionalMetadataLocation) {
        entityDescriptor.getAdditionalMetadataLocations().add((AdditionalMetadataLocation) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 2
Source Project: lams   Source File: DSAKeyValueUnmarshaller.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
        throws UnmarshallingException {
    DSAKeyValue keyValue = (DSAKeyValue) parentXMLObject;

    if (childXMLObject instanceof P) {
        keyValue.setP((P) childXMLObject);
    } else if (childXMLObject instanceof Q) {
        keyValue.setQ((Q) childXMLObject);
    } else if (childXMLObject instanceof G) {
        keyValue.setG((G) childXMLObject);
    } else if (childXMLObject instanceof Y) {
        keyValue.setY((Y) childXMLObject);
    } else if (childXMLObject instanceof J) {
        keyValue.setJ((J) childXMLObject);
    } else if (childXMLObject instanceof Seed) {
        keyValue.setSeed((Seed) childXMLObject);
    } else if (childXMLObject instanceof PgenCounter) {
        keyValue.setPgenCounter((PgenCounter) childXMLObject);
    } else {
        super.processChildElement(parentXMLObject, childXMLObject);
    }
}
 
Example 3
Source Project: lams   Source File: PolicyTypeUnmarshaller.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
        throws UnmarshallingException {
    PolicyType policy = (PolicyType) parentXMLObject;

    if (childXMLObject instanceof DescriptionType) {
        policy.setDescription((DescriptionType) childXMLObject);
    } else if (childXMLObject.getElementQName().equals(DefaultsType.POLICY_DEFAULTS_ELEMENT_NAME)) {
        policy.setPolicyDefaults((DefaultsType) childXMLObject);
    } else if (childXMLObject instanceof TargetType) {
        policy.setTarget((TargetType) childXMLObject);
    } else if (childXMLObject instanceof CombinerParametersType) {
        policy.getCombinerParameters().add((CombinerParametersType) childXMLObject);
    } else if (childXMLObject instanceof RuleCombinerParametersType) {
        policy.getRuleCombinerParameters().add((RuleCombinerParametersType) childXMLObject);
    } else if (childXMLObject instanceof VariableDefinitionType) {
        policy.getVariableDefinitions().add((VariableDefinitionType) childXMLObject);
    } else if (childXMLObject instanceof RuleType) {
        policy.getRules().add((RuleType)childXMLObject);
    } else if (childXMLObject instanceof ObligationsType) {
        policy.setObligations((ObligationsType) childXMLObject);
    } else {
        super.processChildElement(parentXMLObject, childXMLObject);
    }
}
 
Example 4
Source Project: lams   Source File: AttributeUnmarshaller.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {

    Attribute attrib = (Attribute) samlObject;

    if (attribute.getLocalName().equals(Attribute.NAME_ATTTRIB_NAME)) {
        attrib.setName(attribute.getValue());
    } else if (attribute.getLocalName().equals(Attribute.NAME_FORMAT_ATTRIB_NAME)) {
        attrib.setNameFormat(attribute.getValue());
    } else if (attribute.getLocalName().equals(Attribute.FRIENDLY_NAME_ATTRIB_NAME)) {
        attrib.setFriendlyName(attribute.getValue());
    } else {
        QName attribQName = XMLHelper.getNodeQName(attribute);
        if (attribute.isId()) {
            attrib.getUnknownAttributes().registerID(attribQName);
        }
        attrib.getUnknownAttributes().put(attribQName, attribute.getValue());
    }
}
 
Example 5
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    StatusResponseType sr = (StatusResponseType) samlObject;

    if (attribute.getLocalName().equals(StatusResponseType.VERSION_ATTRIB_NAME)) {
        sr.setVersion(SAMLVersion.valueOf(attribute.getValue()));
    } else if (attribute.getLocalName().equals(StatusResponseType.ID_ATTRIB_NAME)) {
        sr.setID(attribute.getValue());
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    } else if (attribute.getLocalName().equals(StatusResponseType.IN_RESPONSE_TO_ATTRIB_NAME)) {
        sr.setInResponseTo(attribute.getValue());
    } else if (attribute.getLocalName().equals(StatusResponseType.ISSUE_INSTANT_ATTRIB_NAME)
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        sr.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else if (attribute.getLocalName().equals(StatusResponseType.DESTINATION_ATTRIB_NAME)) {
        sr.setDestination(attribute.getValue());
    } else if (attribute.getLocalName().equals(StatusResponseType.CONSENT_ATTRIB_NAME)) {
        sr.setConsent(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example 6
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    RoleDescriptor roleDescriptor = (RoleDescriptor) parentSAMLObject;

    if (childSAMLObject instanceof Extensions) {
        roleDescriptor.setExtensions((Extensions) childSAMLObject);
    } else if (childSAMLObject instanceof Signature) {
        roleDescriptor.setSignature((Signature) childSAMLObject);
    } else if (childSAMLObject instanceof KeyDescriptor) {
        roleDescriptor.getKeyDescriptors().add((KeyDescriptor) childSAMLObject);
    } else if (childSAMLObject instanceof Organization) {
        roleDescriptor.setOrganization((Organization) childSAMLObject);
    } else if (childSAMLObject instanceof ContactPerson) {
        roleDescriptor.getContactPersons().add((ContactPerson) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 7
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    LogoutRequest req = (LogoutRequest) parentSAMLObject;

    if (childSAMLObject instanceof BaseID) {
        req.setBaseID((BaseID) childSAMLObject);
    } else if (childSAMLObject instanceof NameID) {
        req.setNameID((NameID) childSAMLObject);
    } else if (childSAMLObject instanceof EncryptedID) {
        req.setEncryptedID((EncryptedID) childSAMLObject);
    } else if (childSAMLObject instanceof SessionIndex) {
        req.getSessionIndexes().add((SessionIndex) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 8
Source Project: lams   Source File: TargetTypeUnmarshaller.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
        throws UnmarshallingException {
    TargetType targetType = (TargetType) parentXMLObject;
    
    if(childXMLObject.getElementQName().equals(ActionsType.DEFAULT_ELEMENT_NAME)){
        targetType.setActions((ActionsType)childXMLObject);
    } else if(childXMLObject.getElementQName().equals(EnvironmentsType.DEFAULT_ELEMENT_NAME)){
        targetType.setEnvironments((EnvironmentsType)childXMLObject);
    } else  if(childXMLObject.getElementQName().equals(ResourcesType.DEFAULT_ELEMENT_NAME)){
        targetType.setResources((ResourcesType)childXMLObject);
    } else  if(childXMLObject.getElementQName().equals(SubjectsType.DEFAULT_ELEMENT_NAME)){
        targetType.setSubjects((SubjectsType)childXMLObject);
    } else {
        super.processChildElement(parentXMLObject, childXMLObject);
    }
}
 
Example 9
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    NameIDMappingRequest req = (NameIDMappingRequest) parentSAMLObject;

    if (childSAMLObject instanceof BaseID) {
        req.setBaseID((BaseID) childSAMLObject);
    } else if (childSAMLObject instanceof NameID) {
        req.setNameID((NameID) childSAMLObject);
    } else if (childSAMLObject instanceof EncryptedID) {
        req.setEncryptedID((EncryptedID) childSAMLObject);
    } else if (childSAMLObject instanceof NameIDPolicy) {
        req.setNameIDPolicy((NameIDPolicy) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 10
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    AuthnRequest req = (AuthnRequest) samlObject;

    if (attribute.getLocalName().equals(AuthnRequest.FORCE_AUTHN_ATTRIB_NAME)) {
        req.setForceAuthn(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (attribute.getLocalName().equals(AuthnRequest.IS_PASSIVE_ATTRIB_NAME)) {
        req.setIsPassive(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (attribute.getLocalName().equals(AuthnRequest.PROTOCOL_BINDING_ATTRIB_NAME)) {
        req.setProtocolBinding(attribute.getValue());
    } else if (attribute.getLocalName().equals(AuthnRequest.ASSERTION_CONSUMER_SERVICE_INDEX_ATTRIB_NAME)) {
        req.setAssertionConsumerServiceIndex(Integer.valueOf(attribute.getValue()));
    } else if (attribute.getLocalName().equals(AuthnRequest.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME)) {
        req.setAssertionConsumerServiceURL(attribute.getValue());
    } else if (attribute.getLocalName().equals(AuthnRequest.ATTRIBUTE_CONSUMING_SERVICE_INDEX_ATTRIB_NAME)) {
        req.setAttributeConsumingServiceIndex(Integer.valueOf(attribute.getValue()));
    } else if (attribute.getLocalName().equals(AuthnRequest.PROVIDER_NAME_ATTRIB_NAME)) {
        req.setProviderName(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example 11
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    AttributeSelectorType attributeSelectorType = (AttributeSelectorType) xmlObject;
    
    if (attribute.getLocalName().equals(AttributeSelectorType.REQUEST_CONTEXT_PATH_ATTRIB_NAME)){
        attributeSelectorType.setRequestContextPath(DatatypeHelper.safeTrimOrNullString(attribute.getValue()));
    } else  if (attribute.getLocalName().equals(AttributeSelectorType.DATA_TYPE_ATTRIB_NAME)){
        attributeSelectorType.setDataType(DatatypeHelper.safeTrimOrNullString(attribute.getValue()));
    } else  if (attribute.getLocalName().equals(AttributeSelectorType.MUST_BE_PRESENT_ATTRIB_NAME)){
        if (attribute.getValue().equals("True") || attribute.getValue().equals("true")) {
            attributeSelectorType.setMustBePresentXSBoolean(XSBooleanValue.valueOf("1"));
        } else {
            attributeSelectorType.setMustBePresentXSBoolean(XSBooleanValue.valueOf("0"));
        }          
    } else {
        super.processAttribute(xmlObject, attribute);
    }

}
 
Example 12
Source Project: lams   Source File: SubjectUnmarshaller.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    Subject subject = (Subject) parentObject;

    if (childObject instanceof BaseID) {
        subject.setBaseID((BaseID) childObject);
    } else if (childObject instanceof NameID) {
        subject.setNameID((NameID) childObject);
    } else if (childObject instanceof EncryptedID) {
        subject.setEncryptedID((EncryptedID) childObject);
    } else if (childObject instanceof SubjectConfirmation) {
        subject.getSubjectConfirmations().add((SubjectConfirmation) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
Example 13
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
        throws UnmarshallingException {
    X509IssuerSerial keyValue = (X509IssuerSerial) parentXMLObject;

    if (childXMLObject instanceof X509IssuerName) {
        keyValue.setX509IssuerName((X509IssuerName) childXMLObject);
    } else if (childXMLObject instanceof X509SerialNumber) {
        keyValue.setX509SerialNumber((X509SerialNumber) childXMLObject);
    } else {
        super.processChildElement(parentXMLObject, childXMLObject);
    }
}
 
Example 14
Source Project: lams   Source File: RequestUnmarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    Request request = (Request) parentSAMLObject;
    
    if (childSAMLObject instanceof Issuer) {
        request.setIssuer((Issuer) childSAMLObject);
    } else if (childSAMLObject instanceof IDPList) {
        request.setIDPList((IDPList) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 15
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    AuthzDecisionStatement authzDS = (AuthzDecisionStatement) parentObject;

    if (childObject instanceof Action) {
        authzDS.getActions().add((Action) childObject);
    } else if (childObject instanceof Evidence) {
        authzDS.setEvidence((Evidence) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
Example 16
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    XACMLPolicyStatementType xacmlpolicystatement = (XACMLPolicyStatementType) parentObject;

    if (childObject instanceof PolicyType) {
        xacmlpolicystatement.getPolicies().add((PolicyType) childObject);
    } else if (childObject instanceof PolicySetType) {
        xacmlpolicystatement.getPolicySets().add((PolicySetType) childObject);
    } else if (childObject instanceof ReferencedPoliciesType) {
        xacmlpolicystatement.setReferencedPolicies((ReferencedPoliciesType) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
Example 17
Source Project: lams   Source File: SignatureUnmarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public Signature unmarshall(Element signatureElement) throws UnmarshallingException {
    log.debug("Starting to unmarshall Apache XML-Security-based SignatureImpl element");

    SignatureImpl signature = new SignatureImpl(signatureElement.getNamespaceURI(),
            signatureElement.getLocalName(), signatureElement.getPrefix());

    try {
        log.debug("Constructing Apache XMLSignature object");

        XMLSignature xmlSignature = new XMLSignature(signatureElement, "");

        SignedInfo signedInfo = xmlSignature.getSignedInfo();

        log.debug("Adding canonicalization and signing algorithms, and HMAC output length to Signature");
        signature.setCanonicalizationAlgorithm(signedInfo.getCanonicalizationMethodURI());
        signature.setSignatureAlgorithm(signedInfo.getSignatureMethodURI());
        signature.setHMACOutputLength(getHMACOutputLengthValue(signedInfo.getSignatureMethodElement()));

        org.apache.xml.security.keys.KeyInfo xmlSecKeyInfo = xmlSignature.getKeyInfo();
        if (xmlSecKeyInfo != null) {
            log.debug("Adding KeyInfo to Signature");
            Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(
                    xmlSecKeyInfo.getElement());
            KeyInfo keyInfo = (KeyInfo) unmarshaller.unmarshall(xmlSecKeyInfo.getElement());
            signature.setKeyInfo(keyInfo);
        }
        signature.setXMLSignature(xmlSignature);
        signature.setDOM(signatureElement);
        return signature;
    } catch (XMLSecurityException e) {
        log.error("Error constructing Apache XMLSignature instance from Signature element: {}", e.getMessage());
        throw new UnmarshallingException("Unable to unmarshall Signature with Apache XMLSignature", e);
    }
}
 
Example 18
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    ObligationType obligation = (ObligationType) parentObject;

    if (childObject instanceof AttributeAssignmentType) {
        obligation.getAttributeAssignments().add((AttributeAssignmentType) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
Example 19
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    AttributedDateTime dateTime = (AttributedDateTime) xmlObject;
    
    QName attrName =
        XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
    if (AttributedDateTime.WSU_ID_ATTR_NAME.equals(attrName)) {
        dateTime.setWSUId(attribute.getValue());
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    } else {
        XMLHelper.unmarshallToAttributeMap(dateTime.getUnknownAttributes(), attribute);
    }
}
 
Example 20
Source Project: lams   Source File: BaseIDUnmarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    BaseID baseID = (BaseID) samlObject;
    if (attribute.getLocalName().equals(BaseID.NAME_QUALIFIER_ATTRIB_NAME)) {
        baseID.setNameQualifier(attribute.getValue());
    } else if (attribute.getLocalName().equals(BaseID.SP_NAME_QUALIFIER_ATTRIB_NAME)) {
        baseID.setSPNameQualifier(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example 21
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    RetrievalMethod rm = (RetrievalMethod) xmlObject;

    if (attribute.getLocalName().equals(RetrievalMethod.URI_ATTRIB_NAME)) {
        rm.setURI(attribute.getValue());
    } else if (attribute.getLocalName().equals(RetrievalMethod.TYPE_ATTRIB_NAME)) {
        rm.setType(attribute.getValue());
    } else {
        super.processAttribute(xmlObject, attribute);
    }
}
 
Example 22
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    AuthzDecisionQuery query = (AuthzDecisionQuery) parentSAMLObject;

    if (childSAMLObject instanceof Action) {
        query.getActions().add((Action) childSAMLObject);
    } else if (childSAMLObject instanceof Evidence) {
        query.setEvidence((Evidence) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 23
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlElement, Attr attribute) throws UnmarshallingException {
    RequestAbstractType request = (RequestAbstractType) samlElement;

    if (RequestAbstractType.ID_ATTRIB_NAME.equals(attribute.getLocalName())) {
        request.setID(attribute.getValue());
    } else if (RequestAbstractType.ISSUEINSTANT_ATTRIB_NAME.equals(attribute.getLocalName())
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        DateTime cal = new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC());
        request.setIssueInstant(cal);
    } else if (RequestAbstractType.MINORVERSION_ATTRIB_NAME.equals(attribute.getLocalName())) {
        int minor;
        try {
            minor = Integer.parseInt(attribute.getValue());
        } catch (NumberFormatException n) {
            log.error("Unable to parse minor version string", n);
            throw new UnmarshallingException(n);
        }
        if (minor == 0) {
            request.setVersion(SAMLVersion.VERSION_10);
        } else if (minor == 1) {
            request.setVersion(SAMLVersion.VERSION_11);
        }
    } else {
        super.processAttribute(samlElement, attribute);
    }
}
 
Example 24
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    AttributeQuery query = (AttributeQuery) parentSAMLObject;

    if (childSAMLObject instanceof Attribute) {
        query.getAttributes().add((Attribute) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 25
Source Project: lams   Source File: AssertionUnmarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public XMLObject unmarshall(Element domElement) throws UnmarshallingException {
    // After regular unmarshalling, check the minor version and set ID-ness if not SAML 1.0
    Assertion assertion = (Assertion) super.unmarshall(domElement);
    if (assertion.getMinorVersion() != 0 && !DatatypeHelper.isEmpty(assertion.getID())) {
        domElement.setIdAttributeNS(null, Assertion.ID_ATTRIB_NAME, true);
    }
    return assertion;
}
 
Example 26
Source Project: lams   Source File: IDPListUnmarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
        throws UnmarshallingException {
    IDPList list = (IDPList) parentSAMLObject;

    if (childSAMLObject instanceof IDPEntry) {
        list.getIDPEntrys().add((IDPEntry) childSAMLObject);
    } else if (childSAMLObject instanceof GetComplete) {
        list.setGetComplete((GetComplete) childSAMLObject);
    } else {
        super.processChildElement(parentSAMLObject, childSAMLObject);
    }
}
 
Example 27
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    AttributeConsumingService service = (AttributeConsumingService) samlObject;

    if (attribute.getLocalName().equals(AttributeConsumingService.INDEX_ATTRIB_NAME)) {
        service.setIndex(Integer.valueOf(attribute.getValue()));
    } else if (attribute.getLocalName().equals(AttributeConsumingService.IS_DEFAULT_ATTRIB_NAME)) {
        service.setIsDefault(XSBooleanValue.valueOf(attribute.getValue()));
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example 28
Source Project: lams   Source File: XMLObjectHelper.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unmarshall a Document from an InputSteam.
 * 
 * @param parserPool the ParserPool instance to use
 * @param inputStream the InputStream to unmarshall
 * @return the unmarshalled XMLObject
 * @throws XMLParserException if there is a problem parsing the input data
 * @throws UnmarshallingException if there is a problem unmarshalling the parsed DOM
 */
public static XMLObject unmarshallFromInputStream(ParserPool parserPool, InputStream inputStream)
        throws XMLParserException, UnmarshallingException {
    Logger log = getLogger();
    log.debug("Parsing InputStream into DOM document");

    Document messageDoc = parserPool.parse(inputStream);
    Element messageElem = messageDoc.getDocumentElement();

    if (log.isTraceEnabled()) {
        log.trace("Resultant DOM message was:");
        log.trace(XMLHelper.nodeToString(messageElem));
    }

    log.debug("Unmarshalling DOM parsed from InputStream");
    Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(messageElem);
    if (unmarshaller == null) {
        log.error("Unable to unmarshall InputStream, no unmarshaller registered for element "
                + XMLHelper.getNodeQName(messageElem));
        throw new UnmarshallingException(
                "Unable to unmarshall InputStream, no unmarshaller registered for element "
                        + XMLHelper.getNodeQName(messageElem));
    }

    XMLObject message = unmarshaller.unmarshall(messageElem);

    log.debug("InputStream succesfully unmarshalled");
    return message;
}
 
Example 29
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    if(attribute.getLocalName().equals(PolicySetCombinerParametersType.POLICY_SET_ID_REF_ATTRIB_NAME)){
        PolicySetCombinerParametersType policySetCombinerParametersType = 
            (PolicySetCombinerParametersType)xmlObject;
        policySetCombinerParametersType.setPolicySetIdRef(
                DatatypeHelper.safeTrimOrNullString(attribute.getValue()));
    } else {
        super.processAttribute(xmlObject, attribute);
    }

}
 
Example 30
Source Project: lams   Source File: KeyInfoTypeUnmarshaller.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
        throws UnmarshallingException {
    KeyInfoType keyInfo = (KeyInfoType) parentXMLObject;

    // KeyInfoType contains a range of specific types, but also
    // support <any>, with an unbounded choice over all (no ordering)
    // so no need to distinguish.
    keyInfo.getXMLObjects().add(childXMLObject);
}