Search in sources :

Example 1 with AzureActiveDirectorySlice

use of com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectorySlice in project microsoft-authentication-library-common-for-android by AzureAD.

the class AdalBrokerRequestAdapter method getRequestAuthorityWithExtraQP.

/**
 * TODO : Refactor to remove this code and move the logic to better place
 */
public static AzureActiveDirectoryAuthority getRequestAuthorityWithExtraQP(final String authority, final List<Pair<String, String>> extraQP) {
    final AzureActiveDirectoryAuthority requestAuthority = (AzureActiveDirectoryAuthority) Authority.getAuthorityFromAuthorityUrl(authority);
    if (extraQP != null) {
        AzureActiveDirectorySlice slice = new AzureActiveDirectorySlice();
        Iterator<Pair<String, String>> itr = extraQP.iterator();
        Pair<String, String> parameter;
        while (itr.hasNext() && (parameter = itr.next()) != null) {
            if (StringUtil.isEmpty(parameter.first)) {
                Logger.warn(TAG, "The extra query parameter.first is empty.");
            } else if (MicrosoftAuthorizationRequest.INSTANCE_AWARE.equalsIgnoreCase(parameter.first)) {
                Logger.info(TAG, "Set the extra query parameter mMultipleCloudAware" + " for MicrosoftStsAuthorizationRequest.");
                Logger.infoPII(TAG, "Set the mMultipleCloudAware to " + (parameter.second == null ? "null" : parameter.second));
                requestAuthority.mMultipleCloudsSupported = null != parameter.second && Boolean.TRUE.toString().equalsIgnoreCase(parameter.second);
                itr.remove();
            } else if (AzureActiveDirectorySlice.SLICE_PARAMETER.equalsIgnoreCase(parameter.first)) {
                slice.setSlice(parameter.second);
                itr.remove();
            } else if (AzureActiveDirectorySlice.DC_PARAMETER.equalsIgnoreCase(parameter.first)) {
                slice.setDataCenter(parameter.second);
                itr.remove();
            }
        }
        Logger.verbose(TAG, "Set the extra query parameter mSlice" + " for MicrosoftStsAuthorizationRequest.");
        Logger.verbosePII(TAG, "Set the mSlice to " + slice.toString());
        requestAuthority.mSlice = slice;
    }
    return requestAuthority;
}
Also used : AzureActiveDirectorySlice(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectorySlice) AzureActiveDirectoryAuthority(com.microsoft.identity.common.internal.authorities.AzureActiveDirectoryAuthority) Pair(android.util.Pair)

Example 2 with AzureActiveDirectorySlice

use of com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectorySlice in project microsoft-authentication-library-common-for-android by AzureAD.

the class OAuth2Strategy method setTokenEndpoint.

protected final void setTokenEndpoint(final String tokenEndpoint) {
    mTokenEndpoint = tokenEndpoint;
    if (mConfig != null && mConfig instanceof MicrosoftStsOAuth2Configuration) {
        final MicrosoftStsOAuth2Configuration oauth2Config = (MicrosoftStsOAuth2Configuration) mConfig;
        final AzureActiveDirectorySlice slice = oauth2Config.getSlice();
        if (slice != null) {
            final Uri.Builder uriBuilder = Uri.parse(mTokenEndpoint).buildUpon();
            if (!TextUtils.isEmpty(slice.getSlice())) {
                uriBuilder.appendQueryParameter(AzureActiveDirectorySlice.SLICE_PARAMETER, slice.getSlice());
            }
            if (!TextUtils.isEmpty(slice.getDC())) {
                uriBuilder.appendQueryParameter(AzureActiveDirectorySlice.DC_PARAMETER, slice.getDC());
            }
            mTokenEndpoint = uriBuilder.build().toString();
        }
    }
}
Also used : AzureActiveDirectorySlice(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectorySlice) MicrosoftStsOAuth2Configuration(com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Configuration) Uri(android.net.Uri)

Aggregations

AzureActiveDirectorySlice (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectorySlice)2 Uri (android.net.Uri)1 Pair (android.util.Pair)1 AzureActiveDirectoryAuthority (com.microsoft.identity.common.internal.authorities.AzureActiveDirectoryAuthority)1 MicrosoftStsOAuth2Configuration (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Configuration)1