private void loadKeys() { clearKeys(); Map<String, String> keys = keyService.getKeys(username); int top = START_TOP; for (Map.Entry<String, String> e : keys.entrySet()) { keyNames.add(e.getKey()); addKeyLabel(e.getKey(), e.getValue(), top); addKeyRemoveButton(e.getKey(), top); top += 20; } }
@Override public OutputStream receiveUpload(String fileName, String mimeType) { FileOutputStream outStream = null; try { File file = keyService.addFile(username, keyNameField.getValue(), fileName); outStream = new FileOutputStream(file); /** SSH requires that key files only have read-write permissions for OWNER */ Set<PosixFilePermission> permissions = new HashSet<PosixFilePermission>(); permissions.add(PosixFilePermission.OWNER_READ); permissions.add(PosixFilePermission.OWNER_WRITE); Files.setPosixFilePermissions(file.toPath(), permissions); } catch (IOException e) { LOG.error("Error while setting key file permissions.", e); } return outStream; }
private void removeKey(String keyName) { keyService.removeKey(username, keyName); loadKeys(); }