Package org.picketlink.identity.federation.ws.trust

Examples of org.picketlink.identity.federation.ws.trust.RequestedSecurityTokenType


        if (requestContext.getSecurityToken() == null)
            throw new WSTrustException(logger.nullValueError("Token issued by STS"));

        // construct the ws-trust security token response.
        RequestedSecurityTokenType requestedSecurityToken = new RequestedSecurityTokenType();

        SecurityToken contextSecurityToken = requestContext.getSecurityToken();
        if (contextSecurityToken == null)
            throw new WSTrustException(logger.nullValueError("Security Token from context"));

        requestedSecurityToken.add(contextSecurityToken.getTokenValue());

        RequestSecurityTokenResponse response = new RequestSecurityTokenResponse();
        if (request.getContext() != null)
            response.setContext(request.getContext());
View Full Code Here


        } catch (ProcessingException e) {
            throw new WSTrustException(e.getMessage(), e);
        }

        // create the WS-Trust response with the renewed token.
        RequestedSecurityTokenType requestedSecurityToken = new RequestedSecurityTokenType();
        SecurityToken contextSecurityToken = context.getSecurityToken();
        if (contextSecurityToken == null)
            throw new WSTrustException(logger.nullValueError("Security Token from context"));
        requestedSecurityToken.add(contextSecurityToken.getTokenValue());

        RequestSecurityTokenResponse response = new RequestSecurityTokenResponse();
        if (request.getContext() != null)
            response.setContext(request.getContext());
        response.setTokenType(request.getTokenType());
View Full Code Here

        }
        return status;
    }

    private RequestedSecurityTokenType parseRequestedSecurityTokenType(XMLEventReader xmlEventReader) throws ParsingException {
        RequestedSecurityTokenType requestedSecurityTokenType = new RequestedSecurityTokenType();

        StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
        StaxParserUtil.validate(startElement, WSTrustConstants.REQUESTED_TOKEN);

        XMLEvent xmlEvent = null;
        while (xmlEventReader.hasNext()) {
            xmlEvent = StaxParserUtil.peek(xmlEventReader);
            if (xmlEvent instanceof EndElement) {
                String endElementTag = StaxParserUtil.getEndElementName((EndElement) xmlEvent);
                if (endElementTag.equals(WSTrustConstants.REQUESTED_TOKEN)) {
                    xmlEvent = StaxParserUtil.getNextEndElement(xmlEventReader);
                    break;
                } else
                    throw logger.parserUnknownEndElement(endElementTag);
            }
            Element tokenElement = StaxParserUtil.getDOMElement(xmlEventReader);
            requestedSecurityTokenType.add(tokenElement);
        }

        return requestedSecurityTokenType;
    }
View Full Code Here

        Lifetime lifetime = response.getLifetime();
        assertNotNull("Unexpected null token lifetime", lifetime);

        // ========================================= Custom Token Validation =========================================//

        RequestedSecurityTokenType requestedToken = response.getRequestedSecurityToken();
        assertNotNull("Unexpected null requested security token", requestedToken);
        Object token = requestedToken.getAny().get(0);
        assertNotNull("Unexpected null token", token);
        assertTrue("Unexpected token class", token instanceof Element);
        Element element = (Element) requestedToken.getAny().get(0);
        assertEquals("Unexpected root element name", "SpecialToken", element.getLocalName());
        assertEquals("Unexpected namespace value", "http://www.tokens.org", element.getNamespaceURI());
        assertEquals("Unexpected attribute value", "http://www.tokens.org/SpecialToken", element.getAttribute("TokenType"));
        element = (Element) element.getFirstChild();
        assertEquals("Unexpected child element name", "SpecialTokenValue", element.getLocalName());
View Full Code Here

        assertEquals("Unexpected key value type", SAMLUtil.SAML11_VALUE_TYPE, keyId.getValueType());
        assertNotNull("Unexpected null key identifier value", keyId.getValue());

        // ====================================== SAMLV1.1 Assertion Validation ======================================//

        RequestedSecurityTokenType requestedToken = response.getRequestedSecurityToken();
        assertNotNull("Unexpected null requested security token", requestedToken);

        // unmarshall the SAMLV1.1 assertion.
        Element assertionElement = (Element) requestedToken.getAny().get(0);
        SAML11AssertionType assertion = SAMLUtil.saml11FromElement(assertionElement);

        // verify the contents of the unmarshalled assertion.
        assertNotNull("Invalid null assertion ID", assertion.getID());
        assertEquals(keyId.getValue().substring(1), assertion.getID());
View Full Code Here

        assertEquals("Unexpected key value type", SAMLUtil.SAML2_VALUE_TYPE, keyId.getValueType());
        assertNotNull("Unexpected null key identifier value", keyId.getValue());

        // ====================================== SAMLV2.0 Assertion Validation ======================================//

        RequestedSecurityTokenType requestedToken = response.getRequestedSecurityToken();
        assertNotNull("Unexpected null requested security token", requestedToken);

        // unmarshall the SAMLV2.0 assertion.
        Element assertionElement = (Element) requestedToken.getAny().get(0);
        AssertionType assertion = SAMLUtil.fromElement(assertionElement);

        // verify the contents of the unmarshalled assertion.
        assertNotNull("Invalid null assertion ID", assertion.getID());
        assertEquals(keyId.getValue().substring(1), assertion.getID());
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.ws.trust.RequestedSecurityTokenType

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.