public void globalInit() throws Exception {
  computeRotationTime();
  InterProcessLock lock=null;
  try {
    lock=_coordinator.getLock(DISTRIBUTED_KEY_TOKEN_LOCK);
    lock.acquire();
    if (!doesConfigExist()) {
      TokenKeysBundle bundle=TokenKeysBundle.createNewTokenKeysBundle();
      createOrUpdateBundle(bundle);
      updateCachedTokenKeys(bundle);
    }
 else {
      updateCachedKeys();
      _log.debug("Token keys configuration exists, loaded keys");
      _log.debug("Current token key {}",_cachedTokenKeysBundle.getCurrentKeyEntry());
    }
    keyRotationExecutor.scheduleWithFixedDelay(new KeyRotationThread(),0,_keyRotationIntervalInMsecs,TimeUnit.MILLISECONDS);
  }
 catch (  Exception ex) {
    _log.error("Exception during initialization of TokenKeyGenerator",ex);
  }
 finally {
    try {
      if (lock != null) {
        lock.release();
      }
    }
 catch (    Exception ex) {
      _log.error("Could not release the lock during TokenKeyGenerator.init()");
      throw ex;
    }
  }
}

public void globalInit ( ) throws Exception { computeRotationTime ( ) ; InterProcessLock lock = null ; try { lock = _coordinator . getLock ( DISTRIBUTED_KEY_TOKEN_LOCK ) ; lock . acquire ( ) ; if ( ! doesConfigExist ( ) ) { TokenKeysBundle bundle = TokenKeysBundle . createNewTokenKeysBundle ( ) ; createOrUpdateBundle ( bundle ) ; updateCachedTokenKeys ( bundle ) ; } else { updateCachedKeys ( ) ; _log . debug ( "Token keys configuration exists, loaded keys" ) ; _log . debug ( "Current token key {}" , _cachedTokenKeysBundle . getCurrentKeyEntry ( ) ) ; } keyRotationExecutor . scheduleWithFixedDelay ( new KeyRotationThread ( ) , 0 , _keyRotationIntervalInMsecs , TimeUnit . MILLISECONDS ) ; } catch ( Exception ex ) { _log . error ( "Exception during initialization of TokenKeyGenerator" , ex ) ; } finally { try { if ( lock != null ) { lock . release ( ) ; } } catch ( Exception ex ) { _log . error ( "Could not release the lock during TokenKeyGenerator.init()" ) ; throw ex ; } } }
initialization method to be called by authsvc . it will create the key configuration if it doesn ' t exist on first startup . else it will just load the cache .
