Search in sources :

Example 6 with Kontrol

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";
}
Also used : ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) Kontrol(loophole.mvc.annotation.Kontrol)

Example 7 with Kontrol

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";
}
Also used : ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) HostSystem(io.bastillion.manage.model.HostSystem) SortedSet(io.bastillion.manage.model.SortedSet) Kontrol(loophole.mvc.annotation.Kontrol)

Example 8 with Kontrol

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;
}
Also used : ServletException(javax.servlet.ServletException) GeneralSecurityException(java.security.GeneralSecurityException) UserSchSessions(io.bastillion.manage.model.UserSchSessions) SchSession(io.bastillion.manage.model.SchSession) ChannelShell(com.jcraft.jsch.ChannelShell) Kontrol(loophole.mvc.annotation.Kontrol)

Example 9 with Kontrol

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";
}
Also used : ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) SortedSet(io.bastillion.manage.model.SortedSet) Kontrol(loophole.mvc.annotation.Kontrol)

Example 10 with Kontrol

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;
}
Also used : ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) Kontrol(loophole.mvc.annotation.Kontrol)

Aggregations

GeneralSecurityException (java.security.GeneralSecurityException)29 ServletException (javax.servlet.ServletException)29 Kontrol (loophole.mvc.annotation.Kontrol)29 SQLException (java.sql.SQLException)25 SortedSet (io.bastillion.manage.model.SortedSet)5 SchSession (io.bastillion.manage.model.SchSession)3 IOException (java.io.IOException)3 User (io.bastillion.manage.model.User)2 UserSchSessions (io.bastillion.manage.model.UserSchSessions)2 File (java.io.File)2 Gson (com.google.gson.Gson)1 EncodeHintType (com.google.zxing.EncodeHintType)1 WriterException (com.google.zxing.WriterException)1 BitMatrix (com.google.zxing.common.BitMatrix)1 QRCodeWriter (com.google.zxing.qrcode.QRCodeWriter)1 ChannelShell (com.jcraft.jsch.ChannelShell)1 HostSystem (io.bastillion.manage.model.HostSystem)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 Calendar (java.util.Calendar)1