Search in sources :

Example 1 with SortedSet

use of io.bastillion.manage.model.SortedSet in project KeyBox by skavanagh.

the class AuthKeysKtrl method enablePublicKey.

@Kontrol(path = "/manage/enablePublicKey", method = MethodType.GET)
public String enablePublicKey() throws ServletException {
    try {
        publicKey = PublicKeyDB.getPublicKey(publicKey.getId());
        PublicKeyDB.enableKey(publicKey.getId());
        profileList = ProfileDB.getAllProfiles();
        userList = UserDB.getUserSet(new SortedSet(SessionAuditDB.SORT_BY_USERNAME)).getItemList();
        sortedSet = PublicKeyDB.getPublicKeySet(sortedSet);
    } catch (SQLException | GeneralSecurityException ex) {
        log.error(ex.toString(), ex);
        throw new ServletException(ex.toString(), ex);
    }
    distributePublicKeys(publicKey);
    return "/manage/view_keys.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 2 with SortedSet

use of io.bastillion.manage.model.SortedSet 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 3 with SortedSet

use of io.bastillion.manage.model.SortedSet 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 4 with SortedSet

use of io.bastillion.manage.model.SortedSet in project KeyBox by skavanagh.

the class SystemStatusDB method getSortedSetStatus.

/**
 * returns all key placement statuses
 *
 * @param userId user id
 */
public static SortedSet getSortedSetStatus(Long userId) throws SQLException, GeneralSecurityException {
    SortedSet sortedSet = new SortedSet();
    sortedSet.setItemList(getAllSystemStatus(userId));
    return sortedSet;
}
Also used : SortedSet(io.bastillion.manage.model.SortedSet)

Example 5 with SortedSet

use of io.bastillion.manage.model.SortedSet in project KeyBox by skavanagh.

the class AuthKeysKtrl method disablePublicKey.

@Kontrol(path = "/manage/disablePublicKey", method = MethodType.GET)
public String disablePublicKey() throws ServletException {
    try {
        publicKey = PublicKeyDB.getPublicKey(publicKey.getId());
        PublicKeyDB.disableKey(publicKey.getId());
        profileList = ProfileDB.getAllProfiles();
        userList = UserDB.getUserSet(new SortedSet(SessionAuditDB.SORT_BY_USERNAME)).getItemList();
        sortedSet = PublicKeyDB.getPublicKeySet(sortedSet);
    } catch (SQLException | GeneralSecurityException ex) {
        log.error(ex.toString(), ex);
        throw new ServletException(ex.toString(), ex);
    }
    distributePublicKeys(publicKey);
    return "/manage/view_keys.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)

Aggregations

SortedSet (io.bastillion.manage.model.SortedSet)6 GeneralSecurityException (java.security.GeneralSecurityException)5 SQLException (java.sql.SQLException)5 ServletException (javax.servlet.ServletException)5 Kontrol (loophole.mvc.annotation.Kontrol)5 HostSystem (io.bastillion.manage.model.HostSystem)1