Package org.apache.wss4j.policy.model

Examples of org.apache.wss4j.policy.model.AlgorithmSuite


        Collection<AssertionInfo> sp11Ais =
            aim.get(new QName(spNamespace, SPConstants.ALGORITHM_SUITE));
        if (sp11Ais != null) {
            for (AssertionInfo ai : sp11Ais) {
                ai.setAsserted(true);
                AlgorithmSuite algorithmSuite = (AlgorithmSuite)ai.getAssertion();
                AlgorithmSuiteType algorithmSuiteType = algorithmSuite.getAlgorithmSuiteType();
                String namespace = algorithmSuiteType.getNamespace();
                if (namespace == null) {
                    namespace = spNamespace;
                }
                Collection<AssertionInfo> algAis =
View Full Code Here


                              List<SecurePart> encrParts,
                              boolean externalRef) throws SOAPException {
        //Do encryption
        if (recToken != null && recToken.getToken() != null) {
            AbstractToken encrToken = recToken.getToken();
            AlgorithmSuite algorithmSuite = sbinding.getAlgorithmSuite();

            // Action
            WSSSecurityProperties properties = getProperties();
            WSSConstants.Action actionToPerform = WSSConstants.ENCRYPT;
            if (recToken.getToken().getDerivedKeys() == DerivedKeys.RequireDerivedKeys) {
                actionToPerform = WSSConstants.ENCRYPT_WITH_DERIVED_KEY;
                if (MessageUtils.isRequestor(message) && recToken.getToken() instanceof X509Token) {
                    properties.setDerivedKeyTokenReference(
                        WSSConstants.DerivedKeyTokenReference.EncryptedKey);
                } else {
                    properties.setDerivedKeyTokenReference(
                        WSSConstants.DerivedKeyTokenReference.DirectReference);
                }
                AlgorithmSuiteType algSuiteType = sbinding.getAlgorithmSuite().getAlgorithmSuiteType();
                properties.setDerivedEncryptionKeyLength(
                           algSuiteType.getEncryptionDerivedKeyLength() / 8);
            }

            if (recToken.getVersion() == SPConstants.SPVersion.SP12) {
                properties.setUse200512Namespace(true);
            }
           
            for (SecurePart encPart : encrParts) {
                properties.addEncryptionPart(encPart);
            }
           
            properties.addAction(actionToPerform);

            if (isRequestor()) {
                properties.setEncryptionKeyIdentifier(getKeyIdentifierType(recToken, encrToken));
                properties.setDerivedKeyKeyIdentifier(
                    WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference);
            } else if (recToken.getToken() instanceof KerberosToken && !isRequestor()) {
                properties.setEncryptionKeyIdentifier(
                    WSSecurityTokenConstants.KeyIdentifier_KerberosSha1Identifier);
                properties.setDerivedKeyKeyIdentifier(
                    WSSecurityTokenConstants.KeyIdentifier_KerberosSha1Identifier);
                if (recToken.getToken().getDerivedKeys() == DerivedKeys.RequireDerivedKeys) {
                    properties.setEncryptionKeyIdentifier(
                        WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference);
                }
            } else if ((recToken.getToken() instanceof IssuedToken
                || recToken.getToken() instanceof SecureConversationToken
                || recToken.getToken() instanceof SpnegoContextToken) && !isRequestor()) {
                properties.setEncryptionKeyIdentifier(
                    WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference);
            } else {
                properties.setEncryptionKeyIdentifier(
                    WSSecurityTokenConstants.KeyIdentifier_EncryptedKeySha1Identifier);
                if (recToken.getToken().getDerivedKeys() == DerivedKeys.RequireDerivedKeys) {
                    properties.setDerivedKeyKeyIdentifier(
                        WSSecurityTokenConstants.KeyIdentifier_EncryptedKeySha1Identifier);
                    properties.setEncryptionKeyIdentifier(
                        WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference);
                    properties.setEncryptSymmetricEncryptionKey(false);
                }
            }

            properties.setEncryptionKeyTransportAlgorithm(
                       algorithmSuite.getAlgorithmSuiteType().getAsymmetricKeyWrap());
            properties.setEncryptionSymAlgorithm(
                       algorithmSuite.getAlgorithmSuiteType().getEncryption());

            String encUser = (String)message.getContextualProperty(SecurityConstants.ENCRYPT_USERNAME);
            if (encUser == null) {
                encUser = (String)message.getContextualProperty(SecurityConstants.USERNAME);
            }
View Full Code Here

        client.setSoap11(message.getVersion() == Soap11.getInstance());
        client.setSecureConv(true);
        String s = message
            .getContextualProperty(Message.ENDPOINT_ADDRESS).toString();
        client.setLocation(s);
        AlgorithmSuite suite = NegotiationUtils.getAlgorithmSuite(aim);
        if (suite != null) {
            client.setAlgorithmSuite(suite);
            int x = suite.getAlgorithmSuiteType().getMaximumSymmetricKeyLength();
            if (x < 256) {
                client.setKeySize(x);
            }
        }
        Map<String, Object> ctx = client.getRequestContext();
View Full Code Here

        //Do encryption
        if (recToken != null && recToken.getToken() != null && encrParts.size() > 0) {
            AbstractToken encrToken = recToken.getToken();
            assertPolicy(recToken);
            assertPolicy(encrToken);
            AlgorithmSuite algorithmSuite = sbinding.getAlgorithmSuite();
            if (encrToken.getDerivedKeys() == DerivedKeys.RequireDerivedKeys) {
                return doEncryptionDerived(recToken, encrTok, encrToken,
                                           attached, encrParts, atEnd);
            } else {
                try {
                    WSSecEncrypt encr = new WSSecEncrypt(wssConfig);
                    encr.setAttachmentCallbackHandler(new AttachmentCallbackHandler(message));
                    String encrTokId = encrTok.getId();
                    if (attached) {
                        encrTokId = encrTok.getWsuId();
                        if (encrTokId == null
                            && (encrToken instanceof SecureConversationToken
                                || encrToken instanceof SecurityContextToken)) {
                            encr.setEncKeyIdDirectId(true);
                            encrTokId = encrTok.getId();
                        } else if (encrTokId == null) {
                            encrTokId = encrTok.getId();
                        }
                        if (encrTokId.startsWith("#")) {
                            encrTokId = encrTokId.substring(1);
                        }
                    } else {
                        encr.setEncKeyIdDirectId(true);
                    }
                    if (encrTok.getTokenType() != null) {
                        encr.setCustomReferenceValue(encrTok.getTokenType());
                    }
                    encr.setEncKeyId(encrTokId);
                    encr.setEphemeralKey(encrTok.getSecret());
                    Crypto crypto = getEncryptionCrypto(recToken);
                    if (crypto != null) {
                        this.message.getExchange().put(SecurityConstants.ENCRYPT_CRYPTO, crypto);
                        setEncryptionUser(encr, recToken, false, crypto);
                    }
                   
                    encr.setDocument(saaj.getSOAPPart());
                    encr.setEncryptSymmKey(false);
                    encr.setSymmetricEncAlgorithm(algorithmSuite.getAlgorithmSuiteType().getEncryption());
                   
                    if (encrToken instanceof IssuedToken || encrToken instanceof SpnegoContextToken
                        || encrToken instanceof SecureConversationToken) {
                        //Setting the AttachedReference or the UnattachedReference according to the flag
                        Element ref;
View Full Code Here

        algSuitePolicy.addPolicyComponent(algSuitePolicyEa);
        All algSuitePolicyAll = new All();
        algSuitePolicyAll.addAssertion(
            new PrimitiveAssertion(new QName(SP12Constants.SP_NS, SP12Constants.ALGO_SUITE_BASIC128)));
        algSuitePolicyEa.addPolicyComponent(algSuitePolicyAll);
        AlgorithmSuite algorithmSuite = new AlgorithmSuite(SPConstants.SPVersion.SP12, algSuitePolicy);
       
        // Symmetric Binding
        Policy bindingPolicy = new Policy();
        ExactlyOne bindingPolicyEa = new ExactlyOne();
        bindingPolicy.addPolicyComponent(bindingPolicyEa);
View Full Code Here

TOP

Related Classes of org.apache.wss4j.policy.model.AlgorithmSuite

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.