Package org.opensaml.saml1.core

Examples of org.opensaml.saml1.core.Assertion


        if (!(OpenSAMLUtil.isMethodSenderVouches(confirmationMethod)
            || OpenSAMLUtil.isMethodHolderOfKey(confirmationMethod))) {
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
        }
       
        Assertion saml2Assertion = assertion.getSaml2();
        if (saml2Assertion == null) {
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
        }
       
        List<AttributeStatement> attributeStatements = saml2Assertion.getAttributeStatements();
        if (attributeStatements == null || attributeStatements.isEmpty()) {
            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
        }
       
        return validatedCredential;
View Full Code Here


        /* add the Assertion element */

        // build an assertion object
        AssertionBuilder assertionBuilder = (AssertionBuilder) builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
        Assertion assertion = assertionBuilder.buildObject();

        // set a few attributes for the assertion
        assertion.setID("_" + UUID.randomUUID().toString());
        assertion.setVersion(SAMLVersion.VERSION_20);
        assertion.setIssueInstant(new DateTime());

        // build an issuer object
        IssuerBuilder issuerBuilder = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
        Issuer issuer = issuerBuilder.buildObject();

       
        String defaultEntityId = String.format("%s://%s:%s/%s/services/ProvisioningService",
                request.getScheme(),
                request.getServerName(),
                request.getServerPort(),
                PAPConfiguration.DEFAULT_WEBAPP_CONTEXT);
       
        PAPConfiguration conf = PAPConfiguration.instance();
       
        String issuerValue = conf.getString(PAPConfiguration.STANDALONE_SERVICE_STANZA+".entity_id", defaultEntityId);

        issuer.setValue(issuerValue);

        assertion.setIssuer(issuer);

        /* build policy statements objects */

        XACMLPolicyStatementTypeImplBuilder policyStatementBuilder = (XACMLPolicyStatementTypeImplBuilder) builderFactory.getBuilder(XACMLPolicyStatementType.TYPE_NAME_XACML20);

        XACMLPolicyStatementType policyStatement = policyStatementBuilder.buildObject(Statement.DEFAULT_ELEMENT_NAME,
                                                                                      XACMLPolicyStatementType.TYPE_NAME_XACML20);

        Iterator<XACMLObject> iterator = policyObjects.iterator();

        while (iterator.hasNext()) {

            XACMLObject xacmlObject = iterator.next();

            if (xacmlObject instanceof PolicySetType) {

                policyStatement.getPolicySets().add((PolicySetType) xacmlObject);

                // if (xacmlObject instanceof PolicySetTypeString) {
                // ((PolicySetTypeString) xacmlObject).releasePolicySetType();
                // }

            } else {

                policyStatement.getPolicies().add((PolicyType) xacmlObject);

                // if (xacmlObject instanceof PolicyTypeString) {
                // ((PolicyTypeString) xacmlObject).releasePolicyType();
                // }

            }

            // add the statement to the assertion
            assertion.getStatements().add(policyStatement);
        }

        // add the assertion to the response
        response.getAssertions().add(assertion);

View Full Code Here

     */
    @Test
    public void testInsert() {
        Hashtable<String, SAMLObject> storage = new Hashtable<String, SAMLObject>();
        Audience audienceMock = createNiceMock(Audience.class);
        Assertion assertionMock = createNiceMock(Assertion.class);
        storage.put("testKey", new SAMLObject<Audience>(audienceMock));
        session = createMock(HttpSession.class);
        expect(session.getId()).andReturn("session123").anyTimes();
        expect(session.getAttribute(SPRING_SAML_STORAGE_KEY)).andReturn(storage);
        session.setAttribute(eq(SPRING_SAML_STORAGE_KEY), anyObject());
View Full Code Here

     */
    @Test
    public void testOverwrite() {
        Hashtable<String, SAMLObject> storage = new Hashtable<String, SAMLObject>();
        Audience audienceMock = createNiceMock(Audience.class);
        Assertion assertionMock = createNiceMock(Assertion.class);
        storage.put("testKey", new SAMLObject<Audience>(audienceMock));
        session = createMock(HttpSession.class);
        expect(session.getId()).andReturn("session123").anyTimes();
        expect(session.getAttribute(SPRING_SAML_STORAGE_KEY)).andReturn(storage);
        session.setAttribute(eq(SPRING_SAML_STORAGE_KEY), anyObject());
View Full Code Here

        String confirmationMethod = assertion.getConfirmationMethods().get(0);
        if (!OpenSAMLUtil.isMethodSenderVouches(confirmationMethod)) {
            throw new WSSecurityException(WSSecurityException.FAILURE, "invalidSAMLsecurity");
        }
       
        Assertion saml2Assertion = assertion.getSaml2();
        if (saml2Assertion == null) {
            throw new WSSecurityException(WSSecurityException.FAILURE, "invalidSAMLsecurity");
        }
       
        boolean authenticatedClient = false;
        for (AttributeStatement attributeStatement : saml2Assertion.getAttributeStatements()) {
            for (Attribute attribute : attributeStatement.getAttributes()) {
                if (!"attribute-role".equals(attribute.getName())) {
                    continue;
                }
                for (XMLObject attributeValue : attribute.getAttributeValues()) {
View Full Code Here

    public void setMethodRolesMap(Map<String, String> rolesMap) {
        super.setMethodRolesMap(rolesMap);
    }
   
    private String getRoleFromAssertion(AssertionWrapper assertion) {
        Assertion saml2Assertion = assertion.getSaml2();
        if (saml2Assertion == null) {
            return null;
        }
       
        List<AttributeStatement> attributeStatements = saml2Assertion.getAttributeStatements();
        if (attributeStatements == null || attributeStatements.isEmpty()) {
            return null;
        }
       
        String nameFormat = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims";
View Full Code Here

                    "OpenSaml engine not initialized. Please make sure to initialize the OpenSaml engine "
                    + "prior using it"
                );
            }
        }
        Assertion assertion =
            assertionBuilder.buildObject(Assertion.DEFAULT_ELEMENT_NAME, Assertion.TYPE_NAME);
        assertion.setID(IDGenerator.generateID("_"));
        assertion.setVersion(SAMLVersion.VERSION_20);
        assertion.setIssueInstant(new DateTime());
        return assertion;
    }
View Full Code Here

        super(targetNamespaceURI, targetLocalName);
    }

    /** {@inheritDoc} */
    protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
        Assertion assertion = (Assertion) parentObject;

        if (childObject instanceof Issuer) {
            assertion.setIssuer((Issuer) childObject);
        } else if (childObject instanceof Signature) {
            assertion.setSignature((Signature) childObject);
        } else if (childObject instanceof Subject) {
            assertion.setSubject((Subject) childObject);
        } else if (childObject instanceof Conditions) {
            assertion.setConditions((Conditions) childObject);
        } else if (childObject instanceof Advice) {
            assertion.setAdvice((Advice) childObject);
        } else if (childObject instanceof Statement) {
            assertion.getStatements().add((Statement) childObject);
        } else {
            super.processChildElement(parentObject, childObject);
        }
    }
View Full Code Here

        }
    }

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

        if (attribute.getLocalName().equals(Assertion.VERSION_ATTRIB_NAME)) {
            assertion.setVersion(SAMLVersion.valueOf(attribute.getValue()));
        } else if (attribute.getLocalName().equals(Assertion.ISSUE_INSTANT_ATTRIB_NAME)
                && !DatatypeHelper.isEmpty(attribute.getValue())) {
            assertion.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
        } else if (attribute.getLocalName().equals(Assertion.ID_ATTRIB_NAME)) {
            assertion.setID(attribute.getValue());
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        } else {
            super.processAttribute(samlObject, attribute);
        }
    }
View Full Code Here

        super(targetNamespaceURI, targetLocalName);
    }

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

        if (assertion.getVersion() != null) {
            domElement.setAttributeNS(null, Assertion.VERSION_ATTRIB_NAME, assertion.getVersion().toString());
        }

        if (assertion.getIssueInstant() != null) {
            String issueInstantStr = Configuration.getSAMLDateFormatter().print(assertion.getIssueInstant());
            domElement.setAttributeNS(null, Assertion.ISSUE_INSTANT_ATTRIB_NAME, issueInstantStr);
        }

        if (assertion.getID() != null) {
            domElement.setAttributeNS(null, Assertion.ID_ATTRIB_NAME, assertion.getID());
            domElement.setIdAttributeNS(null, Assertion.ID_ATTRIB_NAME, true);
        }
    }
View Full Code Here

TOP

Related Classes of org.opensaml.saml1.core.Assertion

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.