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";
}
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();
}
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;
}
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";
}
Aggregations