@Override public void init(Subject subject,Map sharedState,Map options){
  if (debug.messageEnabled()) {
    debug.message("OATH::init");
  }
  this.options=options;
  this.sharedState=sharedState;
  bundle=amCache.getResBundle(amAuthOATH,getLoginLocale());
  try {
    this.authLevel=CollectionHelper.getMapAttr(options,AUTHLEVEL);
    try {
      this.passLen=Integer.parseInt(CollectionHelper.getMapAttr(options,PASSWORD_LENGTH));
    }
 catch (    NumberFormatException e) {
      passLen=0;
    }
    try {
      this.minSecretKeyLength=Integer.parseInt(CollectionHelper.getMapAttr(options,MIN_SECRET_KEY_LENGTH));
    }
 catch (    NumberFormatException e) {
      minSecretKeyLength=0;
    }
    this.secretKeyAttrName=CollectionHelper.getMapAttr(options,SECRET_KEY_ATTRIBUTE_NAME);
    this.windowSize=Integer.parseInt(CollectionHelper.getMapAttr(options,WINDOW_SIZE));
    this.counterAttrName=CollectionHelper.getMapAttr(options,COUNTER_ATTRIBUTE_NAME);
    this.truncationOffset=Integer.parseInt(CollectionHelper.getMapAttr(options,TRUNCATION_OFFSET));
    this.totpTimeStep=Integer.parseInt(CollectionHelper.getMapAttr(options,TOTP_TIME_STEP));
    this.totpStepsInWindow=Integer.parseInt(CollectionHelper.getMapAttr(options,TOTP_STEPS_IN_WINDOW));
    this.loginTimeAttrName=CollectionHelper.getMapAttr(options,LAST_LOGIN_TIME_ATTRIBUTE_NAME);
    this.sharedSecretImplClass=CollectionHelper.getMapAttr(options,SHARED_SECRET_IMPLEMENTATION_CLASS);
    this.totpMaxClockDrift=CollectionHelper.getIntMapAttr(options,MAXIMUM_CLOCK_DRIFT,-1,debug);
    this.observedClockDriftAttrName=CollectionHelper.getMapAttr(options,OBSERVED_CLOCK_DRIFT_ATTRIBUTE_NAME);
    String algorithm=CollectionHelper.getMapAttr(options,ALGORITHM);
    if (algorithm.equalsIgnoreCase("HOTP")) {
      this.algorithm=HOTP;
    }
 else     if (algorithm.equalsIgnoreCase("TOTP")) {
      this.algorithm=TOTP;
    }
 else {
      this.algorithm=ERROR;
    }
    String checksumVal=CollectionHelper.getMapAttr(options,CHECKSUM);
    checksum=Boolean.parseBoolean(checksumVal);
    if (authLevel != null) {
      try {
        setAuthLevel(Integer.parseInt(authLevel));
      }
 catch (      Exception e) {
        debug.error("OATH.init(): Unable to set auth level " + authLevel,e);
      }
    }
  }
 catch (  Exception e) {
    debug.error("OATH.init(): Unable to get module attributes",e);
  }
  try {
    userName=(String)sharedState.get(getUserKey());
  }
 catch (  Exception e) {
    debug.error("OATH.init(): Unable to get username: ",e);
  }
}

@ Override public void init ( Subject subject , Map sharedState , Map options ) { if ( debug . messageEnabled ( ) ) { debug . message ( "OATH::init" ) ; } this . options = options ; this . sharedState = sharedState ; bundle = amCache . getResBundle ( amAuthOATH , getLoginLocale ( ) ) ; try { this . authLevel = CollectionHelper . getMapAttr ( options , AUTHLEVEL ) ; try { this . passLen = Integer . parseInt ( CollectionHelper . getMapAttr ( options , PASSWORD_LENGTH ) ) ; } catch ( NumberFormatException e ) { passLen = 0 ; } try { this . minSecretKeyLength = Integer . parseInt ( CollectionHelper . getMapAttr ( options , MIN_SECRET_KEY_LENGTH ) ) ; } catch ( NumberFormatException e ) { minSecretKeyLength = 0 ; } this . secretKeyAttrName = CollectionHelper . getMapAttr ( options , SECRET_KEY_ATTRIBUTE_NAME ) ; this . windowSize = Integer . parseInt ( CollectionHelper . getMapAttr ( options , WINDOW_SIZE ) ) ; this . counterAttrName = CollectionHelper . getMapAttr ( options , COUNTER_ATTRIBUTE_NAME ) ; this . truncationOffset = Integer . parseInt ( CollectionHelper . getMapAttr ( options , TRUNCATION_OFFSET ) ) ; this . totpTimeStep = Integer . parseInt ( CollectionHelper . getMapAttr ( options , TOTP_TIME_STEP ) ) ; this . totpStepsInWindow = Integer . parseInt ( CollectionHelper . getMapAttr ( options , TOTP_STEPS_IN_WINDOW ) ) ; this . loginTimeAttrName = CollectionHelper . getMapAttr ( options , LAST_LOGIN_TIME_ATTRIBUTE_NAME ) ; this . sharedSecretImplClass = CollectionHelper . getMapAttr ( options , SHARED_SECRET_IMPLEMENTATION_CLASS ) ; this . totpMaxClockDrift = CollectionHelper . getIntMapAttr ( options , MAXIMUM_CLOCK_DRIFT , - 1 , debug ) ; this . observedClockDriftAttrName = CollectionHelper . getMapAttr ( options , OBSERVED_CLOCK_DRIFT_ATTRIBUTE_NAME ) ; String algorithm = CollectionHelper . getMapAttr ( options , ALGORITHM ) ; if ( algorithm . equalsIgnoreCase ( "HOTP" ) ) { this . algorithm = HOTP ; } else if ( algorithm . equalsIgnoreCase ( "TOTP" ) ) { this . algorithm = TOTP ; } else { this . algorithm = ERROR ; } String checksumVal = CollectionHelper . getMapAttr ( options , CHECKSUM ) ; checksum = Boolean . parseBoolean ( checksumVal ) ; if ( authLevel != null ) { try { setAuthLevel ( Integer . parseInt ( authLevel ) ) ; } catch ( Exception e ) { debug . error ( "OATH.init(): Unable to set auth level " + authLevel , e ) ; } } } catch ( Exception e ) { debug . error ( "OATH.init(): Unable to get module attributes" , e ) ; } try { userName = ( String ) sharedState . get ( getUserKey ( ) ) ; } catch ( Exception e ) { debug . error ( "OATH.init(): Unable to get username: " , e ) ; } }
initializes the authentication module . this function gets the modules settings , and the username from the previous authentication module in the chain .
