use of com.microsoft.identity.common.internal.providers.oauth2.OpenIdProviderConfiguration in project microsoft-authentication-library-common-for-android by AzureAD.
the class AzureActiveDirectoryAudience method loadOpenIdProviderConfigurationMetadata.
private static OpenIdProviderConfiguration loadOpenIdProviderConfigurationMetadata(@NonNull final String requestAuthority) throws ServiceException {
final String methodName = ":loadOpenIdProviderConfigurationMetadata";
com.microsoft.identity.common.internal.logging.Logger.info(TAG + methodName, "Loading OpenId Provider Metadata...");
final OpenIdProviderConfigurationClient client = new OpenIdProviderConfigurationClient(requestAuthority);
return client.loadOpenIdProviderConfiguration();
}
use of com.microsoft.identity.common.internal.providers.oauth2.OpenIdProviderConfiguration in project microsoft-authentication-library-common-for-android by AzureAD.
the class AzureActiveDirectoryAudience method getTenantUuidForAlias.
/**
* Must be called on a worker thread.
*
* Method which queries the {@link OpenIdProviderConfiguration}
* to get tenant UUID for the authority with tenant alias.
*
* @return : tenant UUID
* @throws ServiceException
* @throws ClientException
*/
@WorkerThread
public String getTenantUuidForAlias(@NonNull final String authority) throws ServiceException, ClientException {
// if the tenant id is already a UUID, return
if (StringUtil.isUuid(mTenantId)) {
return mTenantId;
}
final OpenIdProviderConfiguration providerConfiguration = loadOpenIdProviderConfigurationMetadata(authority);
final String issuer = providerConfiguration.getIssuer();
final Uri issuerUri = Uri.parse(issuer);
final List<String> paths = issuerUri.getPathSegments();
if (paths.isEmpty()) {
final String errMsg = "OpenId Metadata did not contain a path to the tenant";
com.microsoft.identity.common.internal.logging.Logger.error(TAG, errMsg, null);
throw new ClientException(errMsg);
}
final String tenantUUID = paths.get(0);
if (!StringUtil.isUuid(tenantUUID)) {
final String errMsg = "OpenId Metadata did not contain UUID in the path ";
Logger.error(TAG, errMsg, null);
throw new ClientException(errMsg);
}
return tenantUUID;
}
Aggregations