Package org.picketlink.identity.federation.core.parsers.wst

Examples of org.picketlink.identity.federation.core.parsers.wst.WSTrustParser


        Source requestMessage = this.createSourceFromRequest(request);

        // invoke the token service.
        Source responseMessage = this.tokenService.invoke(requestMessage);
        WSTrustParser parser = new WSTrustParser();
        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 assertionElement = (Element) collection.getRequestSecurityTokenResponses().get(0).getRequestedSecurityToken()
                .getAny().get(0);

        // now construct a WS-Trust renew request with the generated assertion.
        request = this.createRequest("renewcontext", WSTrustConstants.RENEW_REQUEST, SAMLUtil.SAML11_TOKEN_TYPE, null);
        RenewTargetType renewTarget = new RenewTargetType();
        renewTarget.add(assertionElement);
        request.setRenewTarget(renewTarget);

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

        // validate the renew response contents and get the renewed token.
        this.validateSAML11AssertionResponse(baseResponse, "renewcontext", "jduke", SAMLUtil.SAML11_BEARER_URI);
        collection = (RequestSecurityTokenResponseCollection) baseResponse;
        Element renewedAssertionElement = (Element) collection.getRequestSecurityTokenResponses().get(0)
View Full Code Here


        Source requestMessage = this.createSourceFromRequest(request);

        // invoke the token service.
        Source responseMessage = this.tokenService.invoke(requestMessage);
        WSTrustParser parser = new WSTrustParser();
        BaseRequestSecurityTokenResponse baseResponse = (BaseRequestSecurityTokenResponse) parser.parse(DocumentUtil
                .getSourceAsStream(responseMessage));

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

        // now construct a WS-Trust renew request with the generated assertion.
        request = this.createRequest("renewcontext", WSTrustConstants.RENEW_REQUEST, SAMLUtil.SAML2_TOKEN_TYPE, null);
        RenewTargetType renewTarget = new RenewTargetType();
        renewTarget.add(assertionElement);
        request.setRenewTarget(renewTarget);

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

        // validate the renew response contents and get the renewed token.
        this.validateSAMLAssertionResponse(baseResponse, "renewcontext", "jduke", SAMLUtil.SAML2_BEARER_URI);
        collection = (RequestSecurityTokenResponseCollection) baseResponse;
        Element renewedAssertionElement = (Element) collection.getRequestSecurityTokenResponses().get(0)
View Full Code Here

        Source requestMessage = this.createSourceFromRequest(request);

        // invoke the token service.
        Source responseMessage = this.tokenService.invoke(requestMessage);
        WSTrustParser parser = new WSTrustParser();
        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 cancel request with the generated assertion.
        request = this.createRequest("cancelcontext", WSTrustConstants.CANCEL_REQUEST, null, null);
        CancelTargetType cancelTarget = new CancelTargetType();
        cancelTarget.add(assertion);
        request.setCancelTarget(cancelTarget);

        // 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", "cancelcontext", response.getContext());
        assertNotNull("Cancel response should contain a RequestedTokenCancelled element", response.getRequestedTokenCancelled());

        // try to validate the canceled assertion.
        request = this.createRequest("validatecontext", WSTrustConstants.VALIDATE_REQUEST, null, null);
        ValidateTargetType validateTarget = new ValidateTargetType();
        validateTarget.add(assertion);
        request.setValidateTarget(validateTarget);

        // the response should contain a status indicating that the token is not valid.
        responseMessage = this.tokenService.invoke(this.createSourceFromRequest(request));
        collection = (RequestSecurityTokenResponseCollection) parser.parse(DocumentUtil.getSourceAsStream(responseMessage));
        assertEquals("Unexpected number of responses", 1, collection.getRequestSecurityTokenResponses().size());
        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();
View Full Code Here

        Source requestMessage = this.createSourceFromRequest(request);

        // invoke the token service.
        Source responseMessage = this.tokenService.invoke(requestMessage);
        WSTrustParser parser = new WSTrustParser();
        BaseRequestSecurityTokenResponse baseResponse = (BaseRequestSecurityTokenResponse) parser.parse(DocumentUtil
                .getSourceAsStream(responseMessage));

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

        // now construct a WS-Trust cancel request with the generated assertion.
        request = this.createRequest("cancelcontext", WSTrustConstants.CANCEL_REQUEST, null, null);
        CancelTargetType cancelTarget = new CancelTargetType();
        cancelTarget.add(assertion);
        request.setCancelTarget(cancelTarget);

        // 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", "cancelcontext", response.getContext());
        assertNotNull("Cancel response should contain a RequestedTokenCancelled element", response.getRequestedTokenCancelled());

        // try to validate the canceled assertion.
        request = this.createRequest("validatecontext", WSTrustConstants.VALIDATE_REQUEST, null, null);
        ValidateTargetType validateTarget = new ValidateTargetType();
        validateTarget.add(assertion);
        request.setValidateTarget(validateTarget);

        // the response should contain a status indicating that the token is not valid.
        responseMessage = this.tokenService.invoke(this.createSourceFromRequest(request));
        collection = (RequestSecurityTokenResponseCollection) parser.parse(DocumentUtil.getSourceAsStream(responseMessage));
        assertEquals("Unexpected number of responses", 1, collection.getRequestSecurityTokenResponses().size());
        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();
View Full Code Here

        request.getValidateTarget().add(this.createUnknownToken());
        requestMessage = this.createSourceFromRequest(request);
        try {
            this.tokenService.invoke(requestMessage);
            Source responseMessage = this.tokenService.invoke(requestMessage);
            RequestSecurityTokenResponseCollection baseResponseColl = (RequestSecurityTokenResponseCollection) new WSTrustParser()
                    .parse(DocumentUtil.getSourceAsStream(responseMessage));

            RequestSecurityTokenResponse response = baseResponseColl.getRequestSecurityTokenResponses().get(0);
            StatusType status = response.getStatus();
            assertTrue(status.getCode().equals(WSTrustConstants.STATUS_CODE_INVALID));
View Full Code Here

    @Test
    public void testWST_BatchIssue() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/wst/wst-batch-issue.xml");

        WSTrustParser parser = new WSTrustParser();
        RequestSecurityTokenCollection requestCollection = (RequestSecurityTokenCollection) parser.parse(configStream);
        assertNotNull("Request Security Token Collection is null?", requestCollection);

        List<RequestSecurityToken> tokens = requestCollection.getRequestSecurityTokens();
        assertEquals(2, tokens.size());
View Full Code Here

    @Test
    public void testWST_CancelTargetSaml() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/wst/wst-cancel-saml.xml");

        WSTrustParser parser = new WSTrustParser();
        RequestSecurityToken requestToken = (RequestSecurityToken) parser.parse(configStream);
        assertEquals("cancelcontext", requestToken.getContext());
        assertEquals(WSTrustConstants.CANCEL_REQUEST, requestToken.getRequestType().toASCIIString());

        CancelTargetType cancelTarget = requestToken.getCancelTarget();
View Full Code Here

    @Test
    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());
View Full Code Here

    @Test
    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();
       
View Full Code Here

    @Test
    public void testPublicKey() throws Exception {
        ClassLoader tcl = Thread.currentThread().getContextClassLoader();
        InputStream configStream = tcl.getResourceAsStream("parser/wst/wst-issue-public-key.xml");

        WSTrustParser parser = new WSTrustParser();
        RequestSecurityToken requestToken = (RequestSecurityToken) parser.parse(configStream);

        assertEquals("testcontext", requestToken.getContext());
        assertEquals(WSTrustConstants.ISSUE_REQUEST, requestToken.getRequestType().toASCIIString());

        AppliesTo appliesTo = requestToken.getAppliesTo();
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.core.parsers.wst.WSTrustParser

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.