Project

General

Profile

« Previous | Next » 

Revision 50532

without jersey + added only one mapping for /claims

View differences:

modules/uoa-claims-api/branches/no-jersey/src/main/java/eu/dnetlib/openaire/rest/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)
modules/uoa-claims-api/branches/no-jersey/pom.xml
76 76
            <artifactId>asm</artifactId>
77 77
            <version>3.3.1</version>
78 78
        </dependency>
79
        <dependency>
79
        <!--dependency>
80 80
            <groupId>com.sun.jersey</groupId>
81 81
            <artifactId>jersey-bundle</artifactId>
82 82
            <version>1.19</version>
83
        </dependency>
83
        </dependency-->
84 84
        <dependency>
85 85
            <groupId>org.json</groupId>
86 86
            <artifactId>json</artifactId>
87 87
            <version>20140107</version>
88 88
        </dependency>
89
        <dependency>
89
        <!--dependency>
90 90
            <groupId>com.sun.jersey</groupId>
91 91
            <artifactId>jersey-server</artifactId>
92 92
            <version>1.19</version>
......
95 95
            <groupId>com.sun.jersey</groupId>
96 96
            <artifactId>jersey-core</artifactId>
97 97
            <version>1.19</version>
98
        </dependency>
98
        </dependency-->
99 99
        <dependency>
100 100
            <groupId>commons-validator</groupId>
101 101
            <artifactId>commons-validator</artifactId>
102 102
            <version>1.3.1</version>
103 103
        </dependency>
104
        <dependency>
104
        <!--dependency>
105 105
            <groupId>com.sun.jersey.contribs</groupId>
106 106
            <artifactId>jersey-spring</artifactId>
107 107
            <version>1.8</version>
......
135 135
                    <artifactId>spring-aop</artifactId>
136 136
                </exclusion>
137 137
            </exclusions>
138
        </dependency-->
139
        <!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
140
        <dependency>
141
            <groupId>javax.ws.rs</groupId>
142
            <artifactId>javax.ws.rs-api</artifactId>
143
            <version>2.0</version>
138 144
        </dependency>
145

  
139 146
        <dependency>
140 147
            <groupId>io.jsonwebtoken</groupId>
141 148
            <artifactId>jjwt</artifactId>

Also available in: Unified diff