Revision 50532
Added by Katerina Iatropoulou about 6 years ago
HelloWorldService.java | ||
---|---|---|
15 | 15 |
import org.apache.log4j.Logger; |
16 | 16 |
import org.json.XML; |
17 | 17 |
import org.springframework.beans.factory.annotation.Autowired; |
18 |
import org.springframework.stereotype.Component; |
|
18 |
import org.springframework.stereotype.Controller; |
|
19 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
20 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
19 | 21 |
|
20 | 22 |
import javax.annotation.Resource; |
21 | 23 |
import javax.servlet.http.HttpServletRequest; |
24 |
import javax.servlet.http.HttpServletResponse; |
|
22 | 25 |
import javax.ws.rs.*; |
23 | 26 |
import javax.ws.rs.core.Context; |
24 | 27 |
import javax.ws.rs.core.MediaType; |
25 | 28 |
import javax.ws.rs.core.Response; |
29 |
import java.io.IOException; |
|
30 |
import java.io.PrintWriter; |
|
26 | 31 |
import java.util.ArrayList; |
27 | 32 |
import java.util.List; |
28 | 33 |
|
29 | 34 |
/** |
30 | 35 |
* Created by kiatrop on 15/4/2016. |
31 | 36 |
*/ |
32 |
@Component |
|
33 |
@Path("/claimsService") |
|
37 |
@Controller |
|
34 | 38 |
public class HelloWorldService { |
35 | 39 |
|
36 | 40 |
private static final Logger logger = Logger.getLogger(HelloWorldService.class); |
... | ... | |
256 | 260 |
logger.debug("header \"X-XSRF-TOKEN\" has value " + token); |
257 | 261 |
logger.debug("cookie \"AccessToken\" has value " + cookie); |
258 | 262 |
|
263 |
//OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); |
|
264 |
//@PreAuthorize @PostAuthorize @see SPEL expressions |
|
265 |
|
|
259 | 266 |
if(token == null || token.isEmpty() || cookie == null || cookie.isEmpty() || !cookie.equals(token)){ |
260 | 267 |
return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. Maybe you are not registered.")) |
261 | 268 |
.type(MediaType.APPLICATION_JSON) |
... | ... | |
419 | 426 |
.build(); |
420 | 427 |
} |
421 | 428 |
|
429 |
@RequestMapping(value = "/claims", method = RequestMethod.GET) |
|
430 |
public void getClaims(HttpServletRequest request, HttpServletResponse response) { |
|
431 |
PrintWriter writer = null; |
|
432 |
|
|
433 |
try { |
|
434 |
writer = response.getWriter(); |
|
435 |
writer.append("skata"); |
|
436 |
writer.flush(); |
|
437 |
|
|
438 |
} catch (IOException e) { |
|
439 |
logger.error(e); |
|
440 |
} |
|
441 |
|
|
442 |
} |
|
443 |
|
|
422 | 444 |
@GET |
423 | 445 |
@Path("/claims") |
424 | 446 |
@Produces(MediaType.APPLICATION_JSON) |
Also available in: Unified diff
without jersey + added only one mapping for /claims