use of com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest in project hub-alert by blackducksoftware.
the class AzureAuthorizationCodeFlow method newTokenRequest.
@Override
public AuthorizationCodeTokenRequest newTokenRequest(String authorizationCode) {
AuthorizationCodeTokenRequest request = super.newTokenRequest(authorizationCode);
request.setGrantType(AzureOAuthConstants.DEFAULT_GRANT_TYPE);
request.setResponseClass(AzureTokenResponse.class);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_ASSERTION, authorizationCode);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION_TYPE, AzureOAuthConstants.DEFAULT_CLIENT_ASSERTION_TYPE);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION, clientSecret);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_REDIRECT_URI, redirectUri);
return request;
}
use of com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest in project blackduck-alert by blackducksoftware.
the class AzureAuthorizationCodeFlow method newTokenRequest.
@Override
public AuthorizationCodeTokenRequest newTokenRequest(String authorizationCode) {
AuthorizationCodeTokenRequest request = super.newTokenRequest(authorizationCode);
request.setGrantType(AzureOAuthConstants.DEFAULT_GRANT_TYPE);
request.setResponseClass(AzureTokenResponse.class);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_ASSERTION, authorizationCode);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION_TYPE, AzureOAuthConstants.DEFAULT_CLIENT_ASSERTION_TYPE);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION, clientSecret);
request.put(AzureOAuthConstants.REQUEST_BODY_FIELD_REDIRECT_URI, redirectUri);
return request;
}
use of com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest in project blackduck-alert by blackducksoftware.
the class AzureAuthorizationCodeFlowTest method builderTest.
@Test
public void builderTest() {
AzureAuthorizationCodeFlow.Builder builder = new AzureAuthorizationCodeFlow.Builder(method, httpTransport, jsonFactory, genericUrl, clientAuthentication, clientId, authorizationServerEncodedUrl, null, null);
assertNull(builder.getClientSecret());
assertNull(builder.getRedirectUri());
builder.setClientSecret(clientSecret);
builder.setRedirectUri(redirectUri);
assertEquals(clientSecret, builder.getClientSecret());
assertEquals(redirectUri, builder.getRedirectUri());
AuthorizationCodeFlow azureAuthorizationCodeFlow = builder.build();
AuthorizationCodeTokenRequest tokenRequest = azureAuthorizationCodeFlow.newTokenRequest(authorizationCode);
testAuthorizationCodeTokenRequest(tokenRequest);
}
use of com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest in project blackduck-alert by blackducksoftware.
the class AzureAuthorizationCodeFlowTest method newTokenRequestTest.
@Test
public void newTokenRequestTest() {
AzureAuthorizationCodeFlow azureAuthorizationCodeFlow = new AzureAuthorizationCodeFlow(method, httpTransport, jsonFactory, genericUrl, clientAuthentication, clientId, authorizationServerEncodedUrl, clientSecret, redirectUri);
AuthorizationCodeTokenRequest tokenRequest = azureAuthorizationCodeFlow.newTokenRequest(authorizationCode);
assertEquals(authorizationCode, tokenRequest.getCode());
assertEquals(AzureOAuthConstants.DEFAULT_GRANT_TYPE, tokenRequest.getGrantType());
assertEquals(redirectUri, tokenRequest.getRedirectUri());
assertEquals("", tokenRequest.getScopes());
assertEquals(authorizationCode, tokenRequest.get(AzureOAuthConstants.REQUEST_BODY_FIELD_ASSERTION));
assertEquals(AzureOAuthConstants.DEFAULT_CLIENT_ASSERTION_TYPE, tokenRequest.get(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION_TYPE));
assertEquals(clientSecret, tokenRequest.get(AzureOAuthConstants.REQUEST_BODY_FIELD_CLIENT_ASSERTION));
assertEquals(redirectUri, tokenRequest.get(AzureOAuthConstants.REQUEST_BODY_FIELD_REDIRECT_URI));
}
use of com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest in project hub-alert by blackducksoftware.
the class AzureBoardsProperties method requestTokens.
public Optional<Credential> requestTokens(AuthorizationCodeFlow authorizationCodeFlow, String authorizationCode) throws IOException {
AuthorizationCodeTokenRequest tokenRequest = authorizationCodeFlow.newTokenRequest(authorizationCode);
TokenResponse tokenResponse = tokenRequest.execute();
Credential credential = authorizationCodeFlow.createAndStoreCredential(tokenResponse, oauthUserId);
return Optional.ofNullable(credential);
}
Aggregations