当前位置: 首页>>代码示例>>Java>>正文


Java MarshallerFactory.getMarshaller方法代码示例

本文整理汇总了Java中org.opensaml.xml.io.MarshallerFactory.getMarshaller方法的典型用法代码示例。如果您正苦于以下问题:Java MarshallerFactory.getMarshaller方法的具体用法?Java MarshallerFactory.getMarshaller怎么用?Java MarshallerFactory.getMarshaller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opensaml.xml.io.MarshallerFactory的用法示例。


在下文中一共展示了MarshallerFactory.getMarshaller方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSignature

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * Sign the SAML AuthnRequest message
 *
 * @param logoutRequest
 * @param signatureAlgorithm
 * @param cred
 * @return
 * @throws SSOAgentException
 */
public static LogoutRequest setSignature(LogoutRequest logoutRequest, String signatureAlgorithm,
                                         X509Credential cred) throws SSOAgentException {
    try {
        Signature signature = setSignatureRaw(signatureAlgorithm,cred);

        logoutRequest.setSignature(signature);

        List<Signature> signatureList = new ArrayList<Signature>();
        signatureList.add(signature);

        // Marshall and Sign
        MarshallerFactory marshallerFactory =
                org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(logoutRequest);

        marshaller.marshall(logoutRequest);

        org.apache.xml.security.Init.init();
        Signer.signObjects(signatureList);
        return logoutRequest;

    } catch (Exception e) {
        throw new SSOAgentException("Error while signing the Logout Request message", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:35,代码来源:SSOAgentUtils.java

示例2: marshall

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * `
 * Serialize XML objects
 *
 * @param xmlObject : XACML or SAML objects to be serialized
 * @return serialized XACML or SAML objects
 * @throws EntitlementException
 */
private String marshall(XMLObject xmlObject) throws EntitlementException {

    try {
        doBootstrap();
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStream);
        writer.write(element, output);
        return byteArrayOutputStream.toString();
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new EntitlementException("Error Serializing the SAML Response", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:WSXACMLMessageReceiver.java

示例3: setSignatureValue

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * Add signature to any singable XML object.
 * @param xmlObject Singable xml object.
 * @param signatureAlgorithm Signature algorithm to be used.
 * @param cred X509 Credentials.
 * @param <T> Singable XML object with signature.
 * @return Singable XML object with signature.
 * @throws SSOAgentException If error occurred.
 */
public static <T extends SignableXMLObject> T setSignatureValue(T xmlObject, String signatureAlgorithm,
                                                                X509Credential cred)
        throws SSOAgentException {

    try {
        Signature signature = setSignatureRaw(signatureAlgorithm, cred);
        xmlObject.setSignature(signature);

        List<Signature> signatureList = new ArrayList<>();
        signatureList.add(signature);

        // Marshall and Sign
        MarshallerFactory marshallerFactory =
                org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);

        marshaller.marshall(xmlObject);

        org.apache.xml.security.Init.init();
        Signer.signObjects(signatureList);
        return xmlObject;
    } catch (Exception e) {
        throw new SSOAgentException("Error while signing the SAML Request message", e);
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:35,代码来源:SSOAgentUtils.java

示例4: marshall

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * Marshall a SAML XML object into a W3C DOM and then into a String
 *
 * @param pXMLObject SAML Object to marshall
 * @return XML version of the SAML Object in string form
 */
private String marshall(XMLObject pXMLObject) {
  try {
    MarshallerFactory lMarshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
    Marshaller lMarshaller = lMarshallerFactory.getMarshaller(pXMLObject);
    Element lElement = lMarshaller.marshall(pXMLObject);

    DOMImplementationLS lDOMImplementationLS = (DOMImplementationLS) DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
    LSSerializer lSerializer = lDOMImplementationLS.createLSSerializer();
    LSOutput lOutput =  lDOMImplementationLS.createLSOutput();
    lOutput.setEncoding("UTF-8");
    Writer lStringWriter = new StringWriter();
    lOutput.setCharacterStream(lStringWriter);
    lSerializer.write(lElement, lOutput);
    return lStringWriter.toString();
  }
  catch (Exception e) {
    throw new ExInternal("Error Serializing the SAML Response", e);
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:26,代码来源:SAMLResponseCommand.java

示例5: marshall

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * Serializing a SAML2 object into a String
 *
 * @param xmlObject object that needs to serialized.
 * @return serialized object
 * @throws SAMLSSOException
 */
public static String marshall(XMLObject xmlObject) throws SAMLSSOException {
    try {

        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration
                .getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString();
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new SAMLSSOException("Error Serializing the SAML Response", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:SSOUtils.java

示例6: marshall

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * Serializing a SAML2 object into a String
 *
 * @param xmlObject object that needs to serialized.
 * @return serialized object
 * @throws SAML2SSOUIAuthenticatorException
 */
public static String marshall(XMLObject xmlObject) throws SAML2SSOUIAuthenticatorException {

    try {
        doBootstrap();
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration
                .getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString();
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new SAML2SSOUIAuthenticatorException("Error Serializing the SAML Response", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:33,代码来源:Util.java

示例7: marshall

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
private static String marshall(XMLObject xmlObject) throws org.wso2.carbon.identity.base.IdentityException {
    try {
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString("UTF-8");
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw IdentityException.error("Error Serializing the SAML Response", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:24,代码来源:ErrorResponseBuilder.java

示例8: setUp

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void setUp(){
    OrganizationBuilder orgBuilder = (OrganizationBuilder) Configuration.getBuilderFactory().getBuilder(Organization.TYPE_NAME);
    organization = orgBuilder.buildObject();            

    OrganizationNameBuilder orgNameBuilder = (OrganizationNameBuilder) Configuration.getBuilderFactory().getBuilder(OrganizationName.DEFAULT_ELEMENT_NAME);     
    OrganizationName newOrgName = orgNameBuilder.buildObject();
    newOrgName.setName(new LocalizedString("OrgFullName", "en"));
    organization.getOrganizationNames().add(newOrgName);

    OrganizationDisplayNameBuilder orgDisplayNameBuilder = (OrganizationDisplayNameBuilder) Configuration.getBuilderFactory().getBuilder(OrganizationDisplayName.DEFAULT_ELEMENT_NAME); 
    OrganizationDisplayName newOrgDisplayName = orgDisplayNameBuilder.buildObject();
    newOrgDisplayName.setName(new LocalizedString("OrgDisplayName", "en"));
    organization.getDisplayNames().add(newOrgDisplayName);

    OrganizationURLBuilder orgURLBuilder = (OrganizationURLBuilder) Configuration.getBuilderFactory().getBuilder(OrganizationURL.DEFAULT_ELEMENT_NAME);     
    OrganizationURL newOrgURL = orgURLBuilder.buildObject();    
    newOrgURL.setURL(new LocalizedString("http://org.url.edu", "en"));
    organization.getURLs().add(newOrgURL);
    
    MarshallerFactory marshallerFactory = Configuration.getMarshallerFactory();
    orgMarshaller = marshallerFactory.getMarshaller(organization);
    
    UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
    orgUnmarshaller = unmarshallerFactory.getUnmarshaller(organization.getElementQName());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:27,代码来源:RoundTripTest.java

示例9: marshall

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * Serializing a SAML2 object into a String
 *
 * @param xmlObject object that needs to serialized.
 * @return serialized object
 * @throws Exception
 */
public static String marshall(XMLObject xmlObject) throws Exception {
    try {
        doBootstrap();
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                           "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return byteArrayOutputStrm.toString();
    } catch (Exception e) {
        throw new Exception("Error Serializing the SAML Response", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:31,代码来源:Util.java

示例10: writeXML

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
public static String writeXML(XMLObject object)
		throws MarshallingException, TransformerException {
	LOGGER.entering(SamlTool.class.getName(), "writeXML", object);

	// Get the marshaller factory

	MarshallerFactory marshallerFactory = Configuration
			.getMarshallerFactory();

	Marshaller marshaller = marshallerFactory.getMarshaller(object);

	// Marshall the Subject
	Element element = marshaller.marshall(object);

	TransformerFactory tFactory = TransformerFactory.newInstance();
	Transformer transformer = tFactory.newTransformer();

	DOMSource source = new DOMSource(element);
	StringWriter writer = new StringWriter();
	StreamResult result = new StreamResult(writer);
	transformer.transform(source, result);

	LOGGER.exiting(SamlTool.class.getName(), "writeXML", writer.getBuffer()
			.toString());
	return writer.getBuffer().toString();
}
 
开发者ID:vetsin,项目名称:SamlSnort,代码行数:27,代码来源:SamlTool.java

示例11: marshall

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
/**
 * Serialize XML objects
 *
 * @param xmlObject : XACML or SAML objects to be serialized
 * @return serialized XACML or SAML objects
 */
private String marshall(XMLObject xmlObject) throws EntitlementProxyException {

    try {
        doBootstrap();
        System.setProperty(
                DOCUMENT_BUILDER_FACTORY,
                DOCUMENT_BUILDER_FACTORY_IMPL);

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStrm = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStrm);
        writer.write(element, output);
        return new String(byteArrayOutputStrm.toByteArray(), Charset.forName("UTF-8"));
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new EntitlementProxyException("Error Serializing the SAML Response", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:33,代码来源:WSXACMLEntitlementServiceClient.java

示例12: marshallSAMLObject

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
public static org.w3c.dom.Element marshallSAMLObject(final SAMLObject object) throws IllegalAccessException, UnmarshallingException, MarshallingException {
	org.w3c.dom.Element element = null;
	try {
		MarshallerFactory unMarshallerFactory = Configuration.getMarshallerFactory();

		Marshaller marshaller = unMarshallerFactory.getMarshaller(object);

		element = marshaller.marshall(object);
	} catch (ClassCastException e) {
		throw new IllegalArgumentException("The class does not implement the interface XMLObject", e);
	}

	return element;
}
 
开发者ID:rasmusson,项目名称:MockIDP,代码行数:15,代码来源:MockIDPArtifactResolve.java

示例13: writeFormatedXML

import org.opensaml.xml.io.MarshallerFactory; //导入方法依赖的package包/类
public static String writeFormatedXML(XMLObject object)
		throws MarshallingException, TransformerException {
	LOGGER.entering(SamlTool.class.getName(), "writeFormatedXML", object);

	// Get the marshaller factory

	MarshallerFactory marshallerFactory = Configuration
			.getMarshallerFactory();

	Marshaller marshaller = marshallerFactory.getMarshaller(object);

	// Marshall the Subject
	Element element = marshaller.marshall(object);

	TransformerFactory tFactory = TransformerFactory.newInstance();
	Transformer transformer = tFactory.newTransformer();
	transformer.setOutputProperty(OutputKeys.INDENT, "yes");
	transformer.setOutputProperty(
			"{http://xml.apache.org/xslt}indent-amount", "2");
	DOMSource source = new DOMSource(element);
	StringWriter writer = new StringWriter();
	StreamResult result = new StreamResult(writer);
	transformer.transform(source, result);

	LOGGER.exiting(SamlTool.class.getName(), "writeFormatedXML", writer
			.getBuffer().toString());
	return writer.getBuffer().toString();
}
 
开发者ID:vetsin,项目名称:SamlSnort,代码行数:29,代码来源:SamlTool.java


注:本文中的org.opensaml.xml.io.MarshallerFactory.getMarshaller方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。