Package org.picketlink.identity.federation.core.wstrust

Examples of org.picketlink.identity.federation.core.wstrust.SamlCredential


      HttpServletRequest httpRequest = (HttpServletRequest)request;
      if (httpRequest.getRemoteUser() != null)
      {
         try
         {
            SamlCredential samlCredential = getSamlCredential();

            if (log.isTraceEnabled())
            {
               log.trace("Found SamlCredential inside Subject: " + samlCredential);
            }
View Full Code Here


    }

    @Override
    protected Group[] getRoleSets() throws LoginException {
        // Get the SAML Assertion
        SamlCredential samlCredential = null;
        Set<Object> creds = subject.getPublicCredentials();
        for (Object cred : creds) {
            if (cred instanceof SamlCredential) {
                samlCredential = (SamlCredential) cred;
                break;
            }
        }
        if (samlCredential == null)
            throw logger.authSAMLCredentialNotAvailable();

        try {
            String assertionStr = samlCredential.getAssertionAsString();
            if (StringUtil.isNullOrEmpty(assertionStr))
                throw logger.authSAMLAssertionNullOrEmpty();

            SAMLParser parser = new SAMLParser();
            AssertionType assertion = (AssertionType) parser.parse(new ByteArrayInputStream(assertionStr.getBytes()));
View Full Code Here

        }
        if (logger.isTraceEnabled()) {
            logger.trace("decoded samlToken="+samlToken);
        }
       
        return new SamlCredential(samlToken);
    }
View Full Code Here

            }
            else {
                super.callbackHandler.handle(new Callback[] { callback });
               
                if (callback.getCredential() instanceof String) {
                    callback.setCredential(new SamlCredential(DocumentUtil.getDocument(callback.getCredential().toString()).getDocumentElement()));
                }
               
                if (callback.getCredential() instanceof SamlCredential == false)
                    throw logger.authSharedCredentialIsNotSAMLCredential(callback.getCredential().getClass().getName());
                this.credential = (SamlCredential) callback.getCredential();
View Full Code Here

     * Commit will package the samlToken set by the login method in a new {@link SamlCredential}. This new SamlCredential will
     * be put into the Subject public credentials set.
     */
    public boolean commit() throws LoginException {
        if (success) {
            final SamlCredential samlCredential = new SamlCredential(samlToken);
            final boolean added = subject.getPublicCredentials().add(samlCredential);
            populateSubject();
            if (added)
                logger.trace("Added Credential " + samlCredential);

View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public boolean commit() throws LoginException {
        boolean result = super.commit();
        if (result) {
            SamlCredential samlCredential = null;
            Set<Object> creds = subject.getPublicCredentials();
            for (Object cred : creds) {
                if (cred instanceof SamlCredential) {
                    samlCredential = (SamlCredential) cred;
                    break;
View Full Code Here

            roles.add("test2");
            assertion.addStatement(StatementUtil.createAttributeStatement(roles));
            assertion.addStatement(StatementUtil.createAttributeStatement("SomeAttrib", "testX"));

            try {
                SamlCredential cred = new SamlCredential(AssertionUtil.asString(assertion));
                ObjectCallback obj = (ObjectCallback) callbacks[0];
                obj.setCredential(cred);
            } catch (ProcessingException e) {
                throw new RuntimeException(e);
            }
View Full Code Here

            if (assertion != null) {
                Subject subject = sc.getUtil().getSubject();
                // create new SecurityContext with token credential
                SecurityContext newSC = SecurityActions.createSecurityContext();
                newSC.getUtil().createSubjectInfo(principal, new SamlCredential(assertion), subject);
                // replace SecurityContext in the invocation
                invocation.getMetaData().addMetaData("security", "context", newSC);
            }
        }
View Full Code Here

        assertionElement = (Element) assertionDoc.getFirstChild();
        expectedAssertion = new InputSource(getClass().getResourceAsStream("/wstrust/assertion-expected.xml"));
    }

    public void testStringConstructor() throws Exception {
        final SamlCredential samlPrincipal = new SamlCredential(DocumentUtil.getNodeAsString(assertionElement));

        final InputSource actual = new InputSource(new StringReader(samlPrincipal.getAssertionAsString()));
        XMLAssert.assertXMLEqual(expectedAssertion, actual);
    }
View Full Code Here

        final InputSource actual = new InputSource(new StringReader(samlPrincipal.getAssertionAsString()));
        XMLAssert.assertXMLEqual(expectedAssertion, actual);
    }

    public void testElementConstructor() throws Exception {
        final SamlCredential samlPrincipal = new SamlCredential(assertionElement);

        final InputSource actual = new InputSource(new StringReader(samlPrincipal.getAssertionAsString()));
        XMLAssert.assertXMLEqual(expectedAssertion, actual);
    }
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.core.wstrust.SamlCredential

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.