gluu
公開メンバ関数 | 全メンバ一覧
org.xdi.oxauth.model.jwt.JwtClaims クラス
org.xdi.oxauth.model.jwt.JwtClaims の継承関係図
Inheritance graph
org.xdi.oxauth.model.jwt.JwtClaims 連携図
Collaboration graph

公開メンバ関数

 JwtClaims ()
 
 JwtClaims (JSONObject jsonObject)
 
 JwtClaims (String base64JsonObject) throws InvalidJwtException
 
void setExpirationTime (Date expirationTime)
 
void setNotBefore (Date notBefore)
 
void setIssuedAt (Date issuedAt)
 
void setIssuer (String issuer)
 
void setIssuer (URI issuer)
 
void setAudience (String audience)
 
void setAudience (URI audience)
 
void setSubjectIdentifier (String subjectIdentifier)
 
void setSubjectIdentifier (URI subjectIdentifier)
 
void setJwtId (String jwtId)
 
void setJwtId (UUID jwtId)
 
void setType (JwtType type)
 
Set< String > keys ()
 
Object getClaim (String key)
 
boolean hasClaim (String key)
 
String getClaimAsString (String key)
 
JSONObject getClaimAsJSON (String key)
 
List< String > getClaimAsStringList (String key)
 
Date getClaimAsDate (String key)
 
Integer getClaimAsInteger (String key)
 
Long getClaimAsLong (String key)
 
Character getClaimAsCharacter (String key)
 
void setClaimObject (String key, Object value, boolean overrideValue)
 
void setNullClaim (String key)
 
void setClaim (String key, String value)
 
void setClaim (String key, Date value)
 
void setClaim (String key, Boolean value)
 
void setClaim (String key, Integer value)
 
void setClaim (String key, Long value)
 
void setClaim (String key, Character value)
 
void setClaim (String key, List values)
 
void setClaim (String key, JwtSubClaimObject subClaimObject)
 
void setClaim (String key, JSONObject values)
 
void removeClaim (String key)
 
JSONObject toJsonObject () throws InvalidJwtException
 
String toBase64JsonObject () throws InvalidJwtException
 
String toJsonString () throws InvalidJwtException
 
Map< String, List< String > > toMap () throws InvalidJwtException
 
void load (JSONObject jsonObject)
 
void load (String base64JsonObject) throws InvalidJwtException
 

詳解

著者
Javier Rojas Blum Date: 11.09.2012

構築子と解体子

◆ JwtClaims() [1/3]

org.xdi.oxauth.model.jwt.JwtClaims.JwtClaims ( )
inline
30  {
31  super();
32  }

◆ JwtClaims() [2/3]

org.xdi.oxauth.model.jwt.JwtClaims.JwtClaims ( JSONObject  jsonObject)
inline
34  {
35  super(jsonObject);
36  }

◆ JwtClaims() [3/3]

org.xdi.oxauth.model.jwt.JwtClaims.JwtClaims ( String  base64JsonObject) throws InvalidJwtException
inline
38  {
39  super(base64JsonObject);
40  }

関数詳解

◆ getClaim()

Object org.xdi.oxauth.model.jwt.JwtClaimSet.getClaim ( String  key)
inlineinherited
47  {
48  return claims.get(key);
49  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ getClaimAsCharacter()

Character org.xdi.oxauth.model.jwt.JwtClaimSet.getClaimAsCharacter ( String  key)
inlineinherited
159  {
160  Object claim = getClaim(key);
161 
162  if (claim != null) {
163  if (claim instanceof Character) {
164  return (Character) claim;
165  } else {
166  return null;
167  }
168  } else {
169  return null;
170  }
171  }
Object getClaim(String key)
Definition: JwtClaimSet.java:47

◆ getClaimAsDate()

Date org.xdi.oxauth.model.jwt.JwtClaimSet.getClaimAsDate ( String  key)
inlineinherited
103  {
104  Object claim = getClaim(key);
105 
106  if (claim != null) {
107  if (claim instanceof Date) {
108  return (Date) claim;
109  } else if (claim instanceof Integer) {
110  final long c = (Integer) claim;
111  final long date = c * 1000;
112  return new Date(date);
113  } else if (claim instanceof Long) {
114  return new Date((Long) claim * 1000);
115  } else if (claim instanceof Double) {
116  final double c = (Double) claim;
117  final BigDecimal bigDecimal = new BigDecimal(c);
118 
119  long claimLong = bigDecimal.longValue();
120  claimLong = claimLong * 1000;
121 
122  return new Date(claimLong);
123  } else {
124  return null;
125  }
126  } else {
127  return null;
128  }
129  }
Object getClaim(String key)
Definition: JwtClaimSet.java:47

◆ getClaimAsInteger()

Integer org.xdi.oxauth.model.jwt.JwtClaimSet.getClaimAsInteger ( String  key)
inlineinherited
131  {
132  Object claim = getClaim(key);
133 
134  if (claim != null) {
135  if (claim instanceof Integer) {
136  return (Integer) claim;
137  } else {
138  return null;
139  }
140  } else {
141  return null;
142  }
143  }
Object getClaim(String key)
Definition: JwtClaimSet.java:47

◆ getClaimAsJSON()

JSONObject org.xdi.oxauth.model.jwt.JwtClaimSet.getClaimAsJSON ( String  key)
inlineinherited
65  {
66  String claim = getClaimAsString(key);
67 
68  try {
69  if (claim != null) {
70  JSONObject json = null;
71  json = new JSONObject(claim);
72  return json;
73  }
74  } catch (JSONException e) {
75  e.printStackTrace();
76  }
77 
78  return null;
79  }
String getClaimAsString(String key)
Definition: JwtClaimSet.java:55

◆ getClaimAsLong()

Long org.xdi.oxauth.model.jwt.JwtClaimSet.getClaimAsLong ( String  key)
inlineinherited
145  {
146  Object claim = getClaim(key);
147 
148  if (claim != null) {
149  if (claim instanceof Long) {
150  return (Long) claim;
151  } else {
152  return null;
153  }
154  } else {
155  return null;
156  }
157  }
Object getClaim(String key)
Definition: JwtClaimSet.java:47

◆ getClaimAsString()

String org.xdi.oxauth.model.jwt.JwtClaimSet.getClaimAsString ( String  key)
inlineinherited
55  {
56  Object claim = getClaim(key);
57 
58  if (claim != null) {
59  return claim.toString();
60  } else {
61  return null;
62  }
63  }
Object getClaim(String key)
Definition: JwtClaimSet.java:47

◆ getClaimAsStringList()

List<String> org.xdi.oxauth.model.jwt.JwtClaimSet.getClaimAsStringList ( String  key)
inlineinherited
81  {
82  List<String> list = new ArrayList<String>();
83  Object claims = getClaim(key);
84 
85  try {
86  if (claims != null && claims instanceof JSONArray) {
87  JSONArray jsonArray = (JSONArray) claims;
88  for (int i = 0; i < jsonArray.length(); i++) {
89  list.add(jsonArray.getString(i));
90  }
91  } else {
92  String claim = getClaimAsString(key);
93  if (claim != null) {
94  list.add(claim);
95  }
96  }
97  } catch (JSONException e) {
98  }
99 
100  return list;
101  }
String getClaimAsString(String key)
Definition: JwtClaimSet.java:55
Map< String, Object > claims
Definition: JwtClaimSet.java:27
Object getClaim(String key)
Definition: JwtClaimSet.java:47

◆ hasClaim()

boolean org.xdi.oxauth.model.jwt.JwtClaimSet.hasClaim ( String  key)
inlineinherited
51  {
52  return getClaim(key) != null;
53  }
Object getClaim(String key)
Definition: JwtClaimSet.java:47

◆ keys()

Set<String> org.xdi.oxauth.model.jwt.JwtClaimSet.keys ( )
inlineinherited
43  {
44  return claims.keySet();
45  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ load() [1/2]

void org.xdi.oxauth.model.jwt.JwtClaimSet.load ( JSONObject  jsonObject)
inlineinherited
326  {
327  claims.clear();
328 
329  for (Iterator<String> it = jsonObject.keys(); it.hasNext(); ) {
330  String key = it.next();
331  Object value = jsonObject.opt(key);
332 
333  claims.put(key, value);
334  }
335  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ load() [2/2]

void org.xdi.oxauth.model.jwt.JwtClaimSet.load ( String  base64JsonObject) throws InvalidJwtException
inlineinherited
337  {
338  try {
339  String jsonObjectString = new String(Base64Util.base64urldecode(base64JsonObject), Util.UTF8_STRING_ENCODING);
340  load(new JSONObject(jsonObjectString));
341  } catch (UnsupportedEncodingException e) {
342  throw new InvalidJwtException(e);
343  } catch (JSONException e) {
344  throw new InvalidJwtException(e);
345  } catch (Exception e) {
346  throw new InvalidJwtException(e);
347  }
348  }
void load(JSONObject jsonObject)
Definition: JwtClaimSet.java:326

◆ removeClaim()

void org.xdi.oxauth.model.jwt.JwtClaimSet.removeClaim ( String  key)
inlineinherited
246  {
247  claims.remove(key);
248  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setAudience() [1/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setAudience ( String  audience)
inline

Identifies the audience that the JWT is intended for. The principal intended to process the JWT MUST be identified with the value of the audience claim. If the principal processing the claim does not identify itself with the identifier in the "aud" claim value then the JWT MUST be rejected.

引数
audienceThe audience of the JWT.
102  {
103  setClaim(AUDIENCE, audience);
104  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210

◆ setAudience() [2/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setAudience ( URI  audience)
inline

Identifies the audience that the JWT is intended for. The principal intended to process the JWT MUST be identified with the value of the audience claim. If the principal processing the claim does not identify itself with the identifier in the "aud" claim value then the JWT MUST be rejected.

引数
audienceThe audience of the JWT.
114  {
115  if (audience == null) {
116  setNullClaim(AUDIENCE);
117  } else {
118  setClaim(AUDIENCE, audience.toString());
119  }
120  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210
void setNullClaim(String key)
Definition: JwtClaimSet.java:206

◆ setClaim() [1/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
String  value 
)
inlineinherited
210  {
211  claims.put(key, value);
212  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [2/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
Date  value 
)
inlineinherited
214  {
215  claims.put(key, value);
216  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [3/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
Boolean  value 
)
inlineinherited
218  {
219  claims.put(key, value);
220  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [4/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
Integer  value 
)
inlineinherited
222  {
223  claims.put(key, value);
224  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [5/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
Long  value 
)
inlineinherited
226  {
227  claims.put(key, value);
228  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [6/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
Character  value 
)
inlineinherited
230  {
231  claims.put(key, value);
232  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [7/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
List  values 
)
inlineinherited
234  {
235  claims.put(key, values);
236  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [8/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
JwtSubClaimObject  subClaimObject 
)
inlineinherited
238  {
239  claims.put(key, subClaimObject);
240  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaim() [9/9]

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaim ( String  key,
JSONObject  values 
)
inlineinherited
242  {
243  claims.put(key, values);
244  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setClaimObject()

void org.xdi.oxauth.model.jwt.JwtClaimSet.setClaimObject ( String  key,
Object  value,
boolean  overrideValue 
)
inlineinherited
173  {
174  if (value == null) {
175  setNullClaim(key);
176  } else if (value instanceof String) {
177  if (overrideValue) {
178  setClaim(key, (String) value);
179  } else {
180  Object currentValue = getClaim(key);
181  if (currentValue != null) {
182  setClaim(key, Lists.newArrayList(currentValue.toString(), (String) value));
183  } else {
184  setClaim(key, (String) value);
185  }
186  }
187  } else if (value instanceof Date) {
188  setClaim(key, (Date) value);
189  } else if (value instanceof Boolean) {
190  setClaim(key, (Boolean) value);
191  } else if (value instanceof Integer) {
192  setClaim(key, (Integer) value);
193  } else if (value instanceof Long) {
194  setClaim(key, (Long) value);
195  } else if (value instanceof Character) {
196  setClaim(key, (Character) value);
197  } else if (value instanceof List) {
198  setClaim(key, (List) value);
199  } else if (value instanceof JwtSubClaimObject) {
200  setClaim(key, (JwtSubClaimObject) value);
201  } else {
202  throw new UnsupportedOperationException("Claim value is not supported, key: " + key + ", value :" + value);
203  }
204  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210
Object getClaim(String key)
Definition: JwtClaimSet.java:47
void setNullClaim(String key)
Definition: JwtClaimSet.java:206

◆ setExpirationTime()

void org.xdi.oxauth.model.jwt.JwtClaims.setExpirationTime ( Date  expirationTime)
inline

Identifies the expiration time on or after which the token MUST NOT be accepted for processing.

引数
expirationTimeThe expiration time.
47  {
48  setClaim(EXPIRATION_TIME, expirationTime);
49  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210

◆ setIssuedAt()

void org.xdi.oxauth.model.jwt.JwtClaims.setIssuedAt ( Date  issuedAt)
inline

Identifies the time at which the JWT was issued. This claim can be used to determine the age of the token.

引数
issuedAtThe issue date.
68  {
69  setClaim(ISSUED_AT, issuedAt);
70  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210

◆ setIssuer() [1/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setIssuer ( String  issuer)
inline

Identifies the principal that issued the JWT.

引数
issuerThe issuer of the JWT.
77  {
78  setClaim(ISSUER, issuer);
79  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210

◆ setIssuer() [2/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setIssuer ( URI  issuer)
inline

Identifies the principal that issued the JWT.

引数
issuerThe issuer of the JWT.
86  {
87  if (issuer == null) {
88  setNullClaim(ISSUER);
89  } else {
90  setClaim(ISSUER, issuer.toString());
91  }
92  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210
void setNullClaim(String key)
Definition: JwtClaimSet.java:206

◆ setJwtId() [1/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setJwtId ( String  jwtId)
inline

Provides a unique identifier for the JWT.

引数
jwtIdUnique identifier for the JWT.
149  {
150  setClaim(JWT_ID, jwtId);
151  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210

◆ setJwtId() [2/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setJwtId ( UUID  jwtId)
inline

Provides a unique identifier for the JWT.

引数
jwtIdUnique identifier for the JWT.
158  {
159  if (jwtId == null) {
160  setNullClaim(JWT_ID);
161  } else {
162  setClaim(JWT_ID, jwtId.toString());
163  }
164  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210
void setNullClaim(String key)
Definition: JwtClaimSet.java:206

◆ setNotBefore()

void org.xdi.oxauth.model.jwt.JwtClaims.setNotBefore ( Date  notBefore)
inline

Identifies the time before which the token MUST NOT be accepted for processing. The processing of the "nbf" claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the "nbf" claim.

引数
notBeforeThe not-before date.
58  {
59  setClaim(NOT_BEFORE, notBefore);
60  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210

◆ setNullClaim()

void org.xdi.oxauth.model.jwt.JwtClaimSet.setNullClaim ( String  key)
inlineinherited
206  {
207  claims.put(key, null);
208  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ setSubjectIdentifier() [1/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setSubjectIdentifier ( String  subjectIdentifier)
inline

Identifies the subject of the JWT.

引数
subjectIdentifierThe subject of the JWT.
127  {
128  setClaim(SUBJECT_IDENTIFIER, subjectIdentifier);
129  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210

◆ setSubjectIdentifier() [2/2]

void org.xdi.oxauth.model.jwt.JwtClaims.setSubjectIdentifier ( URI  subjectIdentifier)
inline

Identifies the subject of the JWT.

引数
subjectIdentifierThe subject of the JWT.
136  {
137  if (subjectIdentifier == null) {
138  setNullClaim(SUBJECT_IDENTIFIER);
139  } else {
140  setClaim(SUBJECT_IDENTIFIER, subjectIdentifier.toString());
141  }
142  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210
void setNullClaim(String key)
Definition: JwtClaimSet.java:206

◆ setType()

void org.xdi.oxauth.model.jwt.JwtClaims.setType ( JwtType  type)
inline

Declare a type for the contents of this JWT Claims Set.

引数
typeThe type of the JWT claims set.
171  {
172  if (type == null) {
173  setNullClaim(TYPE);
174  } else {
175  setClaim(TYPE, type.toString());
176  }
177  }
void setClaim(String key, String value)
Definition: JwtClaimSet.java:210
void setNullClaim(String key)
Definition: JwtClaimSet.java:206

◆ toBase64JsonObject()

String org.xdi.oxauth.model.jwt.JwtClaimSet.toBase64JsonObject ( ) throws InvalidJwtException
inlineinherited
281  {
282  try {
283  String jsonObjectString = toJsonString();
284  byte[] jsonObjectBytes = jsonObjectString.getBytes(Util.UTF8_STRING_ENCODING);
285  return Base64Util.base64urlencode(jsonObjectBytes);
286  } catch (UnsupportedEncodingException e) {
287  return null;
288  }
289  }
String toJsonString()
Definition: JwtClaimSet.java:291

◆ toJsonObject()

JSONObject org.xdi.oxauth.model.jwt.JwtClaimSet.toJsonObject ( ) throws InvalidJwtException
inlineinherited
250  {
251  JSONObject jsonObject = new JSONObject();
252 
253  try {
254  for (Map.Entry<String, Object> claim : claims.entrySet()) {
255  if (claim.getValue() instanceof Date) {
256  Date date = (Date) claim.getValue();
257  jsonObject.put(claim.getKey(), date.getTime() / 1000);
258  } else if (claim.getValue() instanceof JwtSubClaimObject) {
259  JwtSubClaimObject subClaimObject = (JwtSubClaimObject) claim.getValue();
260  jsonObject.put(subClaimObject.getName(), subClaimObject.toJsonObject());
261  } else if (claim.getValue() instanceof List) {
262  List claimObjectList = (List) claim.getValue();
263  JSONArray claimsJSONArray = new JSONArray();
264  for (Object claimObj : claimObjectList) {
265  claimsJSONArray.put(claimObj);
266  }
267  jsonObject.put(claim.getKey(), claimsJSONArray);
268  } else {
269  jsonObject.put(claim.getKey(), claim.getValue());
270  }
271  }
272  } catch (JSONException e) {
273  throw new InvalidJwtException(e);
274  } catch (Exception e) {
275  throw new InvalidJwtException(e);
276  }
277 
278  return jsonObject;
279  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

◆ toJsonString()

String org.xdi.oxauth.model.jwt.JwtClaimSet.toJsonString ( ) throws InvalidJwtException
inlineinherited
291  {
292  JSONObject jsonObject = toJsonObject();
293  String jsonObjectString = jsonObject.toString();
294  jsonObjectString = jsonObjectString.replace("\\/", "/");
295 
296  return jsonObjectString;
297  }
JSONObject toJsonObject()
Definition: JwtClaimSet.java:250

◆ toMap()

Map<String, List<String> > org.xdi.oxauth.model.jwt.JwtClaimSet.toMap ( ) throws InvalidJwtException
inlineinherited
299  {
300  Map<String, List<String>> map = new HashMap<String, java.util.List<String>>();
301 
302  try {
303  for (Map.Entry<String, Object> claim : claims.entrySet()) {
304  String key = claim.getKey();
305  Object value = claim.getValue();
306 
307  List<String> values = new ArrayList<String>();
308  if (value instanceof JSONArray) {
309  JSONArray jsonArray = (JSONArray) value;
310  for (int i = 0; i < jsonArray.length(); i++) {
311  values.add(jsonArray.getString(i));
312  }
313  } else if (value != null) {
314  values.add(value.toString());
315  }
316 
317  map.put(key, values);
318  }
319  } catch (JSONException e) {
320  throw new InvalidJwtException(e);
321  }
322 
323  return map;
324  }
Map< String, Object > claims
Definition: JwtClaimSet.java:27

このクラス詳解は次のファイルから抽出されました: