com.microsoft.aad.msal4j.OnBehalfOfRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of msal4j Show documentation
Show all versions of msal4j Show documentation
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
The newest version!
// Generated by delombok at Sat Dec 21 00:20:57 UTC 2024
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.microsoft.aad.msal4j;
import com.nimbusds.jwt.SignedJWT;
import com.nimbusds.oauth2.sdk.AuthorizationGrant;
import com.nimbusds.oauth2.sdk.JWTBearerGrant;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.microsoft.aad.msal4j.AbstractMsalAuthorizationGrant.SCOPES_DELIMITER;
class OnBehalfOfRequest extends MsalRequest {
OnBehalfOfParameters parameters;
OnBehalfOfRequest(OnBehalfOfParameters parameters, ConfidentialClientApplication application, RequestContext requestContext) {
super(application, createAuthenticationGrant(parameters), requestContext);
this.parameters = parameters;
}
private static OAuthAuthorizationGrant createAuthenticationGrant(OnBehalfOfParameters parameters) {
AuthorizationGrant jWTBearerGrant;
try {
jWTBearerGrant = new JWTBearerGrant(SignedJWT.parse(parameters.userAssertion().getAssertion()));
} catch (Exception e) {
throw new MsalClientException(e);
}
Map> params = new HashMap<>();
params.put("requested_token_use", Collections.singletonList("on_behalf_of"));
if (parameters.claims() != null) {
params.put("claims", Collections.singletonList(parameters.claims().formatAsJSONString()));
}
return new OAuthAuthorizationGrant(jWTBearerGrant, String.join(SCOPES_DELIMITER, parameters.scopes()), params);
}
@java.lang.SuppressWarnings("all")
public OnBehalfOfParameters parameters() {
return this.parameters;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy