org.wso2.carbon.stratos.common.exception.StratosException Java Examples

The following examples show how to use org.wso2.carbon.stratos.common.exception.StratosException. 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: TenantManagementListener.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Add the default Resident Identity Provider entry when a new tenant is registered.
 *
 * @param tenantInfo Information about the newly created tenant
 */

@Override
public void onTenantCreate(TenantInfoBean tenantInfo) throws StratosException {
    try {
        String tenantDomain = tenantInfo.getTenantDomain();
        IdentityProvider identityProvider = new IdentityProvider();
        identityProvider.setIdentityProviderName(IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME);
        identityProvider.setHomeRealmId("localhost");
        identityProvider.setPrimary(true);
        IdentityProviderManager.getInstance().addResidentIdP(identityProvider, tenantDomain);
    } catch (IdentityProviderManagementException e) {
        String message = "Error when adding Resident Identity Provider entry for tenant " +
                tenantInfo.getTenantDomain();
        throw new StratosException(message, e);
    }
}
 
Example #2
Source File: TenantEventPublisher.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
@Override
public void onTenantCreate(TenantInfoBean tenantInfo) throws StratosException {
    try {
        if (log.isDebugEnabled()) {
            log.debug(String.format("Publishing tenant created event: [tenant-id] %d [tenant-domain] %s",
                    tenantInfo.getTenantId(), tenantInfo.getTenantDomain()));
        }
        Tenant tenant = new Tenant(tenantInfo.getTenantId(), tenantInfo.getTenantDomain());
        TenantCreatedEvent event = new TenantCreatedEvent(tenant);
        publish(event);
    } catch (Exception e) {
        log.error(String.format("Could not publish tenant created event [tenant-id] %d [tenant-domain] %s ",
                tenantInfo.getTenantId(),
                tenantInfo.getTenantDomain()), e);
    }
}
 
Example #3
Source File: WorkflowImplTenantMgtListener.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public void onTenantCreate(TenantInfoBean tenantInfoBean) throws StratosException {
    String fullName = tenantInfoBean.getAdmin() + UserCoreConstants.TENANT_DOMAIN_COMBINER + tenantInfoBean.getTenantDomain() ;
    BPSProfile bpsProfileDTO = new BPSProfile();
    String url = IdentityUtil.getServerURL(WorkflowImplServiceDataHolder.getInstance()
            .getConfigurationContextService().getServerConfigContext().getServicePath(), true, true);
    try {
        bpsProfileDTO.setManagerHostURL(url);
        bpsProfileDTO.setWorkerHostURL(url);
        bpsProfileDTO.setUsername(fullName);
        bpsProfileDTO.setPassword(new char[0]);
        bpsProfileDTO.setProfileName(WFImplConstant.DEFAULT_BPS_PROFILE_NAME);

        WorkflowImplServiceDataHolder.getInstance().getWorkflowImplService()
                .addBPSProfile(bpsProfileDTO, tenantInfoBean
                        .getTenantId());

    }catch (WorkflowImplException e) {
        //This is not thrown exception because this is not blocked to the other functionality. User can create
        // default profile by manually.
        String errorMsg = "Error occured while adding default bps profile, " + e.getMessage();
        log.error(errorMsg);
    }

}
 
Example #4
Source File: TenantManagementListener.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Add the default Resident Identity Provider entry when a new tenant is registered.
 *
 * @param tenantInfo Information about the newly created tenant
 */

@Override
public void onTenantCreate(TenantInfoBean tenantInfo) throws StratosException {
    try {
        String tenantDomain = tenantInfo.getTenantDomain();
        IdentityProvider identityProvider = new IdentityProvider();
        identityProvider.setIdentityProviderName(IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME);
        identityProvider.setHomeRealmId("localhost");
        identityProvider.setPrimary(true);
        IdentityProviderManager.getInstance().addResidentIdP(identityProvider, tenantDomain);
    } catch (IdentityProviderManagementException e) {
        String message = "Error when adding Resident Identity Provider entry for tenant " +
                tenantInfo.getTenantDomain();
        throw new StratosException(message, e);
    }
}
 
Example #5
Source File: TenantEventPublisher.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
@Override
public void onTenantUpdate(TenantInfoBean tenantInfo) throws StratosException {
    try {
        if (log.isInfoEnabled()) {
            log.info(String.format("Publishing tenant updated event: [tenant-id] %d [tenant-domain] %s",
                    tenantInfo.getTenantId(), tenantInfo.getTenantDomain()));
        }
        TenantUpdatedEvent event = new TenantUpdatedEvent(tenantInfo.getTenantId(),
                tenantInfo.getTenantDomain());
        publish(event);
    } catch (Exception e) {
        log.error(String.format("Could not publish tenant updated event:[tenant-id] %d [tenant-domain] %s ",
                tenantInfo.getTenantId(),
                tenantInfo.getTenantDomain()), e);
    }
}
 
Example #6
Source File: TenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public void onPreDelete(int i) throws StratosException {
    try {
        UserAccountAssociationDAO.getInstance().deleteUserAssociationsFromTenantId(i);
    } catch (UserAccountAssociationException e) {
        throw new StratosException(String.format(UserAccountAssociationConstants.ErrorMessages
                .CONN_DELETE_FROM_TENANT_ID_ERROR.getDescription(), i), e);
    }
}
 
Example #7
Source File: ClaimMetadataTenantMgtListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void onPreDelete(int tenantId) throws StratosException {

    try {
        IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().
                removeAllClaims(tenantId);
    } catch (ClaimMetadataException e) {
        throw new StratosException("Error in deleting claim metadata of the tenant: " + tenantId, e);
    }
}
 
Example #8
Source File: TenantConsentMgtListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Delete all consents belongs to a given tenant id.
 *
 * @param tenantId Id of the tenant
 * @throws StratosException
 */
protected void deleteAllConsents(int tenantId) throws StratosException {

    try {
        PrivilegedConsentManager privilegedConsentManager =
                IdentityConsentDataHolder.getInstance().getPrivilegedConsentManager();
        privilegedConsentManager.deletePurposeCategories(tenantId);
        privilegedConsentManager.deletePIICategories(tenantId);
        privilegedConsentManager.deletePurposes(tenantId);
        privilegedConsentManager.deleteReceipts(tenantId);
    } catch (ConsentManagementException e) {
        throw new StratosException("Error in deleting consents of tenant:" + tenantId, e);
    }
}
 
Example #9
Source File: TenantConsentMgtListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Delete all consents belongs to a given tenant before deleting the tenant.
 *
 * @param tenantId Id of the tenant
 * @throws StratosException
 */
@Override
public void onPreDelete(int tenantId) throws StratosException {

    if (log.isDebugEnabled()) {
        log.info("Deleting all consents of the tenant: " + tenantId);
    }
    deleteAllConsents(tenantId);
}
 
Example #10
Source File: TenantConsentMgtListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void onTenantCreate(TenantInfoBean tenantInfoBean) throws StratosException {

    if (isSsoConsentManagementEnabled()) {
        addDefaultPurposeCategory(tenantInfoBean);
    }
}
 
Example #11
Source File: TenantManagementListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Add the default challenge Question Set when a new tenant is registered.
 *
 * @param tenantInfo Information about the newly created tenant
 */
@Override
public void onTenantCreate(TenantInfoBean tenantInfo) throws StratosException {
    try {
        PrivilegedCarbonContext.getThreadLocalCarbonContext().startTenantFlow();
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantInfo.getTenantDomain());
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantInfo.getTenantId());
        UserIdentityManagementUtil.loadDefaultChallenges();

        IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
                (UserOperationEventListener.class.getName(), IdentityMgtEventListener.class.getName());

        if (identityEventListenerConfig != null) {
            if (Boolean.parseBoolean(identityEventListenerConfig.getEnable())) {
                Config emailConfigFile = ConfigBuilder.getInstance().loadEmailConfigFile();
                EmailNotificationConfig emailNotificationConfig = new EmailNotificationConfig();
                emailNotificationConfig.setProperties(emailConfigFile.getProperties());
                ConfigBuilder.getInstance().saveConfiguration(StorageType.REGISTRY, tenantInfo.getTenantId(),
                        emailNotificationConfig);
            }
        }
    } catch (IdentityMgtConfigException e) {
        log.error("Error occurred while saving default email templates in registry for tenant: "
                  + tenantInfo.getTenantDomain());
    } finally {
        PrivilegedCarbonContext.getThreadLocalCarbonContext().endTenantFlow();
    }
}
 
Example #12
Source File: TenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscriptionPlanChange(int i, String s, String s2) throws StratosException {
    return;
}
 
Example #13
Source File: OAuthTenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantCreate(TenantInfoBean tenantInfoBean) throws StratosException {
    return;
}
 
Example #14
Source File: TenantUserRoleManager.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscriptionPlanChange(int tenentId, String oldPlan, String newPlan)
        throws StratosException {

}
 
Example #15
Source File: TenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantInitialActivation(int i) throws StratosException {
    return;
}
 
Example #16
Source File: TenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantRename(int i, String s, String s2) throws StratosException {
    return;
}
 
Example #17
Source File: TenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantUpdate(TenantInfoBean tenantInfoBean) throws StratosException {
    return;
}
 
Example #18
Source File: TenantEventPublisher.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantActivation(int tenantId) throws StratosException {
}
 
Example #19
Source File: TenantManagementListener.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantDeactivation(int tenantId) throws StratosException {
    // It is not required to implement this method for IdP mgt.
}
 
Example #20
Source File: OAuthTenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantActivation(int i) throws StratosException {
    return;
}
 
Example #21
Source File: OAuthTenantMgtListenerImpl.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantRename(int i, String s, String s1) throws StratosException {
    return;
}
 
Example #22
Source File: TenantManagementListener.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantInitialActivation(int tenantId) throws StratosException {
    // It is not required to implement this method for IdP mgt.
}
 
Example #23
Source File: TenantEventPublisher.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscriptionPlanChange(int tenantId, String oldPlan, String newPlan) throws StratosException {
}
 
Example #24
Source File: TenantEventPublisher.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantInitialActivation(int tenantId) throws StratosException {
}
 
Example #25
Source File: AuthenticationEndpointTenantActivityListener.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantCreate(TenantInfoBean tenantInfoBean) throws StratosException {
    /* Method not implemented */
}
 
Example #26
Source File: AuthenticationEndpointTenantActivityListener.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscriptionPlanChange(int tenentId, String oldPlan, String newPlan) throws StratosException {
    /* Method not implemented */
}
 
Example #27
Source File: AuthenticationEndpointTenantActivityListener.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantRename(int tenantId, String oldDomainName, String newDomainName) throws StratosException {
    /* Method not implemented */
}
 
Example #28
Source File: TenantManagementListener.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onSubscriptionPlanChange(int tenentId, String oldPlan, String newPlan) throws StratosException {
    // It is not required to implement this method for IdP mgt.
}
 
Example #29
Source File: AuthenticationEndpointTenantActivityListener.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantUpdate(TenantInfoBean tenantInfoBean) throws StratosException {
    /* Method not implemented */
}
 
Example #30
Source File: TenantEventPublisher.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
@Override
public void onTenantRename(int tenantId, String oldDomainName, String newDomainName) throws StratosException {
}