stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anuruddhal <...@git.apache.org>
Subject [GitHub] stratos pull request: Moving non-API methods to StratosApiV41Utils...
Date Tue, 28 Jul 2015 10:22:58 GMT
Github user anuruddhal commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/287#discussion_r35633294
  
    --- Diff: components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
---
    @@ -2239,4 +2258,501 @@ public static ClusterBean getClusterInfo(String clusterId) throws
RestAPIExcepti
     
             return ObjectConverter.convertClusterToClusterBean(cluster, clusterId);
         }
    +
    +    //util methods for Tenants
    +
    +    /**
    +     * Add Tenant
    +     *
    +     * @param tenantInfoBean
    +     * @throws RestAPIException
    +     */
    +    public static void addTenant(org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean)
throws RestAPIException {
    +
    +        try {
    +            CommonUtil.validateEmail(tenantInfoBean.getEmail());
    +        } catch (Exception e) {
    +            String msg = "Invalid email is provided";
    +            log.error(msg, e);
    +            throw new RestAPIException(msg);
    +        }
    +
    +        String tenantDomain = tenantInfoBean.getTenantDomain();
    +        try {
    +            TenantMgtUtil.validateDomain(tenantDomain);
    +        } catch (Exception e) {
    +            String msg = "Tenant domain validation error for tenant " + tenantDomain;
    +            log.error(msg, e);
    +            throw new RestAPIException(msg);
    +        }
    +
    +        UserRegistry userRegistry = (UserRegistry) PrivilegedCarbonContext.getThreadLocalCarbonContext().
    +                getRegistry(RegistryType.USER_GOVERNANCE);
    +        if (userRegistry == null) {
    +            log.error("Security alert! User registry is null. A user is trying create
a tenant "
    +                    + " without an authenticated session.");
    +            throw new RestAPIException("Security alert! User registry is null. A user
is trying create a tenant "
    +                    + " without an authenticated session.");
    +        }
    +
    +        if (userRegistry.getTenantId() != MultitenantConstants.SUPER_TENANT_ID) {
    +            log.error("Security alert! None super tenant trying to create a tenant.");
    --- End diff --
    
    Fixed with 49f34bb


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message