gluu
公開メンバ関数 | 限定公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.xdi.oxauth.model.common.AbstractToken クラスabstract
org.xdi.oxauth.model.common.AbstractToken の継承関係図
Inheritance graph
org.xdi.oxauth.model.common.AbstractToken 連携図
Collaboration graph

公開メンバ関数

 AbstractToken (int lifeTime)
 
void checkExpired ()
 
void checkExpired (Date now)
 
boolean isValid ()
 
String getCode ()
 
void setCode (String code)
 
Date getCreationDate ()
 
void setCreationDate (Date creationDate)
 
Date getExpirationDate ()
 
void setExpirationDate (Date expirationDate)
 
boolean isRevoked ()
 
synchronized void setRevoked (boolean revoked)
 
boolean isExpired ()
 
synchronized void setExpired (boolean expired)
 
String getAuthMode ()
 
void setAuthMode (String authMode)
 
String getSessionDn ()
 
void setSessionDn (String sessionDn)
 
int getExpiresIn ()
 
String getHash (SignatureAlgorithm signatureAlgorithm)
 

限定公開メンバ関数

 AbstractToken (String code, Date creationDate, Date expirationDate)
 

非公開変数類

String code
 
Date creationDate
 
Date expirationDate
 
boolean revoked
 
boolean expired
 
String authMode
 
String sessionDn
 

詳解

Base class for the access token, refresh token and authorization code.

When created, a token is valid for a given lifetime, and after this period of time, it will be marked as expired automatically by a background process.

When required, the token can be marked as revoked.

著者
Javier Rojas Blum
バージョン
July 31, 2016

構築子と解体子

◆ AbstractToken() [1/2]

org.xdi.oxauth.model.common.AbstractToken.AbstractToken ( int  lifeTime)
inline

Creates and initializes the values of an abstract token.

引数
lifeTimeThe life time of the token.
58  {
59  if (lifeTime <= 0) {
60  throw new IllegalArgumentException("Lifetime of the token is less or equal to zero.");
61  }
62  Calendar calendar = Calendar.getInstance();
63  creationDate = calendar.getTime();
64  calendar.add(Calendar.SECOND, lifeTime);
65  expirationDate = calendar.getTime();
66 
67  code = HandleTokenFactory.generateHandleToken();
68 
69  revoked = false;
70  expired = false;
71  }
Date creationDate
Definition: AbstractToken.java:42
boolean expired
Definition: AbstractToken.java:46
Date expirationDate
Definition: AbstractToken.java:44
boolean revoked
Definition: AbstractToken.java:45
String code
Definition: AbstractToken.java:40

◆ AbstractToken() [2/2]

org.xdi.oxauth.model.common.AbstractToken.AbstractToken ( String  code,
Date  creationDate,
Date  expirationDate 
)
inlineprotected
73  {
74  this.code = code;
77 
78  checkExpired();
79  }
Date creationDate
Definition: AbstractToken.java:42
Date expirationDate
Definition: AbstractToken.java:44
String code
Definition: AbstractToken.java:40
void checkExpired()
Definition: AbstractToken.java:84

関数詳解

◆ checkExpired() [1/2]

void org.xdi.oxauth.model.common.AbstractToken.checkExpired ( )
inline

Checks whether the token has expired and if true, marks itself as expired.

84  {
85  checkExpired(new Date());
86  }
void checkExpired()
Definition: AbstractToken.java:84

◆ checkExpired() [2/2]

void org.xdi.oxauth.model.common.AbstractToken.checkExpired ( Date  now)
inline

Checks whether the token has expired and if true, marks itself as expired.

91  {
92  if (now.after(expirationDate)) {
93  expired = true;
94  }
95  }
boolean expired
Definition: AbstractToken.java:46
Date expirationDate
Definition: AbstractToken.java:44

◆ getAuthMode()

String org.xdi.oxauth.model.common.AbstractToken.getAuthMode ( )
inline

Returns the authentication mode.

戻り値
The authentication mode.
204  {
205  return authMode;
206  }
String authMode
Definition: AbstractToken.java:49

◆ getCode()

String org.xdi.oxauth.model.common.AbstractToken.getCode ( )
inline

Returns the token code.

戻り値
The Code of the token.
112  {
113  return code;
114  }
String code
Definition: AbstractToken.java:40

◆ getCreationDate()

Date org.xdi.oxauth.model.common.AbstractToken.getCreationDate ( )
inline

Returns the creation date of the token.

戻り値
The creation date.
130  {
131  return creationDate != null ? new Date(creationDate.getTime()) : null;
132  }
Date creationDate
Definition: AbstractToken.java:42

◆ getExpirationDate()

Date org.xdi.oxauth.model.common.AbstractToken.getExpirationDate ( )
inline

Returns the expiration date of the token.

戻り値
The expiration date.
148  {
149  return expirationDate != null ? new Date(expirationDate.getTime()) : null;
150  }
Date expirationDate
Definition: AbstractToken.java:44

◆ getExpiresIn()

int org.xdi.oxauth.model.common.AbstractToken.getExpiresIn ( )
inline

Returns the lifetime in seconds of the token.

戻り値
The lifetime in seconds of the token.
230  {
231  int expiresIn = 0;
232 
233  checkExpired();
234  if (isValid()) {
235  long diff = expirationDate.getTime() - new Date().getTime();
236  expiresIn = diff != 0 ? (int) (diff / 1000) : 0;
237  }
238 
239  return expiresIn;
240  }
Date expirationDate
Definition: AbstractToken.java:44
boolean isValid()
Definition: AbstractToken.java:103
void checkExpired()
Definition: AbstractToken.java:84

◆ getHash()

String org.xdi.oxauth.model.common.AbstractToken.getHash ( SignatureAlgorithm  signatureAlgorithm)
inline
242  {
243  String hash = null;
244 
245  try {
246  byte[] digest;
247  if (signatureAlgorithm == SignatureAlgorithm.HS256 ||
248  signatureAlgorithm == SignatureAlgorithm.RS256 ||
249  signatureAlgorithm == SignatureAlgorithm.ES256) {
250  digest = JwtUtil.getMessageDigestSHA256(code);
251  } else if (signatureAlgorithm == SignatureAlgorithm.HS384 ||
252  signatureAlgorithm == SignatureAlgorithm.RS384 ||
253  signatureAlgorithm == SignatureAlgorithm.ES512) {
254  digest = JwtUtil.getMessageDigestSHA384(code);
255  } else if (signatureAlgorithm == SignatureAlgorithm.HS512 ||
256  signatureAlgorithm == SignatureAlgorithm.RS384 ||
257  signatureAlgorithm == SignatureAlgorithm.ES512) {
258  digest = JwtUtil.getMessageDigestSHA512(code);
259  } else { // Default
260  digest = JwtUtil.getMessageDigestSHA256(code);
261  }
262 
263  if (digest != null) {
264  byte[] lefMostHalf = new byte[digest.length / 2];
265  System.arraycopy(digest, 0, lefMostHalf, 0, lefMostHalf.length);
266  hash = Base64Util.base64urlencode(lefMostHalf);
267  }
268  } catch (NoSuchAlgorithmException e) {
269  } catch (UnsupportedEncodingException e) {
270  } catch (NoSuchProviderException e) {
271  } catch (Exception e) {
272  }
273 
274  return hash;
275  }
String code
Definition: AbstractToken.java:40

◆ getSessionDn()

String org.xdi.oxauth.model.common.AbstractToken.getSessionDn ( )
inline
217  {
218  return sessionDn;
219  }
String sessionDn
Definition: AbstractToken.java:51

◆ isExpired()

boolean org.xdi.oxauth.model.common.AbstractToken.isExpired ( )
inline

Return true if the token has expired.

戻り値
true if the token has expired.
185  {
186  return expired;
187  }
boolean expired
Definition: AbstractToken.java:46

◆ isRevoked()

boolean org.xdi.oxauth.model.common.AbstractToken.isRevoked ( )
inline

Returns true if the token has been revoked.

戻り値
true if the token has been revoked.
166  {
167  return revoked;
168  }
boolean revoked
Definition: AbstractToken.java:45

◆ isValid()

boolean org.xdi.oxauth.model.common.AbstractToken.isValid ( )
inline

Checks whether a token is valid, it is valid if it is not revoked and not expired.

戻り値
Returns true if the token is valid.
103  {
104  return !revoked && !expired;
105  }
boolean expired
Definition: AbstractToken.java:46
boolean revoked
Definition: AbstractToken.java:45

◆ setAuthMode()

void org.xdi.oxauth.model.common.AbstractToken.setAuthMode ( String  authMode)
inline

Sets the authentication mode.

引数
authModeThe authentication mode.
213  {
214  this.authMode = authMode;
215  }
String authMode
Definition: AbstractToken.java:49

◆ setCode()

void org.xdi.oxauth.model.common.AbstractToken.setCode ( String  code)
inline

Sets the token code.

引数
codeThe code of the token.
121  {
122  this.code = code;
123  }
String code
Definition: AbstractToken.java:40

◆ setCreationDate()

void org.xdi.oxauth.model.common.AbstractToken.setCreationDate ( Date  creationDate)
inline

Sets the creation date of the token.

引数
creationDateThe creation date.
139  {
140  this.creationDate = creationDate != null ? new Date(creationDate.getTime()) : null;
141  }
Date creationDate
Definition: AbstractToken.java:42

◆ setExpirationDate()

void org.xdi.oxauth.model.common.AbstractToken.setExpirationDate ( Date  expirationDate)
inline

Sets the expiration date of the token.

引数
expirationDateThe expiration date.
157  {
158  this.expirationDate = expirationDate != null ? new Date(expirationDate.getTime()) : null;
159  }
Date expirationDate
Definition: AbstractToken.java:44

◆ setExpired()

synchronized void org.xdi.oxauth.model.common.AbstractToken.setExpired ( boolean  expired)
inline

Sets the value of the expired flag to indicate whether the token has expired.

引数
expiredExpire or not.
195  {
196  this.expired = expired;
197  }
boolean expired
Definition: AbstractToken.java:46

◆ setRevoked()

synchronized void org.xdi.oxauth.model.common.AbstractToken.setRevoked ( boolean  revoked)
inline

Sets the value of the revoked flag to indicate whether the token has been revoked.

引数
revokedRevoke or not.
176  {
177  this.revoked = revoked;
178  }
boolean revoked
Definition: AbstractToken.java:45

◆ setSessionDn()

void org.xdi.oxauth.model.common.AbstractToken.setSessionDn ( String  sessionDn)
inline
221  {
222  this.sessionDn = sessionDn;
223  }
String sessionDn
Definition: AbstractToken.java:51

メンバ詳解

◆ authMode

String org.xdi.oxauth.model.common.AbstractToken.authMode
private

◆ code

String org.xdi.oxauth.model.common.AbstractToken.code
private

◆ creationDate

Date org.xdi.oxauth.model.common.AbstractToken.creationDate
private

◆ expirationDate

Date org.xdi.oxauth.model.common.AbstractToken.expirationDate
private

◆ expired

boolean org.xdi.oxauth.model.common.AbstractToken.expired
private

◆ revoked

boolean org.xdi.oxauth.model.common.AbstractToken.revoked
private

◆ sessionDn

String org.xdi.oxauth.model.common.AbstractToken.sessionDn
private

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