Examples of UsernameToken


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

Examples of com.sun.xml.ws.security.opt.impl.tokens.UsernameToken

        UsernameTokenBinding binding = (UsernameTokenBinding)untBinding.clone();
        JAXBFilterProcessingContext opContext = (JAXBFilterProcessingContext) context;
        EncryptionPolicy encPolicy = (EncryptionPolicy) context.getSecurityPolicy();
        //com.sun.xml.ws.security.opt.impl.tokens.UsernameToken unToken =
        //new com.sun.xml.ws.security.opt.impl.tokens.UsernameToken(opContext.getSOAPVersion());
        UsernameToken unToken = null;
        if (context.getusernameTokenBinding() == null) {
            unToken = new UsernameToken(opContext.getSOAPVersion());
        } else {
            if (untBinding.getUUID().equals(context.getusernameTokenBinding().getUUID())) {
                unToken = context.getusernameTokenBinding().getUsernameToken();
            } else {
                unToken = new UsernameToken(opContext.getSOAPVersion());
            }
        }
        try {
            binding = UsernameTokenDataResolver.setSaltandIterationsforUsernameToken(opContext, unToken, encPolicy, binding);
        } catch (UnsupportedEncodingException ex) {
             throw new XWSSecurityException("error occurred while decoding the salt in username token",ex);
        } catch(XWSSecurityException ex){
             throw ex;
        }
        if (binding.getUseNonce() && unToken.getNonceValue() == null) {
            unToken.setNonce(binding.getNonce());
            String creationTime = "";
            TimestampPolicy tPolicy = (TimestampPolicy) binding.getFeatureBinding();
            if(tPolicy == null)tPolicy = (TimestampPolicy) binding.newTimestampFeatureBinding();
            creationTime = tPolicy.getCreationTime();
            unToken.setCreationTime(creationTime);
        }
        if (binding.getUseCreated() && unToken.getCreatedValue() == null) {
            String creationTime = "";
            TimestampPolicy tPolicy = (TimestampPolicy) binding.getFeatureBinding();
            if(tPolicy == null)tPolicy = (TimestampPolicy) binding.newTimestampFeatureBinding();
            creationTime = tPolicy.getCreationTime();
            unToken.setCreationTime(creationTime);
        }
        binding.setUsernameToken(unToken);
        String dataEncAlgo = null;
        if (context.getAlgorithmSuite() != null) {
            dataEncAlgo = context.getAlgorithmSuite().getEncryptionAlgorithm();
View Full Code Here

Examples of com.sun.xml.ws.security.policy.UserNameToken

                throw new PolicyException(ex);
            }
            key.setUUID(token.getTokenId());
            key.isOptional(((PolicyAssertion) token).isOptional());           
            setTokenInclusion(key,token);
            UserNameToken ut = (UserNameToken)token;
            key.setUseCreated(ut.useCreated());
            key.setUseNonce(ut.useNonce());
            if(!ut.hasPassword()){
                key.setNoPassword(true);
            } else if(ut.useHashPassword()){
                key.setDigestOn(true);
                key.setUseNonce(true);
            }
           
            if(ut.getIssuer() != null){
                Address addr = ut.getIssuer().getAddress();
                if(addr != null)
                    key.setIssuer(addr.getURI().toString());
            } else if(ut.getIssuerName() != null){
                key.setIssuer(ut.getIssuerName().getIssuerName());
            }
           
            if(ut.getClaims() != null){
                key.setClaims(ut.getClaims().getClaimsAsBytes());
            }
           
            //key.setPolicyToken(token);
            return key;
        }else if(PolicyUtil.isSamlToken((PolicyAssertion) token, spVersion)){
View Full Code Here

Examples of com.sun.xml.wss.core.UsernameToken

        } else {
            SecurableSoapMessage secureMessage = context.getSecurableSoapMessage();
            SOAPPart soapPart = secureMessage.getSOAPPart();
           
            AuthenticationTokenPolicy authPolicy = (AuthenticationTokenPolicy)context.getSecurityPolicy();
            UsernameToken token = new UsernameToken(soapPart, "");
           
            AuthenticationTokenPolicy.UsernameTokenBinding policy =
                    resolveUserNameTokenData(context, token, null,authPolicy);
           
            if(policy.getUseNonce()){
                token.setNonce(policy.getNonce());
            }
            if(policy.getDigestOn()){
                token.setDigestOn();
            }
           
            if ( policy.getUseNonce() || policy.getDigestOn() || policy.getUseCreated()) {
                String creationTime = "";
                TimestampPolicy tPolicy = (TimestampPolicy) policy.getFeatureBinding();
                creationTime = tPolicy.getCreationTime();
                token.setCreationTime(creationTime);
            }
           
            if(policy.hasNoPassword()){
                String creationTime = "";
                TimestampPolicy tPolicy = (TimestampPolicy) policy.getFeatureBinding();
                creationTime = tPolicy.getCreationTime();
                token.setCreationTime(creationTime);
            }
            SecurityHeader wsseSecurity = secureMessage.findOrCreateSecurityHeader();
            String wsuId = policy.getUUID();
            if (wsuId != null && !wsuId.equals("")){
                XMLUtil.setWsuIdAttr(token.getAsSoapElement(), wsuId);
            }
            wsseSecurity.insertHeaderBlock(token);
        }
    }
View Full Code Here

Examples of org.apache.cxf.common.security.UsernameToken

            password = policy.getPassword();
        } else {
            // try the UsernameToken
            SecurityToken token = message.get(SecurityToken.class);
            if (token != null && token.getTokenType() == TokenType.UsernameToken) {
                UsernameToken ut = (UsernameToken)token;
                name = ut.getName();
                password = ut.getPassword();
            }
        }
       
        if (name == null || password == null) {
            org.apache.cxf.common.i18n.Message errorMsg =
View Full Code Here

Examples of org.apache.cxf.common.security.UsernameToken

                name = policy.getUserName();
            } else {
                // try the UsernameToken
                SecurityToken token = message.get(SecurityToken.class);
                if (token != null && token.getTokenType() == TokenType.UsernameToken) {
                    UsernameToken ut = (UsernameToken)token;
                    name = ut.getName();
                }
            }
            return new DefaultSecurityContext(name, subject);
        }
    }
View Full Code Here

Examples of org.apache.cxf.common.security.UsernameToken

        SecurityContext context = msg.get(SecurityContext.class);
        if (token == null || context == null || context.getUserPrincipal() == null) {
            super.handleMessage(msg);
            return;
        }
        UsernameToken ut = (UsernameToken)token;
       
        Subject subject = createSubject(ut.getName(), ut.getPassword(), ut.isHashed(),
                                        ut.getNonce(), ut.getCreatedTime());
       
        SecurityContext sc = doCreateSecurityContext(context.getUserPrincipal(), subject);
        msg.put(SecurityContext.class, sc);
    }
View Full Code Here

Examples of org.apache.cxf.common.security.UsernameToken

            password = policy.getPassword();
        } else {
            // try the UsernameToken
            SecurityToken token = message.get(SecurityToken.class);
            if (token != null && token.getTokenType() == TokenType.UsernameToken) {
                UsernameToken ut = (UsernameToken)token;
                name = ut.getName();
                password = ut.getPassword();
            }
        }
       
        if (name == null || password == null) {
            org.apache.cxf.common.i18n.Message errorMsg =
View Full Code Here

Examples of org.apache.cxf.ws.security.policy.model.UsernameToken

    public PolicyAssertion build(Element element) {
       
        SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
            ? SP11Constants.INSTANCE : SP12Constants.INSTANCE;

        UsernameToken usernameToken = new UsernameToken(consts);
        usernameToken.setOptional(PolicyConstants.isOptional(element));

        String attribute = element.getAttributeNS(element.getNamespaceURI(), SPConstants.ATTR_INCLUDE_TOKEN);
        if (attribute != null) {
            usernameToken.setInclusion(consts.getInclusionFromAttributeValue(attribute));
        }

        Element polEl = PolicyConstants.findPolicyElement(element);
        if (polEl != null) {
            NodeList children = polEl.getChildNodes();
            if (children != null) {
                for (int i = 0; i < children.getLength(); i++) {
                    Node child = children.item(i);
                    if (child instanceof Element) {
                        child = (Element)child;
                        QName qname = new QName(child.getNamespaceURI(), child.getLocalName());
                        if (SPConstants.USERNAME_TOKEN10.equals(qname.getLocalPart())) {
                            usernameToken.setUseUTProfile10(true);
                        } else if (SPConstants.USERNAME_TOKEN11.equals(qname.getLocalPart())) {
                            usernameToken.setUseUTProfile11(true);
                        } else if (SP12Constants.NO_PASSWORD.equals(qname)) {
                            usernameToken.setNoPassword(true);
                        } else if (SP12Constants.HASH_PASSWORD.equals(qname)) {
                            usernameToken.setHashPassword(true);
                        } else if (SP12Constants.REQUIRE_DERIVED_KEYS.equals(qname)) {
                            usernameToken.setDerivedKeys(true);
                        } else if (SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS.equals(qname)) {
                            usernameToken.setExplicitDerivedKeys(true);
                        } else if (SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS.equals(qname)) {
                            usernameToken.setImpliedDerivedKeys(true);
                        }
                    }
                }
            }
        }
View Full Code Here

Examples of org.apache.cxf.ws.security.policy.model.UsernameToken

                   
                    if (utWithCallbacks) {
                        WSUsernameTokenPrincipal princ
                            = (WSUsernameTokenPrincipal)wser.get(WSSecurityEngineResult.TAG_PRINCIPAL);
                        for (AssertionInfo ai : ais) {
                            UsernameToken tok = (UsernameToken)ai.getAssertion();
                            if (tok.isHashPassword() != princ.isPasswordDigest()) {
                                ai.setNotAsserted("Password hashing policy not enforced");
                            }
                        }
                    }
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.