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

Examples of org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityTokenResponseCollection


     * @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
     */
    public Object parse(XMLEventReader xmlEventReader) throws ParsingException {
        StaxParserUtil.getNextEvent(xmlEventReader);

        RequestSecurityTokenResponseCollection requestCollection = new RequestSecurityTokenResponseCollection();

        // Peek at the next event
        while (xmlEventReader.hasNext()) {
            StartElement peekedElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
            if (peekedElement == null)
                break;

            String tag = StaxParserUtil.getStartElementName(peekedElement);

            if (WSTrustConstants.RSTR.equalsIgnoreCase(tag)) {
                WSTRequestSecurityTokenResponseParser rstrParser = new WSTRequestSecurityTokenResponseParser();
                RequestSecurityTokenResponse rstr = (RequestSecurityTokenResponse) rstrParser.parse(xmlEventReader);
                requestCollection.addRequestSecurityTokenResponse(rstr);
            }
        }
        return requestCollection;
    }
View Full Code Here


        Source response = dispatchLocal.get().invoke(requestSource);
       
        try {
            InputStream stream = DocumentUtil.getNodeAsStream(DocumentUtil.getNodeFromSource(response));
            RequestSecurityTokenResponseCollection responseCollection = (RequestSecurityTokenResponseCollection) new WSTrustParser()
                    .parse(stream);
            RequestSecurityTokenResponse tokenResponse = responseCollection.getRequestSecurityTokenResponses().get(0);

            StatusType status = tokenResponse.getStatus();
            if (status != null) {
                String code = status.getCode();
                return WSTrustConstants.STATUS_CODE_VALID.equals(code);
View Full Code Here

        DOMSource requestSource = this.createSourceFromRequest(request);
        Source response = dispatchLocal.get().invoke(requestSource);
        // get the WS-Trust response and check for presence of the RequestTokenCanceled element.
        try {
            InputStream stream = DocumentUtil.getNodeAsStream(DocumentUtil.getNodeFromSource(response));
            RequestSecurityTokenResponseCollection responseCollection = (RequestSecurityTokenResponseCollection) new WSTrustParser()
                    .parse(stream);
            RequestSecurityTokenResponse tokenResponse = responseCollection.getRequestSecurityTokenResponses().get(0);
            if (tokenResponse.getRequestedTokenCancelled() != null)
                return true;
            return false;
        } catch (Exception e) {
            throw new WSTrustException(logger.parserError(e));
View Full Code Here

     * @param response the {@code RequestSecurityTokenResponse} to be marshalled.
     * @return the resulting {@code Source} instance.
     */
    protected Source marshallResponse(RequestSecurityTokenResponse response) {
        // add the single response to a RequestSecurityTokenResponse collection, as per the specification.
        RequestSecurityTokenResponseCollection responseCollection = new RequestSecurityTokenResponseCollection();
        responseCollection.addRequestSecurityTokenResponse(response);

        try {
            DOMResult result = new DOMResult(DocumentUtil.createDocument());
            WSTrustResponseWriter writer = new WSTrustResponseWriter(result);
            writer.write(responseCollection);
View Full Code Here

    public void testWST_ResponseRenew() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/wst/wst-response-renew.xml");

        WSTrustParser parser = new WSTrustParser();
        RequestSecurityTokenResponseCollection responseCollection = (RequestSecurityTokenResponseCollection) parser
                .parse(configStream);
        assertNotNull(responseCollection);

        // Now for the writing part
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

    public void testWST_RSTR_Assertion() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/wst/wst-response-assertion-hok-certificate.xml");

        WSTrustParser parser = new WSTrustParser();
        RequestSecurityTokenResponseCollection coll = (RequestSecurityTokenResponseCollection) parser.parse(configStream);
        assertEquals(1, coll.getRequestSecurityTokenResponses().size());

        RequestSecurityTokenResponse rstr = coll.getRequestSecurityTokenResponses().get(0);

        assertEquals("testcontext", rstr.getContext());
        assertEquals(SAMLUtil.SAML2_TOKEN_TYPE, rstr.getTokenType().toASCIIString());

        assertEquals(XMLTimeUtil.parse("2010-11-11T16:34:19.602Z"), rstr.getLifetime().getCreated());
View Full Code Here

        // validate the holder of key contents.
        SubjectConfirmationType subjConfirmation = assertion.getSubject().getConfirmation().get(0);
        this.validateHolderOfKeyContents(subjConfirmation, WSTrustConstants.KEY_TYPE_SYMMETRIC, null, false);

        // check if the response contains the STS-generated key.
        RequestSecurityTokenResponseCollection collection = (RequestSecurityTokenResponseCollection) baseResponse;
        RequestSecurityTokenResponse response = collection.getRequestSecurityTokenResponses().get(0);
        RequestedProofTokenType proofToken = response.getRequestedProofToken();
        assertNotNull("Unexpected null proof token", proofToken);
        assertTrue(proofToken.getAny().get(0) instanceof BinarySecretType);
        BinarySecretType serverBinarySecret = (BinarySecretType) proofToken.getAny().get(0);
        assertNotNull("Unexpected null secret", serverBinarySecret.getValue());
View Full Code Here

                SAMLUtil.SAML2_HOLDER_OF_KEY_URI);
        // validate the holder of key contents.
        SubjectConfirmationType subjConfirmation = assertion.getSubject().getConfirmation().get(0);
        this.validateHolderOfKeyContents(subjConfirmation, WSTrustConstants.KEY_TYPE_SYMMETRIC, null, false);

        RequestSecurityTokenResponseCollection collection = (RequestSecurityTokenResponseCollection) baseResponse;
        RequestSecurityTokenResponse response = collection.getRequestSecurityTokenResponses().get(0);
        RequestedProofTokenType proofToken = response.getRequestedProofToken();
        assertNotNull("Unexpected null proof token", proofToken);
        assertTrue(proofToken.getAny().get(0) instanceof ComputedKeyType);
        ComputedKeyType computedKey = (ComputedKeyType) proofToken.getAny().get(0);
        assertEquals("Unexpected computed key algorithm", WSTrustConstants.CK_PSHA1, computedKey.getAlgorithm());
View Full Code Here

    public void parseRSTWithWSP_15() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/wst/wst-response-unnatachedreference.xml");

        WSTrustParser parser = new WSTrustParser();
        RequestSecurityTokenResponseCollection requestTokenResponseCollection = (RequestSecurityTokenResponseCollection) parser.parse(configStream);
       
        RequestSecurityTokenResponse requestSecurityTokenResponse = requestTokenResponseCollection.getRequestSecurityTokenResponses().get(0);
       
        RequestedReferenceType requestedUnattachedReference = requestSecurityTokenResponse.getRequestedUnattachedReference();
       
        assertNotNull(requestedUnattachedReference);
       
View Full Code Here

        BaseRequestSecurityTokenResponse baseResponse = (BaseRequestSecurityTokenResponse) parser.parse(DocumentUtil
                .getSourceAsStream(responseMessage));

        // validate the response and get the SAML assertion from the request.
        this.validateSAML11AssertionResponse(baseResponse, "testcontext", "jduke", SAMLUtil.SAML11_BEARER_URI);
        RequestSecurityTokenResponseCollection collection = (RequestSecurityTokenResponseCollection) baseResponse;
        Element assertion = (Element) collection.getRequestSecurityTokenResponses().get(0).getRequestedSecurityToken().getAny()
                .get(0);

        // now construct a WS-Trust validate request with the generated assertion.
        request = this.createRequest("validatecontext", WSTrustConstants.VALIDATE_REQUEST, WSTrustConstants.STATUS_TYPE, null);
        ValidateTargetType validateTarget = new ValidateTargetType();
        validateTarget.add(assertion);
        request.setValidateTarget(validateTarget);

        // invoke the token service.
        responseMessage = this.tokenService.invoke(this.createSourceFromRequest(request));
        baseResponse = (BaseRequestSecurityTokenResponse) parser.parse(DocumentUtil.getSourceAsStream(responseMessage));

        // validate the response contents.
        assertNotNull("Unexpected null response", baseResponse);
        assertTrue("Unexpected response type", baseResponse instanceof RequestSecurityTokenResponseCollection);
        collection = (RequestSecurityTokenResponseCollection) baseResponse;
        assertEquals("Unexpected number of responses", 1, collection.getRequestSecurityTokenResponses().size());
        RequestSecurityTokenResponse response = collection.getRequestSecurityTokenResponses().get(0);
        assertEquals("Unexpected response context", "validatecontext", response.getContext());
        assertEquals("Unexpected token type", WSTrustConstants.STATUS_TYPE, response.getTokenType().toString());
        StatusType status = response.getStatus();
        assertNotNull("Unexpected null status", status);
        assertEquals("Unexpected status code", WSTrustConstants.STATUS_CODE_VALID, status.getCode());
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityTokenResponseCollection

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.