Examples of AssertionWrapper


Examples of org.apache.ws.security.saml.ext.AssertionWrapper

       
        // Create a SAML Token
        SAMLParms samlParms = new SAMLParms();
        samlParms.setCallbackHandler(new SamlCallbackHandler());
        try {
            AssertionWrapper assertion = new AssertionWrapper(samlParms);
            Document doc = DOMUtils.createDocument();
            Element token = assertion.toDOM(doc);
            message.setContextualProperty(SAMLConstants.SAML_TOKEN_ELEMENT, token);
        } catch (WSSecurityException ex) {
            StringWriter sw = new StringWriter();
            ex.printStackTrace(new PrintWriter(sw));
            throw new Fault(new RuntimeException(ex.getMessage() + ", stacktrace: " + sw.toString()));
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

public class OnBehalfOfValidator extends SamlAssertionValidator {
   
    @Override
    public Credential validate(Credential credential, RequestData data) throws WSSecurityException {
        Credential validatedCredential = super.validate(credential, data);
        AssertionWrapper assertion = validatedCredential.getAssertion();
       
        Assertion saml2Assertion = assertion.getSaml2();
        if (saml2Assertion == null) {
            throw new WSSecurityException(WSSecurityException.FAILURE, "invalidSAMLsecurity");
        }
       
        List<AttributeStatement> attributeStatements = saml2Assertion.getAttributeStatements();
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

        ep.getEndpointInfo().setProperty(SecurityConstants.TOKEN_ID, id);
        TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName());

        SAMLParms samlParms = new SAMLParms();
        samlParms.setCallbackHandler(new Saml2CallbackHandler());
        AssertionWrapper assertion = new AssertionWrapper(samlParms);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Element assertionElement = assertion.toDOM(db.newDocument());
       
        SecurityToken tok = new SecurityToken(id);
        tok.setTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
        tok.setToken(assertionElement);
        store.add(tok);
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

    // enveloping & detached sigs will be supported too
    private Document createEnvelopedSamlToken(Message message, Document payloadDoc)
        throws Exception {
       
        Element docEl = payloadDoc.getDocumentElement();
        AssertionWrapper assertion = SAMLUtils.createAssertion(message);
       
        QName rootName = DOMUtils.getElementQName(payloadDoc.getDocumentElement());
        if (rootName.equals(envelopeQName)) {
            docEl.appendChild(assertion.toDOM(payloadDoc));
            return payloadDoc;
        }
       
        Document newDoc = DOMUtils.createDocument();
       
        Element root =
            newDoc.createElementNS(envelopeQName.getNamespaceURI(),
                    envelopeQName.getPrefix() + ":" + envelopeQName.getLocalPart());
        newDoc.appendChild(root);
       
        Element assertionEl = assertion.toDOM(newDoc);
        root.appendChild(assertionEl);
       
        payloadDoc.removeChild(docEl);
        newDoc.adoptNode(docEl);
        root.appendChild(docEl);
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

       
        // Process the token
        List<WSSecurityEngineResult> results = processToken(token);

        assertTrue(results != null && results.size() == 1);
        AssertionWrapper assertion =
            (AssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
        assertTrue(assertion != null);
        assertTrue(assertion.getSaml1() != null && assertion.getSaml2() == null);
        assertTrue(assertion.isSigned());
       
        List<String> methods = assertion.getConfirmationMethods();
        String confirmMethod = null;
        if (methods != null && methods.size() > 0) {
            confirmMethod = methods.get(0);
        }
        assertTrue(OpenSAMLUtil.isMethodHolderOfKey(confirmMethod));
        SAMLKeyInfo subjectKeyInfo = assertion.getSubjectKeyInfo();
        assertTrue(subjectKeyInfo.getSecret() != null);
       
        bus.shutdown(true);
    }
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

        assertTrue(token.getToken() != null);
       
        // Process the token
        List<WSSecurityEngineResult> results = processToken(token);
        assertTrue(results != null && results.size() == 1);
        AssertionWrapper assertion =
            (AssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
        assertTrue(assertion != null);
        assertTrue(assertion.getSaml1() == null && assertion.getSaml2() != null);
        assertTrue(assertion.isSigned());
       
        List<String> methods = assertion.getConfirmationMethods();
        String confirmMethod = null;
        if (methods != null && methods.size() > 0) {
            confirmMethod = methods.get(0);
        }
        assertTrue(OpenSAMLUtil.isMethodHolderOfKey(confirmMethod));
        SAMLKeyInfo subjectKeyInfo = assertion.getSubjectKeyInfo();
        assertTrue(subjectKeyInfo.getCerts() != null);
       
        bus.shutdown(true);
    }
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

        assertTrue(token.getToken() != null);
       
        // Process the token
        List<WSSecurityEngineResult> results = processToken(token);
        assertTrue(results != null && results.size() == 1);
        AssertionWrapper assertion =
            (AssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
        assertTrue(assertion != null);
        assertTrue(assertion.getSaml1() != null && assertion.getSaml2() == null);
        assertTrue(assertion.isSigned());
       
        List<String> methods = assertion.getConfirmationMethods();
        String confirmMethod = null;
        if (methods != null && methods.size() > 0) {
            confirmMethod = methods.get(0);
        }
        assertTrue(confirmMethod.contains("bearer"));
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

        assertTrue(token.getToken() != null);
       
        // Process the token
        List<WSSecurityEngineResult> results = processToken(token);
        assertTrue(results != null && results.size() == 1);
        AssertionWrapper assertion =
            (AssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
        assertTrue(assertion != null);
        assertTrue(assertion.getSaml1() == null && assertion.getSaml2() != null);
        assertTrue(assertion.isSigned());
       
        List<String> methods = assertion.getConfirmationMethods();
        String confirmMethod = null;
        if (methods != null && methods.size() > 0) {
            confirmMethod = methods.get(0);
        }
        assertNotNull(confirmMethod);
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

     */
    private Element getSAMLAssertion(Document doc) throws Exception {
        SAMLParms parms = new SAMLParms();
        SamlCallbackHandler callbackHandler = new SamlCallbackHandler(saml2);
        parms.setCallbackHandler(callbackHandler);
        AssertionWrapper assertionWrapper = new AssertionWrapper(parms);

        return assertionWrapper.toDOM(doc);
    }
View Full Code Here

Examples of org.apache.ws.security.saml.ext.AssertionWrapper

        assertTrue(token.getToken() != null);
       
        // Process the token
        List<WSSecurityEngineResult> results = processToken(token);
        assertTrue(results != null && results.size() == 1);
        AssertionWrapper assertion =
            (AssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
        assertTrue(assertion != null);
        assertTrue(assertion.getSaml1() != null && assertion.getSaml2() == null);
        assertTrue(assertion.isSigned());
       
        List<String> methods = assertion.getConfirmationMethods();
        String confirmMethod = null;
        if (methods != null && methods.size() > 0) {
            confirmMethod = methods.get(0);
        }
        assertTrue(confirmMethod.contains("bearer"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.