/
akolonin
/
aigents-java
Обзор
Документация
Войти
/
akolonin
/
aigents-java
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/net/webstructor/mine/auth/AuthSession.java
92 строки
3 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 net.webstructor.mine.core.CoreRelation; import net.webstructor.mine.inf.InfSession; import net.webstructor.mine.util.StringUtil; import net.webstructor.mine.util.StringContext; public class AuthSession { AdmServer m_server; AdmSession m_admSession; InfSession m_infSession = null; // no access by default StringContext m_stringContext; public AuthSession(AdmServer server,AdmSession admSession,StringContext stringContext){ m_server = server; m_admSession = admSession; m_stringContext = stringContext; } public Integer getId(){ return new Integer(0); //return Integer(hashCode()); } public String logout(){ //TODO destroy session return getId().toString(); } public String commit() throws Exception { m_server.m_storage.commit(); if (this.m_infSession != null) this.m_infSession.commit(); return getId().toString(); } public String getAssets() throws Exception { //TODO list assets available in auth db and accessible by user return StringUtil.toString(m_server.m_storage.getRels(StoreSchema.Asset),m_stringContext); } public String setAsset(String[] args) throws Exception { if (args.length<3) throw new Exception("Invalid assetid"); CoreRelation asset = m_server.m_storage.getRel(Integer.parseInt(args[2])); if (asset != null) { if (this.m_infSession != null) this.m_infSession.close(); String path = m_server.m_storage.getName(asset.getId(),StoreSchema.AssetPath); if (path != null) { m_infSession = new InfSession(path,m_stringContext); return path; //return args[2]; } } return null; } public AdmSession getAdmSession(){ return m_admSession; } public InfSession getInfSession(){ return m_infSession; } public String handle(String[] args) throws Exception { String result = null; if (m_infSession != null) result = m_infSession.handle(args); if (result == null && m_admSession != null) result = m_admSession.handle(args); if (result == null) { if (args[0].equalsIgnoreCase("logout")) result = logout(); else if (args[0].equalsIgnoreCase("getassets")) //getassets;<sessionid> => <assetid>;<assetname> * (all visible assets) result = getAssets(); else if (args[0].equalsIgnoreCase("setasset")) //o setasset;<sessionid>;<assetid> => <assetid> (set current asset for session) result = setAsset(args); else if (args[0].equalsIgnoreCase("commit")) { // commit auth DB only //o commit; <sessionid> => <sessionid> result = commit(); } } return result; } }