use of org.glassfish.jersey.logging.LoggingFeature in project jersey by jersey.
the class TaskResource method getTasksResponse.
/**
* Queries task data from google.
*
* @param client Client configured for authentication with access token.
* @return Google task data response or redirect to google authorize page response.
*/
private Response getTasksResponse(final Client client) {
client.register(JacksonFeature.class);
client.register(new LoggingFeature(Logger.getLogger("example.client.tasks"), LoggingFeature.Verbosity.PAYLOAD_ANY));
final WebTarget baseTarget = client.target(GOOGLE_TASKS_BASE_URI);
final Response response = baseTarget.path("users/@me/lists").request().get();
final List<TaskListModel> listOfTaskLists;
switch(response.getStatus()) {
case //Response.Status.UNAUTHORIZED
401:
SimpleOAuthService.setAccessToken(null);
return googleAuthRedirect();
case //Response.Status.OK
200:
listOfTaskLists = processTaskLists(baseTarget, response.readEntity(TaskRootBean.class));
break;
default:
listOfTaskLists = null;
}
final AllTaskListsModel tasks = new AllTaskListsModel(listOfTaskLists);
return Response.ok(tasks).build();
}
use of org.glassfish.jersey.logging.LoggingFeature in project jersey by jersey.
the class Server method start.
/**
* Start SSL-secured HTTP test server.
*
* @throws IOException in case there is an error while reading server key store or trust store.
* @return an instance of the started SSL-secured HTTP test server.
*/
public static Server start(String keystore) throws IOException {
final InputStream trustStore = Server.class.getResourceAsStream(SERVER_TRUST_STORE);
final InputStream keyStore = Server.class.getResourceAsStream(keystore);
// Grizzly ssl configuration
SSLContextConfigurator sslContext = new SSLContextConfigurator();
// set up security context
// contains server key pair
sslContext.setKeyStoreBytes(ByteStreams.toByteArray(keyStore));
sslContext.setKeyStorePass("asdfgh");
// contains client certificate
sslContext.setTrustStoreBytes(ByteStreams.toByteArray(trustStore));
sslContext.setTrustStorePass("asdfgh");
ResourceConfig rc = new ResourceConfig();
rc.register(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.PAYLOAD_ANY));
rc.registerClasses(RootResource.class, SecurityFilter.class, AuthenticationExceptionMapper.class);
final HttpServer grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true, new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(true));
// start Grizzly embedded server //
LOGGER.info("Jersey app started. Try out " + BASE_URI + "\nHit CTRL + C to stop it...");
grizzlyServer.start();
return new Server(grizzlyServer);
}
use of org.glassfish.jersey.logging.LoggingFeature in project jersey by jersey.
the class ResponseReadAndBufferEntityTest method configure.
@Override
protected Application configure() {
enable(TestProperties.DUMP_ENTITY);
enable(TestProperties.LOG_TRAFFIC);
return new ResourceConfig(Resource.class).registerInstances(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.PAYLOAD_ANY));
}
use of org.glassfish.jersey.logging.LoggingFeature in project jersey by jersey.
the class AsyncJaxrsApplication method getSingletons.
@Override
public Set<Object> getSingletons() {
final HashSet<Object> instances = new HashSet<Object>();
instances.add(new LoggingFeature(Logger.getLogger(AsyncJaxrsApplication.class.getName()), LoggingFeature.Verbosity.PAYLOAD_ANY));
return instances;
}
use of org.glassfish.jersey.logging.LoggingFeature in project jersey by jersey.
the class AsyncTest method configureClient.
@Override
protected void configureClient(ClientConfig config) {
// TODO: fails with true on request - should be fixed by resolving JERSEY-2273
config.register(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.HEADERS_ONLY));
config.connectorProvider(new JettyConnectorProvider());
}
Aggregations