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


Java UnmarshallerFactory类代码示例

本文整理汇总了Java中org.opensaml.xml.io.UnmarshallerFactory的典型用法代码示例。如果您正苦于以下问题:Java UnmarshallerFactory类的具体用法?Java UnmarshallerFactory怎么用?Java UnmarshallerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: unmarshall

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructing the SAML or XACML Objects from a String
 *
 * @param xmlString Decoded SAML or XACML String
 * @return SAML or XACML Object
 * @throws org.wso2.carbon.identity.base.IdentityException
 */
public static XMLObject unmarshall(String xmlString) throws IdentityException {

    try {
        DocumentBuilderFactory documentBuilderFactory = getSecuredDocumentBuilderFactory();
        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes(Charsets.UTF_8)));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
        return unmarshaller.unmarshall(element);
    } catch (ParserConfigurationException | UnmarshallingException | SAXException | IOException e) {
        String message = "Error in constructing XML Object from the encoded String";
        throw IdentityException.error(message, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:IdentityUtil.java

示例2: Encrypter

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructor.
 * 
 */
public Encrypter() {
    UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
    encryptedDataUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedData.DEFAULT_ELEMENT_NAME);
    encryptedKeyUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedKey.DEFAULT_ELEMENT_NAME);

    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
    keyInfoBuilder = (XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);

    jcaProviderName = null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:Encrypter.java

示例3: unmarshall

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructing the SAML or XACML Objects from a String
 *
 * @param xmlString Decoded SAML or XACML String
 * @return SAML or XACML Object
 * @throws org.wso2.carbon.identity.entitlement.EntitlementException
 */
public XMLObject unmarshall(String xmlString) throws EntitlementException {

    try {
        doBootstrap();
        DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory();

        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes()));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
        return unmarshaller.unmarshall(element);
    } catch (Exception e) {
        log.error("Error in constructing XML(SAML or XACML) Object from the encoded String", e);
        throw new EntitlementException("Error in constructing XML(SAML or XACML) from the encoded String ", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:WSXACMLMessageReceiver.java

示例4: unmarshall

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructing the SAML or XACML Objects from a String
 *
 * @param xmlString Decoded SAML or XACML String
 * @return SAML or XACML Object
 * @throws org.wso2.carbon.identity.entitlement.EntitlementException
 */
public XMLObject unmarshall(String xmlString) throws EntitlementException {

    try {
        doBootstrap();
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);

        documentBuilderFactory.setExpandEntityReferences(false);
        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        SecurityManager securityManager = new SecurityManager();
        securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
        documentBuilderFactory.setAttribute(SECURITY_MANAGER_PROPERTY, securityManager);

        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        docBuilder.setEntityResolver(new CarbonEntityResolver());
        Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes()));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
        return unmarshaller.unmarshall(element);
    } catch (Exception e) {
        log.error("Error in constructing XML(SAML or XACML) Object from the encoded String", e);
        throw new EntitlementException("Error in constructing XML(SAML or XACML) from the encoded String ", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:33,代码来源:WSXACMLMessageReceiver.java

示例5: unmarshall

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructing the SAML or XACML Objects from a String
 *
 * @param xmlString Decoded SAML or XACML String
 * @return SAML or XACML Object
 * @throws org.wso2.carbon.identity.base.IdentityException
 */
public static XMLObject unmarshall(String xmlString) throws IdentityException {

    try {
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);

        documentBuilderFactory.setExpandEntityReferences(false);
        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        org.apache.xerces.util.SecurityManager securityManager = new SecurityManager();
        securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
        documentBuilderFactory.setAttribute(SECURITY_MANAGER_PROPERTY, securityManager);

        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        docBuilder.setEntityResolver(new CarbonEntityResolver());
        Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes(Charsets.UTF_8)));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
        return unmarshaller.unmarshall(element);
    } catch (ParserConfigurationException | UnmarshallingException | SAXException | IOException e) {
        String message = "Error in constructing XML Object from the encoded String";
        throw IdentityException.error(message, e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:IdentityUtil.java

示例6: setUp

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的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

示例7: unmarshall

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructing the XMLObject Object from a String
 *
 * @param authReqStr
 * @return Corresponding XMLObject which is a SAML2 object
 * @throws Exception
 */
public static XMLObject unmarshall(String authReqStr) throws Exception {
    try {
        doBootstrap();
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);
        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = docBuilder.parse(new ByteArrayInputStream(authReqStr.trim().getBytes()));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
        return unmarshaller.unmarshall(element);
    } catch (Exception e) {
        throw new Exception("Error in constructing AuthRequest from " +
                            "the encoded String ", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:24,代码来源:Util.java

示例8: buildOpenSamlXmlObjectFromResource

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Read a Ressource File.
 * 
 * @param resourceFile
 * @return the string representation of the file
 * @throws IOException
 * @throws SecurityException
 * @throws MessageDecodingException
 */
public static XMLObject buildOpenSamlXmlObjectFromResource(final Resource resourceFile)
		throws Exception {
	// Parse XML file
	BasicParserPool ppMgr = new BasicParserPool();
	ppMgr.setNamespaceAware(true);
	Document inCommonMDDoc = ppMgr.parse(resourceFile.getInputStream());
	Element rootElement = inCommonMDDoc.getDocumentElement();

	// Get apropriate unmarshaller
	UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
	Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(rootElement);

	// Unmarshall using the document root element, an EntitiesDescriptor in this case
	XMLObject xmlObject = unmarshaller.unmarshall(rootElement);

	Assert.assertNotNull("Unable to read test SAML XML file !", xmlObject);

	return xmlObject;
}
 
开发者ID:mxbossard,项目名称:java-saml2-sp,代码行数:29,代码来源:SamlTestResourcesHelper.java

示例9: parseSamlObject

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
public static XMLObject parseSamlObject(String xmlInput)
		throws XMLParserException, UnmarshallingException {
	LOGGER.entering(SamlTool.class.getName(), "parseSamlObject", xmlInput);

	StringReader reader = new StringReader(xmlInput);

	// Parse metadata file
	Document inCommonMDDoc = basicParserPool.parse(reader);
	Element metadataRoot = inCommonMDDoc.getDocumentElement();

	// Get apropriate unmarshaller
	UnmarshallerFactory unmarshallerFactory = Configuration
			.getUnmarshallerFactory();
	Unmarshaller unmarshaller = unmarshallerFactory
			.getUnmarshaller(metadataRoot);

	// Unmarshall using the document root element, an EntitiesDescriptor in
	// this case
	XMLObject result = unmarshaller.unmarshall(metadataRoot);
	LOGGER.exiting(SamlTool.class.getName(), "parseSamlObject", result);
	return result;
}
 
开发者ID:vetsin,项目名称:SamlSnort,代码行数:23,代码来源:SamlTool.java

示例10: setUp

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
	documentBuilderFactory.setNamespaceAware(true);
	Document doc = documentBuilderFactory.newDocumentBuilder().parse(OIORequest.class.getResourceAsStream("request.xml"));
	Configuration.getBuilderFactory();
	UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
	Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(doc.getDocumentElement());
	request = (RequestAbstractType) unmarshaller.unmarshall(doc.getDocumentElement());
	request.getIssuer().setValue("IssuerValue");
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:12,代码来源:UtilsTest.java

示例11: unmarshall

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructing the XMLObject Object from a String
 *
 * @param authReqStr
 * @return Corresponding XMLObject which is a SAML2 object
 * @throws SAML2SSOUIAuthenticatorException
 */
public static XMLObject unmarshall(String authReqStr) throws SAML2SSOUIAuthenticatorException {

    try {
        doBootstrap();
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);

        documentBuilderFactory.setExpandEntityReferences(false);
        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        SecurityManager securityManager = new SecurityManager();
        securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
        documentBuilderFactory.setAttribute(SECURITY_MANAGER_PROPERTY, securityManager);

        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        docBuilder.setEntityResolver(new CarbonEntityResolver());
        Document document = docBuilder.parse(new ByteArrayInputStream(authReqStr.trim()
                .getBytes()));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
        return unmarshaller.unmarshall(element);
    } catch (Exception e) {
        log.error("Error in constructing AuthRequest from the encoded String", e);
        throw new SAML2SSOUIAuthenticatorException("Error in constructing AuthRequest from "
                + "the encoded String ", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:35,代码来源:Util.java

示例12: unmarshall

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Constructing the SAML or XACML Objects from a String
 *
 * @param xmlString Decoded SAML or XACML String
 * @return SAML or XACML Object
 * @throws EntitlementProxyException
 */
private XMLObject unmarshall(String xmlString) throws EntitlementProxyException {

    try {
        doBootstrap();
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        documentBuilderFactory.setNamespaceAware(true);

        documentBuilderFactory.setExpandEntityReferences(false);
        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        SecurityManager securityManager = new SecurityManager();
        securityManager.setEntityExpansionLimit(ENTITY_EXPANSION_LIMIT);
        documentBuilderFactory.setAttribute(SECURITY_MANAGER_PROPERTY, securityManager);

        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        docBuilder.setEntityResolver(new CarbonEntityResolver());
        Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes(Charset.forName
                ("UTF-8"))));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
        return unmarshaller.unmarshall(element);
    } catch (Exception e) {
        log.error("Error in constructing XML(SAML or XACML) Object from the encoded String", e);
        throw new EntitlementProxyException(
                "Error in constructing XML(SAML or XACML) from the encoded String", e);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:35,代码来源:WSXACMLEntitlementServiceClient.java

示例13: parseTokenFromString

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * parseTokenFromString converts a raw wresult and extracts it into an assertion.
 *
 * @param wresult the raw token returned by the IdP
 * @return an assertion
 */
public static Assertion parseTokenFromString(final String wresult) {
    try (final InputStream in = new ByteArrayInputStream(wresult.getBytes("UTF-8"))) {
        final BasicParserPool parserPool = new BasicParserPool();
        parserPool.setNamespaceAware(true);

        final Document document = parserPool.parse(in);
        final Element metadataRoot = document.getDocumentElement();
        final UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
        final Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot);
        final RequestSecurityTokenResponseImpl rsToken = (RequestSecurityTokenResponseImpl) unmarshaller.unmarshall(metadataRoot);

        //Get our SAML token
        final List<RequestedSecurityToken> rst = rsToken.getRequestedSecurityToken();
        final AssertionImpl assertion = (AssertionImpl) rst.get(0).getSecurityTokens().get(0);

        if (assertion == null) {
            LOGGER.debug("parseTokenFromString: assertion null");
        } else {
            LOGGER.debug("parseTokenFromString: {}", assertion);
        }
        return assertion;
    } catch (final Exception ex) {
        LOGGER.warn(ex.getMessage());
        return null;
    }
}
 
开发者ID:Unicon,项目名称:cas-adfs-integration,代码行数:33,代码来源:WsFederationUtils.java

示例14: decodeSAMLResponse

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
public static Response decodeSAMLResponse(String responseMessage)
        throws ConfigurationException, ParserConfigurationException,
        SAXException, IOException, UnmarshallingException {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
    byte[] base64DecodedResponse = Base64.decode(responseMessage);
    Document document = docBuilder.parse(new ByteArrayInputStream(base64DecodedResponse));
    Element element = document.getDocumentElement();
    UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
    Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
    return (Response) unmarshaller.unmarshall(element);
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:14,代码来源:SAMLUtils.java

示例15: convertToSAMLResponse

import org.opensaml.xml.io.UnmarshallerFactory; //导入依赖的package包/类
/**
 * Convert w3c element to a SAML response
 * @param element
 * @return
 */
public org.opensaml.saml2.core.Response convertToSAMLResponse(org.w3c.dom.Element element) {
    org.opensaml.saml2.core.Response samlResponse = null;

    UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
    Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);

    if(unmarshaller == null) {
        raiseSamlValidationError("Invalid SAML Response", null);
    }

    XMLObject responseXmlObj = null;

    try {
        responseXmlObj = unmarshaller.unmarshall(element);
    } catch (UnmarshallingException e) {
        raiseSamlValidationError("Error unmarshalling response from IdP", null);
    }

    if (responseXmlObj instanceof org.opensaml.saml2.core.Response) {
        samlResponse = (org.opensaml.saml2.core.Response) responseXmlObj;
    } else {
        raiseSamlValidationError("Response is in an improper format", null);
    }

    return samlResponse;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:32,代码来源:SamlHelper.java


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