org.wso2.carbon.user.core.tenant.Tenant Java Examples
The following examples show how to use
org.wso2.carbon.user.core.tenant.Tenant.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StratosUserManagerUtils.java From attic-stratos with Apache License 2.0 | 6 votes |
public static String getTenantDomain(int tenantId) { if(tenantId == -1234) { return "carbon.super"; } TenantManager tenantManager = getTenantManager(); Tenant[] tenants = null; try { tenants = (Tenant[]) tenantManager.getAllTenants(); } catch (Exception e) { String msg = "Error in retrieving the tenant information"; log.error(msg, e); } if(tenants != null) { for(Tenant tenant : tenants) { if(tenant.getId() == tenantId) { return tenant.getDomain(); } } } log.warn(String.format("Could not find tenant domain: [tenant-id] %d", tenantId)); return null; }
Example #2
Source File: StratosApiV41Utils.java From attic-stratos with Apache License 2.0 | 6 votes |
/** * Get List of Partial Tenant Domains * * @param domain domain Name * @return List of Partial Tenant Domains * @throws RestAPIException */ public static List<org.apache.stratos.common.beans.TenantInfoBean> searchPartialTenantsDomains(String domain) throws RestAPIException { TenantManager tenantManager = ServiceHolder.getTenantManager(); Tenant[] tenants; try { domain = domain.trim(); tenants = (Tenant[]) tenantManager.getAllTenantsForTenantDomainStr(domain); } catch (Exception e) { String msg = "Error in retrieving the tenant information."; log.error(msg, e); throw new RestAPIException(msg); } List<org.apache.stratos.common.beans.TenantInfoBean> tenantList = new ArrayList<org.apache.stratos.common.beans.TenantInfoBean>(); for (Tenant tenant : tenants) { org.apache.stratos.common.beans.TenantInfoBean bean = ObjectConverter .convertCarbonTenantInfoBeanToTenantInfoBean( TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant)); tenantList.add(bean); } return tenantList; }
Example #3
Source File: StratosApiV41Utils.java From attic-stratos with Apache License 2.0 | 6 votes |
/** * Get a list of available Tenants * * @return list of available Tenants * @throws RestAPIException */ public static List<org.apache.stratos.common.beans.TenantInfoBean> getAllTenants() throws RestAPIException { TenantManager tenantManager = ServiceHolder.getTenantManager(); Tenant[] tenants; try { tenants = (Tenant[]) tenantManager.getAllTenants(); } catch (Exception e) { String msg = "Error in retrieving the tenant information"; log.error(msg, e); throw new RestAPIException(msg); } List<org.apache.stratos.common.beans.TenantInfoBean> tenantList = new ArrayList<org.apache.stratos.common.beans.TenantInfoBean>(); for (Tenant tenant : tenants) { org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean = ObjectConverter .convertCarbonTenantInfoBeanToTenantInfoBean( TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant)); tenantList.add(tenantInfoBean); } return tenantList; }
Example #4
Source File: ServerTenantManagementService.java From identity-api-server with Apache License 2.0 | 6 votes |
private TenantsListResponse createTenantListResponse(TenantSearchResult tenantSearchResult) { List<Tenant> tenants = tenantSearchResult.getTenantList(); TenantsListResponse listResponse = new TenantsListResponse(); if (CollectionUtils.isNotEmpty(tenants)) { List<TenantListItem> tenantListItems = getTenantListItems(tenants); listResponse.setTenants(tenantListItems); listResponse.setCount(tenantListItems.size()); } else { listResponse.setCount(0); } listResponse.setTotalResults(tenantSearchResult.getTotalTenantCount()); listResponse.setStartIndex(tenantSearchResult.getOffSet() + 1); listResponse.setLinks(createLinks(V1_API_PATH_COMPONENT + TENANT_MANAGEMENT_PATH_COMPONENT, tenantSearchResult.getLimit(), tenantSearchResult.getOffSet(), tenantSearchResult.getTotalTenantCount(), tenantSearchResult.getFilter())); return listResponse; }
Example #5
Source File: StratosApiV40.java From attic-stratos with Apache License 2.0 | 6 votes |
private List<TenantInfoBean> searchPartialTenantsDomains(String domain) throws RestAPIException { TenantManager tenantManager = ServiceHolder.getTenantManager(); Tenant[] tenants; try { domain = domain.trim(); tenants = (Tenant[]) tenantManager.getAllTenantsForTenantDomainStr(domain); } catch (Exception e) { String msg = "Error in retrieving the tenant information."; log.error(msg, e); throw new RestAPIException(msg); } List<TenantInfoBean> tenantList = new ArrayList<TenantInfoBean>(); for (Tenant tenant : tenants) { TenantInfoBean bean = TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant); tenantList.add(bean); } return tenantList; }
Example #6
Source File: StratosApiV40.java From attic-stratos with Apache License 2.0 | 6 votes |
private List<TenantInfoBean> getAllTenants() throws RestAPIException { TenantManager tenantManager = ServiceHolder.getTenantManager(); Tenant[] tenants; try { tenants = (Tenant[]) tenantManager.getAllTenants(); } catch (Exception e) { String msg = "Error in retrieving the tenant information"; log.error(msg, e); throw new RestAPIException(msg); } List<TenantInfoBean> tenantList = new ArrayList<TenantInfoBean>(); for (Tenant tenant : tenants) { TenantInfoBean bean = TenantMgtUtil.getTenantInfoBeanfromTenant(tenant.getId(), tenant); tenantList.add(bean); } return tenantList; }
Example #7
Source File: UserStoreManagerService.java From carbon-identity with Apache License 2.0 | 6 votes |
public String[][] getProperties(Tenant tenant) throws UserStoreException { // TODO This method should only called by super tenant // Logic is not implemented yet if (!Util.isSuperTenant()) { StringBuilder stringBuilder = new StringBuilder(AUTH_FAIL); stringBuilder.append(CarbonContext.getThreadLocalCarbonContext().getTenantDomain()).append(" tenant id - ") .append(CarbonContext.getThreadLocalCarbonContext().getTenantId()).append(" user - ") .append(CarbonContext.getThreadLocalCarbonContext().getUsername()); log.warn(stringBuilder.toString()); throw new UserStoreException("Access Denied"); } // TODO implement the logic return new String[0][0]; }
Example #8
Source File: WSRealmTenantManager.java From carbon-identity with Apache License 2.0 | 6 votes |
@Override public Tenant[] getAllTenants() throws UserStoreException { try { org.wso2.carbon.um.ws.api.stub.Tenant[] tenats = stub.getAllTenants(); if (tenats != null) { Tenant[] ts = new Tenant[tenats.length]; for (int i = 0; i < tenats.length; i++) { ts[i] = this.ADBTenantToTenant(tenats[i]); } return ts; } } catch (Exception e) { handleException("", e); } return new Tenant[0]; }
Example #9
Source File: TenantManagerService.java From carbon-identity with Apache License 2.0 | 5 votes |
public Tenant[] getAllTenants() throws UserStoreException { try { return (Tenant[]) getTenantManager().getAllTenants(); } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
Example #10
Source File: TenantManagerService.java From carbon-identity with Apache License 2.0 | 5 votes |
public Tenant getTenant(int tenantId) throws UserStoreException { try { return (Tenant) getTenantManager().getTenant(tenantId); } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
Example #11
Source File: ServerTenantManagementService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * Add a tenant. * * @param tenantModel tenantModel. * @return TenantResponseModel. */ public String addTenant(TenantModel tenantModel) { String resourceId; TenantMgtService tenantMgtService = TenantManagementServiceHolder.getTenantMgtService(); try { Tenant tenant = createTenantInfoBean(tenantModel); resourceId = tenantMgtService.addTenant(tenant); } catch (TenantMgtException e) { throw handleTenantManagementException(e, TenantManagementConstants.ErrorMessage .ERROR_CODE_ERROR_ADDING_TENANT, null); } return resourceId; }
Example #12
Source File: TenantManagerService.java From carbon-identity with Apache License 2.0 | 5 votes |
public void updateTenant(Tenant tenant) throws UserStoreException { try { getTenantManager().updateTenant(tenant); } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
Example #13
Source File: WSRealmTenantManager.java From carbon-identity with Apache License 2.0 | 5 votes |
public int addTenant(Tenant tenant) throws UserStoreException { try { return getStub().addTenant(this.tenantToADBTenant(tenant)); } catch (Exception e) { handleException("", e); } return -1; }
Example #14
Source File: WSRealmTenantManager.java From carbon-identity with Apache License 2.0 | 5 votes |
@Override public Tenant getTenant(int tenantId) throws UserStoreException { try { return this.ADBTenantToTenant(getStub().getTenant(tenantId)); } catch (Exception e) { handleException("", e); } return null; }
Example #15
Source File: WSRealmTenantManager.java From carbon-identity with Apache License 2.0 | 5 votes |
public void updateTenant(Tenant tenant) throws UserStoreException { try { getStub().updateTenant(this.tenantToADBTenant(tenant)); } catch (Exception e) { handleException("", e); } }
Example #16
Source File: WSRealmTenantManager.java From carbon-identity with Apache License 2.0 | 5 votes |
private Tenant ADBTenantToTenant(org.wso2.carbon.um.ws.api.stub.Tenant stubTenant) { Tenant tenant = new Tenant(); tenant.setActive(stubTenant.getActive()); tenant.setAdminName(stubTenant.getAdminName()); tenant.setAdminPassword(stubTenant.getAdminPassword()); tenant.setDomain(stubTenant.getDomain()); tenant.setEmail(stubTenant.getEmail()); tenant.setId(stubTenant.getId()); return tenant; }
Example #17
Source File: WSRealmTenantManager.java From carbon-identity with Apache License 2.0 | 5 votes |
private org.wso2.carbon.um.ws.api.stub.Tenant tenantToADBTenant(Tenant tenant) { org.wso2.carbon.um.ws.api.stub.Tenant stubTenant = new org.wso2.carbon.um.ws.api.stub.Tenant(); stubTenant.setActive(tenant.isActive()); stubTenant.setAdminName(tenant.getAdminName()); stubTenant.setAdminPassword(tenant.getAdminPassword()); stubTenant.setDomain(tenant.getDomain()); stubTenant.setEmail(tenant.getEmail()); stubTenant.setId(tenant.getId()); return stubTenant; }
Example #18
Source File: LDAPTenantManagerService.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * This constructs PartitionInfo which is needed to create partition; from the tenant info * * @param tenant object * @return partition info created out of tenant info */ private PartitionInfo getPartitionInfo(Tenant tenant) throws EmbeddingLDAPException { String partitionID = String.valueOf(tenant.getId()); String realm = tenant.getDomain(); String rootDN = getTenantSuffix(tenant.getDomain()); AdminInfo tenantAdminInfo = getAdminInfo(tenant); return new PartitionInfo(partitionID, realm, rootDN, tenantAdminInfo); }
Example #19
Source File: ServerTenantManagementService.java From identity-api-server with Apache License 2.0 | 5 votes |
/** * Get a tenant identified by tenant unique id. * * @param tenantUniqueID tenant unique identifier. * @return TenantResponseModel. */ public TenantResponseModel getTenant(String tenantUniqueID) { try { Tenant tenant = TenantManagementServiceHolder.getTenantMgtService().getTenant(tenantUniqueID); return createTenantResponse(tenant); } catch (TenantMgtException e) { throw handleTenantManagementException(e, TenantManagementConstants.ErrorMessage. ERROR_CODE_ERROR_RETRIEVING_TENANT, tenantUniqueID); } }
Example #20
Source File: ServerTenantManagementService.java From identity-api-server with Apache License 2.0 | 5 votes |
private TenantResponseModel createTenantResponse(Tenant tenant) { TenantResponseModel tenantResponseModel = new TenantResponseModel(); tenantResponseModel.setCreatedDate(getISOFormatDate(tenant.getCreatedDate())); tenantResponseModel.setDomain(tenant.getDomain()); tenantResponseModel.setId(tenant.getTenantUniqueID()); tenantResponseModel.setLifecycleStatus(getLifeCycleStatus(tenant.isActive())); tenantResponseModel.setOwners(getOwnerResponses(tenant)); return tenantResponseModel; }
Example #21
Source File: ServerTenantManagementService.java From identity-api-server with Apache License 2.0 | 5 votes |
private Tenant createTenantInfoBean(TenantModel tenantModel) throws TenantManagementClientException { Tenant tenant = new Tenant(); tenant.setActive(true); tenant.setDomain(tenantModel.getDomain()); if (tenantModel.getOwners() != null) { tenant.setAdminName(tenantModel.getOwners().get(0).getUsername()); tenant.setAdminFirstName(tenantModel.getOwners().get(0).getFirstname()); tenant.setAdminLastName(tenantModel.getOwners().get(0).getLastname()); tenant.setEmail(tenantModel.getOwners().get(0).getEmail()); String provisioningMethod = tenantModel.getOwners().get(0).getProvisioningMethod(); if (INLINE_PASSWORD.equalsIgnoreCase(provisioningMethod)) { String password = tenantModel.getOwners().get(0).getPassword(); if (StringUtils.isBlank(password)) { throw new TenantManagementClientException(TenantConstants.ErrorMessage. ERROR_CODE_MISSING_REQUIRED_PARAMETER.getCode(), String.format(TenantConstants.ErrorMessage. ERROR_CODE_MISSING_REQUIRED_PARAMETER.getMessage(), "password")); } tenant.setAdminPassword(password); } tenant.setProvisioningMethod(provisioningMethod); List<AdditionalClaims> additionalClaimsList = tenantModel.getOwners().get(0).getAdditionalClaims(); if (CollectionUtils.isNotEmpty(additionalClaimsList)) { tenant.setClaimsMap(createClaimsMapping(additionalClaimsList)); } } else { throw new TenantManagementClientException(TenantConstants.ErrorMessage.ERROR_CODE_OWNER_REQUIRED); } return tenant; }
Example #22
Source File: ServerTenantManagementService.java From identity-api-server with Apache License 2.0 | 5 votes |
private List<TenantListItem> getTenantListItems(List<Tenant> tenants) { List<TenantListItem> tenantListItems = new ArrayList<>(); for (Tenant tenant : tenants) { TenantListItem listItem = new TenantListItem(); listItem.setLifecycleStatus(getLifeCycleStatus(tenant.isActive())); listItem.setCreatedDate(getISOFormatDate(tenant.getCreatedDate())); listItem.setDomain(tenant.getDomain()); listItem.setId(tenant.getTenantUniqueID()); listItem.setOwners(getOwnerResponses(tenant)); tenantListItems.add(listItem); } return tenantListItems; }
Example #23
Source File: ServerTenantManagementService.java From identity-api-server with Apache License 2.0 | 5 votes |
private List<OwnerResponse> getOwnerResponses(Tenant tenant) { List<OwnerResponse> ownerResponseList = new ArrayList<>(); OwnerResponse ownerResponse = new OwnerResponse(); ownerResponse.setUsername(tenant.getAdminName()); ownerResponse.setId(tenant.getAdminUserId()); ownerResponseList.add(ownerResponse); return ownerResponseList; }
Example #24
Source File: CarbonRemoteUserStoreManger.java From carbon-identity with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getProperties(org.wso2.carbon.user.api.Tenant tenant) throws org.wso2.carbon.user.api.UserStoreException { Map<String, String> properties = new HashMap<String, String>(); try { properties = remoteUserStore.getProperties(tenant); } catch (org.wso2.carbon.user.api.UserStoreException e) { if (!CONNECTION_REFUSED.equalsIgnoreCase(e.getMessage())) { throw e; } synchronized (this) { for (Iterator<Entry<String, WSUserStoreManager>> iterator = remoteServers .entrySet().iterator(); iterator.hasNext(); ) { Entry<String, WSUserStoreManager> remoteStore = iterator.next(); try { properties = remoteStore.getValue().getProperties(tenant); remoteUserStore = remoteStore.getValue(); break; } catch (UserStoreException ex) { if (!CONNECTION_REFUSED.equalsIgnoreCase(e.getMessage())) { if(log.isDebugEnabled()){ log.debug(REMOTE_ERROR_MSG,ex); } throw e; } log.error("Failed to connect to the remote server : " + remoteStore.getKey()); } } } } return properties; }
Example #25
Source File: CarbonRemoteUserStoreManger.java From carbon-identity with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getProperties(Tenant tenant) throws UserStoreException { Map<String, String> properties = new HashMap<String, String>(); try { properties = remoteUserStore.getProperties(tenant); } catch (UserStoreException e) { if (!CONNECTION_REFUSED.equalsIgnoreCase(e.getMessage())) { throw e; } synchronized (this) { for (Iterator<Entry<String, WSUserStoreManager>> iterator = remoteServers .entrySet().iterator(); iterator.hasNext(); ) { Entry<String, WSUserStoreManager> remoteStore = iterator.next(); try { properties = remoteStore.getValue().getProperties(tenant); remoteUserStore = remoteStore.getValue(); break; } catch (UserStoreException ex) { if (!CONNECTION_REFUSED.equalsIgnoreCase(e.getMessage())) { if(log.isDebugEnabled()){ log.debug(REMOTE_ERROR_MSG,ex); } throw e; } log.error("Failed to connect to the remote server : " + remoteStore.getKey()); } } } } return properties; }
Example #26
Source File: LDAPTenantManagerService.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * When initializing HybridLDAPTenantManager, the existing partitions for tenants are * initialized. This method adds existing partition to each tenant. * * @param tenant object * @throws UserStoreException */ @Override public void addPartitionToTenant(Tenant tenant) throws UserStoreException { try { ldapPartitionManager.initializeExistingPartition(getPartitionInfo(tenant)); } catch (Exception e) { throw new UserStoreException("Can not add the new partition ", e); } }
Example #27
Source File: LDAPTenantManagerService.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * This constructs AdminInfo which is needed to create partition; from the tenant info * * @param tenant object * @return Admin Info created out of tenant info */ private AdminInfo getAdminInfo(Tenant tenant) throws EmbeddingLDAPException { AdminInfo tenantAdminInfo = new AdminInfo(); /*Set the object class to be used in admin entry by reading it from configuration.*/ try { tenantAdminInfo.addObjectClass( ldapConfigurationBuilder.getLdapConfiguration().getAdminEntryObjectClass()); } catch (EmbeddingLDAPException e) { String errorMessage = "Error in obtaining LDAP Configuration."; logger.error(errorMessage, e); throw new EmbeddingLDAPException(errorMessage, e); } /*Following details of tenant admin is captured from the user through ui.*/ //set admin's user name if (tenant.getAdminName() != null) { tenantAdminInfo.setAdminUserName(tenant.getAdminName()); } if (tenant.getAdminFirstName() != null) { tenantAdminInfo.setAdminCommonName(tenant.getAdminFirstName()); } if (tenant.getAdminLastName() != null) { tenantAdminInfo.setAdminLastName(tenant.getAdminLastName()); } if (tenant.getEmail() != null) { tenantAdminInfo.setAdminEmail(tenant.getEmail()); } if (tenant.getAdminPassword() != null) { tenantAdminInfo.setAdminPassword(tenant.getAdminPassword()); } return tenantAdminInfo; }
Example #28
Source File: TenantManagerService.java From carbon-identity with Apache License 2.0 | 5 votes |
public int addTenant(Tenant tenant) throws UserStoreException { try { return getTenantManager().addTenant(tenant); } catch (org.wso2.carbon.user.api.UserStoreException e) { throw new UserStoreException(e); } }
Example #29
Source File: CassandraUserStoreManager.java From carbon-identity with Apache License 2.0 | 4 votes |
@Override public Map<String, String> getProperties(org.wso2.carbon.user.api.Tenant tenant) throws org.wso2.carbon.user.api.UserStoreException { return null; }
Example #30
Source File: WSRealmTenantManager.java From carbon-identity with Apache License 2.0 | 4 votes |
@Override public org.wso2.carbon.user.api.Tenant[] getAllTenantsForTenantDomainStr(String s) throws org.wso2.carbon.user.api.UserStoreException { return new org.wso2.carbon.user.api.Tenant[0]; }