Search in sources :

Example 21 with IdentityRuntimeException

use of org.wso2.carbon.identity.base.IdentityRuntimeException in project carbon-identity-framework by wso2.

the class AbstractEventHandler method canHandle.

public boolean canHandle(MessageContext messageContext) throws IdentityRuntimeException {
    Event event = ((IdentityEventMessageContext) messageContext).getEvent();
    String eventName = event.getEventName();
    List<Subscription> subscriptionList = null;
    if (configs != null) {
        subscriptionList = configs.getSubscriptions();
    } else {
        return false;
    }
    if (subscriptionList != null) {
        for (Subscription subscription : subscriptionList) {
            if (subscription.getSubscriptionName().equals(eventName)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Event(org.wso2.carbon.identity.event.event.Event) Subscription(org.wso2.carbon.identity.event.bean.Subscription) IdentityEventMessageContext(org.wso2.carbon.identity.event.bean.IdentityEventMessageContext)

Example 22 with IdentityRuntimeException

use of org.wso2.carbon.identity.base.IdentityRuntimeException in project carbon-identity-framework by wso2.

the class DatabaseBasedUserStoreDAOImpl method addUserStoreProperties.

private void addUserStoreProperties(String userStoreProperties, String domainName) throws IdentityUserStoreMgtException {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    String errorMessage = "Error occurred while updating the user store properties for " + "the userstore domain:" + domainName + "in the tenant:" + tenantId;
    try {
        try (Connection connection = IdentityDatabaseUtil.getDBConnection()) {
            try (PreparedStatement userStorePrepStmt = connection.prepareStatement(UserStoreMgtDBQueries.STORE_USERSTORE_PROPERTIES)) {
                String uuid = String.valueOf(UUID.randomUUID());
                userStorePrepStmt.setString(1, uuid);
                userStorePrepStmt.setInt(2, tenantId);
                setBlobValue(userStoreProperties, userStorePrepStmt, 3);
                userStorePrepStmt.setString(4, domainName);
                userStorePrepStmt.setString(5, XML);
                userStorePrepStmt.setString(6, USERSTORE);
                userStorePrepStmt.execute();
                if (log.isDebugEnabled()) {
                    log.debug("The userstore domain:" + domainName + "added for the tenant:" + tenantId);
                }
                IdentityDatabaseUtil.commitTransaction(connection);
            } catch (SQLException e) {
                IdentityDatabaseUtil.rollbackTransaction(connection);
                throw new IdentityUserStoreMgtException(errorMessage, e);
            }
        } catch (IOException | SQLException ex) {
            throw new IdentityUserStoreMgtException(errorMessage, ex);
        }
    } catch (IdentityRuntimeException e) {
        throw new IdentityUserStoreMgtException("Couldn't get a database connection.", e);
    }
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) IOException(java.io.IOException) IdentityRuntimeException(org.wso2.carbon.identity.base.IdentityRuntimeException)

Example 23 with IdentityRuntimeException

use of org.wso2.carbon.identity.base.IdentityRuntimeException in project identity-governance by wso2-extensions.

the class ChallengeQuestionManager method deleteChallengeQuestions.

/**
 * Delete challenge questions from a tenant registry.
 *
 * @param challengeQuestions
 * @param tenantDomain
 * @throws IdentityRecoveryException
 */
public void deleteChallengeQuestions(ChallengeQuestion[] challengeQuestions, String tenantDomain) throws IdentityRecoveryException {
    try {
        tenantDomain = validateTenantDomain(tenantDomain);
        for (ChallengeQuestion question : challengeQuestions) {
            if (isChallengeQuestionExists(question, tenantDomain)) {
                String questionPath = getQuestionPath(question);
                if (StringUtils.isNotEmpty(question.getLocale())) {
                    String locale = question.getLocale();
                    resourceMgtService.deleteIdentityResource(questionPath, tenantDomain, locale);
                } else {
                    resourceMgtService.deleteIdentityResource(questionPath, tenantDomain);
                }
            }
        }
    } catch (IdentityRuntimeException e) {
        log.error("Error deleting challenge quesitons in " + tenantDomain);
        throw new IdentityRecoveryException("Error when deleting challenge questions.", e);
    }
}
Also used : IdentityRuntimeException(org.wso2.carbon.identity.base.IdentityRuntimeException) ChallengeQuestion(org.wso2.carbon.identity.recovery.model.ChallengeQuestion)

Example 24 with IdentityRuntimeException

use of org.wso2.carbon.identity.base.IdentityRuntimeException in project identity-governance by wso2-extensions.

the class CodeInvalidationHandler method canHandle.

public boolean canHandle(MessageContext messageContext) throws IdentityRuntimeException {
    Event event = ((IdentityEventMessageContext) messageContext).getEvent();
    String eventName = event.getEventName();
    if (IdentityEventConstants.Event.POST_DELETE_USER.equals(eventName)) {
        return true;
    }
    return false;
}
Also used : Event(org.wso2.carbon.identity.event.event.Event) IdentityEventMessageContext(org.wso2.carbon.identity.event.bean.IdentityEventMessageContext)

Aggregations

IdentityRuntimeException (org.wso2.carbon.identity.base.IdentityRuntimeException)17 Connection (java.sql.Connection)14 SQLException (java.sql.SQLException)14 PreparedStatement (java.sql.PreparedStatement)13 IOException (java.io.IOException)8 ResultSet (java.sql.ResultSet)5 SessionSerializerException (org.wso2.carbon.identity.application.authentication.framework.exception.SessionSerializerException)4 Registry (org.wso2.carbon.registry.core.Registry)4 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)4 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)3 ArrayList (java.util.ArrayList)2 IdentityEventException (org.wso2.carbon.identity.event.IdentityEventException)2 IdentityEventMessageContext (org.wso2.carbon.identity.event.bean.IdentityEventMessageContext)2 Event (org.wso2.carbon.identity.event.event.Event)2 FunctionLibrary (org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary)2 UserStoreException (org.wso2.carbon.user.api.UserStoreException)2 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1