private RestTokenProvider<JsonValue> buildCustomTokenProvider(TokenTypeId outputTokenType)
     throws STSInitializationException {
   for (CustomTokenOperation customTokenOperation : customTokenProviders) {
     if (customTokenOperation.getCustomTokenName().equals(outputTokenType.getId())) {
       RestTokenProvider customProvider;
       try {
         customProvider =
             Class.forName(customTokenOperation.getCustomOperationClassName())
                 .asSubclass(RestTokenProvider.class)
                 .newInstance();
       } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
         throw new STSInitializationException(
             ResourceException.CONFLICT,
             "Custom token provider instantiation of class "
                 + customTokenOperation.getCustomOperationClassName()
                 + " failed. Correct class name, "
                 + "or expose in classpath, and republish sts instance. Exception: "
                 + e,
             e);
       }
       return new CustomTokenProviderWrapper(customProvider);
     }
   }
   throw new STSInitializationException(
       ResourceException.CONFLICT,
       "No custom token provider found for token type "
           + outputTokenType.getId()
           + ". Republish rest-sts instance with custom token provider specified for custom token type.");
 }
 private RestTokenTransformValidator<JsonValue> buildCustomTokenValidator(
     TokenTypeId inputTokenType,
     ValidationInvocationContext validationInvocationContext,
     boolean invalidateInterimAMSession)
     throws STSInitializationException {
   for (CustomTokenOperation customTokenOperation : customTokenValidators) {
     if (customTokenOperation.getCustomTokenName().equals(inputTokenType.getId())) {
       RestTokenTransformValidator customValidator;
       try {
         customValidator =
             Class.forName(customTokenOperation.getCustomOperationClassName())
                 .asSubclass(RestTokenTransformValidator.class)
                 .newInstance();
       } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
         throw new STSInitializationException(
             ResourceException.CONFLICT,
             "Custom token validator instantiation of class "
                 + customTokenOperation.getCustomOperationClassName()
                 + " failed. Correct class name, "
                 + "or expose in classpath, and republish sts instance. Exception: "
                 + e,
             e);
       }
       return new CustomTokenTransformValidatorWrapper(
           customValidator,
           threadLocalAMTokenCache,
           validationInvocationContext,
           invalidateInterimAMSession);
     }
   }
   throw new STSInitializationException(
       ResourceException.CONFLICT,
       "No custom token validator found for token type "
           + inputTokenType.getId()
           + ". Republish rest-sts instance with custom token validator specified for custom token type.");
 }