Search in sources :

Example 21 with PropertyDTO

use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project product-is by wso2.

the class SCIMUtils method createSecondaryUserStore.

/**
 * Create a secondary user store.
 *
 * @param userStoreType       User store type.
 * @param userStoreDomain     User store domain.
 * @param userStoreProperties Configuration properties for the user store.
 * @param backendURL          Backend URL of the Identity Server.
 * @param sessionCookie       Session Cookie.
 * @throws Exception Thrown if the user store creation fails.
 */
public static void createSecondaryUserStore(String userStoreType, String userStoreDomain, PropertyDTO[] userStoreProperties, String backendURL, String sessionCookie) throws Exception {
    UserStoreConfigAdminServiceClient userStoreConfigAdminServiceClient = new UserStoreConfigAdminServiceClient(backendURL, sessionCookie);
    UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(userStoreType, userStoreDomain, userStoreProperties);
    userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
    Thread.sleep(5000);
    Assert.assertTrue(userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, userStoreDomain), "Domain addition via DTO has failed.");
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) UserStoreConfigAdminServiceClient(org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient)

Example 22 with PropertyDTO

use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project product-is by wso2.

the class UserStoreConfigAdminTestCase method testAddDuplicateUserStore.

@Test(expectedExceptions = UserStoreConfigAdminServiceIdentityUserStoreMgtException.class, groups = "wso2.is", description = "Check add user store via DTO", dependsOnMethods = "testAddUserStore")
public void testAddDuplicateUserStore() throws Exception {
    Property[] properties = (new JDBCUserStoreManager()).getDefaultUserStoreProperties().getMandatoryProperties();
    PropertyDTO[] propertyDTOs = new PropertyDTO[properties.length];
    for (int i = 0; i < properties.length; i++) {
        PropertyDTO propertyDTO = new PropertyDTO();
        propertyDTO.setName(properties[i].getName());
        propertyDTO.setValue(properties[i].getValue());
        propertyDTOs[i] = propertyDTO;
    }
    UserStoreDTO userStoreDTO = userStoreConfigurationClient.createUserStoreDTO(jdbcClass, "lanka.com", propertyDTOs);
    userStoreConfigurationClient.addUserStore(userStoreDTO);
}
Also used : JDBCUserStoreManager(org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) Property(org.wso2.carbon.user.api.Property) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 23 with PropertyDTO

use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project identity-api-server by wso2.

the class ServerUserStoreService method getUserStoreByDomainId.

/**
 * Retrieve user store by its domain id.
 *
 * @param domainId the user store domain id.
 * @return UserStoreConfigurationsRes.
 */
public UserStoreConfigurationsRes getUserStoreByDomainId(String domainId) {
    UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
    List<AddUserStorePropertiesRes> propertiesTobeAdd = new ArrayList<>();
    try {
        UserStoreDTO userStoreDTO = userStoreConfigService.getUserStore(base64URLDecodeId(domainId));
        if (userStoreDTO == null) {
            throw handleException(Response.Status.NOT_FOUND, UserStoreConstants.ErrorMessage.ERROR_CODE_NOT_FOUND);
        }
        List<ClaimAttributeMapping> claimAttributeMappings = getClaimAttributeMappings(ContextLoader.getTenantDomainFromContext(), base64URLDecodeId(domainId));
        UserStoreConfigurationsRes userStoreConfigurations = new UserStoreConfigurationsRes();
        userStoreConfigurations.setClassName(userStoreDTO.getClassName());
        userStoreConfigurations.setDescription(userStoreDTO.getDescription());
        userStoreConfigurations.setName(userStoreDTO.getDomainId());
        userStoreConfigurations.setTypeId(base64URLEncodeId(Objects.requireNonNull(getUserStoreTypeName(userStoreDTO.getClassName()))));
        userStoreConfigurations.setTypeName(getUserStoreTypeName(userStoreDTO.getClassName()));
        PropertyDTO[] dtoProperties = userStoreDTO.getProperties();
        for (PropertyDTO propertyDTO : dtoProperties) {
            AddUserStorePropertiesRes userStorePropertiesRes = new AddUserStorePropertiesRes();
            userStorePropertiesRes.setName(propertyDTO.getName());
            userStorePropertiesRes.setValue(propertyDTO.getValue());
            propertiesTobeAdd.add(userStorePropertiesRes);
        }
        userStoreConfigurations.setProperties(propertiesTobeAdd);
        try {
            userStoreConfigurations.setIsLocal(UserStoreManagerRegistry.isLocalUserStore(userStoreDTO.getClassName()));
            userStoreConfigurations.setClaimAttributeMappings(claimAttributeMappings);
        } catch (UserStoreException e) {
            LOG.error(String.format("Cannot found user store manager type for user store manager: %s", getUserStoreType(userStoreDTO.getClassName())), e);
        }
        return userStoreConfigurations;
    } catch (IdentityUserStoreMgtException e) {
        UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_USER_STORE_BY_DOMAIN_ID;
        throw handleIdentityUserStoreMgtException(e, errorEnum);
    }
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) ClaimAttributeMapping(org.wso2.carbon.identity.api.server.userstore.v1.model.ClaimAttributeMapping) ArrayList(java.util.ArrayList) AddUserStorePropertiesRes(org.wso2.carbon.identity.api.server.userstore.v1.model.AddUserStorePropertiesRes) UserStoreConfigService(org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO) UserStoreException(org.wso2.carbon.user.api.UserStoreException) UserStoreConfigurationsRes(org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreConfigurationsRes) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)

Example 24 with PropertyDTO

use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project identity-api-server by wso2.

the class ServerUserStoreService method buildResponseForPatchReplace.

/**
 * Construct the response for patch replace.
 *
 * @param userStoreDTO {@link UserStoreDTO}.
 * @param propertyDTOS array of {@link PropertyDTO}.
 * @return UserStoreResponse.
 */
private UserStoreResponse buildResponseForPatchReplace(UserStoreDTO userStoreDTO, PropertyDTO[] propertyDTOS) {
    UserStoreResponse userStoreResponseDTO = new UserStoreResponse();
    userStoreResponseDTO.setId((base64URLEncodeId(userStoreDTO.getDomainId())));
    userStoreResponseDTO.setName(userStoreDTO.getDomainId());
    userStoreResponseDTO.setTypeId(base64URLEncodeId(Objects.requireNonNull(getUserStoreTypeName(userStoreDTO.getClassName()))));
    userStoreResponseDTO.setTypeName(getUserStoreTypeName(userStoreDTO.getClassName()));
    userStoreResponseDTO.setDescription(userStoreDTO.getDescription());
    userStoreResponseDTO.setProperties(patchUserStoreProperties(propertyDTOS));
    return userStoreResponseDTO;
}
Also used : UserStoreResponse(org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreResponse)

Example 25 with PropertyDTO

use of org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO in project identity-api-server by wso2.

the class ServerUserStoreService method addUserstoreProperties.

/**
 * Add requested user store properties to the response.
 *
 * @param userStoreDTO            userStoreDTO object.
 * @param userStoreListResponse   userStoreListResponse object.
 * @param requestedAttributesList Requested user store properties name list.
 */
private void addUserstoreProperties(UserStoreDTO userStoreDTO, UserStoreListResponse userStoreListResponse, List<String> requestedAttributesList) {
    for (PropertyDTO propertyDTO : userStoreDTO.getProperties()) {
        if (requestedAttributesList.contains(propertyDTO.getName()) && StringUtils.isNotBlank(propertyDTO.getValue())) {
            AddUserStorePropertiesRes addUserStorePropertiesRes = new AddUserStorePropertiesRes();
            addUserStorePropertiesRes.setName(propertyDTO.getName());
            addUserStorePropertiesRes.setValue(propertyDTO.getValue());
            userStoreListResponse.addPropertiesItem(addUserStorePropertiesRes);
        }
    }
}
Also used : AddUserStorePropertiesRes(org.wso2.carbon.identity.api.server.userstore.v1.model.AddUserStorePropertiesRes) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)

Aggregations

ArrayList (java.util.ArrayList)23 PropertyDTO (org.wso2.carbon.identity.user.endpoint.dto.PropertyDTO)18 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)10 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)10 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO)9 File (java.io.File)7 Test (org.testng.annotations.Test)7 H2DataBaseManager (org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager)6 ResendCodeRequestDTO (org.wso2.carbon.identity.user.endpoint.dto.ResendCodeRequestDTO)6 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)6 Property (org.wso2.carbon.user.api.Property)5 AddUserStorePropertiesRes (org.wso2.carbon.identity.api.server.userstore.v1.model.AddUserStorePropertiesRes)3 PropertyDTO (org.wso2.carbon.identity.recovery.endpoint.dto.PropertyDTO)3 ErrorDTO (org.wso2.carbon.identity.user.endpoint.dto.ErrorDTO)3 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO)3 JDBCUserStoreManager (org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager)3 PublisherDataHolder (org.wso2.carbon.identity.entitlement.stub.dto.PublisherDataHolder)2 PublisherPropertyDTO (org.wso2.carbon.identity.entitlement.stub.dto.PublisherPropertyDTO)2 IdentityRecoveryException (org.wso2.carbon.identity.recovery.IdentityRecoveryException)2 NotificationResponseBean (org.wso2.carbon.identity.recovery.bean.NotificationResponseBean)2