List of usage examples for org.hibernate Query setParameter
@SuppressWarnings("unchecked") Query<R> setParameter(int position, Object val);
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
public static OASessionStore searchActiveOASSOSession(AuthenticationSession moaSession, String oaID, String protocolType) {//from w w w . j a va2s . c om MiscUtil.assertNotNull(moaSession, "MOASession"); MiscUtil.assertNotNull(oaID, "OnlineApplicationIdentifier"); MiscUtil.assertNotNull(protocolType, "usedProtocol"); Logger.trace("Get active OnlineApplication for sessionID " + moaSession.getSessionID() + " with OAID " + oaID + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getActiveOAWithSessionIDandOAIDandProtocol"); query.setParameter("sessionID", moaSession.getSessionID()); query.setParameter("oaID", oaID); query.setParameter("protocol", protocolType); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() == 0) { Logger.trace("No entries found."); return null; } return result.get(0).getActiveOAsessions().get(0); }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
public static AuthenticationSession getSessionWithPendingRequestID(String pedingRequestID) { try {//from w w w. j a v a 2 s . c o m MiscUtil.assertNotNull(pedingRequestID, "pedingRequestID"); Logger.trace("Get authenticated session with pedingRequestID " + pedingRequestID + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getSessionWithPendingRequestID"); query.setParameter("sessionid", pedingRequestID); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() != 1) { Logger.trace("No entries found."); return null; } return decryptSession(result.get(0)); } catch (Throwable e) { Logger.warn("MOASession deserialization-exception by using MOASessionID=" + pedingRequestID); return null; } }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
public static boolean deleteSessionWithPendingRequestID(String id) { MiscUtil.assertNotNull(id, "PendingRequestID"); Logger.trace("Delete MOAsession with PendingRequestID " + id + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction();/* w w w . j ava2s .c o m*/ Query query = session.getNamedQuery("getSessionWithPendingRequestID"); query.setParameter("sessionid", id); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() != 1) { Logger.trace("No entries found."); return false; } else { cleanDelete(result.get(0)); return true; } }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
public static AuthenticationSession getSessionWithUserNameID(String nameID) { try {//ww w . j ava2 s. c o m MiscUtil.assertNotNull(nameID, "nameID"); Logger.trace("Get authenticated session with pedingRequestID " + nameID + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getMOAISessionWithUserNameID"); query.setParameter("usernameid", StringEscapeUtils.escapeHtml(nameID)); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() == 0) { Logger.trace("No entries found."); return null; } return decryptSession(result.get(0)); } catch (Throwable e) { Logger.warn("MOASession deserialization-exception by using MOASessionID=" + nameID); return null; } }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
public static InterfederationSessionStore searchInterfederatedIDPFORSSOWithMOASession(String sessionID) { MiscUtil.assertNotNull(sessionID, "MOASession"); Logger.trace("Get interfederated IDP for SSO with sessionID " + sessionID + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction();/*from ww w . j a v a 2 s . c o m*/ Query query = session.getNamedQuery("getInterfederatedIDPForSSOWithSessionID"); query.setParameter("sessionID", sessionID); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() == 0) { Logger.trace("No entries found."); return null; } return result.get(0).getInderfederation().get(0); }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
public static InterfederationSessionStore searchInterfederatedIDPFORSSOWithMOASessionIDPID(String sessionID, String idpID) {/*w w w.ja v a 2 s . co m*/ MiscUtil.assertNotNull(sessionID, "MOASession"); MiscUtil.assertNotNull(idpID, "Interfederated IDP ID"); Logger.trace( "Get interfederated IDP " + idpID + " for SSO with sessionID " + sessionID + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getInterfederatedIDPForSSOWithSessionIDIDPID"); query.setParameter("sessionID", sessionID); query.setParameter("idpID", idpID); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() == 0) { Logger.trace("No entries found."); return null; } return result.get(0).getInderfederation().get(0); }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
public static InterfederationSessionStore searchInterfederatedIDPFORAttributeQueryWithSessionID( AuthenticationSession moaSession) { MiscUtil.assertNotNull(moaSession, "MOASession"); Logger.trace("Get interfederated IDP for AttributeQuery with sessionID " + moaSession.getSessionID() + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction();//from w w w.j av a 2 s .c o m Query query = session.getNamedQuery("getInterfederatedIDPForAttributeQueryWithSessionID"); query.setParameter("sessionID", moaSession.getSessionID()); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() == 0) { Logger.trace("No entries found."); return null; } return result.get(0).getInderfederation().get(0); }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
/** * @param entityID//from w w w . ja v a2 s. c o m * @param requestID */ public static boolean removeInterfederetedSession(String entityID, String pedingRequestID) { try { Logger.debug("Remove interfederated IDP from local SSO session ..."); MiscUtil.assertNotNull(pedingRequestID, "pedingRequestID"); Logger.trace("Get authenticated session with pedingRequestID " + pedingRequestID + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List<AuthenticatedSessionStore> result; synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getSessionWithPendingRequestID"); query.setParameter("sessionid", pedingRequestID); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() != 1) { Logger.trace("No entries found."); return false; } AuthenticatedSessionStore authsession = result.get(0); List<InterfederationSessionStore> idpSessions = authsession.getInderfederation(); if (idpSessions != null) { for (InterfederationSessionStore idp : idpSessions) { if (idp.getIdpurlprefix().equals(entityID)) idpSessions.remove(idp); } } MOASessionDBUtils.saveOrUpdate(authsession); return true; } catch (Throwable e) { Logger.warn("MOASession deserialization-exception by using MOASessionID=" + pedingRequestID); return false; } }
From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java
License:EUPL
@SuppressWarnings("rawtypes") private static AuthenticatedSessionStore searchInDatabase(String sessionID, boolean commit) throws MOADatabaseException { MiscUtil.assertNotNull(sessionID, "moasessionID"); Logger.trace("Get authenticated session with sessionID " + sessionID + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List result;/*w w w . j a v a2 s . c o m*/ synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getSessionWithID"); query.setParameter("sessionid", sessionID); result = query.list(); //send transaction if (commit) session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() != 1) { Logger.trace("No entries found."); throw new MOADatabaseException("No session found with this sessionID"); } return (AuthenticatedSessionStore) result.get(0); }
From source file:at.gv.egovernment.moa.id.storage.DBExceptionStoreImpl.java
License:EUPL
@SuppressWarnings("rawtypes") private ExceptionStore searchInDatabase(String id) throws MOADatabaseException { MiscUtil.assertNotNull(id, "exceptionID"); Logger.trace("Getting Exception with ID " + id + " from database."); Session session = MOASessionDBUtils.getCurrentSession(); List result;//from w w w . j a v a 2s. c o m synchronized (session) { session.beginTransaction(); Query query = session.getNamedQuery("getExceptionWithID"); query.setParameter("id", id); result = query.list(); //send transaction session.getTransaction().commit(); } Logger.trace("Found entries: " + result.size()); //Assertion requires an unique artifact if (result.size() != 1) { Logger.trace("No entries found."); throw new MOADatabaseException("No Exception found with ID " + id); } return (ExceptionStore) result.get(0); }