use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.
the class ProfileSystemsKtrl method viewProfileSystems.
@Kontrol(path = "/manage/viewProfileSystems", method = MethodType.GET)
public String viewProfileSystems() throws ServletException {
if (profile != null && profile.getId() != null) {
try {
profile = ProfileDB.getProfile(profile.getId());
sortedSet = SystemDB.getSystemSet(sortedSet, profile.getId());
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toString(), ex);
throw new ServletException(ex.toString(), ex);
}
}
return "/manage/view_profile_systems.html";
}
use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.
the class SecureShellKtrl method createTerms.
/**
* creates composite terminals if there are errors or authentication issues.
*/
@Kontrol(path = "/admin/createTerms", method = MethodType.POST)
public String createTerms() throws ServletException {
try {
Long userId = AuthUtil.getUserId(getRequest().getSession());
Long sessionId = AuthUtil.getSessionId(getRequest().getSession());
if (pendingSystemStatus != null && pendingSystemStatus.getId() != null) {
// get status
currentSystemStatus = SystemStatusDB.getSystemStatus(pendingSystemStatus.getId(), userId);
// if initial status run script
if (currentSystemStatus != null && (HostSystem.INITIAL_STATUS.equals(currentSystemStatus.getStatusCd()) || HostSystem.AUTH_FAIL_STATUS.equals(currentSystemStatus.getStatusCd()) || HostSystem.PUBLIC_KEY_FAIL_STATUS.equals(currentSystemStatus.getStatusCd()))) {
// set current session
currentSystemStatus = SSHUtil.openSSHTermOnSystem(passphrase, password, userId, sessionId, currentSystemStatus, userSchSessionMap);
}
if (currentSystemStatus != null && (HostSystem.AUTH_FAIL_STATUS.equals(currentSystemStatus.getStatusCd()) || HostSystem.PUBLIC_KEY_FAIL_STATUS.equals(currentSystemStatus.getStatusCd()))) {
pendingSystemStatus = currentSystemStatus;
} else {
pendingSystemStatus = SystemStatusDB.getNextPendingSystem(userId);
// if success loop through systems until finished or need password
while (pendingSystemStatus != null && currentSystemStatus != null && HostSystem.SUCCESS_STATUS.equals(currentSystemStatus.getStatusCd())) {
currentSystemStatus = SSHUtil.openSSHTermOnSystem(passphrase, password, userId, sessionId, pendingSystemStatus, userSchSessionMap);
pendingSystemStatus = SystemStatusDB.getNextPendingSystem(userId);
}
}
}
// set system list if no pending systems
if (SystemStatusDB.getNextPendingSystem(userId) == null) {
setSystemList(userId, sessionId);
// set allocated systems for connect to
SortedSet sortedSet = new SortedSet();
sortedSet.setOrderByField(SystemDB.SORT_BY_NAME);
if (Auth.MANAGER.equals(AuthUtil.getUserType(getRequest().getSession()))) {
sortedSet = SystemDB.getSystemSet(sortedSet);
} else {
sortedSet = SystemDB.getUserSystemSet(sortedSet, userId);
}
if (sortedSet.getItemList() != null) {
allocatedSystemList = (List<HostSystem>) sortedSet.getItemList();
}
// set theme
this.userSettings = UserThemeDB.getTheme(userId);
}
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toString(), ex);
throw new ServletException(ex.toString(), ex);
}
return "/admin/secure_shell.html";
}
use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.
the class SecureShellKtrl method setPtyType.
@Kontrol(path = "/admin/setPtyType", method = MethodType.GET)
public String setPtyType() throws ServletException {
Long sessionId = null;
try {
sessionId = AuthUtil.getSessionId(getRequest().getSession());
} catch (GeneralSecurityException ex) {
log.error(ex.toString(), ex);
throw new ServletException(ex.toString(), ex);
}
if (SecureShellKtrl.getUserSchSessionMap() != null) {
UserSchSessions userSchSessions = SecureShellKtrl.getUserSchSessionMap().get(sessionId);
if (userSchSessions != null && userSchSessions.getSchSessionMap() != null) {
SchSession schSession = userSchSessions.getSchSessionMap().get(id);
ChannelShell channel = (ChannelShell) schSession.getChannel();
channel.setPtySize((int) Math.floor(userSettings.getPtyWidth() / 8.0000), (int) Math.floor(userSettings.getPtyHeight() / 14.4166), userSettings.getPtyWidth(), userSettings.getPtyHeight());
schSession.setChannel(channel);
}
}
return null;
}
use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.
the class SessionAuditKtrl method viewSessions.
@Kontrol(path = "/manage/viewSessions", method = MethodType.GET)
public String viewSessions() throws ServletException {
if (sortedSet.getOrderByField() == null || sortedSet.getOrderByField().trim().equals("")) {
sortedSet.setOrderByField(SessionAuditDB.SORT_BY_SESSION_TM);
sortedSet.setOrderByDirection("desc");
}
try {
systemList = SystemDB.getSystemSet(new SortedSet(SystemDB.SORT_BY_NAME)).getItemList();
userList = UserDB.getUserSet(new SortedSet(SessionAuditDB.SORT_BY_USERNAME)).getItemList();
sortedSet = SessionAuditDB.getSessions(sortedSet);
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toString(), ex);
throw new ServletException(ex.toString(), ex);
}
return "/manage/view_sessions.html";
}
use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.
the class SystemKtrl method saveSystem.
@Kontrol(path = "/manage/saveSystem", method = MethodType.POST)
public String saveSystem() throws ServletException {
String retVal = "redirect:/manage/viewSystems.ktrl?sortedSet.orderByDirection=" + sortedSet.getOrderByDirection() + "&sortedSet.orderByField=" + sortedSet.getOrderByField();
hostSystem = SSHUtil.authAndAddPubKey(hostSystem, passphrase, password);
try {
if (hostSystem.getId() != null) {
SystemDB.updateSystem(hostSystem);
} else {
hostSystem.setId(SystemDB.insertSystem(hostSystem));
}
sortedSet = SystemDB.getSystemSet(sortedSet);
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toString(), ex);
throw new ServletException(ex.toString(), ex);
}
if (!HostSystem.SUCCESS_STATUS.equals(hostSystem.getStatusCd())) {
retVal = "/manage/view_systems.html";
}
return retVal;
}
Aggregations