Search in sources :

Example 1 with OpenIdProviderConfiguration

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();
}
Also used : OpenIdProviderConfigurationClient(com.microsoft.identity.common.internal.providers.oauth2.OpenIdProviderConfigurationClient)

Example 2 with OpenIdProviderConfiguration

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;
}
Also used : ClientException(com.microsoft.identity.common.exception.ClientException) Uri(android.net.Uri) OpenIdProviderConfiguration(com.microsoft.identity.common.internal.providers.oauth2.OpenIdProviderConfiguration) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

Uri (android.net.Uri)1 WorkerThread (androidx.annotation.WorkerThread)1 ClientException (com.microsoft.identity.common.exception.ClientException)1 OpenIdProviderConfiguration (com.microsoft.identity.common.internal.providers.oauth2.OpenIdProviderConfiguration)1 OpenIdProviderConfigurationClient (com.microsoft.identity.common.internal.providers.oauth2.OpenIdProviderConfigurationClient)1