/**
   * Calculates the signature by concatenating the single values with each other, adding the
   * sharedSecret and using the MD5 algorithm (HMAC-MD5).
   *
   * @param uuid osd uuid
   * @param filesize new filesize
   * @param truncateEpoch current truncate epoch
   * @param expireTimeSet set of all finalized expireTimes
   * @return a signature for a FinalizeVouchersResponse
   */
  public String createSignature(
      String uuid, long filesize, long truncateEpoch, Set<Long> expireTimeSet) {

    String plainText = uuid + Long.toString(filesize) + Long.toString(truncateEpoch);
    for (Long expireTime : expireTimeSet) {
      plainText += expireTime.toString();
    }
    plainText += sharedSecret;

    try {
      MessageDigest md5 = MessageDigest.getInstance("MD5");
      md5.update(plainText.getBytes());
      byte[] digest = md5.digest();

      return OutputUtils.byteArrayToHexString(digest);
    } catch (NoSuchAlgorithmException exc) {
      Logging.logError(Logging.LEVEL_ERROR, this, exc);
      return null;
    }
  }
Ejemplo n.º 2
0
  /** Main loop. */
  public void run() {

    // initially fetch the list of MRCs from the Directory Service
    try {

      knownMRCs =
          master
              .getDirClient()
              .xtreemfs_service_get_by_type(
                  null,
                  RPCAuthentication.authNone,
                  RPCAuthentication.userService,
                  ServiceType.SERVICE_TYPE_MRC)
              .toBuilder();

    } catch (Throwable exc) {
      this.notifyCrashed(exc);
    }

    notifyStarted();
    if (Logging.isInfo())
      Logging.logMessage(
          Logging.LEVEL_INFO,
          Category.lifecycle,
          this,
          "MRC status manager operational, using DIR %s",
          master.getConfig().getDirectoryService().toString());

    while (!quit) {

      synchronized (this) {
        try {
          this.wait(
              knownMRCs == null || knownMRCs.getServicesCount() == 0
                  ? checkIntervalMillis / 2
                  : checkIntervalMillis);
        } catch (InterruptedException ex) {
          break;
        }
      }

      Logging.logMessage(
          Logging.LEVEL_DEBUG, Category.misc, this, "sending request for MRC list to DIR...");

      try {
        // request list of registered MRCs from Directory
        // Service

        knownMRCs =
            master
                .getDirClient()
                .xtreemfs_service_get_by_type(
                    null,
                    RPCAuthentication.authNone,
                    RPCAuthentication.userService,
                    ServiceType.SERVICE_TYPE_MRC)
                .toBuilder();

        Logging.logMessage(
            Logging.LEVEL_DEBUG, Category.misc, this, "... received MRC list from DIR");

        evaluateResponse(knownMRCs);

      } catch (InterruptedException ex) {
        break;
      } catch (Exception exc) {
        if (!quit)
          Logging.logMessage(
              Logging.LEVEL_ERROR, Category.misc, this, OutputUtils.stackTraceToString(exc));
      }

      synchronized (syncLock) {
        syncLock.notifyAll();
      }
    }

    notifyStopped();
  }
Ejemplo n.º 3
0
 @Override
 public void handle(HttpExchange httpExchange) throws IOException {
   sendResponse(httpExchange, OutputUtils.getThreadDump());
 }