-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.java
More file actions
132 lines (115 loc) · 3.54 KB
/
Message.java
File metadata and controls
132 lines (115 loc) · 3.54 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
/*
* 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.msg;
import com.auth0.jwt.algorithms.Algorithm;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Map;
/**
* This interface all the methods related to message processing.
*/
public interface Message {
/**
* Serialize the content of this instance (the claims map) into a JSON object
*
* @return a JSON String representation of the message
* @throws SerializationException
*/
String toJson() throws SerializationException, JsonProcessingException, InvalidClaimException;
/**
* Serialize the content of the claims map into an UrlEncoded string
*
* @return a urlEncoded string
* @throws SerializationException
*/
String toUrlEncoded()
throws SerializationException, JsonProcessingException, InvalidClaimException;
/**
* Serialize the content of this instance (the claims map) into a jwt string
*
* @param KeyJar
* the signing keyjar
* @param String
* the algorithm to use in signing the JWT
* @return a jwt String
* @throws InvalidClaimException
*/
String toJwt(Algorithm algorithm)
throws SerializationException, JsonProcessingException, InvalidClaimException;
/**
* Logic to extract from the string the values
*
* @param input
* The JSON String representation of a message
*/
void fromJson(String input) throws InvalidClaimException;
/**
* @param input
* the urlEncoded String representation of a message
*/
void fromUrlEncoded(String input)
throws MalformedURLException, IOException, InvalidClaimException;
/**
*
* @param input
* the jwt String representation of a message
* @param KeyJar
* that might contain the necessary key
*/
void fromJwt(String input) throws IOException;
/**
*
* @param name
* of the claim
* @param value
* of the claim
*/
void addClaim(String name, Object value);
/**
* Verifies the presence of required message parameters. Verifies the the format of message
* parameters.
*
* @return true if parameters are successfully verified.
* @throws InvalidClaimException
* if verification fails.
*/
public boolean verify() throws InvalidClaimException;
/**
* Whether the message parameters have been verified after last change.
*
* @return true if verified, false otherwise.
*/
public boolean isVerified();
/**
* Get the message parameters.
*
* @return List of the list of claims for this message
*/
Map<String, Object> getClaims();
/**
* @return the error object representing an error in verification
*/
Error getError();
/**
* @return boolean for whether there is an error in verification
*/
boolean hasError();
/**
* @return Parameter requirements.
*/
Map<String, ParameterVerificationDefinition> getParameterVerificationDefinitions();
}