gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.service.KeyGeneratorTimer クラス
org.xdi.oxauth.service.KeyGeneratorTimer 連携図
Collaboration graph

公開メンバ関数

void initTimer ()
 
void process (@Observes @Scheduled KeyGenerationEvent keyGenerationEvent)
 
String updateKeys () throws JSONException, Exception
 

非公開メンバ関数

JSONObject updateKeys (JSONObject jwks) throws Exception
 

非公開変数類

Logger log
 
Event< TimerEvent > timerEvent
 
ConfigurationFactory configurationFactory
 
PersistenceEntryManager ldapEntryManager
 
AppConfiguration appConfiguration
 
AtomicBoolean isActive
 

静的非公開変数類

static final String EVENT_TYPE = "KeyGeneratorTimerEvent"
 
static final int DEFAULT_INTERVAL = 48
 

詳解

著者
Javier Rojas Blum
バージョン
June 15, 2016

関数詳解

◆ initTimer()

void org.xdi.oxauth.service.KeyGeneratorTimer.initTimer ( )
inline
67  {
68  log.debug("Initializing Key Generator Timer");
69 
70  this.isActive = new AtomicBoolean(false);
71 
73  if (interval <= 0) {
74  interval = DEFAULT_INTERVAL;
75  }
76 
77  interval = interval * 3600;
78  timerEvent.fire(new TimerEvent(new TimerSchedule(interval, interval), new KeyGenerationEvent(),
79  Scheduled.Literal.INSTANCE));
80  }
AppConfiguration appConfiguration
Definition: KeyGeneratorTimer.java:63
Event< TimerEvent > timerEvent
Definition: KeyGeneratorTimer.java:54
static final int DEFAULT_INTERVAL
Definition: KeyGeneratorTimer.java:48
int getKeyRegenerationInterval()
Definition: AppConfiguration.java:848
Logger log
Definition: KeyGeneratorTimer.java:51
AtomicBoolean isActive
Definition: KeyGeneratorTimer.java:65

◆ process()

void org.xdi.oxauth.service.KeyGeneratorTimer.process ( @Observes @Scheduled KeyGenerationEvent  keyGenerationEvent)
inline
83  {
85  return;
86  }
87 
88  if (this.isActive.get()) {
89  return;
90  }
91 
92  if (!this.isActive.compareAndSet(false, true)) {
93  return;
94  }
95 
96  try {
97  updateKeys();
98  } catch (Exception e) {
99  log.error(e.getMessage(), e);
100  } finally {
101  this.isActive.set(false);
102  }
103  }
String updateKeys()
Definition: KeyGeneratorTimer.java:105
AppConfiguration appConfiguration
Definition: KeyGeneratorTimer.java:63
Boolean getKeyRegenerationEnabled()
Definition: AppConfiguration.java:840
Logger log
Definition: KeyGeneratorTimer.java:51
AtomicBoolean isActive
Definition: KeyGeneratorTimer.java:65

◆ updateKeys() [1/2]

String org.xdi.oxauth.service.KeyGeneratorTimer.updateKeys ( ) throws JSONException, Exception
inline
105  {
106  String dn = configurationFactory.getPersistenceConfiguration().getConfiguration().getString("configurationEntryDN");
107  Conf conf = ldapEntryManager.find(Conf.class, dn);
108 
109  JSONObject jwks = new JSONObject(conf.getWebKeys());
110  conf.setWebKeys(updateKeys(jwks).toString());
111 
112  long nextRevision = conf.getRevision() + 1;
113  conf.setRevision(nextRevision);
114  ldapEntryManager.merge(conf);
115 
116  return conf.getWebKeys();
117  }
String updateKeys()
Definition: KeyGeneratorTimer.java:105
ConfigurationFactory configurationFactory
Definition: KeyGeneratorTimer.java:57
PersistenceEntryManager ldapEntryManager
Definition: KeyGeneratorTimer.java:60
PersistenceConfiguration getPersistenceConfiguration()
Definition: ConfigurationFactory.java:247
final FileConfiguration getConfiguration()
Definition: ConfigurationFactory.java:661

◆ updateKeys() [2/2]

JSONObject org.xdi.oxauth.service.KeyGeneratorTimer.updateKeys ( JSONObject  jwks) throws Exception
inlineprivate
119  {
120  JSONObject jsonObject = AbstractCryptoProvider.generateJwks(appConfiguration.getKeyRegenerationInterval(),
122 
123  JSONArray keys = jwks.getJSONArray(JSON_WEB_KEY_SET);
124  for (int i = 0; i < keys.length(); i++) {
125  JSONObject key = keys.getJSONObject(i);
126 
127  if (key.has(EXPIRATION_TIME) && !key.isNull(EXPIRATION_TIME)) {
128  GregorianCalendar now = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
129  GregorianCalendar expirationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
130  expirationDate.setTimeInMillis(key.getLong(EXPIRATION_TIME));
131 
132  if (expirationDate.before(now)) {
133  // The expired key is not added to the array of keys
134  log.debug("Removing JWK: {}, Expiration date: {}", key.getString(KEY_ID),
135  key.getString(EXPIRATION_TIME));
136  AbstractCryptoProvider cryptoProvider = CryptoProviderFactory.getCryptoProvider(appConfiguration);
137  cryptoProvider.deleteKey(key.getString(KEY_ID));
138  } else {
139  jsonObject.getJSONArray(JSON_WEB_KEY_SET).put(key);
140  }
141  } else {
142  GregorianCalendar expirationTime = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
143  expirationTime.add(GregorianCalendar.HOUR, appConfiguration.getKeyRegenerationInterval());
144  expirationTime.add(GregorianCalendar.SECOND, appConfiguration.getIdTokenLifetime());
145  key.put(EXPIRATION_TIME, expirationTime.getTimeInMillis());
146 
147  jsonObject.getJSONArray(JSON_WEB_KEY_SET).put(key);
148  }
149  }
150 
151  return jsonObject;
152  }
AppConfiguration appConfiguration
Definition: KeyGeneratorTimer.java:63
int getKeyRegenerationInterval()
Definition: AppConfiguration.java:848
Logger log
Definition: KeyGeneratorTimer.java:51
int getIdTokenLifetime()
Definition: AppConfiguration.java:784

メンバ詳解

◆ appConfiguration

AppConfiguration org.xdi.oxauth.service.KeyGeneratorTimer.appConfiguration
private

◆ configurationFactory

ConfigurationFactory org.xdi.oxauth.service.KeyGeneratorTimer.configurationFactory
private

◆ DEFAULT_INTERVAL

final int org.xdi.oxauth.service.KeyGeneratorTimer.DEFAULT_INTERVAL = 48
staticprivate

◆ EVENT_TYPE

final String org.xdi.oxauth.service.KeyGeneratorTimer.EVENT_TYPE = "KeyGeneratorTimerEvent"
staticprivate

◆ isActive

AtomicBoolean org.xdi.oxauth.service.KeyGeneratorTimer.isActive
private

◆ ldapEntryManager

PersistenceEntryManager org.xdi.oxauth.service.KeyGeneratorTimer.ldapEntryManager
private

◆ log

Logger org.xdi.oxauth.service.KeyGeneratorTimer.log
private

◆ timerEvent

Event<TimerEvent> org.xdi.oxauth.service.KeyGeneratorTimer.timerEvent
private

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