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

公開メンバ関数

 AuthorizationCode (int lifeTime)
 
 AuthorizationCode (String code, Date creationDate, Date expirationDate)
 
boolean isValid ()
 
boolean isUsed ()
 
synchronized void setUsed (boolean used)
 
void checkExpired ()
 
void checkExpired (Date now)
 
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)
 

非公開変数類

boolean used
 

詳解

The authorization code is obtained by using an authorization server as an intermediary between the client and resource owner. Instead of requesting authorization directly from the resource owner, the client directs the resource owner to an authorization server (via its user- agent as defined in [RFC2616]), which in turn directs the resource owner back to the client with the authorization code.

Before directing the resource owner back to the client with the authorization code, the authorization server authenticates the resource owner and obtains authorization. Because the resource owner only authenticates with the authorization server, the resource owner's credentials are never shared with the client.

The authorization code provides a few important security benefits such as the ability to authenticate the client, and the transmission of the access token directly to the client without passing it through the resource owner's user-agent, potentially exposing it to others, including the resource owner.

著者
Javier Rojas Blum Date: 09.29.2011

構築子と解体子

◆ AuthorizationCode() [1/2]

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

Constructs an 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.

引数
lifeTimeThe life time of the token.
55  {
56  super(lifeTime);
57  used = false;
58  }
boolean used
Definition: AuthorizationCode.java:38

◆ AuthorizationCode() [2/2]

org.xdi.oxauth.model.common.AuthorizationCode.AuthorizationCode ( String  code,
Date  creationDate,
Date  expirationDate 
)
inline
60  {
62  used = false;
63  checkExpired();
64  }
Date creationDate
Definition: AbstractToken.java:42
Date expirationDate
Definition: AbstractToken.java:44
String code
Definition: AbstractToken.java:40
boolean used
Definition: AuthorizationCode.java:38
void checkExpired()
Definition: AbstractToken.java:84

関数詳解

◆ checkExpired() [1/2]

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

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)
inlineinherited

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 ( )
inlineinherited

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 ( )
inlineinherited

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 ( )
inlineinherited

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 ( )
inlineinherited

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 ( )
inlineinherited

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)
inlineinherited
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 ( )
inlineinherited
217  {
218  return sessionDn;
219  }
String sessionDn
Definition: AbstractToken.java:51

◆ isExpired()

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

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 ( )
inlineinherited

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

◆ isUsed()

boolean org.xdi.oxauth.model.common.AuthorizationCode.isUsed ( )
inline

Returns whether an authorization code has been used.

戻り値
true if the authorization code has been used.
80  {
81  return used;
82  }
boolean used
Definition: AuthorizationCode.java:38

◆ isValid()

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

Checks whether a token is valid. An authorization code is valid if it has not been used before, not revoked and not expired.

71  {
72  return super.isValid() && !used;
73  }
boolean used
Definition: AuthorizationCode.java:38

◆ setAuthMode()

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

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited
221  {
222  this.sessionDn = sessionDn;
223  }
String sessionDn
Definition: AbstractToken.java:51

◆ setUsed()

synchronized void org.xdi.oxauth.model.common.AuthorizationCode.setUsed ( boolean  used)
inline

Sets the flag to indicate whether a token has been used. The authorization code must be used only once and after it must be marked as used.

引数
usedUsed or not.
91  {
92  this.used = used;
93  }
boolean used
Definition: AuthorizationCode.java:38

メンバ詳解

◆ used

boolean org.xdi.oxauth.model.common.AuthorizationCode.used
private

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