private void updateDefaultKey()

in src/AWSSecretsManagerKeyStrategy.java [192:218]


  private void updateDefaultKey() throws KeyException {
    synchronized(this) {
      GetSecretValueResult getSecretValueResult = getSecretValueResult(null);
      final String newVersion = getSecretValueResult.getVersionId();

      if (currentVersion == null) {
	log.info("Loading initial default key: {}", newVersion);
      } else if (!currentVersion.equals(newVersion)) {
	log.info("Updating default key from {} to {}", currentVersion, newVersion);
      } else {
	log.debug("Default key version has not changed, still {}", currentVersion);
	return;
      }
                
      SecretKey secretKey = getSecretKeyFromGetSecretValueResult(getSecretValueResult);

      if (secretKey == null) {
	log.error("Key could not be retrieved");
	throw new KeyException("Key could not be retrieved on update");
      }

      defaultKey = secretKey;
      currentVersion = getSecretValueResult.getVersionId();
                
      log.info("Default key updated to {}", currentVersion);
    }
  }