Package com.sun.xml.ws.security.opt.impl.tokens

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


                    untBinding = context.getusernameTokenBinding();
                    untBinding.setReferenceType(MessageConstants.DIRECT_REFERENCE_TYPE);
                } else {
                    throw new XWSSecurityException("Internal error: UsernameToken Binding not set on context");
                }
                UsernameToken unt = untBinding.getUsernameToken();
                String unTokenId = untBinding.getUUID();
                if (unTokenId == null || unTokenId.equals("")) {
                    unTokenId = context.generateID();
                }
                if (logger.isLoggable(Level.FINEST)) {
View Full Code Here

    */
    public static UsernameTokenBinding createUntBinding(FilterProcessingContext context,UsernameTokenBinding untBinding, int firstByte) throws XWSSecurityException{
        UsernameTokenBinding binding = (UsernameTokenBinding)untBinding.clone();
        JAXBFilterProcessingContext opContext = (JAXBFilterProcessingContext) context;
        SignaturePolicy authPolicy = (SignaturePolicy) context.getSecurityPolicy();
        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, authPolicy, binding, firstByte);
        } 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

        }
        SecurityUtil.checkIncludeTokenPolicyOpt(context, binding, untokenId);
        String referenceType = binding.getReferenceType();      
        BuilderResult result = new BuilderResult();
        if (MessageConstants.DIRECT_REFERENCE_TYPE.equals(referenceType)) {
            UsernameToken unToken = createUsernameToken(binding, binding.getUsernameToken());
            if (unToken == null) {
                logger.log(Level.SEVERE, LogStringsMessages.WSS_1856_NULL_USERNAMETOKEN());
                throw new XWSSecurityException("Username Token is NULL");
            }
            DirectReference dr = buildDirectReference(unToken.getId(), MessageConstants.USERNAME_STR_REFERENCE_NS);
            buildKeyInfo(dr, binding.getSTRID());
        }               
        result.setKeyInfo(keyInfo);
        return result;   
    }
View Full Code Here

TOP

Related Classes of com.sun.xml.ws.security.opt.impl.tokens.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.