1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.common.rest.api.service;
20
21 import io.swagger.v3.oas.annotations.Operation;
22 import io.swagger.v3.oas.annotations.headers.Header;
23 import io.swagger.v3.oas.annotations.media.Schema;
24 import io.swagger.v3.oas.annotations.responses.ApiResponse;
25 import io.swagger.v3.oas.annotations.responses.ApiResponses;
26 import io.swagger.v3.oas.annotations.security.SecurityRequirement;
27 import io.swagger.v3.oas.annotations.tags.Tag;
28 import javax.ws.rs.BeanParam;
29 import javax.ws.rs.Consumes;
30 import javax.ws.rs.DELETE;
31 import javax.ws.rs.GET;
32 import javax.ws.rs.POST;
33 import javax.ws.rs.Path;
34 import javax.ws.rs.PathParam;
35 import javax.ws.rs.Produces;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
38 import org.apache.syncope.common.lib.to.AccessTokenTO;
39 import org.apache.syncope.common.lib.to.PagedResult;
40 import org.apache.syncope.common.rest.api.RESTHeaders;
41 import org.apache.syncope.common.rest.api.beans.AccessTokenQuery;
42
43
44
45
46 @Tag(name = "AccessTokens")
47 @Path("accessTokens")
48 public interface AccessTokenService extends JAXRSService {
49
50
51
52
53
54
55
56 @Operation(security = {
57 @SecurityRequirement(name = "BasicAuthentication") })
58 @ApiResponses({
59 @ApiResponse(responseCode = "204",
60 description = "JWT successfully generated", headers = {
61 @Header(name = RESTHeaders.TOKEN, schema =
62 @Schema(type = "string"), description = "Generated JWT"),
63 @Header(name = RESTHeaders.TOKEN_EXPIRE, schema =
64 @Schema(type = "string"), description = "Expiration of the generated JWT") }),
65 @ApiResponse(responseCode = "401", description = "Invalid username or password")
66 })
67 @POST
68 @Path("login")
69 @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
70 Response login();
71
72
73
74
75
76
77
78 @Operation(security = {
79 @SecurityRequirement(name = "Bearer") })
80 @ApiResponses(
81 @ApiResponse(responseCode = "204",
82 description = "JWT successfully refreshed", headers = {
83 @Header(name = RESTHeaders.TOKEN, schema =
84 @Schema(type = "string"),
85 description = "Generated JWT"),
86 @Header(name = RESTHeaders.TOKEN_EXPIRE, schema =
87 @Schema(type = "string"),
88 description = "Expiration of the refreshed JWT") }))
89 @POST
90 @Path("refresh")
91 @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
92 Response refresh();
93
94
95
96
97 @Operation(security = {
98 @SecurityRequirement(name = "Bearer") })
99 @ApiResponses(
100 @ApiResponse(responseCode = "204", description = "Operation was successful"))
101 @POST
102 @Path("logout")
103 @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
104 void logout();
105
106
107
108
109
110
111
112 @Operation(security = {
113 @SecurityRequirement(name = "BasicAuthentication"),
114 @SecurityRequirement(name = "Bearer") })
115 @GET
116 @Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
117 @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
118 PagedResult<AccessTokenTO> list(@BeanParam AccessTokenQuery query);
119
120
121
122
123
124
125 @Operation(security = {
126 @SecurityRequirement(name = "BasicAuthentication"),
127 @SecurityRequirement(name = "Bearer") })
128 @ApiResponses(
129 @ApiResponse(responseCode = "204", description = "Operation was successful"))
130 @DELETE
131 @Path("{key}")
132 @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
133 void delete(@PathParam("key") String key);
134 }