All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.aad.msal4j.AuthorizationCodeRequest Maven / Gradle / Ivy

Go to download

Microsoft Authentication Library for Java gives you the ability to obtain tokens from Azure AD v2 (work and school accounts, MSA) and Azure AD B2C, gaining access to Microsoft Cloud API and any other API secured by Microsoft identities

There is a newer version: 1.18.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.aad.msal4j;

import com.nimbusds.oauth2.sdk.AuthorizationCode;
import com.nimbusds.oauth2.sdk.AuthorizationCodeGrant;
import com.nimbusds.oauth2.sdk.AuthorizationGrant;
import com.nimbusds.oauth2.sdk.pkce.CodeVerifier;

class AuthorizationCodeRequest extends MsalRequest {

    AuthorizationCodeRequest(AuthorizationCodeParameters parameters,
                             AbstractClientApplicationBase application,
                             RequestContext requestContext) {
        super(application, createMsalGrant(parameters), requestContext);
    }

    private static AbstractMsalAuthorizationGrant createMsalGrant(AuthorizationCodeParameters parameters) {

        AuthorizationGrant authorizationGrant;
        if (parameters.codeVerifier() != null) {
            authorizationGrant = new AuthorizationCodeGrant(
                    new AuthorizationCode(parameters.authorizationCode()),
                    parameters.redirectUri(),
                    new CodeVerifier(parameters.codeVerifier()));

        } else {
            authorizationGrant = new AuthorizationCodeGrant(
                    new AuthorizationCode(parameters.authorizationCode()), parameters.redirectUri());
        }

        return new OAuthAuthorizationGrant(authorizationGrant, parameters.scopes(), parameters.claims());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy