コード例 #1
0
ファイル: AUTH.java プロジェクト: papillon212/JGroups
 /**
  * Handles a GMS header
  *
  * @param gms_hdr
  * @param msg
  * @return true if the message should be passed up, or else false
  */
 protected boolean handleAuthHeader(GMS.GmsHeader gms_hdr, AuthHeader auth_hdr, Message msg) {
   switch (gms_hdr.getType()) {
     case GMS.GmsHeader.JOIN_REQ:
     case GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER:
     case GMS.GmsHeader.MERGE_REQ:
       if (this.auth_token.authenticate(auth_hdr.getToken(), msg))
         return true; //  authentication passed, send message up the stack
       log.warn(
           "failed to validate AuthHeader token from " + msg.getSrc() + ", token: " + auth_token);
       sendRejectionMessage(gms_hdr.getType(), msg.getSrc(), "authentication failed");
       return false;
     default:
       return true; // pass up
   }
 }
コード例 #2
0
ファイル: AUTH.java プロジェクト: belaban/JGroups
 /**
  * Handles a GMS header
  *
  * @param gms_hdr
  * @param msg
  * @return true if the message should be passed up, or else false
  */
 protected boolean handleAuthHeader(GMS.GmsHeader gms_hdr, AuthHeader auth_hdr, Message msg) {
   if (needsAuthentication(gms_hdr)) {
     if (this.auth_token.authenticate(auth_hdr.getToken(), msg))
       return true; //  authentication passed, send message up the stack
     else {
       log.warn(
           "%s: failed to validate AuthHeader (token: %s) from %s; dropping message",
           local_addr, auth_token.getClass().getSimpleName(), msg.src());
       sendRejectionMessage(gms_hdr.getType(), msg.getSrc(), "authentication failed");
       return false;
     }
   }
   return true;
 }
コード例 #3
0
ファイル: AUTH.java プロジェクト: belaban/JGroups
 protected boolean needsAuthentication(GMS.GmsHeader hdr) {
   switch (hdr.getType()) {
     case GMS.GmsHeader.JOIN_REQ:
     case GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER:
     case GMS.GmsHeader.MERGE_REQ:
       return true;
     case GMS.GmsHeader.JOIN_RSP:
     case GMS.GmsHeader.MERGE_RSP:
     case GMS.GmsHeader.INSTALL_MERGE_VIEW:
       return this.authenticate_coord;
     default:
       return false;
   }
 }
コード例 #4
0
ファイル: AUTH.java プロジェクト: papillon212/JGroups
  public void up(MessageBatch batch) {
    for (Message msg : batch) {
      // If we have a join or merge request --> authenticate, else pass up
      GMS.GmsHeader gms_hdr = getGMSHeader(msg);
      if (gms_hdr != null && needsAuthentication(gms_hdr)) {
        AuthHeader auth_hdr = (AuthHeader) msg.getHeader(id);
        if (auth_hdr == null) {
          log.warn("found GMS join or merge request but no AUTH header");
          sendRejectionMessage(
              gms_hdr.getType(), batch.sender(), "join or merge without an AUTH header");
          batch.remove(msg);
        } else if (!handleAuthHeader(gms_hdr, auth_hdr, msg)) // authentication failed
        batch.remove(msg); // don't pass up
      }
    }

    if (!batch.isEmpty()) up_prot.up(batch);
  }
コード例 #5
0
ファイル: AUTH.java プロジェクト: papillon212/JGroups
 protected static boolean needsAuthentication(GMS.GmsHeader hdr) {
   return hdr.getType() == GMS.GmsHeader.JOIN_REQ
       || hdr.getType() == GMS.GmsHeader.JOIN_REQ_WITH_STATE_TRANSFER
       || hdr.getType() == GMS.GmsHeader.MERGE_REQ;
 }