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


Java Configuration类代码示例

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


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

示例1: unmarshall

import org.opensaml.Configuration; //导入依赖的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: testSingleLogout_IT_SLO_1

import org.opensaml.Configuration; //导入依赖的package包/类
@Test
public void testSingleLogout_IT_SLO_1() throws Exception {
	login();
	Page logoutPage = client.getPage(BASE + "/saml/Logout");
	assertEquals(302, logoutPage.getWebResponse().getStatusCode());
	String logoutRedirect = logoutPage.getWebResponse().getResponseHeaderValue("Location");
       assertTrue(logoutRedirect + " did not start with: " + idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation(), logoutRedirect.startsWith(idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation()));

	handler.url = null;
	client.getPage(BASE + "/sp/priv1.jsp");
	assertNotNull(handler.url);
	assertTrue(handler.url.toString().startsWith(idpMetadata.getFirstMetadata().getSingleSignonServiceLocation(SAMLConstants.SAML2_REDIRECT_BINDING_URI)));
	
	Document document = TestHelper.parseBase64Encoded(Utils.getParameter("SAMLRequest", logoutRedirect));
	LogoutRequest lr = (LogoutRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());
	assertEquals("joetest", lr.getNameID().getValue());
	
	OIOLogoutResponse response = OIOLogoutResponse.fromRequest(new OIOLogoutRequest(lr), StatusCode.SUCCESS_URI, null, idpMetadata.getFirstMetadata().getEntityID(), spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
	String redirectURL = response.getRedirectURL(credential, Utils.getParameter("RelayState", handler.url.toString()));
	
	Page responsePage = client.getPage(redirectURL);
	assertEquals(302, responsePage.getWebResponse().getStatusCode());
	assertEquals("http://localhost:8808/saml", responsePage.getWebResponse().getResponseHeaderValue("Location"));
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:LogoutTest.java

示例3: testBuildLogoutRequest

import org.opensaml.Configuration; //导入依赖的package包/类
@Test
public void testBuildLogoutRequest() throws Exception {
	setHandler();
	OIOLogoutRequest lr = OIOLogoutRequest.buildLogoutRequest(session, "http://logout", "issuer", handler);
	
	assertEquals("issuer", lr.getIssuer());
	assertNotNull(lr.getID());

	Credential cred = TestHelper.getCredential();
	String url = lr.getRedirectRequestURL(cred);
	String req = Utils.getParameter(Constants.SAML_SAMLREQUEST, url);
	Document document = TestHelper.parseBase64Encoded(req);
	LogoutRequest logoutRequest = (LogoutRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());

	
	assertEquals("http://logout", logoutRequest.getDestination());
	assertNotNull(logoutRequest.getIssueInstant());
	assertFalse(logoutRequest.getSessionIndexes().isEmpty());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:20,代码来源:OIOLogoutRequestTest.java

示例4: buildResponse

import org.opensaml.Configuration; //导入依赖的package包/类
protected WebRequestSettings buildResponse(String status, int assuranceLevel) throws Exception {
	Document document = TestHelper.parseBase64Encoded(Utils.getParameter("SAMLRequest", handler.url.toString()));
	AuthnRequest ar = (AuthnRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());
	
	Assertion assertion = TestHelper.buildAssertion(spMetadata.getDefaultAssertionConsumerService().getLocation(), spMetadata.getEntityID());
	
	assertion.getAttributeStatements().get(0).getAttributes().clear();
	assertion.getAttributeStatements().get(0).getAttributes().add(AttributeUtil.createAssuranceLevel(assuranceLevel));
	
	Response r = TestHelper.buildResponse(assertion);
	r.setStatus(SAMLUtil.createStatus(status));
	r.setInResponseTo(ar.getID());
	OIOResponse response = new OIOResponse(r);
	response.sign(credential);
	
	WebRequestSettings req = new WebRequestSettings(new URL(BASE + "/saml/SAMLAssertionConsumer"), SubmitMethod.POST);
	req.setRequestParameters(Arrays.asList(
			new NameValuePair("SAMLResponse", response.toBase64()),
			new NameValuePair("RelayState", Utils.getParameter("RelayState", handler.url.toString()))));
	return req;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:22,代码来源:IntegrationTests.java

示例5: testSingleLogout_IT_SLO_1

import org.opensaml.Configuration; //导入依赖的package包/类
@Test
public void testSingleLogout_IT_SLO_1() throws Exception {
	login();
	Page logoutPage = client.getPage(BASE + "/saml/Logout");
	assertEquals(302, logoutPage.getWebResponse().getStatusCode());
	String logoutRedirect = logoutPage.getWebResponse().getResponseHeaderValue("Location");
	assertTrue(logoutRedirect.startsWith(idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation()));
	
	handler.url = null;
	client.getPage(BASE + "/sp/priv1.jsp");
	assertNotNull(handler.url);
	assertTrue(handler.url.toString().startsWith(idpMetadata.getFirstMetadata().getSingleSignonServiceLocation(SAMLConstants.SAML2_REDIRECT_BINDING_URI)));
	
	Document document = TestHelper.parseBase64Encoded(Utils.getParameter("SAMLRequest", logoutRedirect));
	LogoutRequest lr = (LogoutRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());
	assertEquals("joetest", lr.getNameID().getValue());
	
	OIOLogoutResponse response = OIOLogoutResponse.fromRequest(new OIOLogoutRequest(lr), StatusCode.SUCCESS_URI, null, idpMetadata.getFirstMetadata().getEntityID(), spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
	String redirectURL = response.getRedirectURL(credential, Utils.getParameter("RelayState", handler.url.toString()));
	
	Page responsePage = client.getPage(redirectURL);
	assertEquals(302, responsePage.getWebResponse().getStatusCode());
	assertEquals("http://localhost:8808/saml", responsePage.getWebResponse().getResponseHeaderValue("Location"));
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:LogoutTest.java

示例6: setSignature

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

示例7: buildSOAPMessage

import org.opensaml.Configuration; //导入依赖的package包/类
@Override
protected Envelope buildSOAPMessage(final SAMLObject samlMessage) {
    final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();

    final SOAPObjectBuilder<Envelope> envBuilder =
            (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
    final Envelope envelope = envBuilder.buildObject(
            SOAPConstants.SOAP11_NS, Envelope.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);

    final SOAPObjectBuilder<Body> bodyBuilder =
            (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
    final Body body = bodyBuilder.buildObject(
            SOAPConstants.SOAP11_NS, Body.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);

    body.getUnknownXMLObjects().add(samlMessage);
    envelope.setBody(body);

    return envelope;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:20,代码来源:CasHTTPSOAP11Encoder.java

示例8: MetadataCredentialResolver

import org.opensaml.Configuration; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param metadataProvider provider of the metadata
 * 
 * @throws IllegalArgumentException thrown if the supplied provider is null
 */
public MetadataCredentialResolver(MetadataProvider metadataProvider) {
    super();
    if (metadataProvider == null) {
        throw new IllegalArgumentException("Metadata provider may not be null");
    }
    metadata = metadataProvider;

    cache = new HashMap<MetadataCacheKey, SoftReference<Collection<Credential>>>();

    keyInfoCredentialResolver = Configuration.getGlobalSecurityConfiguration()
            .getDefaultKeyInfoCredentialResolver();
    
    rwlock = new ReentrantReadWriteLock();

    if (metadata instanceof ObservableMetadataProvider) {
        ObservableMetadataProvider observable = (ObservableMetadataProvider) metadataProvider;
        observable.getObservers().add(new MetadataProviderObserver());
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:MetadataCredentialResolver.java

示例9: marshallAttributes

import org.opensaml.Configuration; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    AttributeValueType attributeValue = (AttributeValueType) xmlObject;

    if(!DatatypeHelper.isEmpty(attributeValue.getDataType())){
    	domElement.setAttributeNS(null,AttributeAssignmentType.DATA_TYPE_ATTRIB_NAME, attributeValue.getDataType());
    }
    
    Attr attribute;
    for (Entry<QName, String> entry : attributeValue.getUnknownAttributes().entrySet()) {
        attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
        attribute.setValue(entry.getValue());
        domElement.setAttributeNodeNS(attribute);
        if (Configuration.isIDAttribute(entry.getKey())
                || attributeValue.getUnknownAttributes().isIDAttribute(entry.getKey())) {
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AttributeValueTypeMarshaller.java

示例10: buildSOAPMessage

import org.opensaml.Configuration; //导入依赖的package包/类
/**
 * Builds the SOAP message to be encoded.
 * 
 * @param samlMessage body of the SOAP message
 * 
 * @return the SOAP message
 */
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
    log.debug("Building SOAP message");
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();

    SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
            .getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
    Envelope envelope = envBuilder.buildObject();

    log.debug("Adding SAML message to the SOAP message's body");
    SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
            .getBuilder(Body.DEFAULT_ELEMENT_NAME);
    Body body = bodyBuilder.buildObject();
    body.getUnknownXMLObjects().add(samlMessage);
    envelope.setBody(body);

    return envelope;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:HTTPSOAP11Encoder.java

示例11: marshallAttributes

import org.opensaml.Configuration; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
    RequestAbstractType request = (RequestAbstractType) samlElement;

    if (request.getID() != null) {
        domElement.setAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, request.getID());
        if (request.getMinorVersion() != 0) {
            domElement.setIdAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, true);
        }
    }

    if (request.getIssueInstant() != null) {
        String date = Configuration.getSAMLDateFormatter().print(request.getIssueInstant());
        domElement.setAttributeNS(null, RequestAbstractType.ISSUEINSTANT_ATTRIB_NAME, date);
    }
    if (request.getMinorVersion() != 0) {
        domElement.setAttributeNS(null, RequestAbstractType.MAJORVERSION_ATTRIB_NAME, "1");
        domElement.setAttributeNS(null, RequestAbstractType.MINORVERSION_ATTRIB_NAME, Integer.toString(request
                .getMinorVersion()));
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:RequestAbstractTypeMarshaller.java

示例12: buildSOAPMessage

import org.opensaml.Configuration; //导入依赖的package包/类
/**
 * Builds the SOAP message to be encoded.
 * 
 * @param samlMessage body of the SOAP message
 * 
 * @return the SOAP message
 */
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
    if (log.isDebugEnabled()) {
        log.debug("Building SOAP message");
    }
    XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();

    SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
            .getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
    Envelope envelope = envBuilder.buildObject();

    if (log.isDebugEnabled()) {
        log.debug("Adding SAML message to the SOAP message's body");
    }
    SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
            .getBuilder(Body.DEFAULT_ELEMENT_NAME);
    Body body = bodyBuilder.buildObject();
    body.getUnknownXMLObjects().add(samlMessage);
    envelope.setBody(body);

    return envelope;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:HTTPSOAP11Encoder.java

示例13: init

import org.opensaml.Configuration; //导入依赖的package包/类
/**
 * Helper method for constructors.
 */
private void init() {
    builderFactory = Configuration.getBuilderFactory();
    keyInfoBuilder = 
        (XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);
    dataReferenceBuilder = 
        (XMLEncryptionBuilder<DataReference>) builderFactory.getBuilder(DataReference.DEFAULT_ELEMENT_NAME);
    referenceListBuilder = 
        (XMLEncryptionBuilder<ReferenceList>) builderFactory.getBuilder(ReferenceList.DEFAULT_ELEMENT_NAME);
    retrievalMethodBuilder = 
        (XMLSignatureBuilder<RetrievalMethod>) builderFactory.getBuilder(RetrievalMethod.DEFAULT_ELEMENT_NAME);
    keyNameBuilder = 
        (XMLSignatureBuilder<KeyName>) builderFactory.getBuilder(KeyName.DEFAULT_ELEMENT_NAME);
    carriedKeyNameBuilder = 
        (XMLEncryptionBuilder<CarriedKeyName>) builderFactory.getBuilder(CarriedKeyName.DEFAULT_ELEMENT_NAME);
    
    try{
        idGenerator = new SecureRandomIdentifierGenerator();
    }catch(NoSuchAlgorithmException e){
        log.error("JVM does not support SHA1PRNG random number generation algorithm.");
    }
    
    keyPlacement = KeyPlacement.PEER;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:Encrypter.java

示例14: marshallAttributes

import org.opensaml.Configuration; //导入依赖的package包/类
/** {@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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:LogoutRequestMarshaller.java

示例15: marshallAttributes

import org.opensaml.Configuration; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
    AuthnStatement authnStatement = (AuthnStatement) samlObject;

    if (authnStatement.getAuthnInstant() != null) {
        String authnInstantStr = Configuration.getSAMLDateFormatter().print(authnStatement.getAuthnInstant());
        domElement.setAttributeNS(null, AuthnStatement.AUTHN_INSTANT_ATTRIB_NAME, authnInstantStr);
    }

    if (authnStatement.getSessionIndex() != null) {
        domElement.setAttributeNS(null, AuthnStatement.SESSION_INDEX_ATTRIB_NAME, authnStatement.getSessionIndex());
    }

    if (authnStatement.getSessionNotOnOrAfter() != null) {
        String sessionNotOnOrAfterStr = Configuration.getSAMLDateFormatter().print(
                authnStatement.getSessionNotOnOrAfter());
        domElement.setAttributeNS(null, AuthnStatement.SESSION_NOT_ON_OR_AFTER_ATTRIB_NAME, sessionNotOnOrAfterStr);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AuthnStatementMarshaller.java


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