use of com.microsoft.identity.common.internal.providers.oauth2.IDToken in project microsoft-authentication-library-common-for-android by AzureAD.
the class SchemaUtil method getCredentialTypeFromVersion.
public static String getCredentialTypeFromVersion(@Nullable final String idTokenString) {
final String methodName = "getCredentialTypeFromVersion";
// Default is v2
String idTokenVersion = CredentialType.IdToken.name();
if (!TextUtils.isEmpty(idTokenString)) {
IDToken idToken;
try {
idToken = new IDToken(idTokenString);
final Map<String, ?> idTokenClaims = idToken.getTokenClaims();
final String aadVersion = (String) idTokenClaims.get(AuthenticationConstants.OAuth2.AAD_VERSION);
if (AuthenticationConstants.OAuth2.AAD_VERSION_V1.equalsIgnoreCase(aadVersion)) {
idTokenVersion = CredentialType.V1IdToken.name();
}
} catch (ServiceException e) {
Logger.warn(TAG + ":" + methodName, EXCEPTION_CONSTRUCTING_IDTOKEN + e.getMessage());
}
}
return idTokenVersion;
}
use of com.microsoft.identity.common.internal.providers.oauth2.IDToken in project microsoft-authentication-library-common-for-android by AzureAD.
the class SchemaUtil method getIdentityProvider.
public static String getIdentityProvider(final String idTokenString) {
final String methodName = "getIdentityProvider";
String idp = null;
if (null != idTokenString) {
IDToken idToken;
try {
idToken = new IDToken(idTokenString);
final Map<String, ?> idTokenClaims = idToken.getTokenClaims();
if (null != idTokenClaims) {
// IDP claim is present only in case of guest scenerio and is empty for home tenants.
// Few Apps consuming ADAL use this to differentiate between home vs guest accounts.
idp = (String) idTokenClaims.get(AzureActiveDirectoryIdToken.IDENTITY_PROVIDER);
Logger.verbosePII(TAG + ":" + methodName, "idp: " + idp);
if (null == idp) {
Logger.info(TAG + ":" + methodName, "idp claim was null.");
}
} else {
Logger.warn(TAG + ":" + methodName, "IDToken claims were null.");
}
} catch (ServiceException e) {
Logger.warn(TAG + ":" + methodName, EXCEPTION_CONSTRUCTING_IDTOKEN + e.getMessage());
}
} else {
Logger.warn(TAG + ":" + methodName, "IDToken was null.");
}
return idp;
}
Aggregations