Search in sources :

Example 1 with SCIMConfigProcessor

use of org.wso2.carbon.identity.scim2.common.utils.SCIMConfigProcessor in project identity-inbound-provisioning-scim2 by wso2-extensions.

the class SCIMCommonComponent method activate.

@Activate
protected void activate(ComponentContext ctx) {
    try {
        String filePath = IdentityUtil.getIdentityConfigDirPath() + File.separator + SCIMCommonConstants.CHARON_CONFIG_NAME;
        SCIMConfigProcessor scimConfigProcessor = SCIMConfigProcessor.getInstance();
        scimConfigProcessor.buildConfigFromFile(filePath);
        // reading user schema extension
        if (Boolean.parseBoolean(scimConfigProcessor.getProperty("user-schema-extension-enabled"))) {
            String schemaFilePath = CarbonUtils.getCarbonConfigDirPath() + File.separator + SCIMConfigConstants.SCIM_SCHEMA_EXTENSION_CONFIG;
            SCIMUserSchemaExtensionBuilder.getInstance().buildUserSchemaExtension(schemaFilePath);
        }
        // If custom schema is enabled, read it root attribute URI from the file config if it is configured.
        if (SCIMCommonUtils.isCustomSchemaEnabled()) {
            SCIMCustomSchemaExtensionBuilder.getInstance().setURI(SCIMCommonUtils.getCustomSchemaURI());
        }
        // register UserOperationEventListener implementation
        SCIMUserOperationListener scimUserOperationListener = new SCIMUserOperationListener();
        userOperationEventListenerServiceReg = ctx.getBundleContext().registerService(UserOperationEventListener.class, scimUserOperationListener, null);
        // register scimTenantMgtListener implementation
        SCIMTenantMgtListener scimTenantMgtListener = new SCIMTenantMgtListener();
        tenantMgtListenerServiceReg = ctx.getBundleContext().registerService(TenantMgtListener.class, scimTenantMgtListener, null);
        // Register claim operation event handler implementation.
        ctx.getBundleContext().registerService(AbstractEventHandler.class.getName(), new SCIMClaimOperationEventHandler(), null);
        if (logger.isDebugEnabled()) {
            logger.debug("SCIMClaimOperationEventHandler is successfully registered.");
        }
        // Register default implementation of SCIMUserStoreErrorResolver
        ctx.getBundleContext().registerService(SCIMUserStoreErrorResolver.class.getName(), new DefaultSCIMUserStoreErrorResolver(), null);
        // Register default implementation of SCIMGroupResolver.
        ctx.getBundleContext().registerService(GroupResolver.class.getName(), new SCIMGroupResolver(), null);
        // Update super tenant user/group attributes.
        AdminAttributeUtil.updateAdminUser(MultitenantConstants.SUPER_TENANT_ID, true);
        AdminAttributeUtil.updateAdminGroup(MultitenantConstants.SUPER_TENANT_ID);
        if (logger.isDebugEnabled()) {
            logger.debug("SCIM Common component activated successfully.");
        }
    } catch (CharonException e) {
        logger.error("Error in reading information from identity tables at SCIMCommonComponentStartup.", e);
    } catch (InternalErrorException e) {
        logger.error("Error in reading information from identity tables at SCIMCommonComponentStartup.", e);
    }
}
Also used : UserOperationEventListener(org.wso2.carbon.user.core.listener.UserOperationEventListener) SCIMUserOperationListener(org.wso2.carbon.identity.scim2.common.listener.SCIMUserOperationListener) InternalErrorException(org.wso2.charon3.core.exceptions.InternalErrorException) SCIMConfigProcessor(org.wso2.carbon.identity.scim2.common.utils.SCIMConfigProcessor) SCIMTenantMgtListener(org.wso2.carbon.identity.scim2.common.listener.SCIMTenantMgtListener) TenantMgtListener(org.wso2.carbon.stratos.common.listeners.TenantMgtListener) SCIMTenantMgtListener(org.wso2.carbon.identity.scim2.common.listener.SCIMTenantMgtListener) DefaultSCIMUserStoreErrorResolver(org.wso2.carbon.identity.scim2.common.impl.DefaultSCIMUserStoreErrorResolver) SCIMUserStoreErrorResolver(org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreErrorResolver) AbstractEventHandler(org.wso2.carbon.identity.event.handler.AbstractEventHandler) SCIMClaimOperationEventHandler(org.wso2.carbon.identity.scim2.common.handlers.SCIMClaimOperationEventHandler) SCIMGroupResolver(org.wso2.carbon.identity.scim2.common.listener.SCIMGroupResolver) SCIMGroupResolver(org.wso2.carbon.identity.scim2.common.listener.SCIMGroupResolver) GroupResolver(org.wso2.carbon.user.core.listener.GroupResolver) CharonException(org.wso2.charon3.core.exceptions.CharonException) DefaultSCIMUserStoreErrorResolver(org.wso2.carbon.identity.scim2.common.impl.DefaultSCIMUserStoreErrorResolver) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with SCIMConfigProcessor

use of org.wso2.carbon.identity.scim2.common.utils.SCIMConfigProcessor in project identity-inbound-provisioning-scim2 by wso2-extensions.

the class IdentitySCIMManager method registerCharonConfig.

/**
 * This create the basic operational configurations for charon
 */
private void registerCharonConfig() throws CharonException {
    try {
        // Config charon.
        // This values will be used in /ServiceProviderConfigResource endpoint and some default charon configs.
        CharonConfiguration charonConfiguration = CharonConfiguration.getInstance();
        SCIMConfigProcessor scimConfigProcessor = SCIMConfigProcessor.getInstance();
        charonConfiguration.setDocumentationURL(scimConfigProcessor.getProperty(SCIMCommonConstants.DOCUMENTATION_URL));
        charonConfiguration.setBulkSupport(Boolean.parseBoolean(scimConfigProcessor.getProperty(SCIMCommonConstants.BULK_SUPPORTED)), Integer.parseInt(scimConfigProcessor.getProperty(SCIMCommonConstants.BULK_MAX_OPERATIONS)), Integer.parseInt(scimConfigProcessor.getProperty(SCIMCommonConstants.BULK_MAX_PAYLOAD_SIZE)));
        charonConfiguration.setSortSupport(Boolean.parseBoolean(scimConfigProcessor.getProperty(SCIMCommonConstants.SORT_SUPPORTED)));
        charonConfiguration.setPatchSupport(Boolean.parseBoolean(scimConfigProcessor.getProperty(SCIMCommonConstants.PATCH_SUPPORTED)));
        charonConfiguration.setETagSupport(Boolean.parseBoolean(scimConfigProcessor.getProperty(SCIMCommonConstants.ETAG_SUPPORTED)));
        charonConfiguration.setChangePasswordSupport(Boolean.parseBoolean(scimConfigProcessor.getProperty(SCIMCommonConstants.CHNAGE_PASSWORD_SUPPORTED)));
        charonConfiguration.setFilterSupport(Boolean.parseBoolean(scimConfigProcessor.getProperty(SCIMCommonConstants.FILTER_SUPPORTED)), Integer.parseInt(scimConfigProcessor.getProperty(SCIMCommonConstants.FILTER_MAX_RESULTS)));
        charonConfiguration.setCountValueForPagination(Integer.parseInt(scimConfigProcessor.getProperty(SCIMCommonConstants.PAGINATION_DEFAULT_COUNT)));
        ArrayList<Object[]> schemaList = new ArrayList<>();
        for (AuthenticationSchema authenticationSchema : scimConfigProcessor.getAuthenticationSchemas()) {
            Object[] schema = { authenticationSchema.getName(), authenticationSchema.getDescription(), authenticationSchema.getSpecUri(), authenticationSchema.getDocumentationUri(), authenticationSchema.getType(), authenticationSchema.getPrimary() };
            schemaList.add(schema);
        }
        charonConfiguration.setAuthenticationSchemes(schemaList);
    } catch (Exception e) {
        throw new CharonException("Error in setting up charon configurations.", e);
    }
}
Also used : AuthenticationSchema(org.wso2.carbon.identity.scim2.common.utils.AuthenticationSchema) ArrayList(java.util.ArrayList) CharonException(org.wso2.charon3.core.exceptions.CharonException) CharonConfiguration(org.wso2.charon3.core.config.CharonConfiguration) UserStoreException(org.wso2.carbon.user.api.UserStoreException) CharonException(org.wso2.charon3.core.exceptions.CharonException) SCIMConfigProcessor(org.wso2.carbon.identity.scim2.common.utils.SCIMConfigProcessor)

Aggregations

SCIMConfigProcessor (org.wso2.carbon.identity.scim2.common.utils.SCIMConfigProcessor)2 CharonException (org.wso2.charon3.core.exceptions.CharonException)2 ArrayList (java.util.ArrayList)1 Activate (org.osgi.service.component.annotations.Activate)1 AbstractEventHandler (org.wso2.carbon.identity.event.handler.AbstractEventHandler)1 SCIMUserStoreErrorResolver (org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreErrorResolver)1 SCIMClaimOperationEventHandler (org.wso2.carbon.identity.scim2.common.handlers.SCIMClaimOperationEventHandler)1 DefaultSCIMUserStoreErrorResolver (org.wso2.carbon.identity.scim2.common.impl.DefaultSCIMUserStoreErrorResolver)1 SCIMGroupResolver (org.wso2.carbon.identity.scim2.common.listener.SCIMGroupResolver)1 SCIMTenantMgtListener (org.wso2.carbon.identity.scim2.common.listener.SCIMTenantMgtListener)1 SCIMUserOperationListener (org.wso2.carbon.identity.scim2.common.listener.SCIMUserOperationListener)1 AuthenticationSchema (org.wso2.carbon.identity.scim2.common.utils.AuthenticationSchema)1 TenantMgtListener (org.wso2.carbon.stratos.common.listeners.TenantMgtListener)1 UserStoreException (org.wso2.carbon.user.api.UserStoreException)1 GroupResolver (org.wso2.carbon.user.core.listener.GroupResolver)1 UserOperationEventListener (org.wso2.carbon.user.core.listener.UserOperationEventListener)1 CharonConfiguration (org.wso2.charon3.core.config.CharonConfiguration)1 InternalErrorException (org.wso2.charon3.core.exceptions.InternalErrorException)1