Package org.opensaml.util

Examples of org.opensaml.util.URLBuilder


     * @param messageContext message context for current SP
     * @return true if the request is valid, false otherwise
     */
    protected boolean isResponseURLValid(String returnURL, SAMLMessageContext messageContext) {

        URLBuilder foundURL = new URLBuilder(returnURL);
        URLBuilder defaultURL = new URLBuilder(getDefaultReturnURL(messageContext));

        if (!defaultURL.getHost().equals(foundURL.getHost())) {
            return false;
        }

        return true;

View Full Code Here


     */
    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());
    }
View Full Code Here

     * @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();
    }
View Full Code Here

        }

        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());
    }
View Full Code Here

        String discoveryURL = context.getLocalExtendedMetadata().getIdpDiscoveryURL();

        if (discoveryURL != null) {

            URLBuilder urlBuilder = new URLBuilder(discoveryURL);
            List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
            queryParams.add(new Pair<String, String>(SAMLDiscovery.ENTITY_ID_PARAM, context.getLocalEntityId()));
            queryParams.add(new Pair<String, String>(SAMLDiscovery.RETURN_ID_PARAM, IDP_PARAMETER));
            discoveryURL = urlBuilder.buildURL();

            logger.debug("Using discovery URL from extended metadata");

        } else {
View Full Code Here

TOP

Related Classes of org.opensaml.util.URLBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.