Package org.apache.cxf.rs.security.oauth2.utils.crypto

Examples of org.apache.cxf.rs.security.oauth2.utils.crypto.KeyProperties


    }

    @Override
    public ServerAccessToken createAccessToken(AccessTokenRegistration accessToken)
        throws OAuthServiceException {
        return new BearerAccessToken(accessToken.getClient(), 3600);
    }
View Full Code Here


        return new Client("alice", "alice", true);
    }

    public ServerAccessToken createAccessToken(AccessTokenRegistration accessToken)
        throws OAuthServiceException {
        return new BearerAccessToken(accessToken.getClient(), 3600);
    }
View Full Code Here

            sb.append(token.getTokenKey());
        } else if (OAuthConstants.MAC_TOKEN_TYPE.equals(token.getTokenType())) {
            if (httpProps == null) {
                throw new IllegalArgumentException("MAC scheme requires HTTP Request properties");
            }
            MacAuthorizationScheme macAuthData = new MacAuthorizationScheme(httpProps, token);
            String macAlgo = token.getParameters().get(OAuthConstants.MAC_TOKEN_ALGORITHM);
            String macKey = token.getParameters().get(OAuthConstants.MAC_TOKEN_KEY);
            sb.append(macAuthData.toAuthorizationHeader(macAlgo, macKey));
        } else {
            throw new ClientException(new OAuthServiceException("Unsupported token type"));
        }
       
    }
View Full Code Here

            sb.append(token.getTokenKey());
        } else if (OAuthConstants.MAC_TOKEN_TYPE.equals(token.getTokenType())) {
            if (httpProps == null) {
                throw new IllegalArgumentException("MAC scheme requires HTTP Request properties");
            }
            MacAuthorizationScheme macAuthData = new MacAuthorizationScheme(httpProps, token);
            String macAlgo = token.getParameters().get(OAuthConstants.MAC_TOKEN_ALGORITHM);
            String macKey = token.getParameters().get(OAuthConstants.MAC_TOKEN_KEY);
            sb.append(macAuthData.toAuthorizationHeader(macAlgo, macKey));
        } else {
            throw new ClientException(new OAuthServiceException("Unsupported token type"));
        }
       
    }
View Full Code Here

   
    private boolean compareTcshWithTch(String tempClientSecretHash, String tempClientSecret) {
        if (tempClientSecret == null) {
            return false;
        }
        MessageDigestGenerator mdg = new MessageDigestGenerator();
        byte[] digest = mdg.createDigest(tempClientSecret, "SHA-256");
        int length = digest.length > 128 / 8 ? 128 / 8 : digest.length;
       
        String expectedHash = Base64UrlUtility.encodeChunk(digest, 0, length);
        return tempClientSecretHash.equals(expectedHash);
       
View Full Code Here

    protected SecretKey key;
    private Set<String> tokens = Collections.synchronizedSet(new HashSet<String>());
    private ConcurrentHashMap<String, String> refreshTokens = new ConcurrentHashMap<String, String>();
    private ConcurrentHashMap<String, String> clientsMap = new ConcurrentHashMap<String, String>();
    public DefaultEncryptingOAuthDataProvider(String algo, int keySize) {
        this(new KeyProperties(algo, keySize));
    }
View Full Code Here

            throw new SecurityException();
        }
        return theCek;
    }
    protected byte[] getEncryptedContentEncryptionKey(byte[] theCek) {
        KeyProperties secretKeyProperties = new KeyProperties(getContentEncryptionKeyEncryptionAlgo());
        if (!wrap) {
            return CryptoUtils.encryptBytes(theCek, cekEncryptionKey, secretKeyProperties);
        } else {
            return CryptoUtils.wrapSecretKey(theCek, getContentEncryptionAlgoJava(), cekEncryptionKey,
                                             secretKeyProperties.getKeyAlgo());
        }
    }
View Full Code Here

    }
   
    protected JweDecryptionOutput doDecrypt(JweCompactConsumer consumer) {
        consumer.enforceJweCryptoProperties(props);
        byte[] cek = getContentEncryptionKey(consumer);
        KeyProperties keyProperties = new KeyProperties(getContentEncryptionAlgorithm(consumer));
        keyProperties.setAdditionalData(getContentEncryptionCipherAAD(consumer));
        AlgorithmParameterSpec spec = getContentEncryptionCipherSpec(consumer);
        keyProperties.setAlgoSpec(spec);
        boolean compressionSupported =
            JwtConstants.DEFLATE_ZIP_ALGORITHM.equals(consumer.getJweHeaders().getZipAlgorithm());
        keyProperties.setCompressionSupported(compressionSupported);
        Key secretKey = CryptoUtils.createSecretKeySpec(cek, keyProperties.getKeyAlgo());
        byte[] bytes =
            CryptoUtils.decryptBytes(getEncryptedContentWithAuthTag(consumer), secretKey, keyProperties);
        return new JweDecryptionOutput(consumer.getJweHeaders(), bytes);
    }
View Full Code Here

        super(props, reader);
        this.cekDecryptionKey = cekDecryptionKey;
        this.unwrap = unwrap;
    }
    protected byte[] getContentEncryptionKey(JweCompactConsumer consumer) {
        KeyProperties keyProps = new KeyProperties(getKeyEncryptionAlgorithm(consumer));
        if (!unwrap) {
            keyProps.setBlockSize(getKeyCipherBlockSize());
            return CryptoUtils.decryptBytes(getEncryptedContentEncryptionKey(consumer),
                                            getCekDecryptionKey(), keyProps);
        } else {
            return CryptoUtils.unwrapSecretKey(getEncryptedContentEncryptionKey(consumer),
                                               getContentEncryptionAlgorithm(consumer),
View Full Code Here

            theHeaders.setContentType(contentType);
        }
       
        byte[] theCek = getContentEncryptionKey();
        String contentEncryptionAlgoJavaName = Algorithm.toJavaName(theHeaders.getContentEncryptionAlgorithm());
        KeyProperties keyProps = new KeyProperties(contentEncryptionAlgoJavaName);
        keyProps.setCompressionSupported(compressionRequired(theHeaders));
        byte[] additionalEncryptionParam = theHeaders.toCipherAdditionalAuthData(writer);
        keyProps.setAdditionalData(additionalEncryptionParam);
       
        byte[] theIv = getContentEncryptionCipherInitVector();
        AlgorithmParameterSpec specParams = getContentEncryptionCipherSpec(theIv);
        keyProps.setAlgoSpec(specParams);
        byte[] jweContentEncryptionKey = getEncryptedContentEncryptionKey(theCek);
        JweEncryptionInternal state = new JweEncryptionInternal();
        state.theHeaders = theHeaders;
        state.jweContentEncryptionKey = jweContentEncryptionKey;
        state.keyProps = keyProps;
View Full Code Here

TOP

Related Classes of org.apache.cxf.rs.security.oauth2.utils.crypto.KeyProperties

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.