Exemplo n.º 1
0
  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;
    }
  }
Exemplo n.º 2
0
  @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;
  }
Exemplo n.º 3
0
 private void removeKey(String keyName) {
   keyService.removeKey(username, keyName);
   loadKeys();
 }