Examples of UserStoreException


Examples of org.wso2.carbon.user.core.UserStoreException

                return;
            }
        }

        if (realmConfig.getAdminUserName().equals(userName)) {
            throw new UserStoreException("Cannot delete admin user");
        }

        String sqlStmt1 = realmConfig
                .getUserStoreProperty(JDBCRealmConstants.ON_DELETE_USER_REMOVE_USER_ROLE);
        if (sqlStmt1 == null) {
            throw new UserStoreException("The sql statement for delete user-role mapping is null");
        }

        String sqlStmt2 = realmConfig
                .getUserStoreProperty(JDBCRealmConstants.ON_DELETE_USER_REMOVE_ATTRIBUTE);
        if (sqlStmt2 == null) {
            throw new UserStoreException("The sql statement for delete user attribute is null");
        }

        String sqlStmt3 = realmConfig.getUserStoreProperty(JDBCRealmConstants.DELETE_USER);
        if (sqlStmt3 == null) {
            throw new UserStoreException("The sql statement for delete user is null");
        }

        Connection dbConnection = null;
        try {
            dbConnection = getDBConnection();
            if (sqlStmt1.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
                this.updateStringValuesToDatabase(dbConnection, sqlStmt1, userName, tenantId,
                        tenantId);
                this.updateStringValuesToDatabase(dbConnection, sqlStmt2, userName, tenantId,
                        tenantId);
                this.updateStringValuesToDatabase(dbConnection, sqlStmt3, userName, tenantId);
            } else {
                this.updateStringValuesToDatabase(dbConnection, sqlStmt1, userName);
                this.updateStringValuesToDatabase(dbConnection, sqlStmt2, userName);
                this.updateStringValuesToDatabase(dbConnection, sqlStmt3, userName);
            }
            this.jdbcUserRealm.getAuthorizationManager().clearUserAuthorization(userName);
            dbConnection.commit();
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            log.error("Using sql : " + sqlStmt1 + " :: " + sqlStmt2);
            throw new UserStoreException(e.getMessage(), e);
        } finally {
            DatabaseUtil.closeAllConnections(dbConnection);
        }

    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

    public void updateUserListOfRole(String roleName, String deletedUsers[], String[] newUsers)
            throws UserStoreException {

        if (realmConfig.getEveryOneRoleName().equals(roleName)) {
            throw new UserStoreException("Everyone role is not updatable");
        }

        if (deletedUsers != null) {
            Arrays.sort(deletedUsers);
            if (realmConfig.getAdminRoleName().equals(roleName)
                    && Arrays.binarySearch(deletedUsers, realmConfig.getAdminUserName()) > -1) {
                log.error("An attempt to remove Admin user from Admin role ");
                throw new UserStoreException("Cannot remove Admin user from Admin role");
            }
        }

        if (isReadOnly() == true && hybridRoleManager.isExistingRole(roleName)) {
            hybridRoleManager.updateUserListOfHybridRole(roleName, deletedUsers, newUsers);
        } else {
            String sqlStmt1 = realmConfig
                    .getUserStoreProperty(JDBCRealmConstants.REMOVE_USER_FROM_ROLE);
            if (sqlStmt1 == null) {
                throw new UserStoreException("The sql statement for remove user from role is null");
            }

            Connection dbConnection = null;
            try {
                dbConnection = getDBConnection();
                String type = DatabaseCreator.getDatabaseType(dbConnection);
                String sqlStmt2 = realmConfig
                        .getUserStoreProperty(JDBCRealmConstants.ADD_USER_TO_ROLE + "-" + type);
                if (sqlStmt2 == null) {
                    sqlStmt2 = realmConfig
                            .getUserStoreProperty(JDBCRealmConstants.ADD_USER_TO_ROLE);
                }
                if (sqlStmt2 == null) {
                    throw new UserStoreException("The sql statement for add user to role is null");
                }
                if (deletedUsers != null) {
                    if (sqlStmt1.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt1,
                                deletedUsers, tenantId, roleName, tenantId, tenantId);
                    } else {
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt1,
                                deletedUsers, tenantId, roleName);
                    }
                }
                if (newUsers != null) {
                    if (sqlStmt1.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2,
                                newUsers, tenantId, roleName, tenantId, tenantId);
                    } else {
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2,
                                newUsers, tenantId, roleName);
                    }
                }
                dbConnection.commit();
            } catch (SQLException e) {
                log.error(e.getMessage(), e);
                throw new UserStoreException(e.getMessage(), e);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                throw new UserStoreException(e.getMessage(), e);
            } finally {
                DatabaseUtil.closeAllConnections(dbConnection);
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

        if (deletedRoles != null) {
            Arrays.sort(deletedRoles);
            if(Arrays.binarySearch(deletedRoles, realmConfig.getEveryOneRoleName()) > -1){
                log.error("An attempt to remove "+userName+" user from Everyone role ");
                throw new UserStoreException("Everyone role is not updatable");
            }
        }
       
        if (deletedRoles != null) {
            Arrays.sort(deletedRoles);
            if (realmConfig.getAdminUserName().equals(userName)
                    && Arrays.binarySearch(deletedRoles, realmConfig.getAdminRoleName()) > -1) {
                log.error("An attempt to remove Admin user from Admin role ");
                throw new UserStoreException("Cannot remove Admin user from Admin role");
            }
        }

        if (isReadOnly() == true) {
            hybridRoleManager.updateHybridRoleListOfUser(userName, deletedRoles, newRoles);
        } else {
            String sqlStmt1 = realmConfig
                    .getUserStoreProperty(JDBCRealmConstants.REMOVE_ROLE_FROM_USER);
            if (sqlStmt1 == null) {
                throw new UserStoreException("The sql statement for remove user from role is null");
            }
            Connection dbConnection = null;
            try {
                dbConnection = getDBConnection()
                String type = DatabaseCreator.getDatabaseType(dbConnection);
                String sqlStmt2 = realmConfig
                        .getUserStoreProperty(JDBCRealmConstants.ADD_ROLE_TO_USER + "-" + type);
                if (sqlStmt2 == null) {
                    sqlStmt2 = realmConfig
                            .getUserStoreProperty(JDBCRealmConstants.ADD_ROLE_TO_USER);
                }
                if (sqlStmt2 == null) {
                    throw new UserStoreException("The sql statement for add user to role is null");
                }

                if (deletedRoles != null) {
                    if (sqlStmt1.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt1,
                                deletedRoles, tenantId, userName, tenantId, tenantId);
                    } else {
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt1,
                                deletedRoles, tenantId, userName);
                    }
                }

                if (newRoles != null) {
                    if (sqlStmt1.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
                        // System.out.println("" +
                        // DatabaseUtil.getIntegerValueFromDatabase(dbConnection,
                        // sqlStmt, params));
                        // System.out.println("" +
                        // DatabaseUtil.getIntegerValueFromDatabase(dbConnection,
                        // sqlStmt, params));
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2,
                                newRoles, tenantId, userName, tenantId, tenantId);
                    } else {
                        DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2,
                                newRoles, tenantId, userName);
                    }
                }
                dbConnection.commit();
            } catch (SQLException e) {
                log.error(e.getMessage(), e);
                throw new UserStoreException(e.getMessage(), e);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                throw new UserStoreException(e.getMessage(), e);
            } finally {
                DatabaseUtil.closeAllConnections(dbConnection);
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

            String profileName) throws UserStoreException {
        if (profileName == null) {
            profileName = UserCoreConstants.DEFAULT_PROFILE;
        }
        if (claimValue == null) {
            throw new UserStoreException("Cannot set null values.");
        }
        Connection dbConnection = null;
        try {
            dbConnection = getDBConnection();
            ClaimMapping cMapping = (ClaimMapping) claimManager.getClaimMapping(claimURI);
            String property;
            if (cMapping != null) {
                property = cMapping.getMappedAttribute();
            } else {
                property = claimURI;
            }
            String value = getProperty(dbConnection, userName, property, profileName);
            if (value == null) {
                addProperty(dbConnection, userName, property, claimValue, profileName);
            } else {
                updateProperty(dbConnection, userName, property, claimValue, profileName);
            }
            dbConnection.commit();
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            throw new UserStoreException(e);
        } finally {
            DatabaseUtil.closeAllConnections(dbConnection);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                }
            }
            dbConnection.commit();
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            throw new UserStoreException(e);
        } finally {
            DatabaseUtil.closeAllConnections(dbConnection);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

            dbConnection = getDBConnection();
            this.deleteProperty(dbConnection, userName, property, profileName);
            dbConnection.commit();
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            throw new UserStoreException(e);
        } finally {
            DatabaseUtil.closeAllConnections(dbConnection);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                this.deleteProperty(dbConnection, userName, property, profileName);
            }
            dbConnection.commit();
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            throw new UserStoreException(e);
        } finally {
            DatabaseUtil.closeAllConnections(dbConnection);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

        if (this.authenticate(userName, oldCredential)) {
            this.updateCredentialByAdmin(userName, newCredential);
        } else {
            log.error("Wrong username/password provided");
            throw new UserStoreException("Wrong username/password provided");
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                return;
            }
        }

        if (!checkUserPasswordValid(newCredential)) {
            throw new UserStoreException(
                "Credential not valid. Credential must be a non null string with following format, " +
                    realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_JAVA_REG_EX));

        }

        String sqlStmt = realmConfig
                .getUserStoreProperty(JDBCRealmConstants.UPDATE_USER_PASSWORD);
        if (sqlStmt == null) {
            throw new UserStoreException("The sql statement for delete user claim value is null");
        }
        String saltValue = null;
        if ("true".equals(realmConfig.getUserStoreProperties().get(
                JDBCRealmConstants.STORE_SALTED_PASSWORDS))) {
            byte[] bytes = new byte[16];
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                }
            }
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            log.error("Using sql : " + sqlstmt);
            throw new UserStoreException(e.getMessage());
        } finally {
            DatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt);
        }
        return date;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.