com.github.scribejava.apis.MicrosoftAzureActiveDirectoryApi Maven / Gradle / Ivy
package com.github.scribejava.apis;
import com.github.scribejava.apis.microsoftazureactivedirectory.BaseMicrosoftAzureActiveDirectoryApi;
import com.github.scribejava.apis.microsoftazureactivedirectory.MicrosoftAzureActiveDirectoryBearerSignature;
import com.github.scribejava.core.oauth2.bearersignature.BearerSignature;
/**
* Microsoft Azure Active Directory Api
*
* @see
* Understand the OAuth 2.0 authorization code flow in Azure AD | Microsoft Docs
* @see
* Azure AD Java web app Getting Started | Microsoft Docs
* @see
* Azure AD Graph API Operations on the Signed-in User
* @see https://portal.azure.com
*/
public class MicrosoftAzureActiveDirectoryApi extends BaseMicrosoftAzureActiveDirectoryApi {
private final String resource;
protected MicrosoftAzureActiveDirectoryApi() {
this(COMMON_TENANT, null);
}
protected MicrosoftAzureActiveDirectoryApi(String tenant, String resource) {
super(tenant);
this.resource = resource;
}
private static class InstanceHolder {
private static final MicrosoftAzureActiveDirectoryApi INSTANCE = new MicrosoftAzureActiveDirectoryApi();
}
public static MicrosoftAzureActiveDirectoryApi instance() {
return InstanceHolder.INSTANCE;
}
public static MicrosoftAzureActiveDirectoryApi customTenant(String tenant) {
return new MicrosoftAzureActiveDirectoryApi(tenant, null);
}
public static MicrosoftAzureActiveDirectoryApi customResource(String resource) {
return new MicrosoftAzureActiveDirectoryApi(COMMON_TENANT, resource);
}
public static MicrosoftAzureActiveDirectoryApi custom(String tenant, String resource) {
return new MicrosoftAzureActiveDirectoryApi(tenant, resource);
}
@Override
protected String getAuthorizationBaseUrl() {
final String authorizationBaseUrl = super.getAuthorizationBaseUrl();
return resource == null || resource.isEmpty() ? authorizationBaseUrl
: authorizationBaseUrl + "?resource=" + resource;
}
@Override
public BearerSignature getBearerSignature() {
return MicrosoftAzureActiveDirectoryBearerSignature.instance();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy