Search in sources :

Example 26 with Kontrol

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

the class AuthKeysKtrl method manageViewKeys.

@Kontrol(path = "/manage/viewKeys", method = MethodType.GET)
public String manageViewKeys() throws ServletException {
    try {
        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);
    }
    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 27 with Kontrol

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

the class AuthKeysKtrl method deletePublicKey.

@Kontrol(path = "/admin/deletePublicKey", method = MethodType.GET)
public String deletePublicKey() throws ServletException {
    if (publicKey.getId() != null) {
        try {
            // get public key then delete
            publicKey = PublicKeyDB.getPublicKey(publicKey.getId());
            PublicKeyDB.deletePublicKey(publicKey.getId(), AuthUtil.getUserId(getRequest().getSession()));
        } catch (SQLException | GeneralSecurityException ex) {
            log.error(ex.toString(), ex);
            throw new ServletException(ex.toString(), ex);
        }
    }
    distributePublicKeys(publicKey);
    return "redirect:/admin/viewKeys.ktrl?sortedSet.orderByDirection=" + sortedSet.getOrderByDirection() + "&sortedSet.orderByField=" + sortedSet.getOrderByField();
}
Also used : ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) GeneralSecurityException(java.security.GeneralSecurityException) Kontrol(loophole.mvc.annotation.Kontrol)

Example 28 with Kontrol

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

the class AuthKeysKtrl method downloadPvtKey.

@Kontrol(path = "/admin/downloadPvtKey", method = MethodType.GET)
public String downloadPvtKey() throws ServletException {
    String privateKey = null;
    try {
        privateKey = EncryptionUtil.decrypt((String) getRequest().getSession().getAttribute(PVT_KEY));
    } catch (GeneralSecurityException ex) {
        log.error(ex.toString(), ex);
        throw new ServletException(ex.toString(), ex);
    }
    if (StringUtils.isNotEmpty(publicKey.getKeyNm()) && StringUtils.isNotEmpty(privateKey)) {
        try {
            getResponse().setContentType("application/octet-stream");
            getResponse().setHeader("Content-Disposition", "attachment;filename=" + publicKey.getKeyNm() + ".key");
            getResponse().getOutputStream().write(privateKey.getBytes());
            getResponse().getOutputStream().flush();
            getResponse().getOutputStream().close();
        } catch (IOException ex) {
            log.error(ex.toString(), ex);
            throw new ServletException(ex.toString(), ex);
        }
    }
    // remove pvt key
    getRequest().getSession().setAttribute(PVT_KEY, null);
    getRequest().getSession().removeAttribute(PVT_KEY);
    return null;
}
Also used : ServletException(javax.servlet.ServletException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) Kontrol(loophole.mvc.annotation.Kontrol)

Example 29 with Kontrol

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

the class UsersKtrl method viewUsers.

@Kontrol(path = "/manage/viewUsers", method = MethodType.GET)
public String viewUsers() throws ServletException {
    try {
        userId = AuthUtil.getUserId(getRequest().getSession());
        sortedSet = UserDB.getUserSet(sortedSet);
    } catch (SQLException | GeneralSecurityException ex) {
        log.error(ex.toString(), ex);
        throw new ServletException(ex.toString(), ex);
    }
    return "/manage/view_users.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