/******************************************************************************* * Copyright 2014 Federal Chancellery Austria * MOA-ID has been developed in a cooperation between BRZ, the Federal * Chancellery Austria - ICT staff unit, and Graz University of Technology. * * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * http://www.osor.eu/eupl/ * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. *******************************************************************************/ package at.gv.egovernment.moa.id.storage; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import org.apache.commons.lang.SerializationUtils; import org.apache.commons.lang.StringEscapeUtils; import org.hibernate.HibernateException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.core.JsonProcessingException; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.idp.slo.SLOInformationInterface; import at.gv.egiz.eaaf.core.exceptions.EAAFConfigurationException; import at.gv.egiz.eaaf.core.impl.utils.Random; import at.gv.egiz.eaaf.modules.pvp2.sp.exception.AssertionAttributeExtractorExeption; import at.gv.egiz.eaaf.modules.pvp2.sp.impl.utils.AssertionAttributeExtractor; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.data.AuthenticationSessionExtensions; import at.gv.egovernment.moa.id.auth.data.AuthenticationSessionWrapper; import at.gv.egovernment.moa.id.auth.exception.AuthenticationException; import at.gv.egovernment.moa.id.auth.exception.BuildException; import at.gv.egovernment.moa.id.commons.api.AuthConfiguration; import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters; import at.gv.egovernment.moa.id.commons.api.data.IAuthenticationSession; import at.gv.egovernment.moa.id.commons.db.dao.session.AuthenticatedSessionStore; import at.gv.egovernment.moa.id.commons.db.dao.session.InterfederationSessionStore; import at.gv.egovernment.moa.id.commons.db.dao.session.OASessionStore; import at.gv.egovernment.moa.id.commons.db.dao.session.OldSSOSessionIDStore; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.commons.utils.JsonMapper; import at.gv.egovernment.moa.id.config.auth.OAAuthParameterDecorator; import at.gv.egovernment.moa.id.data.EncryptedData; import at.gv.egovernment.moa.id.util.SessionEncrytionUtil; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.MiscUtil; @Repository("AuthenticationSessionStoreage") @Transactional("sessionTransactionManager") public class DBAuthenticationSessionStoreage implements IAuthenticationSessionStoreage{ @PersistenceContext(unitName="session") private EntityManager entityManager; @Autowired AuthConfiguration authConfig; private static JsonMapper mapper = new JsonMapper(); @Override public AuthenticationSession createInternalSSOSession(IRequest target) throws MOADatabaseException, BuildException { String id = Random.nextLongRandom(); try { AuthenticatedSessionStore dbsession = new AuthenticatedSessionStore(); dbsession.setSessionid(id); //set Timestamp in this state, because automated timestamp generation is buggy in Hibernate 4.2.1 Date now = new Date(); dbsession.setCreated(now); dbsession.setUpdated(now); //set additional session informations AuthenticationSessionExtensions sessionExt = new AuthenticationSessionExtensions(); sessionExt.setUniqueSessionId(target.getUniqueSessionIdentifier()); dbsession.setAdditionalInformationBytes(mapper.serialize(sessionExt).getBytes("UTF-8")); AuthenticationSession session = new AuthenticationSession(id, now, (IAuthenticationSession)target.getSessionData(AuthenticationSessionWrapper.class)); encryptSession(session, dbsession); //store AssertionStore element to Database entityManager.persist(dbsession); Logger.info("Create MOA SSO-Session with internal sessionID: " + id); return session; // } catch (MOADatabaseException e) { // Logger.warn("MOASession could not be created."); // throw new MOADatabaseException(e); } catch (JsonProcessingException | UnsupportedEncodingException e) { Logger.warn("Extended session information can not be stored.", e); throw new MOADatabaseException("Extended session information can not be stored.", e); } } @Override public AuthenticationSession getInternalSSOSession(String sessionID) throws MOADatabaseException { if (MiscUtil.isEmpty(sessionID)) return null; try { AuthenticatedSessionStore dbsession = searchInDatabase(sessionID); return decryptSession(dbsession); } catch (MOADatabaseException e) { Logger.info("No MOA Session with id: " + sessionID); return null; } catch (Throwable e) { Logger.warn("MOASession deserialization-exception by using MOASessionID=" + sessionID, e); throw new MOADatabaseException("MOASession deserialization-exception"); } } @Override public AuthenticationSessionExtensions getAuthenticationSessionExtensions(String sessionID) throws MOADatabaseException { AuthenticatedSessionStore dbsession = searchInDatabase(sessionID); if (dbsession.getAdditionalInformationBytes() != null) { try { return (AuthenticationSessionExtensions)mapper.deserialize(new String(dbsession.getAdditionalInformationBytes(), "UTF-8"), AuthenticationSessionExtensions.class); } catch (Exception e) { Logger.warn("Extended session information extraction FAILED!", e); } } return null; } @Override public void setAuthenticationSessionExtensions(String sessionID, AuthenticationSessionExtensions sessionExtensions) throws MOADatabaseException { try { AuthenticatedSessionStore dbsession = searchInDatabase(sessionID); dbsession.setAdditionalInformationBytes( mapper.serialize(sessionExtensions).getBytes("UTF-8")); entityManager.merge(dbsession); Logger.debug("MOASession with sessionID=" + sessionID + " is stored in Database"); } catch (MOADatabaseException e) { Logger.warn("MOASession could not be stored."); throw new MOADatabaseException("MOASession could not be stored.", e); } catch (JsonProcessingException | UnsupportedEncodingException e) { Logger.warn("Extended session information can not be stored.", e); throw new MOADatabaseException("Extended session information can not be stored.", e); } } @Override public void destroyInternalSSOSession(String internalSsoSessionID) throws MOADatabaseException { Query query = entityManager.createNamedQuery("getSessionWithID"); query.setParameter("sessionid", internalSsoSessionID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() != 1) { Logger.trace("No entries found."); throw new MOADatabaseException("No session found with this sessionID"); } AuthenticatedSessionStore dbsession = (AuthenticatedSessionStore) results.get(0); cleanDelete(dbsession); } @Override public void setAuthenticated(String moaSessionID, boolean isAuthenticated) { AuthenticatedSessionStore session; try { session = searchInDatabase(moaSessionID); session.setAuthenticated(isAuthenticated); entityManager.merge(session); } catch (MOADatabaseException e) { Logger.warn("isAuthenticated can not be stored in MOASession " + moaSessionID, e); } } @Override public String getInternalSSOSessionWithSSOID(String externelSSOId) throws MOADatabaseException { MiscUtil.assertNotNull(externelSSOId, "SSOsessionID"); Logger.trace("Get authenticated session with SSOID " + externelSSOId + " from database."); Query query = entityManager.createNamedQuery("getSessionWithSSOID"); query.setParameter("sessionid", externelSSOId); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() != 1) { Logger.trace("No entries found."); return null; } else try { return decryptSession(results.get(0)).getSSOSessionID(); } catch (Throwable e) { Logger.warn("MOASession deserialization-exception by using internal MOASessionID=" + results.get(0).getSessionid(), e); throw new MOADatabaseException("MOASession deserialization-exception"); } } @Override public boolean isSSOSession(String sessionID) throws MOADatabaseException { try { AuthenticatedSessionStore dbsession = searchInDatabase(sessionID); return dbsession.isSSOSession(); } catch (MOADatabaseException e) { Logger.info("No MOA Session with id: " + sessionID); throw new MOADatabaseException("No MOA Session with id: " + sessionID); } } @Override public AuthenticatedSessionStore isValidSessionWithSSOID(String SSOId) { //TODO: is this method really needed?? MiscUtil.assertNotNull(SSOId, "SSOSessionID"); Logger.trace("Get authenticated session with SSOID " + SSOId + " from database."); Query query = entityManager.createNamedQuery("getSessionWithSSOID"); query.setParameter("sessionid", SSOId); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() != 1) { Logger.trace("No entries found."); return null; } else return results.get(0); } @Override public void addSSOInformation(String internalSSOSessionID, String externalSSOSessionID, SLOInformationInterface SLOInfo, IRequest protocolRequest) throws AuthenticationException { Query query = entityManager.createNamedQuery("getSessionWithID"); query.setParameter("sessionid", internalSSOSessionID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() != 1) { Logger.trace("No entries found."); throw new AuthenticationException("No session found with this sessionID", null); } AuthenticatedSessionStore dbsession = results.get(0); OASessionStore activeOA = null; //check if OA already has an active OA session if (dbsession.getActiveOAsessions() != null) { for (OASessionStore el : dbsession.getActiveOAsessions()) { if (el.getOaurlprefix().equals(protocolRequest.getSPEntityId())) activeOA = el; } } if (activeOA == null) activeOA = new OASessionStore(); //set active OA applications activeOA.setOaurlprefix(protocolRequest.getSPEntityId()); activeOA.setMoasession(dbsession); activeOA.setCreated(new Date()); //set additional information for SLO if (SLOInfo != null) { activeOA.setAssertionSessionID(SLOInfo.getSessionIndex()); activeOA.setUserNameID(SLOInfo.getUserNameIdentifier()); activeOA.setUserNameIDFormat(SLOInfo.getUserNameIDFormat()); activeOA.setProtocolType(SLOInfo.getProtocolType()); activeOA.setAttributeQueryUsed(false); activeOA.setAuthURL(protocolRequest.getAuthURL()); } List activeOAs = dbsession.getActiveOAsessions(); activeOAs.add(activeOA); dbsession.setActiveOAsessions(activeOAs); //Store used SSOId if (dbsession.getSSOsessionid() != null) { OldSSOSessionIDStore oldSSOId = new OldSSOSessionIDStore(); oldSSOId.setOldsessionid(dbsession.getSSOsessionid()); oldSSOId.setMoasession(dbsession); List oldSSOIds = dbsession.getOldssosessionids(); oldSSOIds.add(oldSSOId); } dbsession.setSSOSession(true); dbsession.setSSOsessionid(externalSSOSessionID); dbsession.setAuthenticated(true); //Store MOASession entityManager.merge(dbsession); if (SLOInfo != null) Logger.info("Add SSO-Session login information for OA: " + protocolRequest.getSPEntityId() + " and AssertionID: " + SLOInfo.getSessionIndex()); else Logger.info("Add SSO-Session login information for OA: " + protocolRequest.getSPEntityId()); } @Override public List getAllActiveOAFromMOASession(String ssoSessionId) { MiscUtil.assertNotNull( ssoSessionId, "MOASession"); Logger.trace("Get OAs for moaSession " + ssoSessionId + " from database."); Query query = entityManager.createNamedQuery("getAllActiveOAsForSessionID"); query.setParameter("sessionID", ssoSessionId); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); return results; } @Override public List getAllActiveIDPsFromMOASession(String ssoSessionId) { MiscUtil.assertNotNull( ssoSessionId, "MOASession"); Logger.trace("Get active IDPs for moaSession " + ssoSessionId + " from database."); Query query = entityManager.createNamedQuery("getAllActiveIDPsForSessionID"); query.setParameter("sessionID", ssoSessionId); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); return results; } @Override public String searchSSOSessionWithNameIDandOAID(String oaID, String userNameID) { MiscUtil.assertNotNull(oaID, "OnlineApplicationIdentifier"); MiscUtil.assertNotNull(userNameID, "userNameID"); Logger.trace("Get moaSession for userNameID " + userNameID + " and OA " + oaID + " from database."); Query query = entityManager.createNamedQuery("getMOASessionWithNameIDandOAID"); query.setParameter("oaID", oaID); query.setParameter("nameID", userNameID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() != 1) { Logger.trace("No unique entry found."); return null; } try { AuthenticationSession decrytedSession = decryptSession(results.get(0)); return decrytedSession.getSSOSessionID(); } catch (BuildException e) { Logger.warn("MOASession deserialization-exception by using MOASessionID=" + results.get(0).getSessionid(), e); return null; } } @Override public OASessionStore searchActiveOASSOSession(IAuthenticationSession moaSession, String oaID, String protocolType) { MiscUtil.assertNotNull(moaSession, "MOASession"); MiscUtil.assertNotNull(oaID, "OnlineApplicationIdentifier"); MiscUtil.assertNotNull(protocolType, "usedProtocol"); Logger.trace("Get active OnlineApplication for sessionID " + moaSession.getSSOSessionID() + " with OAID " + oaID + " from database."); Query query = entityManager.createNamedQuery("getActiveOAWithSessionIDandOAIDandProtocol"); query.setParameter("sessionID", moaSession.getSSOSessionID()); query.setParameter("oaID", oaID); query.setParameter("protocol", protocolType); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() == 0) { Logger.trace("No entries found."); return null; } return results.get(0).getActiveOAsessions().get(0); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.storage.IAuthenticationSessionStoreage#markOAWithAttributeQueryUsedFlag(at.gv.egovernment.moa.id.auth.data.AuthenticationSession, java.lang.String, java.lang.String) */ @Override public void markOAWithAttributeQueryUsedFlag(IAuthenticationSession session, String oaurl, String requestedModule) { OASessionStore activeOA = searchActiveOASSOSession(session, oaurl, requestedModule); if (activeOA != null) { activeOA.setAttributeQueryUsed(true); entityManager.merge(activeOA); } } @Override public IAuthenticationSession getSessionWithUserNameID(String nameID) { MiscUtil.assertNotNull(nameID, "nameID"); Logger.trace("Get authenticated session with pedingRequestID " + nameID + " from database."); Query query = entityManager.createNamedQuery("getMOAISessionWithUserNameID"); query.setParameter("usernameid", StringEscapeUtils.escapeHtml(nameID)); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() == 0) { Logger.trace("No entries found."); return null; } try { return decryptSession(results.get(0)); } catch (Throwable e) { Logger.warn("MOASession deserialization-exception by using MOASessionID=" + nameID); return null; } } @Override public InterfederationSessionStore searchInterfederatedIDPFORSSOWithMOASession(String sessionID) { MiscUtil.assertNotNull(sessionID, "MOASession"); Logger.trace("Get interfederated IDP for SSO with sessionID " + sessionID + " from database."); Query query = entityManager.createNamedQuery("getInterfederatedIDPForSSOWithSessionID"); query.setParameter("sessionID", sessionID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() == 0) { Logger.trace("No entries found."); return null; } return results.get(0).getInderfederation().get(0); } @Override public InterfederationSessionStore searchInterfederatedIDPFORSSOWithMOASessionIDPID(String sessionID, String idpID) { MiscUtil.assertNotNull(sessionID, "MOASession"); MiscUtil.assertNotNull(idpID, "Interfederated IDP ID"); Logger.trace("Get interfederated IDP "+ idpID + " for SSO with sessionID " + sessionID + " from database."); Query query = entityManager.createNamedQuery("getInterfederatedIDPForSSOWithSessionIDIDPID"); query.setParameter("sessionID", sessionID); query.setParameter("idpID", idpID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() == 0) { Logger.trace("No entries found."); return null; } return results.get(0).getInderfederation().get(0); } @Override public void addFederatedSessionInformation(IRequest req, String idpEntityID, AssertionAttributeExtractor extractor) throws MOADatabaseException, AssertionAttributeExtractorExeption, BuildException, EAAFConfigurationException { AuthenticatedSessionStore dbsession = null; String internalSSOSessionId = null; Date now = new Date(); //search for active session if (MiscUtil.isNotEmpty(req.getInternalSSOSessionIdentifier())) { Logger.debug("Internal SSO-Session object: " + req.getInternalSSOSessionIdentifier() + " used for federated SSO"); internalSSOSessionId = req.getInternalSSOSessionIdentifier(); } else { Logger.debug("No internal SSO-Session object exists for federated SSO --> create new session object"); internalSSOSessionId = createInternalSSOSession(req).getSSOSessionID(); } if (MiscUtil.isNotEmpty(internalSSOSessionId)) { try { dbsession = searchInDatabase(internalSSOSessionId); }catch (MOADatabaseException e) { Logger.error("NO MOASession found but MOASession MUST already exist!"); throw e; } } else { Logger.error("NO MOASession found but MOASession MUST already exist!"); throw new MOADatabaseException("NO MOASession found but MOASession MUST already exist!"); } dbsession.setUpdated(now); //decrypt MOASession AuthenticationSession session = decryptSession(dbsession); //federated Session are never authenticated locally, // because they get always authentication information from federated IDP session.setAuthenticated(false); dbsession.setAuthenticated(false); //encrypt MOASession encryptSession(session, dbsession); //mark as federated SSO session dbsession.setInterfederatedSSOSession(true); //add interfederation information List idpList = dbsession.getInderfederation(); //check if federated IDP is already stored InterfederationSessionStore idp = null; if (idpList == null) { idpList = new ArrayList(); dbsession.setInderfederation(idpList); } else { for (InterfederationSessionStore el : idpList) { //resue old entry if interfederation IDP is reused for authentication if (el.getIdpurlprefix().equals(idpEntityID)) idp = el; } } //create new interfederation IDP entry if (idp == null) { idp = new InterfederationSessionStore(); idp.setCreated(now); idp.setIdpurlprefix(idpEntityID); idp.setAuthURL(req.getAuthURL()); IOAAuthParameters oa = authConfig.getServiceProviderConfiguration(idp.getIdpurlprefix(), OAAuthParameterDecorator.class); idp.setStoreSSOInformation(oa.isInterfederationSSOStorageAllowed()); idp.setMoasession(dbsession); idpList.add(idp); } idp.setSessionIndex(extractor.getSessionIndex()); idp.setUserNameID(extractor.getNameID()); idp.setAttributesRequested(false); idp.setQAALevel(extractor.getQAALevel()); entityManager.merge(dbsession); } @Override public InterfederationSessionStore searchInterfederatedIDPFORAttributeQueryWithSessionID(String moaSessionID) { MiscUtil.assertNotNull(moaSessionID, "MOASessionID"); Logger.trace("Get interfederated IDP for AttributeQuery with sessionID " + moaSessionID + " from database."); Query query = entityManager.createNamedQuery("getInterfederatedIDPForAttributeQueryWithSessionID"); query.setParameter("sessionID", moaSessionID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() == 0) { Logger.trace("No entries found."); return null; } return results.get(0).getInderfederation().get(0); } @Override public 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."); Query query = entityManager.createNamedQuery("getSessionWithPendingRequestID"); query.setParameter("sessionid", pedingRequestID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() != 1) { Logger.trace("No entries found."); return false; } AuthenticatedSessionStore authsession = results.get(0); List idpSessions = authsession.getInderfederation(); if (idpSessions != null) { for (InterfederationSessionStore idp : idpSessions) { if (idp.getIdpurlprefix().equals(entityID)) idpSessions.remove(idp); } } entityManager.merge(authsession); return true; } catch (Throwable e) { Logger.warn("MOASession deserialization-exception by using MOASessionID=" + pedingRequestID); return false; } } @Override public void clean(Date now, long authDataTimeOutCreated, long authDataTimeOutUpdated) { Date expioredatecreate = new Date(now.getTime() - authDataTimeOutCreated); Date expioredateupdate = new Date(now.getTime() - authDataTimeOutUpdated); Query query = entityManager.createNamedQuery("getMOAISessionsWithTimeOut"); query.setParameter("timeoutcreate", expioredatecreate); query.setParameter("timeoutupdate", expioredateupdate); List results = query.getResultList(); if (results.size() != 0) { for(AuthenticatedSessionStore result : results) { try { cleanDelete(result); Logger.info("Authenticated session with sessionID=" + result.getSessionid() + " after session timeout."); } catch (HibernateException e){ Logger.warn("Authenticated session with sessionID=" + result.getSessionid() + " not removed after timeout! (Error during Database communication)", e); } } } } private static void encryptSession(AuthenticationSession session, AuthenticatedSessionStore dbsession) throws BuildException { byte[] serialized = SerializationUtils.serialize(session); EncryptedData encdata = SessionEncrytionUtil.getInstance().encrypt(serialized); dbsession.setSession(encdata.getEncData()); dbsession.setIv(encdata.getIv()); } private static AuthenticationSession decryptSession(AuthenticatedSessionStore dbsession) throws BuildException { EncryptedData encdata = new EncryptedData(dbsession.getSession(), dbsession.getIv()); byte[] decrypted = SessionEncrytionUtil.getInstance().decrypt(encdata); return (AuthenticationSession) SerializationUtils.deserialize(decrypted); } private void cleanDelete(AuthenticatedSessionStore result) { result.setSession("blank".getBytes()); entityManager.merge(result); entityManager.remove(result); } @SuppressWarnings("rawtypes") private AuthenticatedSessionStore searchInDatabase(String sessionID) throws MOADatabaseException { MiscUtil.assertNotNull(sessionID, "moasessionID"); Logger.trace("Get authenticated session with sessionID " + sessionID + " from database."); Query query = entityManager.createNamedQuery("getSessionWithID"); query.setParameter("sessionid", sessionID); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); //Assertion requires an unique artifact if (results.size() != 1) { Logger.trace("No entries found."); throw new MOADatabaseException("No session found with this sessionID"); } return (AuthenticatedSessionStore) results.get(0); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.storage.IAuthenticationSessionStoreage#deleteIdpInformation(at.gv.egovernment.moa.id.commons.db.dao.session.InterfederationSessionStore) */ @Override public void deleteIdpInformation(InterfederationSessionStore nextIDPInformation) { entityManager.remove(nextIDPInformation); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.storage.IAuthenticationSessionStoreage#persistIdpInformation(at.gv.egovernment.moa.id.commons.db.dao.session.InterfederationSessionStore) */ @Override public void persistIdpInformation(InterfederationSessionStore nextIDPInformation) { entityManager.merge(nextIDPInformation); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.storage.IAuthenticationSessionStoreage#checkSSOTokenAlreadyUsed(java.lang.String) */ @Override public OldSSOSessionIDStore checkSSOTokenAlreadyUsed(String ssoId) { Query query = entityManager.createNamedQuery("getSSOSessionWithOldSessionID"); query.setParameter("sessionid", ssoId); List results = query.getResultList(); Logger.trace("Found entries: " + results.size()); // Assertion requires an unique artifact if (results.size() == 0) { return null; } return results.get(0); } }