-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathService.java
More file actions
206 lines (189 loc) · 8.81 KB
/
Copy pathService.java
File metadata and controls
206 lines (189 loc) · 8.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* Copyright (C) 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.oidc.service;
import java.util.Map;
import org.oidc.common.MissingRequiredAttributeException;
import org.oidc.common.SerializationType;
import org.oidc.common.ServiceName;
import org.oidc.common.UnsupportedSerializationTypeException;
import org.oidc.common.ValueException;
import org.oidc.msg.DeserializationException;
import org.oidc.msg.InvalidClaimException;
import org.oidc.msg.Message;
import org.oidc.msg.SerializationException;
import org.oidc.service.base.HttpArguments;
import org.oidc.service.base.RequestArgumentProcessingException;
import org.oidc.service.base.ServiceContext;
import org.oidc.service.data.State;
/**
* Provides the methods that are needed to support any request-response protocol such as OIDC,
* OAuth2 etc.
*/
public interface Service {
/**
* Builds the request message and constructs the HTTP headers.
*
* This is the starting point for a pipeline that will:
*
* - construct the request message - add/remove information to/from the request message in the way
* a specific client authentication method requires. - gather a set of HTTP headers like
* Content-type and Authorization. - serialize the request message into the necessary format
* (JSON, urlencoded, signed JWT)
*
* @param requestParameters Additional request parameters used for constructing the message.
* @return The information needed for building the HTTP request to OP.
* @throws UnsupportedSerializationTypeException If the serialization type is not supported.
* @throws RequestArgumentProcessingException If the request arguments are invalid.
* @throws SerializationException If the request cannot be serialized.
*/
public HttpArguments getRequestParameters(Map<String, Object> requestParameters)
throws UnsupportedSerializationTypeException, RequestArgumentProcessingException,
SerializationException;
/**
* This the start of a pipeline that will:
*
* - Deserializes a response into its response message class. - verifies the correctness of the
* response by running the verify method belonging to the message class used.
*
* @param response The response, can be either in a JSON or an urlencoded format.
* @param serializationType Which serialization that was used.
* @param stateKey The key that corresponds to the appropriate State object.
* @throws DeserializationException If the response cannot be deserialized.
* @throws InvalidClaimException If the response cannot be verified.
* @return The parsed and to some extent verified response.
**/
public Message parseResponse(String response, SerializationType serializationType, String stateKey)
throws DeserializationException, InvalidClaimException;
/**
* This the start of a pipeline that will:
*
* - Deserializes a response into its response message class. - verifies the correctness of the
* response by running the verify method belonging to the message class used.
*
* @param response The response, can be either in a JSON or an urlencoded format.
* @param stateKey The key that corresponds to the appropriate State object.
* @throws DeserializationException If the response cannot be deserialized.
* @throws InvalidClaimException If the response cannot be verified.
* @return The parsed and to some extent verified response.
**/
public Message parseResponse(String response, String stateKey)
throws DeserializationException, InvalidClaimException;
/**
* This the start of a pipeline that will:
*
* - Deserializes a response into its response message class. - verifies the correctness of the
* response by running the verify method belonging to the message class used.
*
* This method only takes the String version of the response in order for the response to be
* parsed. The serialization format will default to the service’s responseBodyType value. This
* method does not require a stateKey since it is used for services that are not expected to store
* state in the state DB.
*
* @param response The response, can be either in a JSON or an urlencoded format
* @throws DeserializationException If the response cannot be deserialized.
* @throws InvalidClaimException If the response cannot be verified.
* @return The parsed and to some extent verified response.
**/
public Message parseResponse(String response)
throws DeserializationException, InvalidClaimException;
/**
* This is the start of a pipeline that will:
*
* - Deserializes a response into its response message class. - verifies the correctness of the
* response by running the verify method belonging to the message class used.
*
* This method takes the String version of the response and the serializationType in order for the
* response to be parsed. This method does not require a stateKey since it is used for services
* that are not expected to store state in the state DB.
*
* @param response The response, can be either in a JSON or an urlencoded format.
* @param serializationType Which serialization that was used.
* @throws DeserializationException If the response cannot be deserialized.
* @throws InvalidClaimException If the response cannot be verified.
* @return The parsed and to some extent verified response.
**/
public Message parseResponse(String response, SerializationType serializationType)
throws DeserializationException, InvalidClaimException;
/**
* This method will run after the response has been parsed and verified. It requires response and
* stateKey in order for the service context to be updated. StateKey is used to fetch and update
* the appropriate State associated with a specific service. This method may update certain
* attributes of the service context such as issuer, clientId, or clientSecret.
*
* @param response The response as a Message instance.
* @param stateKey The key that identifies the State object.
* @throws MissingRequiredAttributeException If the response is missing a required attribute.
* @throws ValueException If the response message is unexpected.
* @throws InvalidClaimException If the response contains invalid claims.
**/
public void updateServiceContext(Message response, String stateKey)
throws MissingRequiredAttributeException, ValueException, InvalidClaimException;
/**
* This method will run after the response has been parsed and verified. It requires response in
* order for the service context to be updated. This method may update certain attributes of the
* service context such as issuer, clientId, or clientSecret. This method does not require a
* stateKey since it is used for services that are not expected to store state in the state DB.
*
* @param response The response as a Message instance
* @throws MissingRequiredAttributeException If the response is missing a required attribute.
* @throws ValueException If the response message is unexpected.
* @throws InvalidClaimException If the response contains invalid claims.
*/
public void updateServiceContext(Message response)
throws MissingRequiredAttributeException, ValueException, InvalidClaimException;
/**
* Get the request message for this service.
*
* @return The request message for this service.
*/
public Message getRequestMessage();
/**
* Get the response message for this service.
*
* @return The response message for this service.
*/
public Message getResponseMessage();
/**
* Get the service context attached to this service.
*
* @return The service context attached to this service.
*/
public ServiceContext getServiceContext();
/**
* Get the map of arguments sent to the post constructors.
*
* @return The map of arguments sent to the post constructors.
*/
public Map<String, Object> getPostConstructorArgs();
/**
* Get the map of arguments sent to the pre constructors.
*
* @return The map of arguments sent to the pre constructors.
*/
public Map<String, Object> getPreConstructorArgs();
/**
* Get the state attached to this service.
*
* @return The state attached to this service.
*/
public State getState();
/**
* Get the name for this service.
*
* @return The name for this service.
*/
public ServiceName getServiceName();
}