Search in sources :

Example 1 with UserMappingAttributeParam

use of com.emc.storageos.model.tenant.UserMappingAttributeParam in project coprhd-controller by CoprHD.

the class ApiTest method createTenant.

private TenantOrgRestRep createTenant(String label, String domain, String attrKey, String attrValue) throws Exception {
    BalancedWebResource rootUser = createHttpsClient(SYSADMIN, SYSADMIN_PASS_WORD, baseUrls);
    UserInfo info = rootUser.path("/user/whoami").get(UserInfo.class);
    String rootTenantId = info.getTenant();
    String rootToken = (String) _savedTokens.get(SYSADMIN);
    TenantCreateParam tenantParam = new TenantCreateParam();
    tenantParam.setLabel(label);
    tenantParam.setDescription("description for " + label);
    tenantParam.setUserMappings(new ArrayList<UserMappingParam>());
    UserMappingParam tenant2UserMapping = new UserMappingParam();
    tenant2UserMapping.setDomain(domain);
    UserMappingAttributeParam tenant2Attr = new UserMappingAttributeParam();
    tenant2Attr.setKey(attrKey);
    tenant2Attr.setValues(Collections.singletonList(attrValue));
    tenant2UserMapping.setAttributes(Collections.singletonList(tenant2Attr));
    tenantParam.getUserMappings().add(tenant2UserMapping);
    String subtenant_url = "/tenants/" + rootTenantId + "/subtenants";
    TenantOrgRestRep tenantOrg = rootUser.path(subtenant_url).header(AUTH_TOKEN_HEADER, rootToken).post(TenantOrgRestRep.class, tenantParam);
    return tenantOrg;
}
Also used : UserMappingAttributeParam(com.emc.storageos.model.tenant.UserMappingAttributeParam) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam) UserInfo(com.emc.storageos.model.user.UserInfo) TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep) TenantCreateParam(com.emc.storageos.model.tenant.TenantCreateParam)

Example 2 with UserMappingAttributeParam

use of com.emc.storageos.model.tenant.UserMappingAttributeParam in project coprhd-controller by CoprHD.

the class ApiTestBase method updateRootTenantAttrs.

/**
 * Update tenant attributes for the root tenant
 */
protected void updateRootTenantAttrs() {
    TenantResponse tenantResp = rSys.path("/tenant").get(TenantResponse.class);
    rootTenantId = tenantResp.getTenant();
    /*
         * PUT the ou=sanity attribute mapping into the root tenant attributes
         */
    TenantUpdateParam tenantUpdate = new TenantUpdateParam();
    tenantUpdate.setUserMappingChanges(new UserMappingChanges());
    tenantUpdate.getUserMappingChanges().setAdd(new ArrayList<UserMappingParam>());
    UserMappingParam rootMapping = new UserMappingParam();
    rootMapping.setDomain("SANITY.local");
    UserMappingAttributeParam rootAttr = new UserMappingAttributeParam();
    rootAttr.setKey("ou");
    rootAttr.setValues(Collections.singletonList(ROOTTENANT_ATTR));
    rootMapping.setAttributes(Collections.singletonList(rootAttr));
    tenantUpdate.getUserMappingChanges().getAdd().add(rootMapping);
    // TODO: FIX: not sure why name is required for update
    tenantUpdate.setLabel(ROOTTENANT_NAME);
    ClientResponse resp = rSys.path("/tenants/" + rootTenantId.toString()).put(ClientResponse.class, tenantUpdate);
    Assert.assertEquals(200, resp.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) UserMappingAttributeParam(com.emc.storageos.model.tenant.UserMappingAttributeParam) UserMappingChanges(com.emc.storageos.model.tenant.UserMappingChanges) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam) TenantResponse(com.emc.storageos.model.tenant.TenantResponse) TenantUpdateParam(com.emc.storageos.model.tenant.TenantUpdateParam)

Example 3 with UserMappingAttributeParam

use of com.emc.storageos.model.tenant.UserMappingAttributeParam in project coprhd-controller by CoprHD.

the class ApiTest method authnProviderAddDomainTest.

// quick test to see if the added domain of AP server is converted to all lowercase
public void authnProviderAddDomainTest() throws Exception {
    AuthnCreateParam param = new AuthnCreateParam();
    param.setLabel("domain test AP server");
    param.setDescription("AP server configuration created by ApiTest.java");
    param.setDisable(false);
    param.getDomains().add("asd.locl");
    param.setManagerDn("CN=Manager,DC=root,DC=com");
    param.setManagerPassword("secret");
    param.setSearchBase("OU=People,DC=root,DC=com");
    param.setSearchFilter("mail=%u");
    param.setServerUrls(new HashSet<String>());
    param.getServerUrls().add("ldaps:\\" + LDAP_SERVER1_IP);
    param.setMode("ldap");
    AuthnProviderRestRep resp = rSys.path("/vdc/admin/authnproviders").post(AuthnProviderRestRep.class, param);
    Assert.assertNotNull(resp);
    // update the AP server by adding a domain name with mixed case
    AuthnUpdateParam updateParam = new AuthnUpdateParam();
    Set<String> toAddSet = new HashSet<String>();
    toAddSet.add("sAnItY2.local");
    updateParam.getDomainChanges().setAdd(toAddSet);
    ClientResponse response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).put(ClientResponse.class, updateParam);
    Assert.assertEquals(200, response.getStatus());
    // verify the added domain name is converted to lower case
    response = rSys.path("/vdc/admin/authnproviders/" + resp.getId()).get(ClientResponse.class);
    AuthnProviderRestRep responseRestRep = response.getEntity(AuthnProviderRestRep.class);
    Assert.assertFalse(responseRestRep.getDomains().contains("sAnItY2.local"));
    Assert.assertTrue(responseRestRep.getDomains().contains("sanity2.local"));
    // use the added domain to create a subtenant, verify it's successful
    TenantCreateParam tenantParam = new TenantCreateParam();
    tenantParam.setLabel("sub2");
    tenantParam.setDescription("My sub tenant 2");
    UserMappingParam tenantMapping1 = new UserMappingParam();
    tenantMapping1.setDomain("sAnItY2.local");
    UserMappingAttributeParam attriParam = new UserMappingAttributeParam("department", Collections.singletonList("ASD"));
    tenantMapping1.getAttributes().add(attriParam);
    tenantParam.getUserMappings().add(tenantMapping1);
    response = rSys.path("/tenants/" + rootTenantId + "/subtenants").post(ClientResponse.class, tenantParam);
    Assert.assertEquals(200, response.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AuthnUpdateParam(com.emc.storageos.model.auth.AuthnUpdateParam) UserMappingAttributeParam(com.emc.storageos.model.tenant.UserMappingAttributeParam) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam) AuthnCreateParam(com.emc.storageos.model.auth.AuthnCreateParam) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep) HashSet(java.util.HashSet) TenantCreateParam(com.emc.storageos.model.tenant.TenantCreateParam)

Example 4 with UserMappingAttributeParam

use of com.emc.storageos.model.tenant.UserMappingAttributeParam in project coprhd-controller by CoprHD.

the class UserMappingForm method createUserMappingParam.

public UserMappingParam createUserMappingParam() {
    UserMappingParam userMappingParam = new UserMappingParam();
    userMappingParam.setDomain(domain);
    for (String group : groups.split(LINE_BREAK)) {
        if (!StringUtils.isBlank(group)) {
            userMappingParam.getGroups().add(group.trim());
        }
    }
    List<UserMappingAttributeParam> attributeParams = Lists.newArrayList();
    if (!attributes.isEmpty()) {
        for (AttributeMapping mapping : attributes) {
            if (mapping != null) {
                attributeParams.add(mapping.createAttributeParam());
            }
        }
    }
    userMappingParam.setAttributes(attributeParams);
    return userMappingParam;
}
Also used : UserMappingAttributeParam(com.emc.storageos.model.tenant.UserMappingAttributeParam) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam)

Example 5 with UserMappingAttributeParam

use of com.emc.storageos.model.tenant.UserMappingAttributeParam in project coprhd-controller by CoprHD.

the class KeystoneUtils method prepareUserMappings.

/**
 * Prepares userMappings with OpenStack Tenant ID for CoprHD Tenant.
 *
 * @param openstackId OpenStack Tenant ID.
 * @return UserMappings.
 */
public List<UserMappingParam> prepareUserMappings(String openstackId) {
    AuthnProvider provider = getKeystoneProvider();
    // Create mapping rules
    List<UserMappingParam> userMappings = new ArrayList<>();
    List<String> values = new ArrayList<>();
    values.add(openstackId);
    List<UserMappingAttributeParam> attributes = new ArrayList<>();
    attributes.add(new UserMappingAttributeParam(KeystoneUtils.OPENSTACK_TENANT_ID, values));
    userMappings.add(new UserMappingParam(provider.getDomains().iterator().next(), attributes, new ArrayList<String>()));
    return userMappings;
}
Also used : UserMappingAttributeParam(com.emc.storageos.model.tenant.UserMappingAttributeParam) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam)

Aggregations

UserMappingAttributeParam (com.emc.storageos.model.tenant.UserMappingAttributeParam)9 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)9 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)4 TenantOrgRestRep (com.emc.storageos.model.tenant.TenantOrgRestRep)3 TenantResponse (com.emc.storageos.model.tenant.TenantResponse)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)2 TenantUpdateParam (com.emc.storageos.model.tenant.TenantUpdateParam)2 UserMappingChanges (com.emc.storageos.model.tenant.UserMappingChanges)2 ArrayList (java.util.ArrayList)2 AuthnCreateParam (com.emc.storageos.model.auth.AuthnCreateParam)1 AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)1 RoleAssignmentChanges (com.emc.storageos.model.auth.RoleAssignmentChanges)1 RoleAssignmentEntry (com.emc.storageos.model.auth.RoleAssignmentEntry)1 RoleAssignments (com.emc.storageos.model.auth.RoleAssignments)1 ProjectParam (com.emc.storageos.model.project.ProjectParam)1 TenantOrgList (com.emc.storageos.model.tenant.TenantOrgList)1 UserInfo (com.emc.storageos.model.user.UserInfo)1 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)1 UserTenant (com.emc.storageos.security.resource.UserInfoPage.UserTenant)1