private void obtainUserRealm(){ this.userRealm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); }
private void obtainUserRealm(){ this.userRealm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); }
private void obtainUserRealm(){ this.userRealm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); }
/** * Shows application visibility to the user * @param appPath Path of the application * @param username Username of the user * @param opType Op type (ALLOW OR DENY) * @return whether it is success */ public boolean showAppVisibilityToUser(String appPath, String username, String opType){ String userRole = "Internal/private_" + username; try { if("ALLOW".equalsIgnoreCase(opType)) { org.wso2.carbon.user.api.UserRealm realm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); realm.getAuthorizationManager().authorizeRole(userRole, appPath, ActionConstants.GET); return true; }else if("DENY".equalsIgnoreCase(opType)){ org.wso2.carbon.user.api.UserRealm realm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); realm.getAuthorizationManager().denyRole(userRole, appPath, ActionConstants.GET); return true; } return false; } catch (org.wso2.carbon.user.api.UserStoreException e) { log.error("Error while updating visibility of mobile app at " + appPath, e); return false; } } }
private void assignApplicationRole(String applicationName, String username) throws IdentityApplicationManagementException { String roleName = getAppRoleName(applicationName); String[] newRoles = {roleName}; try { // assign new application role to the user. UserRealm realm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); if (realm != null) { String[] roleListOfUser = realm.getUserStoreManager().getRoleListOfUser(username); if (ArrayUtils.contains(roleListOfUser, roleName)) { if (log.isDebugEnabled()) { log.debug("The user: " + username + " is already having the role: " + roleName); } } else { realm.getUserStoreManager().updateRoleListOfUser(username, null, newRoles); if (log.isDebugEnabled()) { log.debug("Assigning application role : " + roleName + " to the user : " + username); } } } } catch (UserStoreException e) { throw new IdentityApplicationManagementException("Error while assigning application role: " + roleName + " to the user: " + username, e); } }
private boolean validateUserForOwnerUpdate(OAuthAppDO oAuthAppDO) throws IdentityOAuthAdminException { try { String userName = null; String usernameWithDomain = null; if (oAuthAppDO.getAppOwner() != null) { userName = oAuthAppDO.getAppOwner().getUserName(); if (StringUtils.isEmpty(userName) || CarbonConstants.REGISTRY_SYSTEM_USERNAME.equals(userName)) { return false; } String domainName = oAuthAppDO.getAppOwner().getUserStoreDomain(); usernameWithDomain = UserCoreUtil.addDomainToName(userName, domainName); } UserRealm realm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); if (realm == null || StringUtils.isEmpty(usernameWithDomain)) { return false; } boolean isUserExist = realm.getUserStoreManager().isExistingUser(usernameWithDomain); if (!isUserExist) { throw new IdentityOAuthAdminException("User validation failed for owner update in the application: " + oAuthAppDO.getApplicationName() + " as user is not existing."); } } catch (UserStoreException e) { throw handleError("User validation failed for owner update in the application: " + oAuthAppDO.getApplicationName(), e); } return true; }
if(axisService != null){ UserRealm userRealm = (UserRealm)PrivilegedCarbonContext.getThreadLocalCarbonContext() .getUserRealm(); String serviceGroupId = axisService.getAxisServiceGroup().getServiceGroupName(); String serviceName = axisService.getName();
if (axisService != null) { UserRealm userRealm = (UserRealm) PrivilegedCarbonContext.getThreadLocalCarbonContext() .getUserRealm(); String serviceGroupId = axisService.getAxisServiceGroup().getServiceGroupName(); String serviceName = axisService.getName();
if (axisService != null) { UserRealm userRealm = (UserRealm) PrivilegedCarbonContext.getThreadLocalCarbonContext() .getUserRealm(); String serviceGroupId = axisService.getAxisServiceGroup().getServiceGroupName(); String serviceName = axisService.getName();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PrivilegedCarbonContext .getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName());
UserRealm realm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm();
org.wso2.carbon.user.api.UserRealm realm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm();