public synchronized boolean verifyAndAdvanceState(Byte newStep){
  logger.debug("NODE {}: ZWaveSecurityCommandClass in verifyAndAdvanceState with newstep={}, currentstep={}",node.getNodeId(),ZWaveSecurityCommandClass.commandToString(newStep),ZWaveSecurityCommandClass.commandToString(currentStep));
  if (!INIT_COMMAND_ORDER_LIST.contains(newStep)) {
    return true;
  }
  if (INIT_COMMAND_ORDER_LIST.indexOf(newStep) > 0) {
    int currentIndex=INIT_COMMAND_ORDER_LIST.indexOf(currentStep);
    int newIndex=INIT_COMMAND_ORDER_LIST.indexOf(newStep);
    if (newIndex != currentIndex && newIndex - currentIndex > 1) {
      if (HALT_ON_IMPROPER_ORDER) {
        setErrorState(String.format("NODE %d: Commands received out of order, aborting current=%s, new=%s",node.getNodeId(),ZWaveSecurityCommandClass.commandToString(currentStep),ZWaveSecurityCommandClass.commandToString(newStep)));
        return false;
      }
 else {
        logger.warn("NODE {}: Commands received out of order (warning only, continuing) current={}, new={}",node.getNodeId(),ZWaveSecurityCommandClass.commandToString(currentStep),ZWaveSecurityCommandClass.commandToString(newStep));
      }
    }
  }
  currentStep=newStep;
  return true;
}

public synchronized boolean verifyAndAdvanceState ( Byte newStep ) { logger . debug ( "NODE {}: ZWaveSecurityCommandClass in verifyAndAdvanceState with newstep={}, currentstep={}" , node . getNodeId ( ) , ZWaveSecurityCommandClass . commandToString ( newStep ) , ZWaveSecurityCommandClass . commandToString ( currentStep ) ) ; if ( ! INIT_COMMAND_ORDER_LIST . contains ( newStep ) ) { return true ; } if ( INIT_COMMAND_ORDER_LIST . indexOf ( newStep ) > 0 ) { int currentIndex = INIT_COMMAND_ORDER_LIST . indexOf ( currentStep ) ; int newIndex = INIT_COMMAND_ORDER_LIST . indexOf ( newStep ) ; if ( newIndex != currentIndex && newIndex - currentIndex > 1 ) { if ( HALT_ON_IMPROPER_ORDER ) { setErrorState ( String . format ( "NODE %d: Commands received out of order, aborting current=%s, new=%s" , node . getNodeId ( ) , ZWaveSecurityCommandClass . commandToString ( currentStep ) , ZWaveSecurityCommandClass . commandToString ( newStep ) ) ) ; return false ; } else { logger . warn ( "NODE {}: Commands received out of order (warning only, continuing) current={}, new={}" , node . getNodeId ( ) , ZWaveSecurityCommandClass . commandToString ( currentStep ) , ZWaveSecurityCommandClass . commandToString ( newStep ) ) ; } } } currentStep = newStep ; return true ; }
since these operations are security sensitive we must ensure they are executing in the proper sequence
