use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class ThriftAuthenticatorServiceImpl method addThriftSession.
private void addThriftSession(ThriftSession thriftSession) throws IdentityException {
// add to cache
authenticatedSessions.put(thriftSession.getSessionId(), thriftSession);
// add to database
ThriftSessionDAO sessionDAO = this.thriftSessionDAO.getInstance();
sessionDAO.addSession(thriftSession);
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class DBThriftSessionDAO method getSession.
@Override
public ThriftSession getSession(String sessionId) throws IdentityException {
Connection connection = null;
PreparedStatement prepStmt = null;
ResultSet rSet = null;
ThriftSession thriftSession = new ThriftSession();
try {
connection = ThriftAuthenticationDatabaseUtil.getDBConnection(false);
prepStmt = connection.prepareStatement(ThriftAuthenticationConstants.GET_THRIFT_SESSION_SQL);
prepStmt.setString(1, sessionId);
rSet = prepStmt.executeQuery();
while (rSet.next()) {
if (rSet.getString(1) != null && rSet.getString(1).length() > 0) {
thriftSession.setSessionId(rSet.getString(1));
thriftSession.setUserName(rSet.getString(2));
thriftSession.setCreatedAt(rSet.getLong(3));
thriftSession.setLastAccess(rSet.getLong(4));
}
}
} catch (AuthenticationException e) {
String errorMsg = ERROR_WHEN_GETTING_AN_IDENTITY_PERSISTENCE_STORE_INSTANCE;
log.error(errorMsg, e);
throw IdentityException.error(errorMsg, e);
} catch (SQLException e) {
log.error(ERROR_WHEN_EXECUTING_THE_SQL + " " + ThriftAuthenticationConstants.GET_THRIFT_SESSION_SQL);
log.error(e.getMessage(), e);
throw IdentityException.error("Error when reading the Thrift session information from " + THE_PERSISTENCE_STORE);
} finally {
ThriftAuthenticationDatabaseUtil.closeAllConnections(connection, rSet, prepStmt);
}
return thriftSession;
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class ThriftAuthenticatorServiceImpl method onSuccessLogin.
private void onSuccessLogin(ThriftSession authSession) throws IdentityException {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
try {
carbonContext.setUsername((String) (authSession.getAttribute(ServerConstants.AUTHENTICATION_SERVICE_USERNAME)));
carbonContext.setTenantDomain((String) (authSession.getAttribute(MultitenantConstants.TENANT_DOMAIN)));
carbonContext.setTenantId((Integer) (authSession.getAttribute(MultitenantConstants.TENANT_ID)));
} catch (Exception e) {
String authErrorMsg = "Error populating current carbon context from thrift auth session: " + e.getMessage();
throw IdentityException.error(authErrorMsg);
}
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class IdentityPersistenceManager method addXmppSettings.
/**
* Add XMPP settings.
*
* @param userId
* @param xmppServer
* @param xmppUserName
* @param xmppUserCode
* @param enabled
* @throws IdentityException
*/
public void addXmppSettings(Registry registry, String userId, String xmppServer, String xmppUserName, String xmppUserCode, boolean enabled, boolean isPINEnabled) throws IdentityException {
XMPPSettingsDAO dao = new XMPPSettingsDAO(registry);
dao.addXmppSettings(userId, xmppServer, xmppUserName, xmppUserCode, enabled, isPINEnabled);
}
use of org.wso2.carbon.identity.base.IdentityException in project carbon-identity-framework by wso2.
the class IdentityPersistenceManager method removeParameter.
/**
* @param parameterDO
* @throws IdentityException
*/
public void removeParameter(Registry registry, ParameterDO parameterDO) throws IdentityException {
ParameterDAO dao = new ParameterDAO(registry);
dao.removeParameter(parameterDO);
}
Aggregations