本文整理汇总了Java中org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser.getTenantDomain方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticatedUser.getTenantDomain方法的具体用法?Java AuthenticatedUser.getTenantDomain怎么用?Java AuthenticatedUser.getTenantDomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser
的用法示例。
在下文中一共展示了AuthenticatedUser.getTenantDomain方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processAuthenticationResponse
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入方法依赖的package包/类
@Override
protected void processAuthenticationResponse(HttpServletRequest request,
HttpServletResponse response,
AuthenticationContext context)
throws AuthenticationFailedException {
String tokenResponse = request.getParameter("tokenResponse");
if (tokenResponse != null && !tokenResponse.contains("errorCode")) {
String appID = FIDOUtil.getOrigin(request);
AuthenticatedUser user = getUsername(context);
U2FService u2FService = U2FService.getInstance();
FIDOUser fidoUser = new FIDOUser(user.getUserName(), user.getTenantDomain(),
user.getUserStoreDomain(), AuthenticateResponse.fromJson(tokenResponse));
fidoUser.setAppID(appID);
u2FService.finishAuthentication(fidoUser);
context.setSubject(user);
} else {
if (log.isDebugEnabled()) {
log.debug("FIDO authentication filed : " + tokenResponse);
}
throw new InvalidCredentialsException("FIDO device authentication failed ");
}
}
示例2: retrieveAllNunNullUserClaimValues
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入方法依赖的package包/类
private Map<String, String> retrieveAllNunNullUserClaimValues(AuthenticatedUser authenticatedUser,
ClaimManager claimManager, ApplicationConfig appConfig,
org.wso2.carbon.user.core.UserStoreManager userStore) throws FrameworkException {
String tenantDomain = authenticatedUser.getTenantDomain();
String tenantAwareUserName = authenticatedUser.getUserName();
Map<String, String> allLocalClaims = new HashMap<>();
try {
org.wso2.carbon.user.api.ClaimMapping[] claimMappings = claimManager
.getAllClaimMappings(ApplicationConstants.LOCAL_IDP_DEFAULT_CLAIM_DIALECT);
List<String> localClaimURIs = new ArrayList<>();
for (org.wso2.carbon.user.api.ClaimMapping mapping : claimMappings) {
String claimURI = mapping.getClaim().getClaimUri();
localClaimURIs.add(claimURI);
}
allLocalClaims = userStore.getUserClaimValues(tenantAwareUserName,
localClaimURIs.toArray(new String[localClaimURIs.size()]), null);
if (allLocalClaims != null) {
for (Map.Entry<String, String> entry : allLocalClaims.entrySet()) {
//set local2sp role mappings
if (FrameworkConstants.LOCAL_ROLE_CLAIM_URI.equals(entry.getKey())) {
RealmConfiguration realmConfiguration = userStore.getRealmConfiguration();
String claimSeparator = realmConfiguration
.getUserStoreProperty(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
if (StringUtils.isBlank(claimSeparator)) {
claimSeparator = IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR_DEFAULT;
}
String roleClaim = entry.getValue();
List<String> rolesList = new LinkedList<>(Arrays.asList(roleClaim.split(claimSeparator)));
roleClaim = getServiceProviderMappedUserRoles(appConfig, rolesList, claimSeparator);
entry.setValue(roleClaim);
}
}
} else {
return new HashMap<>();
}
} catch (UserStoreException e) {
if (e.getMessage().contains("UserNotFound")) {
if (log.isDebugEnabled()) {
log.debug("User " + tenantAwareUserName + " not found in user store");
}
} else {
throw new FrameworkException("Error occurred while getting all user claims for " +
authenticatedUser + " in " + tenantDomain, e);
}
}
return allLocalClaims;
}
示例3: initiateAuthenticationRequest
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入方法依赖的package包/类
@Override
protected void initiateAuthenticationRequest(HttpServletRequest request,
HttpServletResponse response,
AuthenticationContext context)
throws AuthenticationFailedException {
//FIDO BE service component
U2FService u2FService = U2FService.getInstance();
try {
//authentication page's URL.
String loginPage;
loginPage = context.getAuthenticatorProperties().get(IdentityApplicationConstants.Authenticator.FIDO
.FIDO_AUTH);
if (StringUtils.isBlank(loginPage)){
loginPage = ConfigurationFacade.getInstance().getAuthenticationEndpointURL().replace("login.do",
"fido-auth.jsp");
}
//username from basic authenticator.
AuthenticatedUser user = getUsername(context);
//origin as appID eg.: http://example.com:8080
String appID = FIDOUtil.getOrigin(request);
//calls BE service method to generate challenge.
FIDOUser fidoUser = new FIDOUser(user.getUserName(), user.getTenantDomain(), user.getUserStoreDomain(), appID);
AuthenticateRequestData data = u2FService.startAuthentication(fidoUser);
//redirect to FIDO login page
if (data != null) {
response.sendRedirect(response.encodeRedirectURL(loginPage + ("?"))
+ "&authenticators=" + getName() + ":" + "LOCAL" + "&type=fido&sessionDataKey=" +
request.getParameter("sessionDataKey") +
"&data=" + data.toJson());
} else {
String redirectURL = ConfigurationFacade.getInstance().getAuthenticationEndpointRetryURL();
redirectURL = response.encodeRedirectURL(redirectURL + ("?")) + "&failedUsername=" + URLEncoder.encode(user.getUserName(), IdentityCoreConstants.UTF_8) +
"&statusMsg=" + URLEncoder.encode(FIDOAuthenticatorConstants.AUTHENTICATION_ERROR_MESSAGE, IdentityCoreConstants.UTF_8) +
"&status=" + URLEncoder.encode(FIDOAuthenticatorConstants.AUTHENTICATION_STATUS, IdentityCoreConstants.UTF_8);
response.sendRedirect(redirectURL);
}
} catch (IOException e) {
throw new AuthenticationFailedException(
"Could not initiate FIDO authentication request", e);
}
}
示例4: getAllTimeAuthorizedClientIds
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入方法依赖的package包/类
/**
* This method is to list the application authorized by OAuth resource owners
*
* @param authzUser username of the resource owner
* @return set of distinct client IDs authorized by user until now
* @throws IdentityOAuth2Exception if failed to update the access token
*/
public Set<String> getAllTimeAuthorizedClientIds(AuthenticatedUser authzUser) throws IdentityOAuth2Exception {
String accessTokenStoreTable = OAuthConstants.ACCESS_TOKEN_STORE_TABLE;
PreparedStatement ps = null;
Connection connection = IdentityDatabaseUtil.getDBConnection();;
ResultSet rs = null;
Set<String> distinctConsumerKeys = new HashSet<>();
boolean isUsernameCaseSensitive = IdentityUtil.isUserStoreInUsernameCaseSensitive(authzUser.toString());
String tenantDomain = authzUser.getTenantDomain();
String tenantAwareUsernameWithNoUserDomain = authzUser.getUserName();
String userDomain = authzUser.getUserStoreDomain();
if ((userDomain != null)){
userDomain.toUpperCase();
}
try {
int tenantId = OAuth2Util.getTenantId(tenantDomain);
if (OAuth2Util.checkAccessTokenPartitioningEnabled() &&
OAuth2Util.checkUserNameAssertionEnabled()) {
accessTokenStoreTable = OAuth2Util.getAccessTokenStoreTableFromUserId(authzUser.toString());
}
String sqlQuery = SQLQueries.GET_DISTINCT_APPS_AUTHORIZED_BY_USER_ALL_TIME.replace(
IDN_OAUTH2_ACCESS_TOKEN, accessTokenStoreTable);
if (!isUsernameCaseSensitive) {
sqlQuery = sqlQuery.replace(AUTHZ_USER, LOWER_AUTHZ_USER);
}
ps = connection.prepareStatement(sqlQuery);
if (isUsernameCaseSensitive) {
ps.setString(1, tenantAwareUsernameWithNoUserDomain);
} else {
ps.setString(1, tenantAwareUsernameWithNoUserDomain.toLowerCase());
}
ps.setInt(2, tenantId);
ps.setString(3, userDomain);
rs = ps.executeQuery();
while (rs.next()) {
String consumerKey = persistenceProcessor.getPreprocessedClientId(rs.getString(1));
distinctConsumerKeys.add(consumerKey);
}
} catch (SQLException e) {
throw new IdentityOAuth2Exception(
"Error occurred while retrieving all distinct Client IDs authorized by " +
"User ID : " + authzUser + " until now", e);
} finally {
IdentityDatabaseUtil.closeAllConnections(connection, rs, ps);
}
return distinctConsumerKeys;
}