use of org.wso2.carbon.identity.application.authentication.framework.exception.UserSessionException in project carbon-identity-framework by wso2.
the class UserSessionStore method getUserIdsOfUserStore.
/**
* Method to return the user Ids of the users in a given user store from the database.
* @deprecated
* User ids of local users are no longer stored in IDN_AUTH_USER table and user ids of all the users in a domain
* should not be retrieved at once.
*
* @param userDomain name of the user Store domain
* @param tenantId id of the tenant domain
* @return the list of user Ids of users stored in the given user store
* @throws UserSessionException if an error occurs when retrieving the user id list from the database
*/
@Deprecated
public List<String> getUserIdsOfUserStore(String userDomain, int tenantId) throws UserSessionException {
List<String> userIds = new ArrayList<>();
try (Connection connection = IdentityDatabaseUtil.getSessionDBConnection(false)) {
try (PreparedStatement preparedStatement = connection.prepareStatement(SQLQueries.SQL_SELECT_USER_IDS_OF_USER_STORE)) {
preparedStatement.setString(1, userDomain.toUpperCase());
preparedStatement.setInt(2, tenantId);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
userIds.add(resultSet.getString(1));
}
}
} catch (SQLException e1) {
throw new UserSessionException("Error while retrieving user Ids stored in the user domain: " + userDomain + ", Tenant Id: " + tenantId, e1);
}
} catch (SQLException e) {
throw new UserSessionException("Error while retrieving user Ids stored in the user domain: " + userDomain + ", Tenant Id: " + tenantId, e);
}
return userIds;
}
use of org.wso2.carbon.identity.application.authentication.framework.exception.UserSessionException in project carbon-identity-framework by wso2.
the class UserSessionStore method getIdPId.
/**
* Retrieve IDP ID from the IDP table using IDP name and tenant ID.
*
* @param idpName IDP name.
* @param tenantId Tenant ID.
* @return IDP ID.
* @throws UserSessionException
*/
public int getIdPId(String idpName, int tenantId) throws UserSessionException {
int idPId = -1;
if (idpName.equals("LOCAL")) {
return idPId;
}
try (Connection connection = IdentityDatabaseUtil.getDBConnection(false)) {
try (PreparedStatement preparedStatement = connection.prepareStatement(SQLQueries.SQL_SELECT_IDP_WITH_TENANT)) {
preparedStatement.setString(1, idpName);
preparedStatement.setInt(2, tenantId);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (resultSet.next()) {
idPId = resultSet.getInt(1);
}
}
}
} catch (SQLException e) {
throw new UserSessionException("Error while retrieving the IdP id of: " + idpName + " and tenant ID: " + tenantId, e);
}
return idPId;
}
use of org.wso2.carbon.identity.application.authentication.framework.exception.UserSessionException in project carbon-identity-framework by wso2.
the class UserSessionStore method getUserId.
/**
* Method to return the user Id of a user from the database.
* @deprecated use {@link #getFederatedUserId(String, int, int)} instead.
* Initially when the user store did not support user id, it was created and stored in here. Now the user store
* support user ids for local users, this is not required for local users anymore. However similar capability is
* still required for federated users.
*
* @param userName Name of the authenticated user
* @param tenantId Id of the tenant domain
* @param userDomain Name of the user Store domain
* @return the user id of the user
* @throws UserSessionException if an error occurs when retrieving the user id of the user from the database
*/
@Deprecated
public String getUserId(String userName, int tenantId, String userDomain) throws UserSessionException {
String userId = null;
try (Connection connection = IdentityDatabaseUtil.getSessionDBConnection(false)) {
try (PreparedStatement preparedStatement = connection.prepareStatement(SQLQueries.SQL_SELECT_USER_IDS_OF_USER)) {
preparedStatement.setString(1, userName);
preparedStatement.setInt(2, tenantId);
preparedStatement.setString(3, (userDomain == null) ? FEDERATED_USER_DOMAIN : userDomain.toUpperCase());
try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (resultSet.next()) {
userId = resultSet.getString(1);
}
}
} catch (SQLException e1) {
throw new UserSessionException("Error while retrieving User Id of the user: " + userName + ", Tenant Id: " + tenantId + ", User domain: " + userDomain, e1);
}
} catch (SQLException e) {
throw new UserSessionException("Error while retrieving User Id of the user: " + userName + ", Tenant Id: " + tenantId + ", User domain: " + userDomain, e);
}
return userId;
}
use of org.wso2.carbon.identity.application.authentication.framework.exception.UserSessionException in project carbon-identity-framework by wso2.
the class UserSessionStore method getAppId.
/**
* Method to get app id from SP_APP table.
*
* @param applicationName application Name
* @param appTenantID app tenant id
* @return the application id
* @throws UserSessionException if an error occurs when retrieving app id
*
* @deprecated Since the UserSessionStore should not invoke the application management table.
*/
@Deprecated
public int getAppId(String applicationName, int appTenantID) throws UserSessionException {
Integer appId;
JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate(JdbcUtils.Database.SESSION);
try {
appId = jdbcTemplate.fetchSingleRecord(SQLQueries.SQL_SELECT_APP_ID_OF_APP, ((resultSet, rowNumber) -> resultSet.getInt(1)), preparedStatement -> {
preparedStatement.setString(1, applicationName);
preparedStatement.setInt(2, appTenantID);
});
} catch (DataAccessException e) {
throw new UserSessionException("Error while retrieving the app id of " + applicationName + ", " + "tenant id" + appTenantID + ".", e);
}
return appId == null ? 0 : appId;
}
Aggregations