# HG changeset patch # User Torsten Irländer # Date 1374745466 -7200 # Node ID f7b5ff46f3e7b1bd29ce08aee8baf46d8b7497c6 # Parent a6185d60c2a183b8fa4eb65fb17ee3ee88585a36 Added service to get so general information on the service like loggend in user etc. diff -r a6185d60c2a1 -r f7b5ff46f3e7 src/main/java/de/intevation/lada/rest/InfoService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/rest/InfoService.java Thu Jul 25 11:44:26 2013 +0200 @@ -0,0 +1,59 @@ +package de.intevation.lada.rest; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.UriInfo; + +import de.intevation.lada.auth.Authentication; +import de.intevation.lada.auth.AuthenticationException; + +/** + * This class produces a RESTful service to read, write and update + * LOrt objects. + * + * @author Torsten Irländer + */ +@Path("/info") +@RequestScoped +public class InfoService +{ + /** + * The authorization module. + */ + @Inject + @Named("ldapauth") + private Authentication authentication; + + /** + * Request SQL-Queries + * + * Query parameters are used for the filter in form of key-value pairs. + * + * @param info The URL query parameters. + * @param headers The HTTP header containing authorization information. + * @return Response object. + */ + @GET + @Produces("text/json") + public Response filter( + @Context UriInfo info, + @Context HttpHeaders headers + ) { + try { + if (!authentication.isAuthorizedUser(headers)) { + return new Response(false, 699, null); + } + Response response = new Response(true, 200, null); + return response; + } + catch(AuthenticationException ae) { + return new Response(false, 699, null); + } + } +}