/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param credential * The client credential used for token acquisition. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final ClientCredential credential, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, credential, (String) null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param credential * The client credential used for token acquisition. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final ClientCredential credential, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, credential, (String) null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param credential * The client credential used for token acquisition. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final ClientCredential credential, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, credential, (String) null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param credential * object representing Private Key to use for token acquisition. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. * @throws AuthenticationException * thrown if {@link AsymmetricKeyCredential} fails to sign the * JWT token. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final AsymmetricKeyCredential credential, final AuthenticationCallback callback) throws AuthenticationException { return acquireTokenByRefreshToken(refreshToken, credential, (String) null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. This method is suitable for the daemon OAuth2 * flow when a client secret is not possible. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param clientId * Name or ID of the client requesting the token. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. * @throws AuthenticationException * thrown if the access token is not refreshed successfully */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final String clientId, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, clientId, (String)null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param clientId * Name or ID of the client requesting the token. * @param credential * The client assertion used for token acquisition. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final String clientId, final ClientAssertion credential, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, clientId, credential, null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. This method is suitable for the daemon OAuth2 * flow when a client secret is not possible. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param clientId * Name or ID of the client requesting the token. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. * @throws AuthenticationException * thrown if the access token is not refreshed successfully */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final String clientId, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, clientId, (String)null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param clientId * Name or ID of the client requesting the token. * @param clientAssertion * The client assertion to use for client authentication. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final String clientId, final ClientAssertion clientAssertion, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, clientId, clientAssertion, null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param credential * object representing Private Key to use for token acquisition. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. * @throws AuthenticationException * thrown if {@link AsymmetricKeyCredential} fails to sign the * JWT token. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final AsymmetricKeyCredential credential, final AuthenticationCallback callback) throws AuthenticationException { return acquireTokenByRefreshToken(refreshToken, credential, (String) null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param clientId * Name or ID of the client requesting the token. * @param clientAssertion * The client assertion to use for client authentication. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final String clientId, final ClientAssertion clientAssertion, final AuthenticationCallback callback) { return acquireTokenByRefreshToken(refreshToken, clientId, clientAssertion, null, callback); }
/** * Acquires a security token from the authority using a Refresh Token * previously received. * * @param refreshToken * Refresh Token to use in the refresh flow. * @param credential * object representing Private Key to use for token acquisition. * @param callback * optional callback object for non-blocking execution. * @return A {@link Future} object representing the * {@link AuthenticationResult} of the call. It contains Access * Token, Refresh Token and the Access Token's expiration time. * @throws AuthenticationException * thrown if {@link AsymmetricKeyCredential} fails to sign the * JWT token. */ public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final AsymmetricKeyCredential credential, final AuthenticationCallback callback) throws AuthenticationException { return acquireTokenByRefreshToken(refreshToken, credential, (String) null, callback); }
@Override public Map<String, Object> refresh(Map<String, Object> config) { // TODO: Support national clouds! String cloud = "https://login.microsoftonline.com"; String tenantId = (String) config.get(TENANT_ID); String authority = cloud + "/" + tenantId; String clientId = (String) config.get(CLIENT_ID); String refreshToken = (String) config.get(REFRESH_TOKEN); try { AuthenticationContext context = new AuthenticationContext(authority, true, Executors.newSingleThreadExecutor()); Future<AuthenticationResult> resultFuture = context.acquireTokenByRefreshToken(refreshToken, clientId, null); AuthenticationResult result = resultFuture.get(); config.put(ACCESS_TOKEN, result.getAccessToken()); config.put(REFRESH_TOKEN, result.getRefreshToken()); return config; } catch (InterruptedException | MalformedURLException | ExecutionException ex) { throw new RuntimeException(ex); } } }
@Override public Map<String, Object> refresh(Map<String, Object> config) { // TODO: Support national clouds! String cloud = "https://login.microsoftonline.com"; String tenantId = (String) config.get(TENANT_ID); String authority = cloud + "/" + tenantId; String clientId = (String) config.get(CLIENT_ID); String refreshToken = (String) config.get(REFRESH_TOKEN); try { AuthenticationContext context = new AuthenticationContext(authority, true, Executors.newSingleThreadExecutor()); Future<AuthenticationResult> resultFuture = context.acquireTokenByRefreshToken(refreshToken, clientId, null); AuthenticationResult result = resultFuture.get(); config.put(ACCESS_TOKEN, result.getAccessToken()); config.put(REFRESH_TOKEN, result.getRefreshToken()); return config; } catch (InterruptedException | MalformedURLException | ExecutionException ex) { throw new RuntimeException(ex); } } }
throws AuthenticationException { return acquireTokenByRefreshToken( refreshToken, credential.getClientId(),
throws AuthenticationException { return acquireTokenByRefreshToken( refreshToken, credential.getClientId(),
throws AuthenticationException { return acquireTokenByRefreshToken( refreshToken, credential.getClientId(),