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


Java URLBuilder.getQueryParams方法代码示例

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


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

示例1: getEncode

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/**
 * Performs HTTP GET based encoding.
 * 
 * @param artifactContext current request context
 * @param outTransport outbound HTTP transport
 * 
 * @throws MessageEncodingException thrown if there is a problem GET encoding the artifact
 */
protected void getEncode(SAMLMessageContext artifactContext, HTTPOutTransport outTransport)
        throws MessageEncodingException {
    log.debug("Performing HTTP GET SAML 2 artifact encoding");

    URLBuilder urlBuilder = getEndpointURL(artifactContext);

    List<Pair<String, String>> params = urlBuilder.getQueryParams();

    AbstractSAMLArtifact artifact = buildArtifact(artifactContext);
    if(artifact == null){
        log.error("Unable to build artifact for message to relying party");
        throw new MessageEncodingException("Unable to builder artifact for message to relying party");
    }
    params.add(new Pair<String, String>("SAMLart", artifact.base64Encode()));

    if (checkRelayState(artifactContext.getRelayState())) {
        params.add(new Pair<String, String>("RelayState", artifactContext.getRelayState()));
    }

    outTransport.sendRedirect(urlBuilder.buildURL());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:HTTPArtifactEncoder.java

示例2: getEncode

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/**
 * Performs HTTP GET based encoding.
 * 
 * @param artifactContext current request context
 * @param outTransport outbound HTTP transport
 * 
 * @throws MessageEncodingException thrown if there is a problem GET encoding the artifact
 */
protected void getEncode(SAMLMessageContext artifactContext, HTTPOutTransport outTransport)
        throws MessageEncodingException {
    log.debug("Performing HTTP GET SAML 2 artifact encoding");

    URLBuilder urlBuilder = new URLBuilder(getEndpointURL(artifactContext));

    List<Pair<String, String>> params = urlBuilder.getQueryParams();

    params.add(new Pair<String, String>("SAMLart", buildArtifact(artifactContext).base64Encode()));

    if (checkRelayState(artifactContext.getRelayState())) {
        params.add(new Pair<String, String>("RelayState", artifactContext.getRelayState()));
    }

    outTransport.sendRedirect(urlBuilder.buildURL());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:25,代码来源:HTTPArtifactEncoder.java

示例3: buildRedirectURL

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/**
 * Builds the URL to redirect the client to.
 * 
 * @param messagesContext current message context
 * @param endpointURL endpoint URL to send encoded message to
 * @param message Deflated and Base64 encoded message
 * 
 * @return URL to redirect client to
 * 
 * @throws MessageEncodingException thrown if the SAML message is neither a RequestAbstractType or Response
 */
protected String buildRedirectURL(SAMLMessageContext messagesContext, String endpointURL, String message)
        throws MessageEncodingException {
    log.debug("Building URL to redirect client to");
    URLBuilder urlBuilder = new URLBuilder(endpointURL);

    List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
    queryParams.clear();

    if (messagesContext.getOutboundSAMLMessage() instanceof RequestAbstractType) {
        queryParams.add(new Pair<String, String>("SAMLRequest", message));
    } else if (messagesContext.getOutboundSAMLMessage() instanceof StatusResponseType) {
        queryParams.add(new Pair<String, String>("SAMLResponse", message));
    } else {
        throw new MessageEncodingException(
                "SAML message is neither a SAML RequestAbstractType or StatusResponseType");
    }

    String relayState = messagesContext.getRelayState();
    if (checkRelayState(relayState)) {
        queryParams.add(new Pair<String, String>("RelayState", relayState));
    }

    Credential signingCredential = messagesContext.getOuboundSAMLMessageSigningCredential();
    if (signingCredential != null) {
        // TODO pull SecurityConfiguration from SAMLMessageContext? needs to be added
        String sigAlgURI = getSignatureAlgorithmURI(signingCredential, null);
        Pair<String, String> sigAlg = new Pair<String, String>("SigAlg", sigAlgURI);
        queryParams.add(sigAlg);
        String sigMaterial = urlBuilder.buildQueryString();

        queryParams.add(new Pair<String, String>("Signature", generateSignature(signingCredential, sigAlgURI,
                sigMaterial)));
    }

    return urlBuilder.buildURL();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:HTTPRedirectDeflateEncoder.java

示例4: buildRedirectURL

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/**
 * @see org.opensaml.saml2.binding.encoding.HTTPRedirectDeflateEncoder#buildRedirectURL(org.opensaml.common.binding.SAMLMessageContext,
 *      java.lang.String, java.lang.String)
 */
private String buildRedirectURL(String message, String relayState, Credential signingCredential) throws MessageEncodingException {

	if (log.isDebugEnabled())
		log.debug("Building URL to redirect client to: " + response.getDestination());

	URLBuilder urlBuilder = new URLBuilder(response.getDestination());

	List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
	queryParams.clear();
	queryParams.add(new Pair<String, String>(Constants.SAML_SAMLRESPONSE, message));

	// Quick patch made because Microsoft ADFS cannot handle an empty relaystate param
	// Beware that ADFS sends an errormessage, but is not logging the user out, so the errormessage SHOULD tell the end users to close their browsers
	if(relayState != null) {
        queryParams.add(new Pair<String, String>(Constants.SAML_RELAYSTATE, relayState));
	}

	Encoder enc = new Encoder();
	if (signingCredential != null) {
		queryParams.add(new Pair<String, String>(Constants.SAML_SIGALG, enc.getSignatureAlgorithmURI(signingCredential, null)));
		String sigMaterial = urlBuilder.buildQueryString();

		queryParams.add(new Pair<String, String>(Constants.SAML_SIGNATURE,
				enc.generateSignature(signingCredential, enc.getSignatureAlgorithmURI(signingCredential, null), sigMaterial)));
	}
	return urlBuilder.buildURL();
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:32,代码来源:OIOLogoutResponse.java

示例5: buildRedirectURL

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
public String buildRedirectURL(String endpointURL, String relayState, String message) {
    URLBuilder urlBuilder = new URLBuilder(endpointURL);
    List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
    queryParams.clear();
    queryParams.add(new Pair<String, String>("mgvhostparam", "0"));
    queryParams.add(new Pair<String, String>("SAMLRequest", message));
    if (checkRelayState(relayState)) {
        queryParams.add(new Pair<String, String>("RelayState", relayState));
    }
    return urlBuilder.buildURL();
}
 
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:12,代码来源:SAMLRequestSender.java

示例6: doEncode

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void doEncode(MessageContext messageContext) throws MessageEncodingException {
    if (!(messageContext instanceof SAMLMessageContext)) {
        log.error("Invalid message context type, this encoder only support SAMLMessageContext");
        throw new MessageEncodingException(
                "Invalid message context type, this encoder only support SAMLMessageContext");
    }

    if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) {
        log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport");
        throw new MessageEncodingException(
                "Invalid outbound message transport type, this encoder only support HTTPOutTransport");
    }

    SAMLMessageContext<SAMLObject, Response, NameIdentifier> artifactContext = (SAMLMessageContext) messageContext;
    HTTPOutTransport outTransport = (HTTPOutTransport) artifactContext.getOutboundMessageTransport();

    URLBuilder urlBuilder = getEndpointURL(artifactContext);

    List<Pair<String, String>> params = urlBuilder.getQueryParams();

    params.add(new Pair<String, String>("TARGET", artifactContext.getRelayState()));

    SAML1ArtifactBuilder artifactBuilder;
    if (artifactContext.getOutboundMessageArtifactType() != null) {
        artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(
                artifactContext.getOutboundMessageArtifactType());
    } else {
        artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(defaultArtifactType);
        artifactContext.setOutboundMessageArtifactType(defaultArtifactType);
    }

    AbstractSAML1Artifact artifact;
    String artifactString;
    for (Assertion assertion : artifactContext.getOutboundSAMLMessage().getAssertions()) {
        artifact = artifactBuilder.buildArtifact(artifactContext, assertion);
        if(artifact == null){
            log.error("Unable to build artifact for message to relying party");
            throw new MessageEncodingException("Unable to builder artifact for message to relying party");
        }

        try {
            artifactMap.put(artifact.base64Encode(), messageContext.getInboundMessageIssuer(), messageContext
                    .getOutboundMessageIssuer(), assertion);
        } catch (MarshallingException e) {
            log.error("Unable to marshall assertion to be represented as an artifact", e);
            throw new MessageEncodingException("Unable to marshall assertion to be represented as an artifact", e);
        }
        artifactString = artifact.base64Encode();
        params.add(new Pair<String, String>("SAMLart", artifactString));
    }

    String redirectUrl = urlBuilder.buildURL();

    log.debug("Sending redirect to URL {} to relying party {}", redirectUrl, artifactContext
            .getInboundMessageIssuer());
    outTransport.sendRedirect(urlBuilder.buildURL());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:59,代码来源:HTTPArtifactEncoder.java

示例7: doEncode

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void doEncode(MessageContext messageContext) throws MessageEncodingException {
    if (!(messageContext instanceof SAMLMessageContext)) {
        log.error("Invalid message context type, this encoder only support SAMLMessageContext");
        throw new MessageEncodingException(
                "Invalid message context type, this encoder only support SAMLMessageContext");
    }

    if (!(messageContext.getOutboundMessageTransport() instanceof HTTPOutTransport)) {
        log.error("Invalid outbound message transport type, this encoder only support HTTPOutTransport");
        throw new MessageEncodingException(
                "Invalid outbound message transport type, this encoder only support HTTPOutTransport");
    }

    SAMLMessageContext<SAMLObject, Response, NameIdentifier> artifactContext = (SAMLMessageContext) messageContext;
    HTTPOutTransport outTransport = (HTTPOutTransport) artifactContext.getOutboundMessageTransport();

    URLBuilder urlBuilder = new URLBuilder(getEndpointURL(artifactContext));

    List<Pair<String, String>> params = urlBuilder.getQueryParams();

    params.add(new Pair<String, String>("TARGET", HTTPTransportUtils.urlEncode(artifactContext.getRelayState())));

    SAML1ArtifactBuilder artifactBuilder;
    if (artifactContext.getOutboundMessageArtifactType() != null) {
        artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(
                artifactContext.getOutboundMessageArtifactType());
    } else {
        artifactBuilder = Configuration.getSAML1ArtifactBuilderFactory().getArtifactBuilder(defaultArtifactType);
        artifactContext.setOutboundMessageArtifactType(defaultArtifactType);
    }

    AbstractSAML1Artifact artifact;
    String artifactString;
    for (Assertion assertion : artifactContext.getOutboundSAMLMessage().getAssertions()) {
        artifact = artifactBuilder.buildArtifact(artifactContext, assertion);

        try {
            artifactMap.put(artifact.base64Encode(), messageContext.getInboundMessageIssuer(), messageContext
                    .getOutboundMessageIssuer(), assertion);
        } catch (MarshallingException e) {
            log.error("Unable to marshall assertion to be represented as an artifact", e);
            throw new MessageEncodingException("Unable to marshall assertion to be represented as an artifact", e);
        }
        artifactString = artifact.base64Encode();
        params.add(new Pair<String, String>("SAMLart", artifactString));
    }

    String redirectUrl = urlBuilder.buildURL();

    log.debug("Sending redirect to URL {} to relying party {}", redirectUrl, artifactContext
            .getInboundMessageIssuer());
    outTransport.sendRedirect(urlBuilder.buildURL());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:55,代码来源:HTTPArtifactEncoder.java

示例8: buildInTransport

import org.opensaml.util.URLBuilder; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected InTransport buildInTransport() {
    //
    // Encode the "outbound" message context, with simple signature
    //
    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    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");
    
    BasicSAMLMessageContext outboundMessgeContext = new BasicSAMLMessageContext();
    outboundMessgeContext.setOutboundMessageTransport(outTransport);
    outboundMessgeContext.setOutboundSAMLMessage(buildInboundSAMLMessage());
    outboundMessgeContext.setRelayState(expectedRelayValue);
    outboundMessgeContext.setPeerEntityEndpoint(samlEndpoint);
    outboundMessgeContext.setOutboundSAMLMessageSigningCredential(signingX509Cred);
    
    HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
    try {
        encoder.encode(outboundMessgeContext);
    } catch (MessageEncodingException e) {
        fail("Could not encode outbound message context");
    }
    
    // Now populate the new "inbound" message context with the "outbound" encoded info
    MockHttpServletRequest request = new MockHttpServletRequest();
    HTTPInTransport inTransport = new HttpServletRequestAdapter(request);
    
    request.setMethod("GET");
    
    // The Spring mock object doesn't convert between the query params and the getParameter apparently,
    // so have to set them both ways.
    URLBuilder urlBuilder = new URLBuilder(response.getRedirectedUrl());
    request.setQueryString(urlBuilder.buildQueryString());
    for (Pair<String, String> param : urlBuilder.getQueryParams()) {
        request.setParameter(param.getFirst(), param.getSecond());
    }
    
    return inTransport;
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:45,代码来源:SAML2HTTPRedirectDeflateSignatureSecurityPolicyRuleTest.java


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