[CXF-5697] Some minor updates for WHICH_JAR
[cxf.git] / services / sts / sts-core / src / main / java / org / apache / cxf / sts / rest / RESTSecurityTokenService.java
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.cxf.sts.rest;
21
22 import java.util.List;
23
24 import javax.ws.rs.DELETE;
25 import javax.ws.rs.DefaultValue;
26 import javax.ws.rs.GET;
27 import javax.ws.rs.POST;
28 import javax.ws.rs.Path;
29 import javax.ws.rs.PathParam;
30 import javax.ws.rs.Produces;
31 import javax.ws.rs.QueryParam;
32 import javax.ws.rs.core.MediaType;
33 import javax.ws.rs.core.Response;
34
35 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
36
37 @Path("/token")
38 public interface RESTSecurityTokenService {
39
40 enum Action {
41 issue("issue"),
42 validate("validate"),
43 renew("renew"),
44 cancel("cancel");
45 private String value;
46
47 Action(String value) {
48 this.value = value;
49 }
50
51 public String getValue() {
52 return value;
53 }
54 }
55
56 /**
57 * @return Issues required token type with default token settings.
58 */
59
60 @GET
61 @Path("{tokenType}")
62 @Produces(MediaType.APPLICATION_XML)
63 Response getXMLToken(@PathParam("tokenType") String tokenType, @QueryParam("keyType") String keyType,
64 @QueryParam("claim") List<String> requestedClaims,
65 @QueryParam("appliesTo") String appliesTo,
66 @QueryParam("wstrustResponse") @DefaultValue("false") boolean wstrustResponse);
67
68 @GET
69 @Path("{tokenType}")
70 @Produces("application/json;qs=0.8")
71 Response getJSONToken(@PathParam("tokenType") @DefaultValue("jwt") String tokenType,
72 @QueryParam("keyType") String keyType,
73 @QueryParam("claim") List<String> requestedClaims,
74 @QueryParam("appliesTo") String appliesTo);
75
76 @GET
77 @Path("{tokenType}")
78 @Produces("text/plain;qs=0.9")
79 Response getPlainToken(@PathParam("tokenType") String tokenType, @QueryParam("keyType") String keyType,
80 @QueryParam("claim") List<String> requestedClaims,
81 @QueryParam("appliesTo") String appliesTo);
82
83 @POST
84 @Produces({
85 MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
86 })
87 Response getToken(@QueryParam("action") @DefaultValue("issue") Action action, RequestSecurityTokenType request);
88
89 /**
90 * Same as {@link #getToken(Action, RequestSecurityTokenType)} with 'cancel' action.
91 *
92 * @param request
93 * @return
94 */
95 @DELETE
96 @Path("/")
97 @Produces({
98 MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
99 })
100 Response removeToken(RequestSecurityTokenType request);
101
102 @POST
103 @Path("KeyExchangeToken")
104 @Produces({
105 MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON
106 })
107 Response getKeyExchangeToken(RequestSecurityTokenType request);
108
109 }