com.microsoft.aad.msal4j.UserIdentifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of msal4j Show documentation
Show all versions of msal4j Show documentation
Microsoft Authentication Library for Java gives you the ability to obtain tokens from Azure AD v2 (work and school
accounts, MSA) and Azure AD B2C, gaining access to Microsoft Cloud API and any other API secured by Microsoft
identities
// Generated by delombok at Fri Jul 26 21:46:44 UTC 2024
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.microsoft.aad.msal4j;
/**
* Used for populating the X-AnchorMailbox header, which is used in the cached credential service
* (CCS) routing
*/
public class UserIdentifier {
// Format is "userObjectId@userTenantId"
private static final String OID_HEADER_FORMAT = "%s@%s";
private String upn;
private String oid;
private UserIdentifier() {
}
public static UserIdentifier fromUpn(String upn) {
UserIdentifier userIdentifier = new UserIdentifier();
userIdentifier.upn = upn;
return userIdentifier;
}
public static UserIdentifier fromHomeAccountId(String homeAccountId) {
UserIdentifier userIdentifier = new UserIdentifier();
// HomeAccountId is userObjectId.userTenantId
String[] homeAccountIdParts = homeAccountId.split("\\.");
if (homeAccountIdParts.length < 2 || StringHelper.isBlank(homeAccountIdParts[0]) || StringHelper.isBlank(homeAccountIdParts[1])) {
userIdentifier.oid = null;
return userIdentifier;
}
userIdentifier.oid = String.format(OID_HEADER_FORMAT, homeAccountIdParts[0], homeAccountIdParts[1]);
return userIdentifier;
}
@java.lang.SuppressWarnings("all")
String upn() {
return this.upn;
}
@java.lang.SuppressWarnings("all")
String oid() {
return this.oid;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy