org.opensaml.xml.io.MarshallingException Java Examples
The following examples show how to use
org.opensaml.xml.io.MarshallingException.
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: SessionKeyMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { SessionKey key = (SessionKey) samlObject; if (key.isSOAP11MustUnderstandXSBoolean() != null) { XMLHelper.marshallAttribute(SessionKey.SOAP11_MUST_UNDERSTAND_ATTR_NAME, key.isSOAP11MustUnderstandXSBoolean().toString(), domElement, false); } if (key.getSOAP11Actor() != null) { XMLHelper.marshallAttribute(SessionKey.SOAP11_ACTOR_ATTR_NAME, key.getSOAP11Actor(), domElement, false); } if (key.getAlgorithm() != null) { domElement.setAttributeNS(null, SessionKey.ALGORITHM_ATTRIB_NAME, key.getAlgorithm()); } }
Example #2
Source File: KeyDescriptorMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { KeyDescriptor keyDescriptor = (KeyDescriptor) xmlObject; if (keyDescriptor.getUse() != null) { UsageType use = keyDescriptor.getUse(); // UsageType enum contains more values than are allowed by SAML 2 schema if (use.equals(UsageType.SIGNING) || use.equals(UsageType.ENCRYPTION)) { domElement.setAttribute(KeyDescriptor.USE_ATTRIB_NAME, use.toString().toLowerCase()); } else if (use.equals(UsageType.UNSPECIFIED)) { // emit nothing for unspecified - this is semantically equivalent to non-existent attribute } else { // Just in case values are unknowingly added to UsageType in the future... throw new MarshallingException("KeyDescriptor had illegal value for use attribute: " + use.toString()); } } }
Example #3
Source File: AssertionMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { Assertion assertion = (Assertion) samlObject; if (assertion.getVersion() != null) { domElement.setAttributeNS(null, Assertion.VERSION_ATTRIB_NAME, assertion.getVersion().toString()); } if (assertion.getIssueInstant() != null) { String issueInstantStr = Configuration.getSAMLDateFormatter().print(assertion.getIssueInstant()); domElement.setAttributeNS(null, Assertion.ISSUE_INSTANT_ATTRIB_NAME, issueInstantStr); } if (assertion.getID() != null) { domElement.setAttributeNS(null, Assertion.ID_ATTRIB_NAME, assertion.getID()); domElement.setIdAttributeNS(null, Assertion.ID_ATTRIB_NAME, true); } }
Example #4
Source File: Decrypter.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Ensure that the XMLObject is marshalled. * * @param xmlObject the object to check and marshall * @throws DecryptionException thrown if there is an error when marshalling the XMLObject */ protected void checkAndMarshall(XMLObject xmlObject) throws DecryptionException { Element targetElement = xmlObject.getDOM(); if (targetElement == null) { Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject); if (marshaller == null) { marshaller = Configuration.getMarshallerFactory().getMarshaller(Configuration.getDefaultProviderQName()); if (marshaller == null) { String errorMsg = "No marshaller available for " + xmlObject.getElementQName(); log.error(errorMsg); throw new DecryptionException(errorMsg); } } try { targetElement = marshaller.marshall(xmlObject); } catch (MarshallingException e) { log.error("Error marshalling target XMLObject", e); throw new DecryptionException("Error marshalling target XMLObject", e); } } }
Example #5
Source File: EncryptedTypeMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { EncryptedType et = (EncryptedType) xmlObject; if (et.getID() != null) { domElement.setAttributeNS(null, EncryptedType.ID_ATTRIB_NAME, et.getID()); domElement.setIdAttributeNS(null, EncryptedType.ID_ATTRIB_NAME, true); } if (et.getType() != null) { domElement.setAttributeNS(null, EncryptedType.TYPE_ATTRIB_NAME, et.getType()); } if (et.getMimeType() != null) { domElement.setAttributeNS(null, EncryptedType.MIMETYPE_ATTRIB_NAME, et.getMimeType()); } if (et.getEncoding() != null) { domElement.setAttributeNS(null, EncryptedType.ENCODING_ATTRIB_NAME, et.getEncoding()); } }
Example #6
Source File: RequestMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { Request request = (Request) xmlObject; if (request.getProviderName() != null) { domElement.setAttributeNS(null, Request.PROVIDER_NAME_ATTRIB_NAME, request.getProviderName()); } if (request.isPassiveXSBoolean() != null) { domElement.setAttributeNS(null, Request.IS_PASSIVE_NAME_ATTRIB_NAME, request.isPassiveXSBoolean().toString()); } if (request.isSOAP11MustUnderstandXSBoolean() != null) { XMLHelper.marshallAttribute(Request.SOAP11_MUST_UNDERSTAND_ATTR_NAME, request.isSOAP11MustUnderstandXSBoolean().toString(), domElement, false); } if (request.getSOAP11Actor() != null) { XMLHelper.marshallAttribute(Request.SOAP11_ACTOR_ATTR_NAME, request.getSOAP11Actor(), domElement, false); } }
Example #7
Source File: ChannelBindingsMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { ChannelBindings cb = (ChannelBindings) xmlObject; if (cb.getType() != null) { domElement.setAttributeNS(null, ChannelBindings.TYPE_ATTRIB_NAME, cb.getType()); } if (cb.isSOAP11MustUnderstandXSBoolean() != null) { XMLHelper.marshallAttribute(ChannelBindings.SOAP11_MUST_UNDERSTAND_ATTR_NAME, cb.isSOAP11MustUnderstandXSBoolean().toString(), domElement, false); } if (cb.getSOAP11Actor() != null) { XMLHelper.marshallAttribute(ChannelBindings.SOAP11_ACTOR_ATTR_NAME, cb.getSOAP11Actor(), domElement, false); } }
Example #8
Source File: ResponseMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { Response response = (Response) xmlObject; if (response.getAssertionConsumerServiceURL() != null) { domElement.setAttributeNS(null, Response.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME, response.getAssertionConsumerServiceURL()); } if (response.isSOAP11MustUnderstandXSBoolean() != null) { XMLHelper.marshallAttribute(Response.SOAP11_MUST_UNDERSTAND_ATTR_NAME, response.isSOAP11MustUnderstandXSBoolean().toString(), domElement, false); } if (response.getSOAP11Actor() != null) { XMLHelper.marshallAttribute(Response.SOAP11_ACTOR_ATTR_NAME, response.getSOAP11Actor(), domElement, false); } }
Example #9
Source File: XMLObjectHelper.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Marshall an XMLObject. If the XMLObject already has a cached DOM via {@link XMLObject#getDOM()}, * that Element will be returned. Otherwise the object will be fully marshalled and that Element returned. * * @param xmlObject the XMLObject to marshall * @return the marshalled Element * @throws MarshallingException if there is a problem marshalling the XMLObject */ public static Element marshall(XMLObject xmlObject) throws MarshallingException { Logger log = getLogger(); log.debug("Marshalling XMLObject"); if (xmlObject.getDOM() != null) { log.debug("XMLObject already had cached DOM, returning that element"); return xmlObject.getDOM(); } Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject); if (marshaller == null) { log.error("Unable to marshall XMLOBject, no marshaller registered for object: " + xmlObject.getElementQName()); } Element messageElem = marshaller.marshall(xmlObject); if (log.isTraceEnabled()) { log.trace("Marshalled XMLObject into DOM:"); log.trace(XMLHelper.nodeToString(messageElem)); } return messageElem; }
Example #10
Source File: BaseMessageEncoder.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Helper method that marshalls the given message. * * @param message message the marshall and serialize * * @return marshalled message * * @throws MessageEncodingException thrown if the give message can not be marshalled into its DOM representation */ protected Element marshallMessage(XMLObject message) throws MessageEncodingException { log.debug("Marshalling message"); try { Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(message); if (marshaller == null) { log.error("Unable to marshall message, no marshaller registered for message object: " + message.getElementQName()); throw new MessageEncodingException( "Unable to marshall message, no marshaller registered for message object: " + message.getElementQName()); } Element messageElem = marshaller.marshall(message); if (log.isTraceEnabled()) { log.trace("Marshalled message into DOM:\n{}", XMLHelper.nodeToString(messageElem)); } return messageElem; } catch (MarshallingException e) { log.error("Encountered error marshalling message to its DOM representation", e); throw new MessageEncodingException("Encountered error marshalling message into its DOM representation", e); } }
Example #11
Source File: AttributeTypeMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException { AttributeType attribute = (AttributeType) samlElement; if (attribute.getIssuer() != null) { domElement.setAttributeNS(null, AttributeType.ISSUER_ATTRIB_NAME, attribute.getIssuer()); } if (attribute.getDataType() != null) { domElement.setAttributeNS(null, AttributeType.DATATYPE_ATTRIB_NAME, attribute.getDataType()); } if (attribute.getAttributeID() != null) { domElement.setAttributeNS(null, AttributeType.ATTRIBUTEID_ATTTRIB_NAME, attribute.getAttributeID()); } }
Example #12
Source File: MissingAttributeDetailTypeMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { MissingAttributeDetailType madt = (MissingAttributeDetailType) xmlObject; if (madt.getAttributeId() != null) { domElement.setAttributeNS(null, MissingAttributeDetailType.ATTRIBUTE_ID_ATTRIB_NAME, madt.getAttributeId()); } if (madt.getDataType() != null) { domElement.setAttributeNS(null, MissingAttributeDetailType.DATA_TYPE_ATTRIB_NAME, madt.getDataType()); } if (madt.getIssuer() != null) { domElement.setAttributeNS(null, MissingAttributeDetailType.ISSUER_ATTRIB_NAME, madt.getIssuer()); } }
Example #13
Source File: AuthzDecisionQueryMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { AuthzDecisionQuery query = (AuthzDecisionQuery) samlObject; if (query.getResource() != null) { domElement.setAttributeNS(null, AuthzDecisionQuery.RESOURCE_ATTRIB_NAME, query.getResource()); } super.marshallAttributes(samlObject, domElement); }
Example #14
Source File: AgreementMethodMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { AgreementMethod am = (AgreementMethod) xmlObject; if (am.getAlgorithm() != null) { domElement.setAttributeNS(null, AgreementMethod.ALGORITHM_ATTRIBUTE_NAME, am.getAlgorithm()); } }
Example #15
Source File: EncryptionMethodMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { EncryptionMethod em = (EncryptionMethod) xmlObject; if (em.getAlgorithm() != null) { domElement.setAttributeNS(null, EncryptionMethod.ALGORITHM_ATTRIB_NAME, em.getAlgorithm()); } }
Example #16
Source File: KeyInfoReferenceMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { KeyInfoReference ref = (KeyInfoReference) xmlObject; if (ref.getID() != null) { domElement.setAttributeNS(null, KeyInfoReference.ID_ATTRIB_NAME, ref.getID()); domElement.setIdAttributeNS(null, KeyInfoReference.ID_ATTRIB_NAME, true); } if (ref.getURI() != null) { domElement.setAttributeNS(null, KeyInfoReference.URI_ATTRIB_NAME, ref.getURI()); } }
Example #17
Source File: SignatureMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public Element marshall(XMLObject xmlObject) throws MarshallingException { try { Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); return marshall(xmlObject, document); } catch (ParserConfigurationException e) { throw new MarshallingException("Unable to create Document to place marshalled elements in", e); } }
Example #18
Source File: LogoutRequestMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { LogoutRequest req = (LogoutRequest) samlObject; if (req.getReason() != null) { domElement.setAttributeNS(null, LogoutRequest.REASON_ATTRIB_NAME, req.getReason()); } if (req.getNotOnOrAfter() != null) { String noaStr = Configuration.getSAMLDateFormatter().print(req.getNotOnOrAfter()); domElement.setAttributeNS(null, LogoutRequest.NOT_ON_OR_AFTER_ATTRIB_NAME, noaStr); } super.marshallAttributes(samlObject, domElement); }
Example #19
Source File: KeywordsMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { Keywords words = (Keywords) samlObject; if (words.getXMLLang() != null) { Attr attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), SAMLConstants.XML_NS, LangBearing.XML_LANG_ATTR_LOCAL_NAME, SAMLConstants.XML_PREFIX); attribute.setValue(words.getXMLLang()); domElement.setAttributeNodeNS(attribute); } }
Example #20
Source File: AuthnContextDeclMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { AuthnContextDecl authnCtxDecl = (AuthnContextDecl) xmlObject; Attr attribute; for (Entry<QName, String> entry : authnCtxDecl.getUnknownAttributes().entrySet()) { attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey()); attribute.setValue(entry.getValue()); domElement.setAttributeNodeNS(attribute); if (Configuration.isIDAttribute(entry.getKey()) || authnCtxDecl.getUnknownAttributes().isIDAttribute(entry.getKey())) { attribute.getOwnerElement().setIdAttributeNode(attribute, true); } } }
Example #21
Source File: Encrypter.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Ensure that the XMLObject is marshalled. * * @param xmlObject the object to check and marshall * @throws EncryptionException thrown if there is an error when marshalling the XMLObject */ protected void checkAndMarshall(XMLObject xmlObject) throws EncryptionException { Element targetElement = xmlObject.getDOM(); if (targetElement == null) { Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(xmlObject); try { targetElement = marshaller.marshall(xmlObject); } catch (MarshallingException e) { log.error("Error marshalling target XMLObject", e); throw new EncryptionException("Error marshalling target XMLObject", e); } } }
Example #22
Source File: NameIdentifierMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException { NameIdentifier nameIdentifier = (NameIdentifier) samlElement; if (nameIdentifier.getNameQualifier() != null) { domElement .setAttributeNS(null, NameIdentifier.NAMEQUALIFIER_ATTRIB_NAME, nameIdentifier.getNameQualifier()); } if (nameIdentifier.getFormat() != null) { domElement.setAttributeNS(null, NameIdentifier.FORMAT_ATTRIB_NAME, nameIdentifier.getFormat()); } }
Example #23
Source File: VariableReferenceTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { VariableReferenceType variableReferenceType = (VariableReferenceType) xmlObject; if(!DatatypeHelper.isEmpty(variableReferenceType.getVariableId())){ domElement.setAttribute(VariableReferenceType.VARIABLE_ID_ATTRIB_NAME, variableReferenceType.getVariableId()); } }
Example #24
Source File: RuleCombinerParametersTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { RuleCombinerParametersType ruleCombinerParametersType = (RuleCombinerParametersType)xmlObject; if(!DatatypeHelper.isEmpty(ruleCombinerParametersType.getRuleIdRef())){ domElement.setAttribute(RuleCombinerParametersType.RULE_ID_REF_ATTRIB_NAME, ruleCombinerParametersType.getRuleIdRef()); } }
Example #25
Source File: StatusMessageTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException { StatusMessageType message = (StatusMessageType)xmlObject; if(message.getValue() != null){ XMLHelper.appendTextContent(domElement, message.getValue()); } }
Example #26
Source File: RenewingMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { Renewing renewing = (Renewing) xmlObject; if (renewing.isAllowXSBoolean() != null) { domElement.setAttributeNS(null, Renewing.ALLOW_ATTRIB_NAME, renewing.isAllowXSBoolean().toString()); } if (renewing.isOKXSBoolean() != null) { domElement.setAttributeNS(null, Renewing.OK_ATTRIB_NAME, renewing.isOKXSBoolean().toString()); } }
Example #27
Source File: ResourceContentTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { ResourceContentType resourceContent = (ResourceContentType)xmlObject; Attr attribute; for (Entry<QName, String> entry : resourceContent.getUnknownAttributes().entrySet()) { attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey()); attribute.setValue(entry.getValue()); domElement.setAttributeNodeNS(attribute); if (Configuration.isIDAttribute(entry.getKey()) || resourceContent.getUnknownAttributes().isIDAttribute(entry.getKey())) { attribute.getOwnerElement().setIdAttributeNode(attribute, true); } } }
Example #28
Source File: AttributeQueryMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException { AttributeQuery attributeQuery = (AttributeQuery) samlElement; if (attributeQuery.getResource() != null) { domElement.setAttributeNS(null, AttributeQuery.RESOURCE_ATTRIB_NAME, attributeQuery.getResource()); } }
Example #29
Source File: AssertionMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException { Assertion assertion = (Assertion) samlElement; if (assertion.getID() != null) { domElement.setAttributeNS(null, Assertion.ID_ATTRIB_NAME, assertion.getID()); if (assertion.getMinorVersion() != 0) { domElement.setIdAttributeNS(null, Assertion.ID_ATTRIB_NAME, true); } } if (assertion.getIssuer() != null) { domElement.setAttributeNS(null, Assertion.ISSUER_ATTRIB_NAME, assertion.getIssuer()); } if (assertion.getIssueInstant() != null) { String date = ISODateTimeFormat.dateTime().print(assertion.getIssueInstant()); domElement.setAttributeNS(null, Assertion.ISSUEINSTANT_ATTRIB_NAME, date); } domElement.setAttributeNS(null, Assertion.MAJORVERSION_ATTRIB_NAME, "1"); if (assertion.getMinorVersion() == 0) { domElement.setAttributeNS(null, Assertion.MINORVERSION_ATTRIB_NAME, "0"); } else { domElement.setAttributeNS(null, Assertion.MINORVERSION_ATTRIB_NAME, "1"); } }
Example #30
Source File: LocalizedURIMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException { LocalizedURI name = (LocalizedURI) samlObject; if (name.getURI() != null) { XMLHelper.appendTextContent(domElement, name.getURI().getLocalString()); } }