public SASLResponse processSASLRequest(SASLRequest saslReq,Message message,String respMessageID){
  if (debug.messageEnabled()) {
    debug.message("CramMD5MechanismHandler.processSASLRequest: ");
  }
  String refToMessageID=saslReq.getRefToMessageID();
  boolean isFirstRequest=(refToMessageID == null || refToMessageID.length() == 0);
  if (debug.messageEnabled()) {
    debug.message("CramMD5MechanismHandler.processSASLRequest: " + "refToMessageID = " + refToMessageID);
  }
  SASLResponse saslResp=null;
  byte[] data=saslReq.getData();
  if (data == null) {
    if (isFirstRequest) {
      saslResp=new SASLResponse(SASLResponse.CONTINUE);
      saslResp.setServerMechanism(AuthnSvcConstants.MECHANISM_CRAMMD5);
      byte[] challenge=generateChallenge();
      if (debug.messageEnabled()) {
        debug.message("CramMD5MechanismHandler.processSASLRequest:" + " add respMessageID: " + respMessageID);
      }
      challengeMap.put(respMessageID,challenge);
      saslResp.setData(challenge);
    }
 else {
      saslResp=new SASLResponse(SASLResponse.ABORT);
    }
  }
 else {
    String dataStr=null;
    try {
      dataStr=new String(data,"UTF-8");
    }
 catch (    Exception ex) {
      debug.error("CramMD5MechanismHandler.processSASLRequest: ",ex);
    }
    if (dataStr == null) {
      saslResp=new SASLResponse(SASLResponse.ABORT);
    }
 else {
      saslResp=authenticate(dataStr,message);
    }
    if (isFirstRequest) {
      saslResp.setServerMechanism(AuthnSvcConstants.MECHANISM_PLAIN);
    }
  }
  return saslResp;
}

public SASLResponse processSASLRequest ( SASLRequest saslReq , Message message , String respMessageID ) { if ( debug . messageEnabled ( ) ) { debug . message ( "CramMD5MechanismHandler.processSASLRequest: " ) ; } String refToMessageID = saslReq . getRefToMessageID ( ) ; boolean isFirstRequest = ( refToMessageID == null || refToMessageID . length ( ) == 0 ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "CramMD5MechanismHandler.processSASLRequest: " + "refToMessageID = " + refToMessageID ) ; } SASLResponse saslResp = null ; byte [ ] data = saslReq . getData ( ) ; if ( data == null ) { if ( isFirstRequest ) { saslResp = new SASLResponse ( SASLResponse . CONTINUE ) ; saslResp . setServerMechanism ( AuthnSvcConstants . MECHANISM_CRAMMD5 ) ; byte [ ] challenge = generateChallenge ( ) ; if ( debug . messageEnabled ( ) ) { debug . message ( "CramMD5MechanismHandler.processSASLRequest:" + " add respMessageID: " + respMessageID ) ; } challengeMap . put ( respMessageID , challenge ) ; saslResp . setData ( challenge ) ; } else { saslResp = new SASLResponse ( SASLResponse . ABORT ) ; } } else { String dataStr = null ; try { dataStr = new String ( data , "UTF-8" ) ; } catch ( Exception ex ) { debug . error ( "CramMD5MechanismHandler.processSASLRequest: " , ex ) ; } if ( dataStr == null ) { saslResp = new SASLResponse ( SASLResponse . ABORT ) ; } else { saslResp = authenticate ( dataStr , message ) ; } if ( isFirstRequest ) { saslResp . setServerMechanism ( AuthnSvcConstants . MECHANISM_PLAIN ) ; } } return saslResp ; }
generates a sasl response according to the sasl request .
