/** * Create an authenticating REST client for WebLogic Server interactions. * * @param config The client configuration * @param logger The Logger to use for client logging. * * @return A javax.ws.rs.Client based on the specified configuration */ public static Client getClient(CommonWebLogicConfiguration config, Logger logger) { HttpAuthenticationFeature httpAuthFeature = HttpAuthenticationFeature.universalBuilder().credentialsForBasic(config.getAdminUserName(), config.getAdminPassword()).build(); ClientBuilder restClientBuilder = ClientBuilder.newBuilder(); restClientBuilder.register(CsrfProtectionFilter.class); restClientBuilder.register(httpAuthFeature); restClientBuilder.register(MultiPartFeature.class); restClientBuilder.register(JsonProcessingFeature.class); restClientBuilder.property(JsonGenerator.PRETTY_PRINTING, true); // format JSON content for readability // Register the logging filter only if configured to log the REST requests/responses (or the REST entities). // The REST entity logging is a finer level of detail that requires the logging filter, so it overrides the other // configuration property. if (config.isLogRESTMessages() || config.isLogRESTEntities()) { // Honor the verbose logging property to determine whether REST entities should be printed restClientBuilder.register(new LoggingFilter(logger, config.isLogRESTEntities())); } return restClientBuilder.build(); }