Package org.opensaml.saml2.core

Examples of org.opensaml.saml2.core.AuthnRequest


        storage.storeMessage((String) notNull(), (XMLObject) notNull());
        replyMock();

        profile.sendAuthenticationRequest(samlContext, options);

        AuthnRequest authnRequest = (AuthnRequest) samlContext.getOutboundSAMLMessage();
        assertNotNull(authnRequest.getID());
        assertNotNull(authnRequest.getIssueInstant());
        assertEquals(false, authnRequest.isForceAuthn());
        assertEquals(false, authnRequest.isPassive());
        assertEquals("http://localhost:8081/spring-security-saml2-webapp", authnRequest.getIssuer().getValue());
        assertEquals("http://localhost:8081/spring-security-saml2-webapp/saml/SSO", authnRequest.getAssertionConsumerServiceURL());
        assertEquals("http://localhost:8080/opensso/SSORedirect/metaAlias/idp", authnRequest.getDestination());
        assertEquals(org.opensaml.common.xml.SAMLConstants.SAML2_POST_BINDING_URI, authnRequest.getProtocolBinding());
        assertEquals(org.opensaml.common.xml.SAMLConstants.SAML2_REDIRECT_BINDING_URI, samlContext.getPeerEntityEndpoint().getBinding());
        verifyMock();

    }
View Full Code Here


        samlContext.setPeerEntityMetadata(metadata.getEntityDescriptor(idpId));
        samlContext.setPeerEntityRoleMetadata(metadata.getRole(idpId, IDPSSODescriptor.DEFAULT_ELEMENT_NAME, SAMLConstants.SAML20P_NS));
        storage.storeMessage((String) notNull(), (XMLObject) notNull());
        replyMock();
        profile.sendAuthenticationRequest(samlContext, options);
        AuthnRequest authnRequest = (AuthnRequest) samlContext.getOutboundSAMLMessage();
        verifyMock();
        assertTrue(!authnRequest.isSigned());
    }
View Full Code Here

    public void testPassive() throws Exception {
        options.setPassive(true);
        storage.storeMessage((String) notNull(), (XMLObject) notNull());
        replyMock();
        profile.sendAuthenticationRequest(samlContext, options);
        AuthnRequest authnRequest = (AuthnRequest) samlContext.getOutboundSAMLMessage();
        verifyMock();
        assertEquals(false, authnRequest.isForceAuthn());
        assertEquals(true, authnRequest.isPassive());
        assertTrue(authnRequest.getScoping().getProxyCount() > 0);
    }
View Full Code Here

    public void testForce() throws Exception {
        options.setForceAuthN(true);
        storage.storeMessage((String) notNull(), (XMLObject) notNull());
        replyMock();
        profile.sendAuthenticationRequest(samlContext, options);
        AuthnRequest authnRequest = (AuthnRequest) samlContext.getOutboundSAMLMessage();
        verifyMock();
        assertEquals(true, authnRequest.isForceAuthn());
        assertEquals(false, authnRequest.isPassive());
        assertTrue(authnRequest.getScoping().getProxyCount() > 0);
    }
View Full Code Here

    public void testDisallowProxy() throws Exception {
        options.setProxyCount(null);
        storage.storeMessage((String) notNull(), (XMLObject) notNull());
        replyMock();
        profile.sendAuthenticationRequest(samlContext, options);
        AuthnRequest authnRequest = (AuthnRequest) samlContext.getOutboundSAMLMessage();
        verifyMock();
        assertEquals(false, authnRequest.isForceAuthn());
        assertEquals(false, authnRequest.isPassive());
        assertNull(authnRequest.getScoping().getProxyCount());
    }
View Full Code Here

        super(namespaceURI, elementLocalName);
    }

    /** {@inheritDoc} */
    protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
        AuthnRequest req = (AuthnRequest) samlObject;

        if (attribute.getLocalName().equals(AuthnRequest.FORCE_AUTHN_ATTRIB_NAME))
            req.setForceAuthn(XSBooleanValue.valueOf(attribute.getValue()));
        else if (attribute.getLocalName().equals(AuthnRequest.IS_PASSIVE_ATTRIB_NAME))
            req.setIsPassive(XSBooleanValue.valueOf(attribute.getValue()));
        else if (attribute.getLocalName().equals(AuthnRequest.PROTOCOL_BINDING_ATTRIB_NAME))
            req.setProtocolBinding(attribute.getValue());
        else if (attribute.getLocalName().equals(AuthnRequest.ASSERTION_CONSUMER_SERVICE_INDEX_ATTRIB_NAME))
            req.setAssertionConsumerServiceIndex(Integer.valueOf(attribute.getValue()));
        else if (attribute.getLocalName().equals(AuthnRequest.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME))
            req.setAssertionConsumerServiceURL(attribute.getValue());
        else if (attribute.getLocalName().equals(AuthnRequest.ATTRIBUTE_CONSUMING_SERVICE_INDEX_ATTRIB_NAME))
            req.setAttributeConsumingServiceIndex(Integer.valueOf(attribute.getValue()));
        else if (attribute.getLocalName().equals(AuthnRequest.PROVIDER_NAME_ATTRIB_NAME))
            req.setProviderName(attribute.getValue());
        else
            super.processAttribute(samlObject, attribute);
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
            throws UnmarshallingException {
        AuthnRequest req = (AuthnRequest) parentSAMLObject;

        if (childSAMLObject instanceof Subject)
            req.setSubject((Subject) childSAMLObject);
        else if (childSAMLObject instanceof NameIDPolicy)
            req.setNameIDPolicy((NameIDPolicy) childSAMLObject);
        else if (childSAMLObject instanceof Conditions)
            req.setConditions((Conditions) childSAMLObject);
        else if (childSAMLObject instanceof RequestedAuthnContext)
            req.setRequestedAuthnContext((RequestedAuthnContext) childSAMLObject);
        else if (childSAMLObject instanceof Scoping)
            req.setScoping((Scoping) childSAMLObject);
        else
            super.processChildElement(parentSAMLObject, childSAMLObject);
    }
View Full Code Here

        super(namespaceURI, elementLocalName);
    }

    /** {@inheritDoc} */
    protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
        AuthnRequest req = (AuthnRequest) samlObject;

        if (req.isForceAuthnXSBoolean() != null)
            domElement.setAttributeNS(null, AuthnRequest.FORCE_AUTHN_ATTRIB_NAME, req.isForceAuthnXSBoolean().toString());

        if (req.isPassiveXSBoolean() != null)
            domElement.setAttributeNS(null, AuthnRequest.IS_PASSIVE_ATTRIB_NAME, req.isPassiveXSBoolean().toString());

        if (req.getProtocolBinding() != null)
            domElement.setAttributeNS(null, AuthnRequest.PROTOCOL_BINDING_ATTRIB_NAME, req.getProtocolBinding());

        if (req.getAssertionConsumerServiceIndex() != null)
            domElement.setAttributeNS(null, AuthnRequest.ASSERTION_CONSUMER_SERVICE_INDEX_ATTRIB_NAME, req
                    .getAssertionConsumerServiceIndex().toString());

        if (req.getAssertionConsumerServiceURL() != null)
            domElement.setAttributeNS(null, AuthnRequest.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME, req
                    .getAssertionConsumerServiceURL());

        if (req.getAttributeConsumingServiceIndex() != null)
            domElement.setAttributeNS(null, AuthnRequest.ATTRIBUTE_CONSUMING_SERVICE_INDEX_ATTRIB_NAME, req
                    .getAttributeConsumingServiceIndex().toString());

        if (req.getProviderName() != null)
            domElement.setAttributeNS(null, AuthnRequest.PROVIDER_NAME_ATTRIB_NAME, req.getProviderName());

        super.marshallAttributes(samlObject, domElement);
    }
View Full Code Here

            return null;
        }

        Endpoint endpoint = null;
        if (getSamlRequest() != null) {
            AuthnRequest request = (AuthnRequest) getSamlRequest();

            endpoints = filterEndpointsByProtocolBinding(endpoints);
            if (endpoints == null || endpoints.isEmpty()) {
                return null;
            }

            if (request.getAssertionConsumerServiceIndex() != null) {
                log.debug("Selecting endpoint by ACS index for request {} from entity {}", request.getID(),
                        getEntityMetadata().getEntityID());
                endpoint = selectEndpointByACSIndex(request, (List<IndexedEndpoint>) endpoints);
            } else if (request.getAssertionConsumerServiceURL() != null) {
                log.debug("Selecting endpoint by ACS URL for request {} from entity {}", request.getID(),
                        getEntityMetadata().getEntityID());
                endpoint = selectEndpointByACSURL(request, (List<IndexedEndpoint>) endpoints);
            }
        }
View Full Code Here

     *
     * @return filtered endpoints
     */
    protected List<? extends Endpoint> filterEndpointsByProtocolBinding(List<? extends Endpoint> endpoints) {
        log.debug("Filtering peer endpoints.  Supported peer endpoint bindings: {}", getSupportedIssuerBindings());
        AuthnRequest request = (AuthnRequest) getSamlRequest();

        boolean filterByRequestBinding = false;
        String acsBinding = DatatypeHelper.safeTrimOrNullString(request.getProtocolBinding());
        if (acsBinding != null && request.getAssertionConsumerServiceIndex() != null) {
            filterByRequestBinding = true;
        }

        List<Endpoint> filteredEndpoints = new ArrayList<Endpoint>(endpoints);
        Iterator<Endpoint> endpointItr = filteredEndpoints.iterator();
View Full Code Here

TOP

Related Classes of org.opensaml.saml2.core.AuthnRequest

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.