Package com.sun.xml.ws.security.impl.policy

Examples of com.sun.xml.ws.security.impl.policy.UsernameToken


    public void addKeyBinding(Binding binding,WSSPolicy policy, Token token,boolean ignoreDK) throws PolicyException{
        PolicyAssertion tokenAssertion = (PolicyAssertion)token;
        SecurityPolicyVersion spVersion = SecurityPolicyUtil.getSPVersion(tokenAssertion);
        if(PolicyUtil.isUsernameToken(tokenAssertion, spVersion)){
            AuthenticationTokenPolicy.UsernameTokenBinding untBinding =new AuthenticationTokenPolicy.UsernameTokenBinding();
            UsernameToken unToken = (UsernameToken)tokenAssertion;
            untBinding.setUUID(token.getTokenId());           
            setUsernameTokenRefType(untBinding,unToken);
            //this code need not be called for UT
            setTokenInclusion(untBinding,(Token) tokenAssertion);
            setTokenValueType(untBinding, tokenAssertion);
            untBinding.isOptional(tokenAssertion.isOptional());
            if(unToken.getIssuer() != null){
                Address addr = unToken.getIssuer().getAddress();
                if(addr != null)
                    untBinding.setIssuer(addr.getURI().toString());
            } else if(unToken.getIssuerName() != null){
                untBinding.setIssuer(unToken.getIssuerName().getIssuerName());
            }
           
            if(unToken.getClaims() != null){
                untBinding.setClaims(unToken.getClaims().getClaimsAsBytes());
            }
           
            untBinding.setUseCreated(unToken.useCreated());
            untBinding.setUseNonce(unToken.useNonce());           

            if (!ignoreDK && unToken.isRequireDerivedKeys()) {
                DerivedTokenKeyBinding dtKB = new DerivedTokenKeyBinding();
                //Support for PasswordDerivedKeys
                if ((binding instanceof AsymmetricBinding) && (((AsymmetricBinding) binding).getInitiatorToken() != null)) {
                    skb.setKeyBinding(untBinding);
                    dtKB.setOriginalKeyBinding(skb);
                    policy.setKeyBinding(dtKB);
                } else {
                    dtKB.setOriginalKeyBinding(untBinding);
                    policy.setKeyBinding(dtKB);
                }
                dtKB.setUUID(pid.generateID());

            } else if (unToken.isRequireDerivedKeys()) {
                DerivedTokenKeyBinding dtKB = new DerivedTokenKeyBinding();
                if ((binding instanceof AsymmetricBinding) && (((AsymmetricBinding) binding).getInitiatorToken() != null)) {
                    skb.setKeyBinding(untBinding);
                    dtKB.setOriginalKeyBinding(skb);
                    policy.setKeyBinding(dtKB);
View Full Code Here


            tokenProcessor.setTokenInclusion(sct,(Token) tokenAssertion);
            //sct.setPolicyToken((Token) tokenAssertion);
            sct.setUUID(((Token)tokenAssertion).getTokenId());
        }else if(PolicyUtil.isUsernameToken(tokenAssertion, spVersion)){
            AuthenticationTokenPolicy.UsernameTokenBinding utb=new AuthenticationTokenPolicy.UsernameTokenBinding();
            UsernameToken unt = (UsernameToken)tokenAssertion;
            utb.setUUID(token.getTokenId());
            utb.setReferenceType(MessageConstants.DIRECT_REFERENCE_TYPE);
            tokenProcessor.setTokenValueType(utb, tokenAssertion);
            tokenProcessor.setTokenInclusion(utb,(Token) tokenAssertion);
            tokenProcessor.setUsernameTokenRefType(utb, unt);
            if(unt.getIssuer() != null){
                Address addr = unt.getIssuer().getAddress();
                if(addr != null)
                    utb.setIssuer(addr.getURI().toString());
            } else if(unt.getIssuerName() != null){
                utb.setIssuer(unt.getIssuerName().getIssuerName());
            }
           
            if(unt.getClaims() != null){
                utb.setClaims(unt.getClaims().getClaimsAsBytes());
            }
            utb.setUseCreated(unt.useCreated());
            utb.setUseNonce(unt.useNonce());
            //utb.setNoPassword(true);
            if(unt.isRequireDerivedKeys()){
            DerivedTokenKeyBinding dtKB =  new DerivedTokenKeyBinding();
            skb.setKeyBinding(utb);
            policy.setKeyBinding(dtKB);
            dtKB.setOriginalKeyBinding(skb);
            dtKB.setUUID(pid.generateID());
View Full Code Here

TOP

Related Classes of com.sun.xml.ws.security.impl.policy.UsernameToken

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.