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


Java BasicSAMLMessageContext类代码示例

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


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

示例1: buildRedirectURL

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
public String buildRedirectURL(Credential signingCredential, String relayState) throws MessageEncodingException {
	SAMLMessageContext<?, RequestAbstractType, ?> messageContext = new BasicSAMLMessageContext<SAMLObject, RequestAbstractType, SAMLObject>();
	// Build the parameters for the request
	messageContext.setOutboundSAMLMessage(request);
	messageContext.setRelayState(relayState);

	// Sign the parameters
	messageContext.setOutboundSAMLMessageSigningCredential(signingCredential);

          String messageStr = XMLHelper.nodeToString(marshallMessage(request));

          ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
          Deflater deflater = new Deflater(Deflater.DEFLATED, true);
          DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
          try {
		deflaterStream.write(messageStr.getBytes("UTF-8"));
		deflaterStream.finish();
	} catch (IOException e) {
		throw new RuntimeException("Unable to deflate message", e);
	}

          String encoded = Base64.encodeBytes(bytesOut.toByteArray(), Base64.DONT_BREAK_LINES);
	return super.buildRedirectURL(messageContext, request.getDestination(), encoded);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:OIORequest.java

示例2: decodeSamlMessage

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
public static SAMLMessageContext decodeSamlMessage(HttpServletRequest request, HttpServletResponse response) throws Exception {

        SAMLMessageContext<SAMLObject, SAMLObject, NameID> samlMessageContext =
                new BasicSAMLMessageContext<SAMLObject, SAMLObject, NameID>();

        HttpServletRequestAdapter httpServletRequestAdapter =
                new HttpServletRequestAdapter(request);
        samlMessageContext.setInboundMessageTransport(httpServletRequestAdapter);
        samlMessageContext.setInboundSAMLProtocol(SAMLConstants.SAML20P_NS);
        HttpServletResponseAdapter httpServletResponseAdapter =
                new HttpServletResponseAdapter(response, request.isSecure());
        samlMessageContext.setOutboundMessageTransport(httpServletResponseAdapter);
        samlMessageContext.setPeerEntityRole(IDPSSODescriptor.DEFAULT_ELEMENT_NAME);

        SecurityPolicyResolver securityPolicyResolver =
                getSecurityPolicyResolver(request.isSecure());

        samlMessageContext.setSecurityPolicyResolver(securityPolicyResolver);
        HTTPPostDecoder samlMessageDecoder = new HTTPPostDecoder();
        samlMessageDecoder.decode(samlMessageContext);
        return samlMessageContext;
    }
 
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:23,代码来源:SAMLUtils.java

示例3: redirectUserWithRequest

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
private void redirectUserWithRequest(HttpServletResponse httpServletResponse, AuthnRequest authnRequest) {
    HttpServletResponseAdapter responseAdapter = new HttpServletResponseAdapter(httpServletResponse, true);
    BasicSAMLMessageContext<SAMLObject, AuthnRequest, SAMLObject> context = new BasicSAMLMessageContext<SAMLObject, AuthnRequest, SAMLObject>();
    context.setPeerEntityEndpoint(getIPDEndpoint());
    context.setOutboundSAMLMessage(authnRequest);
    context.setOutboundMessageTransport(responseAdapter);
    context.setOutboundSAMLMessageSigningCredential(SPCredentials.getCredential());

    HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
    logger.info("AuthnRequest: ");
    OpenSAMLUtils.logSAMLObject(authnRequest);

    logger.info("Redirecting to IDP");
    try {
        encoder.encode(context);
    } catch (MessageEncodingException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:rasmusson,项目名称:webprofile-ref-project,代码行数:20,代码来源:AccessFilter.java

示例4: buildMessageContext

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
/**
 * Build the SAML message context from a HttpServletRequest.
 * 
 * @param request
 *            the HttpServletRequest
 * @param binding
 * @return the SAML message context
 * @throws SecurityException
 *             in case of Security problem
 * @throws MessageDecodingException
 *             in case of decoding problem
 */
@SuppressWarnings("rawtypes")
protected MessageContext buildMessageContext(final HttpServletRequest request, final SamlBindingEnum binding)
		throws SecurityException, MessageDecodingException {
	Validate.notNull(request, "Request must be supplied !");

	final MessageContext messageContext = new BasicSAMLMessageContext();
	messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(request));

	try {
		final SAMLMessageDecoder decoder = this.getSamlMessageDecoder(binding);
		decoder.decode(messageContext);
	} catch (final SecurityException e) {
		// Decoder throw SecurityException that we can skip
		this.securityLogger.debug("Security problem while decoding incoming SAML message !", e);
		if (this.isAllowDecodingSecurityException()) {
			throw e;
		}
	}

	this.validateMessageContext(messageContext);

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

示例5: renderMergedOutputModel

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
@Override
protected void renderMergedOutputModel(
        final Map<String, Object> model, final HttpServletRequest request, final HttpServletResponse response) throws Exception {

    response.setCharacterEncoding(this.encoding);

    final WebApplicationService service = this.samlArgumentExtractor.extractService(request);
    final String serviceId = service != null ? service.getId() : "UNKNOWN";

    try {
        final Response samlResponse = newSamlObject(Response.class);
        samlResponse.setID(generateId());
        samlResponse.setIssueInstant(new DateTime());
        samlResponse.setVersion(SAMLVersion.VERSION_11);
        samlResponse.setRecipient(serviceId);
        if (service instanceof SamlService) {
            final SamlService samlService = (SamlService) service;

            if (samlService.getRequestID() != null) {
                samlResponse.setInResponseTo(samlService.getRequestID());
            }
        }
        prepareResponse(samlResponse, model);

        final BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
        messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, request.isSecure()));
        messageContext.setOutboundSAMLMessage(samlResponse);
        this.encoder.encode(messageContext);
    } catch (final Exception e) {
        logger.error("Error generating SAML response for service {}.", serviceId);
        throw e;
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:34,代码来源:AbstractSaml10ResponseView.java

示例6: testEncoding

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testEncoding() throws Exception {
    SAMLObjectBuilder<Response> requestBuilder = (SAMLObjectBuilder<Response>) builderFactory
            .getBuilder(Response.DEFAULT_ELEMENT_NAME);
    Response samlMessage = requestBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setIssueInstant(new DateTime(0));
    samlMessage.setVersion(SAMLVersion.VERSION_11);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine,
    "/templates/saml1-post-binding.vm");

    MockHttpServletResponse response = new MockHttpServletResponse();
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, false));
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");
    
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(-608085328, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:33,代码来源:HTTPPostEncoderTest.java

示例7: testEncoding

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
/** Tests encoding a simple SAML message. */
@SuppressWarnings("unchecked")
public void testEncoding() throws Exception {
    SAMLObjectBuilder<Request> requestBuilder = (SAMLObjectBuilder<Request>) builderFactory
            .getBuilder(Request.DEFAULT_ELEMENT_NAME);
    Request request = requestBuilder.buildObject();
    request.setID("foo");
    request.setIssueInstant(new DateTime(0));
    request.setVersion(SAMLVersion.VERSION_11);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(new HttpServletResponseAdapter(response, false));
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(request);
    messageContext.setRelayState("relay");
    
    HTTPSOAP11Encoder encoder = new HTTPSOAP11Encoder();
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/xml", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals("http://www.oasis-open.org/committees/security", response.getHeader("SOAPAction"));
    assertEquals(-280457420, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:33,代码来源:HTTPSOAP11EncoderTest.java

示例8: setUp

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void setUp() throws Exception {
    super.setUp();
    
    httpRequest = new MockHttpServletRequest();
    httpRequest.setMethod("POST");
    httpRequest.setParameter("TARGET", expectedRelayValue);
    
    messageContext = new BasicSAMLMessageContext();
    messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(httpRequest));
    
    decoder = new HTTPPostDecoder(null);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:14,代码来源:HTTPPostDecoderTest.java

示例9: setUp

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void setUp() throws Exception {
    super.setUp();
    
    httpRequest = new MockHttpServletRequest();
    httpRequest.setMethod("POST");
    
    messageContext = new BasicSAMLMessageContext();
    messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(httpRequest));
    
    decoder = new HTTPSOAP11Decoder(null);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:HTTPSOAP11DecoderTest.java

示例10: testRequestEncoding

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testRequestEncoding() throws Exception {
    SAMLObjectBuilder<AuthnRequest> responseBuilder = (SAMLObjectBuilder<AuthnRequest>) builderFactory
            .getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
    AuthnRequest samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");

    HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine,
    "/templates/saml2-post-binding.vm");
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(-243324550, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:34,代码来源:HTTPPostEncoderTest.java

示例11: testRequestEncoding

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testRequestEncoding() throws Exception {
    SAMLObjectBuilder<AuthnRequest> responseBuilder = (SAMLObjectBuilder<AuthnRequest>) builderFactory
            .getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
    AuthnRequest samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");

    HTTPPostSimpleSignEncoder encoder = new HTTPPostSimpleSignEncoder(velocityEngine,
    "/templates/saml2-post-simplesign-binding.vm");
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(-1110321790, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:34,代码来源:HTTPPostSimpleSignEncoderTest.java

示例12: setUp

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void setUp() throws Exception {
    super.setUp();
    
    httpRequest = new MockHttpServletRequest();
    httpRequest.setMethod("POST");
    httpRequest.setParameter("RelayState", expectedRelayValue);
    
    messageContext = new BasicSAMLMessageContext();
    messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(httpRequest));
    
    decoder = new HTTPPostDecoder();
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:14,代码来源:HTTPPostDecoderTest.java

示例13: setUp

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void setUp() throws Exception {
    super.setUp();
    
    httpRequest = new MockHttpServletRequest();
    httpRequest.setMethod("GET");
    httpRequest.setParameter("RelayState", expectedRelayValue);
    
    messageContext = new BasicSAMLMessageContext();
    messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(httpRequest));
    
    decoder = new HTTPRedirectDeflateDecoder();
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:14,代码来源:HTTPRedirectDeflateDecoderTest.java

示例14: setUp

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
/** {@inheritDoc} */
protected void setUp() throws Exception {
    super.setUp();
    
    httpRequest = new MockHttpServletRequest();
    httpRequest.setMethod("POST");
    
    messageContext = new BasicSAMLMessageContext();
    messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(httpRequest));
    
    decoder = new HTTPSOAP11Decoder();
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:HTTPSOAP11DecoderTest.java

示例15: getMessageContextFromRequest

import org.opensaml.common.binding.BasicSAMLMessageContext; //导入依赖的package包/类
private static BasicSAMLMessageContext<LogoutRequest, ?, ?> getMessageContextFromRequest(HttpServletRequest request) {
    // Unpack the <LogoutRequest> from the request
    BasicSAMLMessageContext<LogoutRequest, ?, ?> messageContext = new BasicSAMLMessageContext<LogoutRequest, SAMLObject, SAMLObject>();
    messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(request));
    return messageContext;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:7,代码来源:OIOLogoutRequest.java


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