예제 #1
0
  /**
   * Verifies license version 1 signature.
   *
   * @param key Public key.
   * @param lic License version 1.
   * @return {@code true} if signature was verified, {@code false} - otherwise.
   * @throws GeneralSecurityException If any exception occurs while verifying.
   */
  public static boolean verifySignatureV1(PublicKey key, GridLicenseV1 lic)
      throws GeneralSecurityException {
    assert key != null;
    assert lic != null;

    byte[] data = getDataV1ForSign(lic);
    byte[] sign = U.hexString2ByteArray(lic.getSignature());

    return verifySignature(SIGN_ALG, PRV, key, data, sign);
  }
예제 #2
0
  /**
   * Gets license version 1 data for sign.
   *
   * @param lic GridGain license version 1.
   * @return Data for sign.
   */
  public static byte[] getDataV1ForSign(GridLicenseV1 lic) {
    assert lic != null;

    try {
      return new SB()
          .a(lic.getVersion())
          .a(lic.getId())
          .a(lic.getIssueDate() != null ? U.format(lic.getIssueDate(), DATE_PTRN) : "")
          .a(lic.getIssueOrganization())
          .a(lic.getUserOrganization())
          .a(lic.getUserWww())
          .a(lic.getUserEmail())
          .a(lic.getType())
          .a(lic.getExpireDate() != null ? U.format(lic.getExpireDate(), DATE_PTRN) : "")
          .a(lic.getMeteringKey1())
          .a(lic.getMeteringKey2())
          .a(lic.getMaxCpus())
          .a(lic.getMaxNodes())
          .toString()
          .getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new GridRuntimeException(e);
    }
  }