コード例 #1
0
  private String findRoleUidByName(List<Role> roles, String roleName) {
    if (roleName == null || roleName.trim().isEmpty()) {
      return null;
    }

    for (Role role : roles) {
      if (roleName.equalsIgnoreCase(role.getName())) {
        return role.getId();
      }
    }

    return null;
  }
コード例 #2
0
 /**
  * Deletes a role from the package.
  *
  * @param packageId
  * @param role
  * @throws EslException
  */
 public void deleteRole(PackageId packageId, Role role) throws EslException {
   String path =
       template
           .urlFor(UrlTemplate.ROLE_ID_PATH)
           .replace("{packageId}", packageId.getId())
           .replace("{roleId}", role.getId())
           .build();
   try {
     client.delete(path);
   } catch (RequestException e) {
     throw new EslServerException("Could not delete role", e);
   } catch (Exception e) {
     throw new EslException("Could not delete role", e);
   }
 }
コード例 #3
0
  private void sendSmsToSigner(PackageId packageId, Role role) {
    String path =
        template
            .urlFor(UrlTemplate.SEND_SMS_TO_SIGNER_PATH)
            .replace("{packageId}", packageId.getId())
            .replace("{roleId}", role.getId())
            .build();

    try {
      client.post(path, null);
    } catch (RequestException e) {
      throw new EslException("Could not send SMS to the signer.", e);
    } catch (Exception e) {
      throw new EslException("Could not send SMS to the signer." + " Exception: " + e.getMessage());
    }
  }
コード例 #4
0
  /**
   * Updates a role from the package.
   *
   * @param packageId
   * @param role
   * @return The updated role
   * @throws EslException
   */
  public Role updateRole(PackageId packageId, Role role) throws EslException {
    String path =
        template
            .urlFor(UrlTemplate.ROLE_ID_PATH)
            .replace("{packageId}", packageId.getId())
            .replace("{roleId}", role.getId())
            .build();

    String roleJson = JacksonUtil.serializeDirty(role);
    String stringResponse;
    try {
      stringResponse = client.put(path, roleJson);
    } catch (RequestException e) {
      throw new EslServerException("Could not update role", e);
    } catch (Exception e) {
      throw new EslException("Could not update role", e);
    }
    return Serialization.fromJson(stringResponse, Role.class);
  }
コード例 #5
0
  private String getSigningUrl(PackageId packageId, Role role) {

    String path =
        template
            .urlFor(UrlTemplate.SIGNER_URL_PATH)
            .replace("{packageId}", packageId.getId())
            .replace("{roleId}", role.getId())
            .build();

    try {
      String response = client.get(path);
      SigningUrl signingUrl = Serialization.fromJson(response, SigningUrl.class);
      return signingUrl.getUrl();
    } catch (RequestException e) {
      throw new EslException("Could not get a signing url.", e);
    } catch (Exception e) {
      throw new EslException("Could not get a signing url." + " Exception: " + e.getMessage());
    }
  }
コード例 #6
0
  /**
   * Adds a signer to the specified package
   *
   * @param packageId The id of the package in which the signer will be added
   * @param signer The signer to be added
   * @return The role id of the signer
   */
  public String addSigner(PackageId packageId, com.silanis.esl.sdk.Signer signer) {
    Role apiPayload =
        new SignerConverter(signer).toAPIRole(UUID.randomUUID().toString().replace("-", ""));

    String path =
        template
            .urlFor(UrlTemplate.ADD_SIGNER_PATH)
            .replace("{packageId}", packageId.getId())
            .build();

    try {
      String json = Serialization.toJson(apiPayload);
      String response = client.post(path, json);
      Role apiRole = Serialization.fromJson(response, Role.class);
      return apiRole.getId();

    } catch (RequestException e) {
      throw new EslServerException("Could not add signer.", e);
    } catch (Exception e) {
      throw new EslException("Could not add signer." + " Exception: " + e.getMessage());
    }
  }
コード例 #7
0
 public void notifySigner(PackageId packageId, GroupId groupId) {
   Role role = findRoleForGroup(packageId, groupId.getId());
   notifySigner(packageId, role.getId());
 }