Search in sources :

Example 16 with Kontrol

use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.

the class SecureShellKtrl method createSession.

@Kontrol(path = "/admin/createSession", method = MethodType.GET)
public String createSession() throws ServletException {
    Long userId = null;
    try {
        userId = AuthUtil.getUserId(getRequest().getSession());
    } catch (GeneralSecurityException ex) {
        log.error(ex.toString(), ex);
        throw new ServletException(ex.toString(), ex);
    }
    if (systemSelectId != null && !systemSelectId.isEmpty()) {
        try {
            SystemStatusDB.setInitialSystemStatus(systemSelectId, userId, AuthUtil.getUserType(getRequest().getSession()));
            pendingSystemStatus = SystemStatusDB.getNextPendingSystem(userId);
            createTerms();
        } catch (SQLException | GeneralSecurityException | ServletException ex) {
            log.error(ex.toString(), ex);
            throw new ServletException(ex.toString(), ex);
        }
    }
    return null;
}
Also used : ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) Kontrol(loophole.mvc.annotation.Kontrol)

Example 17 with Kontrol

use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.

the class SecureShellKtrl method selectSystemsForCompositeTerms.

@Kontrol(path = "/admin/selectSystemsForCompositeTerms", method = MethodType.GET)
public String selectSystemsForCompositeTerms() throws ServletException {
    if (systemSelectId != null && !systemSelectId.isEmpty()) {
        try {
            Long userId = AuthUtil.getUserId(getRequest().getSession());
            SystemStatusDB.setInitialSystemStatus(systemSelectId, userId, AuthUtil.getUserType(getRequest().getSession()));
            pendingSystemStatus = SystemStatusDB.getNextPendingSystem(userId);
            User user = UserDB.getUser(userId);
            user.setIpAddress(AuthUtil.getClientIPAddress(getRequest()));
            AuthUtil.setSessionId(getRequest().getSession(), SessionAuditDB.createSessionLog(user));
        } 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) User(io.bastillion.manage.model.User) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) Kontrol(loophole.mvc.annotation.Kontrol)

Example 18 with Kontrol

use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.

the class SecureShellKtrl method disconnectTerm.

@Kontrol(path = "/admin/disconnectTerm", method = MethodType.GET)
public String disconnectTerm() 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) {
            SchSession schSession = userSchSessions.getSchSessionMap().get(id);
            // disconnect ssh session
            if (schSession != null) {
                if (schSession.getChannel() != null)
                    schSession.getChannel().disconnect();
                if (schSession.getSession() != null)
                    schSession.getSession().disconnect();
                schSession.setChannel(null);
                schSession.setSession(null);
                schSession.setInputToChannel(null);
                schSession.setCommander(null);
                schSession.setOutFromChannel(null);
            }
            // remove from map
            userSchSessions.getSchSessionMap().remove(id);
        }
    }
    return null;
}
Also used : ServletException(javax.servlet.ServletException) GeneralSecurityException(java.security.GeneralSecurityException) UserSchSessions(io.bastillion.manage.model.UserSchSessions) SchSession(io.bastillion.manage.model.SchSession) Kontrol(loophole.mvc.annotation.Kontrol)

Example 19 with Kontrol

use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.

the class SessionAuditKtrl method getJSONTermOutputForSession.

@Kontrol(path = "/manage/getJSONTermOutputForSession", method = MethodType.GET)
public String getJSONTermOutputForSession() throws ServletException {
    try {
        String json = new Gson().toJson(SessionAuditDB.getTerminalLogsForSession(sessionId, instanceId));
        getResponse().getOutputStream().write(json.getBytes());
    } catch (SQLException | GeneralSecurityException | IOException ex) {
        log.error(ex.toString(), ex);
        throw new ServletException(ex.toString(), ex);
    }
    return null;
}
Also used : ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) Gson(com.google.gson.Gson) IOException(java.io.IOException) Kontrol(loophole.mvc.annotation.Kontrol)

Example 20 with Kontrol

use of loophole.mvc.annotation.Kontrol in project KeyBox by skavanagh.

the class SystemKtrl method viewAdminSystems.

@Kontrol(path = "/admin/viewSystems", method = MethodType.GET)
public String viewAdminSystems() throws ServletException {
    try {
        Long userId = AuthUtil.getUserId(getRequest().getSession());
        if (Auth.MANAGER.equals(AuthUtil.getUserType(getRequest().getSession()))) {
            sortedSet = SystemDB.getSystemSet(sortedSet);
            profileList = ProfileDB.getAllProfiles();
        } else {
            sortedSet = SystemDB.getUserSystemSet(sortedSet, userId);
            profileList = UserProfileDB.getProfilesByUser(userId);
        }
        if (script != null && script.getId() != null) {
            script = ScriptDB.getScript(script.getId(), userId);
        }
    } catch (SQLException | GeneralSecurityException ex) {
        log.error(ex.toString(), ex);
        throw new ServletException(ex.toString(), ex);
    }
    return "/admin/view_systems.html";
}
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