Examples of SamlCredential


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

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

        final SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();

        when(messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).thenReturn(true);
        when(messageContext.getMessage()).thenReturn(soapMessage);

        SamlCredential samlPrincipal = new SamlCredential(StreamUtils.readStreamString(getClass().getResourceAsStream("assertion.xml"), "UTF-8"));

        boolean result = handler.handleMessage(messageContext);
        assertTrue(result);

        final SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
        final Iterator<SOAPElement> securityHeaders = envelope.getHeader().getChildElements(new QName("Security", "wsse", SOAPSamlHandler.WSSE_NS));
       
        while (securityHeaders.hasNext())
        {
            final SOAPElement securityElement = securityHeaders.next();
            final Iterator<SOAPElement> assertions = securityElement.getChildElements(assertionQName);
            while (assertions.hasNext())
            {
                final SOAPElement assertionElement = assertions.next();
                final String expected = samlPrincipal.getAssertionAsString();
                final String actual = SamlCredential.assertionToString(assertionElement);
                assertTrue(XMLHelper.compareXMLContent(expected, actual));
            }
        }
    }
View Full Code Here

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

        final Smooks smooks = createSmooks("Envelope/Header/Security");

        final StringSource source = new StringSource("<Envelope><Header>" + SECURITY_START + "</t:Security></Header></Envelope>");
        final StringResult result = new StringResult();

        final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
        final Subject subject = new Subject();
        subject.getPublicCredentials().add(samlPrincipal);
       
        final String expected = "<Envelope><Header>" + SECURITY_START + "<dummyAssertion/></t:Security></Header></Envelope>";
        final String actual = (String) Subject.doAs(subject, new PrivilegedAction<String>()
View Full Code Here

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

        final String soap = "<Envelope>" + HEADER_START + "</h:Header></Envelope>";
        final StringSource source = new StringSource(soap);
        final StringResult result = new StringResult();
       
        final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
        final Subject subject = new Subject();
        subject.getPublicCredentials().add(samlPrincipal);
       
        final String expected = "<Envelope>" + HEADER_START + SECURITY_START + "<dummyAssertion/></t:Security></h:Header></Envelope>";
        final String actual = (String) Subject.doAs(subject, new PrivilegedAction<String>()
View Full Code Here

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

       
        final String soap = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject.xml"), "UTF-8");
        final StringSource source = new StringSource(soap);
        final StringResult result = new StringResult();
       
        final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
        final Subject subject = new Subject();
        subject.getPublicCredentials().add(samlPrincipal);

        final String expected = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject-expected.xml"), "UTF-8");
        final String actual = (String) Subject.doAs(subject, new PrivilegedAction<String>()
View Full Code Here

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

       
        final String soap = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject-no-security-header.xml"), "UTF-8");
        final StringSource source = new StringSource(soap);
        final StringResult result = new StringResult();
       
        final SamlCredential samlPrincipal = new SamlCredential("<dummyAssertion/>");
        final Subject subject = new Subject();
        subject.getPublicCredentials().add(samlPrincipal);

        final String expected = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject-expected.xml"), "UTF-8");
        final String actual = (String) Subject.doAs(subject, new PrivilegedAction<String>()
View Full Code Here

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

public class SamlVisitor extends SOAPSecurityHeaderVisitor
{
    @Override
    protected String getHeaderToInsert()
    {
        SamlCredential samlCredential = SamlContext.getFirstSamlCredential();
        if (samlCredential != null)
        {
            return samlCredential.getAssertionAsString();
        }
        return null;
    }
View Full Code Here

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

                if ( securityNode.getNodeType() == Node.ELEMENT_NODE )
                {
                    final String localName = securityNode.getLocalName();
                    if ("Assertion".equalsIgnoreCase(localName))
                    {
                        credentials.add(new SamlCredential((Element)securityNode));
                    }
                }
            }
           
            // build the AuthenticationRequest.
View Full Code Here

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

            throw new SecurityException("Could not extract saml token info from :" + soap, e);
        }
       
        if (samlToken != null)
        {
            Set<Object> credential = Collections.<Object>singleton(new SamlCredential(samlToken));
            return new AuthenticationRequestImpl.Builder(null, credential).build();
        }
       
        return null;
    }
View Full Code Here

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

        if (outBound.booleanValue())
            return true;

        try
        {
            final SamlCredential samlCredential = SamlContext.getFirstSamlCredential();
            if (samlCredential != null)
            {
                final Element assertionElement = samlCredential.getAssertionAsElement();
              SOAPSamlHandlerUtil.addAssertion(soapContext, securityQName, assertionElement);
            }
        }
        catch (final SOAPException e)
        {
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.