public SPlatformSessionImpl(final SPlatformSession session) { id = session.getId(); creationDate = session.getCreationDate(); duration = session.getDuration(); lastRenewDate = session.getLastRenewDate(); userName = session.getUserName(); userId = session.getUserId(); }
@Override public synchronized void addSession(final SPlatformSession session) throws SSessionAlreadyExistsException { final long id = session.getId(); if (platformSessions.containsKey(id)) { throw new SSessionAlreadyExistsException("A session wih id \"" + id + "\" already exists"); } platformSessions.put(id, session); }
public PlatformSession login() throws PlatformLoginException { try { PlatformServiceAccessor platformAccessor = ServiceAccessorFactory.getInstance().createPlatformServiceAccessor(); final PlatformSessionService platformSessionService = platformAccessor.getPlatformSessionService(); SPlatformSession platformSession = platformSessionService.createSession("local"); final Date creationDate = platformSession.getCreationDate(); return new PlatformSessionImpl(platformSession.getId(), creationDate, platformSession.getDuration(), "local", platformSession.getUserId()); } catch (final Exception e) { throw new PlatformLoginException(e); } } }
@Override public boolean isValid(final long sessionId) throws SSessionNotFoundException { if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), "isValid")); } final SPlatformSession session = platformSessionProvider.getSession(sessionId); final Date now = new Date(); if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), "isValid")); } return session.getExpirationDate().after(now); }
public PlatformSession login() throws PlatformLoginException { try { PlatformServiceAccessor platformAccessor = ServiceAccessorFactory.getInstance().createPlatformServiceAccessor(); final PlatformSessionService platformSessionService = platformAccessor.getPlatformSessionService(); SPlatformSession platformSession = platformSessionService.createSession("local"); final Date creationDate = platformSession.getCreationDate(); return new PlatformSessionImpl(platformSession.getId(), creationDate, platformSession.getDuration(), "local", platformSession.getUserId()); } catch (final Exception e) { throw new PlatformLoginException(e); } } }
public SPlatformSessionImpl(final SPlatformSession session) { id = session.getId(); creationDate = session.getCreationDate(); duration = session.getDuration(); lastRenewDate = session.getLastRenewDate(); userName = session.getUserName(); userId = session.getUserId(); }
@Override public void updateSession(final SPlatformSession session) throws SSessionNotFoundException { final long id = session.getId(); if (!platformSessions.containsKey(id)) { throw new SSessionNotFoundException("No session found with id \"" + id + "\""); } platformSessions.put(id, session); }
@Override public boolean isValid(final long sessionId) throws SSessionNotFoundException { if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogBeforeMethod(this.getClass(), "isValid")); } final SPlatformSession session = platformSessionProvider.getSession(sessionId); final Date now = new Date(); if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) { logger.log(this.getClass(), TechnicalLogSeverity.TRACE, LogUtil.getLogAfterMethod(this.getClass(), "isValid")); } return session.getExpirationDate().after(now); }
@Override @CustomTransactions @AvailableOnStoppedNode public PlatformSession login(final String userName, final String password) throws PlatformLoginException { PlatformServiceAccessor platformAccessor; try { platformAccessor = ServiceAccessorFactory.getInstance().createPlatformServiceAccessor(); } catch (final Exception e) { e.printStackTrace();// no logger available yet throw new PlatformLoginException(e.getMessage()); } final PlatformLoginService platformLoginService = platformAccessor.getPlatformLoginService(); // PlatformService platformService = platformAccessor.getPlatformService(); // TO UNCOMMENT lvaills // first call before create session: put the platform in cache if necessary // putPlatformInCacheIfNecessary(platformAccessor, platformService); // TO UNCOMMENT lvaills final SPlatformSession platformSession; try { platformSession = platformLoginService.login(userName, password); } catch (SPlatformLoginException e) { throw new PlatformLoginException(e); } catch (SInvalidPlatformCredentialsException ignored) { throw new InvalidPlatformCredentialsException("Wrong username of password"); } final long id = platformSession.getId(); final Date creationDate = platformSession.getCreationDate(); final long duration = platformSession.getDuration(); final long userId = platformSession.getUserId(); return new PlatformSessionImpl(id, creationDate, duration, userName, userId); }
@Override public void updateSession(final SPlatformSession session) throws SSessionNotFoundException { final long id = session.getId(); if (!platformSessions.containsKey(id)) { throw new SSessionNotFoundException("No session found with id \"" + id + "\""); } platformSessions.put(id, session); }
@Override @CustomTransactions @AvailableOnStoppedNode public PlatformSession login(final String userName, final String password) throws PlatformLoginException { PlatformServiceAccessor platformAccessor; try { platformAccessor = ServiceAccessorFactory.getInstance().createPlatformServiceAccessor(); } catch (final Exception e) { e.printStackTrace();// no logger available yet throw new PlatformLoginException(e.getMessage()); } final PlatformLoginService platformLoginService = platformAccessor.getPlatformLoginService(); // PlatformService platformService = platformAccessor.getPlatformService(); // TO UNCOMMENT lvaills // first call before create session: put the platform in cache if necessary // putPlatformInCacheIfNecessary(platformAccessor, platformService); // TO UNCOMMENT lvaills final SPlatformSession platformSession; try { platformSession = platformLoginService.login(userName, password); } catch (SPlatformLoginException e) { throw new PlatformLoginException(e); } catch (SInvalidPlatformCredentialsException ignored) { throw new InvalidPlatformCredentialsException("Wrong username of password"); } final long id = platformSession.getId(); final Date creationDate = platformSession.getCreationDate(); final long duration = platformSession.getDuration(); final long userId = platformSession.getUserId(); return new PlatformSessionImpl(id, creationDate, duration, userName, userId); }
@Override public synchronized void addSession(final SPlatformSession session) throws SSessionAlreadyExistsException { final long id = session.getId(); if (platformSessions.containsKey(id)) { throw new SSessionAlreadyExistsException("A session wih id \"" + id + "\" already exists"); } platformSessions.put(id, session); }
private long createPlatformSession(final PlatformSessionService platformSessionService, final SessionAccessor sessionAccessor) throws SSessionException { final SPlatformSession createSession = platformSessionService.createSession("SYSTEM"); final long sessionId = createSession.getId(); sessionAccessor.setSessionInfo(sessionId, -1); return sessionId; }
private long createPlatformSession(final PlatformSessionService platformSessionService, final SessionAccessor sessionAccessor) throws SSessionException { final SPlatformSession createSession = platformSessionService.createSession("SYSTEM"); final long sessionId = createSession.getId(); sessionAccessor.setSessionInfo(sessionId, -1); return sessionId; }
@Override public void contextInitialized(final ServletContextEvent sce) { try { PlatformServiceAccessor platformAccessor = getPlatformAccessor(); final SessionAccessor sessionAccessor = ServiceAccessorFactory.getInstance().createSessionAccessor(); PlatformSessionService platformSessionService = platformAccessor.getPlatformSessionService(); SPlatformSession createSession = platformSessionService.createSession("john"); sessionAccessor.setSessionInfo(createSession.getId(), -1); PlatformAPIImpl platformAPI = new PlatformAPIImpl(); if (platformAPI.isPlatformCreated()) { platformAPI.startNode(); } platformSessionService.deleteSession(createSession.getId()); sessionAccessor.deleteSessionId(); } catch (final Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }
@Override public void contextInitialized(final ServletContextEvent sce) { try { PlatformServiceAccessor platformAccessor = getPlatformAccessor(); final SessionAccessor sessionAccessor = ServiceAccessorFactory.getInstance().createSessionAccessor(); PlatformSessionService platformSessionService = platformAccessor.getPlatformSessionService(); SPlatformSession createSession = platformSessionService.createSession("john"); sessionAccessor.setSessionInfo(createSession.getId(), -1); PlatformAPIImpl platformAPI = new PlatformAPIImpl(); if (platformAPI.isPlatformCreated()) { platformAPI.startNode(); } platformSessionService.deleteSession(createSession.getId()); sessionAccessor.deleteSessionId(); } catch (final Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }