ironmanAJ
ironmanAJ

Reputation: 128

Ws-Fed Response using open saml

I am trying to build ws-fed protocol response using org.opensaml.ws.wsfed. RequestSecurityTokenResponse here i added the RequestedSecurityToken with saml assertions in it. When trying to add wst:lifetime,TokenType,RequestType and wst:KeyType there is no methods to set these values in RequestSecurityTokenResponse. for reference https://javadoc.io/doc/org.opensaml/openws/latest/index.html Attached code for reference

RequestSecurityTokenResponse securityTokenResponse = new org.opensaml.ws.wsfed.impl.RequestSecurityTokenResponseBuilder().buildObject();
            RequestedSecurityToken requestedSecurityToken = new org.opensaml.ws.wsfed.impl.RequestedSecurityTokenBuilder().buildObject();
            // Generating life time
            Lifetime lifetime = new LifetimeBuilder().buildObject();
            Created created = new CreatedBuilder().buildObject();
            created.setDateTime(new DateTime());
            Expires expires = new ExpiresBuilder().buildObject();
            expires.setDateTime(new DateTime().plusHours(2));
            lifetime.setCreated(created);
            lifetime.setExpires(expires);

//            securityTokenResponse.getDOM().appendChild();

            // Token type generation
            TokenType tokenType = new TokenTypeBuilder().buildObject();
            tokenType.setValue("urn:oasis:names:tc:SAML:1.0:assertion");

            //Request Type
            RequestType requestType = new  RequestTypeBuilder().buildObject();
            requestType.setValue("http://schemas.xmlsoap.org/ws/2005/02/trust/Issue");

            // KeyType
            KeyType keytype = new KeyTypeBuilder().buildObject();
            keytype.setValue("http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey");


            // Getting SAML Assertions before building the WSFed Response
            org.opensaml.saml1.core.Assertion assertion =  buildSAML1Assertion(samlResponseParams);


            requestedSecurityToken.getSecurityTokens().add(assertion);
            securityTokenResponse.getRequestedSecurityToken().add(requestedSecurityToken);

How to add these to the RequestSecurityTokenResponse Thanks.

Upvotes: 0

Views: 60

Answers (0)

Related Questions