Package org.apache.cxf.rs.security.oauth2.tokens.mac

Examples of org.apache.cxf.rs.security.oauth2.tokens.mac.NonceHistory


            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


    public static String generateRandomTokenKey() throws OAuthServiceException {
        try {
            byte[] bytes = UUID.randomUUID().toString().getBytes("UTF-8");
            return new MD5SequenceGenerator().generate(bytes);
        } catch (Exception ex) {
            throw new OAuthServiceException(OAuthConstants.SERVER_ERROR, ex);
        }
    }
View Full Code Here

    }

    @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

    @Test
    public void testVerifyNonce() {
        long now = System.currentTimeMillis();
        Nonce nonce1 = new Nonce("nonce1", now - 2000); // first request 2 seconds back
        Nonce nonce2 = new Nonce("nonce2", now - 1000); // second request 1 second back
        NonceHistory nonceHistory = new NonceHistory(200, nonce1); // first request time delta is 200ms
        nonceHistory.addNonce(nonce2);

        EasyMock.expect(nonceStore.getNonceHistory("testTokenKey")).andReturn(nonceHistory);
        EasyMock.replay(nonceStore);
        nonceVerifier.setAllowedWindow(2000); // allowed window is 2 seconds
        nonceVerifier.verifyNonce("testTokenKey", "nonce3", Long.toString(now - 500));
View Full Code Here

    @Test
    public void testVerifyNonceDuplicateNonce() {
        long now = System.currentTimeMillis();
        Nonce nonce1 = new Nonce("nonce1", now - 2000); // first request 2 seconds back
        Nonce nonce2 = new Nonce("nonce2", now - 1000); // second request 1 second back
        NonceHistory nonceHistory = new NonceHistory(200, nonce1); // first request time delta is 200ms
        nonceHistory.addNonce(nonce2);

        EasyMock.expect(nonceStore.getNonceHistory("testTokenKey")).andReturn(nonceHistory);
        EasyMock.replay(nonceStore);
        nonceVerifier.setAllowedWindow(2000); // allowed window is 2 seconds
        try {
View Full Code Here

    @Test
    public void testVerifyNonceInvalidTimestamp() {
        long now = System.currentTimeMillis();
        Nonce nonce1 = new Nonce("nonce1", now - 2000); // first request 2 seconds back
        Nonce nonce2 = new Nonce("nonce2", now - 1000); // second request 1 second back
        NonceHistory nonceHistory = new NonceHistory(200, nonce1); // first request time delta is 200ms
        nonceHistory.addNonce(nonce2);

        EasyMock.expect(nonceStore.getNonceHistory("testTokenKey")).andReturn(nonceHistory);
        EasyMock.replay(nonceStore);
        nonceVerifier.setAllowedWindow(2000); // allowed window is 2 seconds
        try {
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

TOP

Related Classes of org.apache.cxf.rs.security.oauth2.tokens.mac.NonceHistory

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.