/
akolonin
/
aigents-java
Обзор
Документация
Войти
/
akolonin
/
aigents-java
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/net/webstructor/mine/auth/AdmServer.java
60 строк
2 KB
Anton Kolonin
Manually merging changes as suggested by https://github.com/rssdev10/aigents-java/commit/aee40c39eacd2279bc562e224d2d24c4ff7d98c0
03 янв 2019, 17:27
03 янв 2019, 17:27
d436abd
Код
Авторство
О чём код?
/* * Copyright 2005-2008, Anton Kolonin, * All rights reserved. * * This software is proprietary information belonging to Anton Kolonin. * You shall not disclose this and shall not use it in any way * without of written permission granted by Anton Kolonin. */ package net.webstructor.mine.auth; import java.util.HashMap; import net.webstructor.mine.util.StringContext; import net.webstructor.mine.store.Storage; import net.webstructor.mine.store.SimpleMemoryStorage; public class AdmServer { private static AdmServer m_instance = null; private HashMap m_sessions = new HashMap(); public static AdmServer getInstance(String path){ if (m_instance == null) m_instance = new AdmServer(path); return m_instance; } String m_path; Storage m_storage = null; public AdmServer(String path){ m_path = path; } //TODO synchronize public String createSession(String username,String password,StringContext stringContext){ if (m_storage == null) { try { m_storage = new SimpleMemoryStorage(); m_storage.startUp(m_path,new StoreSchema()); } catch (Exception e) { return e.toString(); } } //TODO check username and password AuthSession sess = new AuthSession( this, new AdmSession(this,stringContext), stringContext); Integer id = sess.getId(); m_sessions.put(id,sess); return id.toString(); } //TODO synchronize public AuthSession getSession(String sessionid){ Integer id = Integer.valueOf(sessionid); return (AuthSession)m_sessions.get(id); } }