Package org.apache.ws.security.message.token

Examples of org.apache.ws.security.message.token.SecurityContextToken


            secretKey = (byte[])result.get(WSSecurityEngineResult.TAG_SECRET);
            String id = (String)result.get(WSSecurityEngineResult.TAG_ID);
            principal = new CustomTokenPrincipal(id);
        } else if (WSConstants.SCT == action) {
            secretKey = (byte[])result.get(WSSecurityEngineResult.TAG_SECRET);
            SecurityContextToken sct =
                (SecurityContextToken)result.get(
                        WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN
                );
            principal = new CustomTokenPrincipal(sct.getIdentifier());
        } else if (WSConstants.DKT == action) {
            DerivedKeyToken dkt =
                (DerivedKeyToken)result.get(WSSecurityEngineResult.TAG_DERIVED_KEY_TOKEN);
            int keyLength = dkt.getLength();
            if (keyLength <= 0) {
View Full Code Here


        WSDocInfo wsDocInfo,
        Vector returnResults,
        WSSConfig config,
        RequestData requestData
    ) throws WSSecurityException {
        SecurityContextToken sct = new SecurityContextToken(elem);
        this.identifier = sct.getIdentifier();
        this.secret = this.getSecret(cb, sct);
        this.sctId = sct.getID();
       
        returnResults.add(
            0,
            new WSSecurityEngineResult(WSConstants.SCT, sct)
        );
View Full Code Here

        }
       
        if (cancelTarget != null && cancelTarget.isDOMElement()) {
            try {
                Element cancelTargetElement = (Element)cancelTarget.getToken();
                SecurityContextToken sct = new SecurityContextToken(cancelTargetElement);
                String identifier = sct.getIdentifier();
                SecurityToken token = tokenParameters.getTokenStore().getToken(identifier);
                if (token == null) {
                    LOG.fine("Identifier: " + identifier + " is not found in the cache");
                    return response;
                }
View Full Code Here

        SymmetricKeyHandler keyHandler = new SymmetricKeyHandler(tokenParameters);
        keyHandler.createSymmetricKey();
       
        try {
            Document doc = DOMUtils.createDocument();
            SecurityContextToken sct =
                new SecurityContextToken(getWSCVersion(tokenRequirements.getTokenType()), doc);
   
            TokenProviderResponse response = new TokenProviderResponse();
            response.setToken(sct.getElement());
            response.setTokenId(sct.getIdentifier());
            if (returnEntropy) {
                response.setEntropy(keyHandler.getEntropyBytes());
            }
            long keySize = keyHandler.getKeySize();
            response.setKeySize(keySize);
            response.setComputedKey(keyHandler.isComputedKey());
           
            // putting the secret key into the cache
            Date expires = null;
            if (lifetime > 0) {
                expires = new Date();
                long currentTime = expires.getTime();
                expires.setTime(currentTime + (lifetime * 1000L));
            }
           
            SecurityToken token = new SecurityToken(sct.getIdentifier(), null, expires);
            token.setSecret(keyHandler.getSecret());
            token.setPrincipal(tokenParameters.getPrincipal());
            if (tokenParameters.getRealm() != null) {
                Properties props = token.getProperties();
                if (props == null) {
                    props = new Properties();
                }
                props.setProperty(STSConstants.TOKEN_REALM, tokenParameters.getRealm());
                token.setProperties(props);
            }
            if (lifetime > 0) {
                Integer lifetimeInteger = new Integer(Long.valueOf(lifetime).intValue());
                tokenParameters.getTokenStore().add(token, lifetimeInteger);
            } else {
                tokenParameters.getTokenStore().add(token);
            }

            // Create the references
            TokenReference attachedReference = new TokenReference();
            attachedReference.setIdentifier(sct.getID());
            attachedReference.setUseDirectReference(true);
            attachedReference.setWsseValueType(tokenRequirements.getTokenType());
            response.setAttachedReference(attachedReference);
           
            TokenReference unAttachedReference = new TokenReference();
            unAttachedReference.setIdentifier(sct.getIdentifier());
            unAttachedReference.setUseDirectReference(true);
            unAttachedReference.setWsseValueType(tokenRequirements.getTokenType());
            response.setUnattachedReference(unAttachedReference);
           
            response.setLifetime(lifetime);
View Full Code Here

        response.setValid(false);
       
        if (validateTarget != null && validateTarget.isDOMElement()) {
            try {
                Element validateTargetElement = (Element)validateTarget.getToken();
                SecurityContextToken sct = new SecurityContextToken(validateTargetElement);
                String identifier = sct.getIdentifier();
                SecurityToken token = tokenParameters.getTokenStore().getToken(identifier);
                if (token == null) {
                    LOG.fine("Identifier: " + identifier + " is not found in the cache");
                    return response;
                }
View Full Code Here

                        );
                    }
                    return new ReceivedToken(tokenElement);
                } else if (actInt == WSConstants.SCT) {
                    // Need to check special case of SecurityContextToken Identifier separately
                    SecurityContextToken sct =
                        (SecurityContextToken)
                            engineResult.get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN);
                    if (referenceURI.equals(sct.getIdentifier())) {
                        return new ReceivedToken(sct.getElement());
                    }
                }
            }
        }
        throw new STSException("Cannot retreive token from reference", STSException.REQUEST_FAILED);
View Full Code Here

            List<WSSecurityEngineResult> wsSecEngineResults = rResult.getResults();

            for (WSSecurityEngineResult wser : wsSecEngineResults) {
                Integer actInt = (Integer)wser.get(WSSecurityEngineResult.TAG_ACTION);
                if (actInt.intValue() == WSConstants.SCT) {
                    SecurityContextToken tok =
                        (SecurityContextToken)wser.get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN);
                    message.getExchange().put(SecurityConstants.TOKEN_ID, tok.getIdentifier());
                   
                    byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET);
                    if (secret != null) {
                        SecurityToken token = new SecurityToken(tok.getIdentifier());
                        token.setToken(tok.getElement());
                        token.setSecret(secret);
                        token.setTokenType(tok.getTokenType());
                        getTokenStore(message).add(token);
                    }
                    return true;
                }
            }
View Full Code Here

    private SecurityToken findCancelToken(Exchange exchange, Element el) throws WSSecurityException {
        Element childElement = DOMUtils.getFirstElement(el);
        String uri = "";
        if ("SecurityContextToken".equals(childElement.getLocalName())) {
            SecurityContextToken sct = new SecurityContextToken(childElement);
            uri = sct.getIdentifier();
        } else {
            SecurityTokenReference ref = new SecurityTokenReference(childElement);
            uri = ref.getReference().getURI();
        }
        TokenStore store = (TokenStore)exchange.get(Endpoint.class).getEndpointInfo()
View Full Code Here

        TokenCancellerParameters cancellerParameters = createCancellerParameters();
        TokenRequirements tokenRequirements = cancellerParameters.getTokenRequirements();
       
        // Create a CancelTarget consisting of a SecurityContextToken
        Document doc = DOMUtils.createDocument();
        SecurityContextToken sct = new SecurityContextToken(doc);
        ReceivedToken cancelTarget = new ReceivedToken(sct.getElement());
        tokenRequirements.setCancelTarget(cancelTarget);
       
        assertTrue(sctCanceller.canHandleToken(cancelTarget));
       
        TokenCancellerResponse cancellerResponse = sctCanceller.cancelToken(cancellerParameters);
View Full Code Here

        TokenValidatorParameters validatorParameters = createValidatorParameters();
        TokenRequirements tokenRequirements = validatorParameters.getTokenRequirements();
       
        // Create a ValidateTarget consisting of a SecurityContextToken
        Document doc = DOMUtils.createDocument();
        SecurityContextToken sct = new SecurityContextToken(doc);
        ReceivedToken validateTarget = new ReceivedToken(sct.getElement());
        tokenRequirements.setValidateTarget(validateTarget);
       
        assertTrue(sctValidator.canHandleToken(validateTarget));
       
        TokenValidatorResponse validatorResponse =
View Full Code Here

TOP

Related Classes of org.apache.ws.security.message.token.SecurityContextToken

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.