@Test public void shouldSetParameterAuthenticationHeader() throws Exception { final AuthenticationCustomizer customizer = new AuthenticationCustomizer(); final Map<String, Object> options = new HashMap<>(); options.put("authenticationType", AuthenticationType.apiKey); options.put("authenticationParameterName", "apiKey"); options.put("authenticationParameterValue", "{{key}}"); options.put("authenticationParameterPlacement", "header"); final ComponentProxyComponent component = new SwaggerProxyComponent("dataset-test", "dataset-test"); final CamelContext context = mock(CamelContext.class); component.setCamelContext(context); when(context.resolvePropertyPlaceholders("apiKey")).thenReturn("apiKey"); when(context.resolvePropertyPlaceholders("{{key}}")).thenReturn("dolphins"); when(context.resolvePropertyPlaceholders("header")).thenReturn("header"); customizer.customize(component, options); assertThat(options).doesNotContainKeys("authenticationParameterName", "authenticationParameterValue", "authenticationParameterPlacement"); assertHeaderSetTo(component, "apiKey", "dolphins"); }
@Override public void customize(final ComponentProxyComponent proxyComponent, final Map<String, Object> options) { consumeOption(options, "authenticationType", authenticationTypeObject -> { final String authenticationTypeAsString = String.valueOf(authenticationTypeObject); final AuthenticationType authenticationType = AuthenticationType.fromString(authenticationTypeAsString); if (authenticationType == AuthenticationType.none) { return; } final SwaggerProxyComponent component = (SwaggerProxyComponent) proxyComponent; final CamelContext context = component.getCamelContext(); final Configuration configuration = new Configuration(this, context, options); switch (authenticationType) { case oauth2: OAuth.setup(component, configuration); break; case basic: Basic.setup(component, configuration); break; case apiKey: ApiKey.setup(component, configuration); break; default: throw new IllegalStateException("Unsupported authentication type: " + authenticationType); } }); }
AuthenticationCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent proxyComponent, final Map<String, Object> options) { consumeOption(options, "authenticationType", authenticationTypeObject -> { final String authenticationTypeAsString = String.valueOf(authenticationTypeObject); final AuthenticationType authenticationType = AuthenticationType.fromString(authenticationTypeAsString); if (authenticationType == AuthenticationType.none) { return; } final SwaggerProxyComponent component = (SwaggerProxyComponent) proxyComponent; final CamelContext context = component.getCamelContext(); final Configuration configuration = new Configuration(this, context, options); switch (authenticationType) { case oauth2: OAuth.setup(component, configuration); break; case basic: Basic.setup(component, configuration); break; case apiKey: ApiKey.setup(component, configuration); break; default: throw new IllegalStateException("Unsupported authentication type: " + authenticationType); } }); } }
AuthenticationCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent proxyComponent, final Map<String, Object> options) { consumeOption(options, "authenticationType", authenticationTypeObject -> { final String authenticationTypeAsString = String.valueOf(authenticationTypeObject); final AuthenticationType authenticationType = AuthenticationType.fromString(authenticationTypeAsString); if (authenticationType == AuthenticationType.none) { return; } final SwaggerProxyComponent component = (SwaggerProxyComponent) proxyComponent; final CamelContext context = component.getCamelContext(); final Configuration configuration = new Configuration(this, context, options); switch (authenticationType) { case oauth2: OAuth.setup(component, configuration); break; case basic: Basic.setup(component, configuration); break; case apiKey: ApiKey.setup(component, configuration); break; default: throw new IllegalStateException("Unsupported authentication type: " + authenticationType); } }); }  }
AuthenticationCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent proxyComponent, final Map<String, Object> options) { consumeOption(options, "authenticationType", authenticationTypeObject -> { final String authenticationTypeAsString = String.valueOf(authenticationTypeObject); final AuthenticationType authenticationType = AuthenticationType.fromString(authenticationTypeAsString); if (authenticationType == AuthenticationType.none) { return; } final SwaggerProxyComponent component = (SwaggerProxyComponent) proxyComponent; final CamelContext context = component.getCamelContext(); final Configuration configuration = new Configuration(this, context, options); switch (authenticationType) { case oauth2: OAuth.setup(component, configuration); break; case basic: Basic.setup(component, configuration); break; case apiKey: ApiKey.setup(component, configuration); break; default: throw new IllegalStateException("Unsupported authentication type: " + authenticationType); } }); }  @Override void customize(final ComponentProxyComponent proxyComponent, final Map<String, Object> options); }
AuthenticationCustomizer implements ComponentProxyCustomizer { @Override public void customize(final ComponentProxyComponent proxyComponent, final Map<String, Object> options) { consumeOption(options, "authenticationType", authenticationTypeObject -> { final String authenticationTypeAsString = String.valueOf(authenticationTypeObject); final AuthenticationType authenticationType = AuthenticationType.fromString(authenticationTypeAsString); if (authenticationType == AuthenticationType.none) { return; } final SwaggerProxyComponent component = (SwaggerProxyComponent) proxyComponent; final CamelContext context = component.getCamelContext(); final Configuration configuration = new Configuration(this, context, options); switch (authenticationType) { case oauth2: OAuth.setup(component, configuration); break; case basic: Basic.setup(component, configuration); break; case apiKey: ApiKey.setup(component, configuration); break; default: throw new IllegalStateException("Unsupported authentication type: " + authenticationType); } }); }  @Override void customize(final ComponentProxyComponent proxyComponent, final Map<String, Object> options);  }