Package org.apache.cxf.sts.request

Examples of org.apache.cxf.sts.request.BinarySecret


        TokenProviderParameters providerParameters =
            createProviderParameters(WSConstants.WSS_SAML_TOKEN_TYPE, STSConstants.SYMMETRIC_KEY_KEYTYPE);
        assertTrue(samlTokenProvider.canHandleToken(WSConstants.WSS_SAML_TOKEN_TYPE));
       
        Entropy entropy = new Entropy();
        BinarySecret binarySecret = new BinarySecret();
        binarySecret.setBinarySecretValue(WSSecurityUtil.generateNonce(256 / 8));
        entropy.setBinarySecret(binarySecret);
        providerParameters.getKeyRequirements().setEntropy(entropy);
       
        binarySecret.setBinarySecretType("bad-type");
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on a bad type");
        } catch (STSException ex) {
            // expected as no type is provided
        }
       
        binarySecret.setBinarySecretType(STSConstants.NONCE_TYPE);
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on no computed key algorithm");
        } catch (STSException ex) {
            // expected as no computed key algorithm is provided
View Full Code Here


        TokenProviderParameters providerParameters =
            createProviderParameters(WSConstants.WSS_SAML_TOKEN_TYPE, STSConstants.SYMMETRIC_KEY_KEYTYPE);
        assertTrue(samlTokenProvider.canHandleToken(WSConstants.WSS_SAML_TOKEN_TYPE));
       
        Entropy entropy = new Entropy();
        BinarySecret binarySecret = new BinarySecret();
        binarySecret.setBinarySecretValue(WSSecurityUtil.generateNonce(256 / 8));
        entropy.setBinarySecret(binarySecret);
        providerParameters.getKeyRequirements().setEntropy(entropy);
       
        TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
        assertTrue(providerResponse != null);
View Full Code Here

        TokenProviderParameters providerParameters =
            createProviderParameters(WSConstants.WSS_SAML2_TOKEN_TYPE, STSConstants.SYMMETRIC_KEY_KEYTYPE);
        assertTrue(samlTokenProvider.canHandleToken(WSConstants.WSS_SAML2_TOKEN_TYPE));
       
        Entropy entropy = new Entropy();
        BinarySecret binarySecret = new BinarySecret();
        binarySecret.setBinarySecretValue(WSSecurityUtil.generateNonce(256 / 8));
        entropy.setBinarySecret(binarySecret);
        providerParameters.getKeyRequirements().setEntropy(entropy);
       
        binarySecret.setBinarySecretType("bad-type");
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on a bad type");
        } catch (STSException ex) {
            // expected as no type is provided
        }
       
        binarySecret.setBinarySecretType(STSConstants.NONCE_TYPE);
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on no computed key algorithm");
        } catch (STSException ex) {
            // expected as no computed key algorithm is provided
View Full Code Here

        // Test Entropy
        clientEntropy = keyRequirements.getEntropy();
        if (clientEntropy == null) {
            LOG.log(Level.WARNING, "A SymmetricKey KeyType is requested, but no client entropy is provided");
        } else if (clientEntropy.getBinarySecret() != null) {
            BinarySecret binarySecret = clientEntropy.getBinarySecret();
            if (STSConstants.NONCE_TYPE.equals(binarySecret.getBinarySecretType())) {
                byte[] nonce = binarySecret.getBinarySecretValue();
                if (nonce == null || (nonce.length < (keySize / 8))) {
                    LOG.log(Level.WARNING, "User Entropy rejected");
                    clientEntropy = null;
                }
                String computedKeyAlgorithm = keyRequirements.getComputedKeyAlgorithm();
                if (!STSConstants.COMPUTED_KEY_PSHA1.equals(computedKeyAlgorithm)) {
                    LOG.log(
                        Level.WARNING,
                        "The computed key algorithm of " + computedKeyAlgorithm + " is not supported"
                    );
                    throw new STSException(
                        "Computed Key Algorithm not supported", STSException.INVALID_REQUEST
                    );
                }
            } else if (STSConstants.SYMMETRIC_KEY_TYPE.equals(binarySecret.getBinarySecretType())
                || binarySecret.getBinarySecretType() == null) {
                byte[] secretValue = binarySecret.getBinarySecretValue();
                if (((long)secretValue.length * 8L) < signatureProperties.getMinimumKeySize()
                    || ((long)secretValue.length * 8L) > signatureProperties.getMaximumKeySize()) {
                    LOG.log(
                        Level.WARNING, "Received secret of length " + secretValue.length
                        + " bits is not accepted"
                    );
                    LOG.log(Level.WARNING, "User Entropy rejected");
                    clientEntropy = null;
                }
            } else {
                LOG.log(
                    Level.WARNING, "The type " + binarySecret.getBinarySecretType() + " is not supported"
                );
                throw new STSException(
                    "No user supplied entropy for SymmetricKey case", STSException.INVALID_REQUEST
                );
            }
View Full Code Here

    public void createSymmetricKey() {
        computedKey = false;
        boolean generateEntropy = true;
       
        if (clientEntropy != null) {
            BinarySecret binarySecret = clientEntropy.getBinarySecret();
            if (binarySecret != null
                && (STSConstants.SYMMETRIC_KEY_TYPE.equals(binarySecret.getBinarySecretType())
                    || binarySecret.getBinarySecretType() == null)) {
                secret = binarySecret.getBinarySecretValue();
                generateEntropy = false;
            } else if (clientEntropy.getDecryptedKey() != null) {
                secret = clientEntropy.getDecryptedKey();
                generateEntropy = false;
            }
View Full Code Here

        TokenProviderParameters providerParameters =
            createProviderParameters(WSConstants.WSS_SAML_TOKEN_TYPE, STSConstants.SYMMETRIC_KEY_KEYTYPE);
        assertTrue(samlTokenProvider.canHandleToken(WSConstants.WSS_SAML_TOKEN_TYPE));
       
        Entropy entropy = new Entropy();
        BinarySecret binarySecret = new BinarySecret();
        binarySecret.setBinarySecretValue(WSSecurityUtil.generateNonce(256 / 8));
        entropy.setBinarySecret(binarySecret);
        providerParameters.getKeyRequirements().setEntropy(entropy);
       
        binarySecret.setBinarySecretType("bad-type");
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on a bad type");
        } catch (STSException ex) {
            // expected as no type is provided
        }
       
        binarySecret.setBinarySecretType(STSConstants.NONCE_TYPE);
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on no computed key algorithm");
        } catch (STSException ex) {
            // expected as no computed key algorithm is provided
View Full Code Here

        TokenProviderParameters providerParameters =
            createProviderParameters(WSConstants.WSS_SAML_TOKEN_TYPE, STSConstants.SYMMETRIC_KEY_KEYTYPE);
        assertTrue(samlTokenProvider.canHandleToken(WSConstants.WSS_SAML_TOKEN_TYPE));
       
        Entropy entropy = new Entropy();
        BinarySecret binarySecret = new BinarySecret();
        binarySecret.setBinarySecretValue(WSSecurityUtil.generateNonce(256 / 8));
        entropy.setBinarySecret(binarySecret);
        providerParameters.getKeyRequirements().setEntropy(entropy);
       
        TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
        assertTrue(providerResponse != null);
View Full Code Here

        TokenProviderParameters providerParameters =
            createProviderParameters(WSConstants.WSS_SAML2_TOKEN_TYPE, STSConstants.SYMMETRIC_KEY_KEYTYPE);
        assertTrue(samlTokenProvider.canHandleToken(WSConstants.WSS_SAML2_TOKEN_TYPE));
       
        Entropy entropy = new Entropy();
        BinarySecret binarySecret = new BinarySecret();
        binarySecret.setBinarySecretValue(WSSecurityUtil.generateNonce(256 / 8));
        entropy.setBinarySecret(binarySecret);
        providerParameters.getKeyRequirements().setEntropy(entropy);
       
        binarySecret.setBinarySecretType("bad-type");
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on a bad type");
        } catch (STSException ex) {
            // expected as no type is provided
        }
       
        binarySecret.setBinarySecretType(STSConstants.NONCE_TYPE);
        try {
            samlTokenProvider.createToken(providerParameters);
            fail("Failure expected on no computed key algorithm");
        } catch (STSException ex) {
            // expected as no computed key algorithm is provided
View Full Code Here

        // Test Entropy
        clientEntropy = keyRequirements.getEntropy();
        if (clientEntropy == null) {
            LOG.log(Level.WARNING, "A SymmetricKey KeyType is requested, but no client entropy is provided");
        } else if (clientEntropy.getBinarySecret() != null) {
            BinarySecret binarySecret = clientEntropy.getBinarySecret();
            if (STSConstants.NONCE_TYPE.equals(binarySecret.getBinarySecretType())) {
                byte[] nonce = binarySecret.getBinarySecretValue();
                if (nonce == null || (nonce.length < (keySize / 8))) {
                    LOG.log(Level.WARNING, "User Entropy rejected");
                    clientEntropy = null;
                }
                String computedKeyAlgorithm = keyRequirements.getComputedKeyAlgorithm();
                if (!STSConstants.COMPUTED_KEY_PSHA1.equals(computedKeyAlgorithm)) {
                    LOG.log(
                        Level.WARNING,
                        "The computed key algorithm of " + computedKeyAlgorithm + " is not supported"
                    );
                    throw new STSException(
                        "Computed Key Algorithm not supported", STSException.INVALID_REQUEST
                    );
                }
            } else if (STSConstants.SYMMETRIC_KEY_TYPE.equals(binarySecret.getBinarySecretType())
                || binarySecret.getBinarySecretType() == null) {
                byte[] secretValue = binarySecret.getBinarySecretValue();
                if (((long)secretValue.length * 8L) < signatureProperties.getMinimumKeySize()
                    || ((long)secretValue.length * 8L) > signatureProperties.getMaximumKeySize()) {
                    LOG.log(
                        Level.WARNING, "Received secret of length " + secretValue.length
                        + " bits is not accepted"
                    );
                    LOG.log(Level.WARNING, "User Entropy rejected");
                    clientEntropy = null;
                }
            } else {
                LOG.log(
                    Level.WARNING, "The type " + binarySecret.getBinarySecretType() + " is not supported"
                );
                throw new STSException(
                    "No user supplied entropy for SymmetricKey case", STSException.INVALID_REQUEST
                );
            }
View Full Code Here

    public void createSymmetricKey() {
        computedKey = false;
        boolean generateEntropy = true;
       
        if (clientEntropy != null) {
            BinarySecret binarySecret = clientEntropy.getBinarySecret();
            if (binarySecret != null
                && (STSConstants.SYMMETRIC_KEY_TYPE.equals(binarySecret.getBinarySecretType())
                    || binarySecret.getBinarySecretType() == null)) {
                secret = binarySecret.getBinarySecretValue();
                generateEntropy = false;
            } else if (clientEntropy.getDecryptedKey() != null) {
                secret = clientEntropy.getDecryptedKey();
                generateEntropy = false;
            }
View Full Code Here

TOP

Related Classes of org.apache.cxf.sts.request.BinarySecret

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.