gluu
公開メンバ関数 | 静的公開変数類 | 関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.gluu.credmanager.core.ConfigurationHandler クラス
org.gluu.credmanager.core.ConfigurationHandler の継承関係図
Inheritance graph
org.gluu.credmanager.core.ConfigurationHandler 連携図
Collaboration graph

公開メンバ関数

MainSettings getSettings ()
 
Set< String > retrieveAcrs ()
 
String getName ()
 
void jobToBeExecuted (JobExecutionContext context)
 
AppStateEnum getAppState ()
 
Map< String, Integer > getAcrLevelMapping ()
 
Set< String > getEnabledAcrs ()
 

静的公開変数類

static final Pair< Integer, Integer > BOUNDS_MINCREDS_2FA = new Pair<>(1, 3)
 
static final String DEFAULT_ACR = "credmanager"
 
static final List< String > DEFAULT_SUPPORTED_METHODS = Arrays.asList("u2f", "otp", "super_gluu", "twilio_sms")
 

関数

void init ()
 

非公開メンバ関数

void inited ()
 
void initDevicesSweeper ()
 
void setAppState (AppStateEnum state)
 
void computeLoggingLevel ()
 
void computeMinCredsForStrongAuth ()
 
void computeBrandingPath ()
 
void computePassResetable ()
 
void compute2FAEnforcementPolicy ()
 
void refreshAcrPluginMapping ()
 

非公開変数類

Logger logger
 
MainSettings settings
 
LdapService ldapService
 
OxdService oxdService
 
EventBus eventBus
 
ExtensionsManager extManager
 
TimerService timerService
 
LogService logService
 
TrustedDevicesSweeper devicesSweeper
 
AuthnScriptsReloader scriptsReloader
 
Set< String > serverAcrs
 
String acrQuartzJobName
 
ObjectMapper mapper
 
AppStateEnum appState
 

静的非公開変数類

static final int RETRIES = 15
 
static final int RETRY_INTERVAL = 20
 
static final int TRUSTED_DEVICE_EXPIRATION_DAYS = 30
 
static final int TRUSTED_LOCATION_EXPIRATION_DAYS = 15
 

詳解

著者
jgomer

関数詳解

◆ compute2FAEnforcementPolicy()

void org.gluu.credmanager.core.ConfigurationHandler.compute2FAEnforcementPolicy ( )
inlineprivate
324  {
325  if (Utils.isEmpty(settings.getEnforcement2FA())) {
326  settings.setEnforcement2FA(Collections.singletonList(EnforcementPolicy.EVERY_LOGIN));
327  }
328  }
List< EnforcementPolicy > getEnforcement2FA()
Definition: MainSettings.java:146
void setEnforcement2FA(List< EnforcementPolicy > enforcement2FA)
Definition: MainSettings.java:186
MainSettings settings
Definition: ConfigurationHandler.java:58

◆ computeBrandingPath()

void org.gluu.credmanager.core.ConfigurationHandler.computeBrandingPath ( )
inlineprivate
300  {
301 
302  String path = settings.getBrandingPath();
303  try {
304  if (Utils.isNotEmpty(path) && !Files.isDirectory(Paths.get(path))) {
305  throw new IOException("Not a directory");
306  }
307  } catch (Exception e) {
308  logger.error("Filesystem directory {} for custom branding is wrong. Using default theme", path);
309  logger.error(e.getMessage(), e);
311  }
312 
313  }
Logger logger
Definition: ConfigurationHandler.java:55
String getBrandingPath()
Definition: MainSettings.java:100
MainSettings settings
Definition: ConfigurationHandler.java:58
void setBrandingPath(String brandingPath)
Definition: MainSettings.java:162

◆ computeLoggingLevel()

void org.gluu.credmanager.core.ConfigurationHandler.computeLoggingLevel ( )
inlineprivate
278  {
280  }
void setLogLevel(String logLevel)
Definition: MainSettings.java:154
MainSettings settings
Definition: ConfigurationHandler.java:58
String getLogLevel()
Definition: MainSettings.java:95
LogService logService
Definition: ConfigurationHandler.java:76
String updateLoggingLevel(String levelInConfFile)
Definition: LogService.java:37

◆ computeMinCredsForStrongAuth()

void org.gluu.credmanager.core.ConfigurationHandler.computeMinCredsForStrongAuth ( )
inlineprivate
282  {
283 
284  int defaultValue = (BOUNDS_MINCREDS_2FA.getX() + BOUNDS_MINCREDS_2FA.getY()) / 2;
285  Integer providedValue = settings.getMinCredsFor2FA();
286 
287  if (providedValue == null) {
288  logger.info("Using default value {} for minimum number of credentials to enable strong authentication");
289  settings.setMinCredsFor2FA(defaultValue);
290  } else {
291  if (providedValue < BOUNDS_MINCREDS_2FA.getX() || providedValue > BOUNDS_MINCREDS_2FA.getY()) {
292  logger.info("Value for min_creds_2FA={} not in interval [{},{}]. Defaulting to {}", providedValue,
293  BOUNDS_MINCREDS_2FA.getX(), BOUNDS_MINCREDS_2FA.getY(), defaultValue);
294  settings.setMinCredsFor2FA(defaultValue);
295  }
296  }
297 
298  }
static final Pair< Integer, Integer > BOUNDS_MINCREDS_2FA
Definition: ConfigurationHandler.java:45
void setMinCredsFor2FA(Integer minCredsFor2FA)
Definition: MainSettings.java:166
Integer getMinCredsFor2FA()
Definition: MainSettings.java:138
Logger logger
Definition: ConfigurationHandler.java:55
MainSettings settings
Definition: ConfigurationHandler.java:58

◆ computePassResetable()

void org.gluu.credmanager.core.ConfigurationHandler.computePassResetable ( )
inlineprivate
315  {
316 
318  logger.error("Pass reset set automatically to false. Check if you are using a backend LDAP");
320  }
321 
322  }
void setEnablePassReset(boolean enablePassReset)
Definition: MainSettings.java:150
boolean isBackendLdapEnabled()
Definition: LdapService.java:304
boolean isEnablePassReset()
Definition: MainSettings.java:90
Logger logger
Definition: ConfigurationHandler.java:55
LdapService ldapService
Definition: ConfigurationHandler.java:61
MainSettings settings
Definition: ConfigurationHandler.java:58

◆ getAcrLevelMapping()

Map<String, Integer> org.gluu.credmanager.core.ConfigurationHandler.getAcrLevelMapping ( )
inline
222  {
223 
224  Map<String, Integer> map = new HashMap<>();
225  try {
226  String oidcEndpointURL = ldapService.getOIDCEndpoint();
227  JsonNode levels = mapper.readTree(new URL(oidcEndpointURL)).get("auth_level_mapping");
228  Iterator<Map.Entry<String, JsonNode>> it = levels.fields();
229 
230  while (it.hasNext()) {
231  Map.Entry<String, JsonNode> entry = it.next();
232  try {
233  Integer levl = Integer.parseInt(entry.getKey());
234  Iterator<JsonNode> arrayIt = entry.getValue().elements();
235  while (arrayIt.hasNext()) {
236  map.put(arrayIt.next().asText(), levl);
237  }
238  } catch (Exception e) {
239  logger.error("Error parsing level for {}: {}", entry.getKey(), e.getMessage());
240  }
241  }
242  } catch (Exception e) {
243  logger.error(e.getMessage(), e);
244  }
245  return map;
246 
247  }
String getOIDCEndpoint()
Definition: LdapService.java:77
Logger logger
Definition: ConfigurationHandler.java:55
LdapService ldapService
Definition: ConfigurationHandler.java:61
ObjectMapper mapper
Definition: ConfigurationHandler.java:88

◆ getAppState()

AppStateEnum org.gluu.credmanager.core.ConfigurationHandler.getAppState ( )
inline
218  {
219  return appState;
220  }
AppStateEnum appState
Definition: ConfigurationHandler.java:90

◆ getEnabledAcrs()

Set<String> org.gluu.credmanager.core.ConfigurationHandler.getEnabledAcrs ( )
inline
249  {
250  Set<String> plugged = new HashSet<>(settings.getAcrPluginMap().keySet());
251  plugged.retainAll(retrieveAcrs());
252  return plugged;
253  }
Set< String > retrieveAcrs()
Definition: ConfigurationHandler.java:135
Map< String, String > getAcrPluginMap()
Definition: MainSettings.java:110
MainSettings settings
Definition: ConfigurationHandler.java:58

◆ getName()

String org.gluu.credmanager.core.ConfigurationHandler.getName ( )
inline
153  {
154  return acrQuartzJobName;
155  }
String acrQuartzJobName
Definition: ConfigurationHandler.java:86

◆ getSettings()

MainSettings org.gluu.credmanager.core.ConfigurationHandler.getSettings ( )
inline
126  {
127  return settings;
128  }
MainSettings settings
Definition: ConfigurationHandler.java:58

◆ init()

void org.gluu.credmanager.core.ConfigurationHandler.init ( )
inlinepackage
99  {
100 
101  try {
102  //Update log level
104  //Check LDAP access to proceed with acr timer
105  if (ldapService.isInService()) {
106  setAppState(AppStateEnum.LOADING);
107 
108  //This is a trick so the timer event logic can be coded inside this managed bean
110  /*
111  A gap of 5 seconds is enough for the RestEasy scanning process to take place (in case oxAuth is already up and running)
112  RETRIES*RETRY_INTERVAL seconds gives room to recover the acr list. This big amount of time may be required
113  in cases where cred-manager service starts too soon (even before oxAuth itself)
114  */
116  } else {
117  setAppState(AppStateEnum.FAIL);
118  }
119  } catch (Exception e) {
120  setAppState(AppStateEnum.FAIL);
121  logger.error(e.getMessage(), e);
122  }
123 
124  }
static final int RETRIES
Definition: ConfigurationHandler.java:49
static final int RETRY_INTERVAL
Definition: ConfigurationHandler.java:50
String acrQuartzJobName
Definition: ConfigurationHandler.java:86
boolean isInService()
Definition: LdapService.java:73
Logger logger
Definition: ConfigurationHandler.java:55
void setAppState(AppStateEnum state)
Definition: ConfigurationHandler.java:269
void computeLoggingLevel()
Definition: ConfigurationHandler.java:278
LdapService ldapService
Definition: ConfigurationHandler.java:61
void addListener(JobListener jobListener, String jobName)
Definition: TimerService.java:66
JobKey schedule(String name, int count, int sleepTime)
Definition: TimerService.java:48
TimerService timerService
Definition: ConfigurationHandler.java:73

◆ initDevicesSweeper()

void org.gluu.credmanager.core.ConfigurationHandler.initDevicesSweeper ( )
inlineprivate
255  {
256 
257  TrustedDevicesSettings tsettings = settings.getTrustedDevicesSettings();
258 
259  long devicesExpiration = TimeUnit.DAYS.toMillis(Optional.ofNullable(tsettings)
261 
262  long locationExpiration = TimeUnit.DAYS.toMillis(Optional.ofNullable(tsettings)
264 
265  devicesSweeper.activate(locationExpiration, devicesExpiration);
266 
267  }
static final int TRUSTED_LOCATION_EXPIRATION_DAYS
Definition: ConfigurationHandler.java:52
static final int TRUSTED_DEVICE_EXPIRATION_DAYS
Definition: ConfigurationHandler.java:51
TrustedDevicesSweeper devicesSweeper
Definition: ConfigurationHandler.java:79
void activate(long locationExpiration, long deviceExpiration)
Definition: TrustedDevicesSweeper.java:53
TrustedDevicesSettings getTrustedDevicesSettings()
Definition: MainSettings.java:125
Integer getDeviceExpirationDays()
Definition: TrustedDevicesSettings.java:28
Integer getLocationExpirationDays()
Definition: TrustedDevicesSettings.java:23
MainSettings settings
Definition: ConfigurationHandler.java:58

◆ inited()

void org.gluu.credmanager.core.ConfigurationHandler.inited ( )
inlineprivate
93  {
94  logger.info("ConfigurationHandler inited");
95  mapper = new ObjectMapper();
96  acrQuartzJobName = getClass().getSimpleName() + "_acr";
97  }
String acrQuartzJobName
Definition: ConfigurationHandler.java:86
Logger logger
Definition: ConfigurationHandler.java:55
ObjectMapper mapper
Definition: ConfigurationHandler.java:88

◆ jobToBeExecuted()

void org.gluu.credmanager.core.ConfigurationHandler.jobToBeExecuted ( JobExecutionContext  context)
inline
158  {
159 
160  try {
161  if (serverAcrs == null) {
162  Date nextJobExecutionAt = context.getNextFireTime();
163  //Do an attempt to retrieve acrs
164  retrieveAcrs();
165 
166  if (serverAcrs == null) {
167  if (nextJobExecutionAt == null) { //Run out of attempts!
168  logger.warn("The list of supported acrs could not be obtained.");
169  setAppState(AppStateEnum.FAIL);
170  } else {
171  logger.warn("Retrying in {} seconds", RETRY_INTERVAL);
172  }
173  } else {
174  //TODO: uncomment this block for production
175  /*
176  //This is required to guarantee the list of acrs is really complete (after oxauth starts, the list
177  //can still contain just a few elements)
178  Thread.sleep(RETRIES * RETRY_INTERVAL * 100);
179  logger.debug("Additional attempt");
180  retrieveAcrs();
181  */
182  if (serverAcrs.contains(DEFAULT_ACR)) {
187 
188  extManager.scan();
189  if (oxdService.initialize()) {
190  setAppState(AppStateEnum.OPERATING);
192  //TODO: uncomment
193  //scriptsReloader.init();
194  //initDevicesSweeper();
195  logger.info("=== WEBAPP INITIALIZED SUCCESSFULLY ===");
196  } else {
197  logger.warn("oxd configuration could not be initialized.");
198  setAppState(AppStateEnum.FAIL);
199  }
200  } else {
201  logger.error("Your Gluu server is missing one critical acr value: {}.", DEFAULT_ACR);
202  setAppState(AppStateEnum.FAIL);
203  }
204  }
205  if (appState.equals(AppStateEnum.FAIL)) {
206  logger.error("Application not in operable state, please fix configuration issues before proceeding.");
207  logger.info("=== WEBAPP INITIALIZATION FAILED ===");
208  }
209  }
210  } catch (Exception e) {
211  if (!appState.equals(AppStateEnum.OPERATING)) {
212  logger.error(e.getMessage(), e);
213  }
214  }
215 
216  }
static final String DEFAULT_ACR
Definition: ConfigurationHandler.java:46
void computeMinCredsForStrongAuth()
Definition: ConfigurationHandler.java:282
Set< String > serverAcrs
Definition: ConfigurationHandler.java:84
OxdService oxdService
Definition: ConfigurationHandler.java:64
static final int RETRY_INTERVAL
Definition: ConfigurationHandler.java:50
void computeBrandingPath()
Definition: ConfigurationHandler.java:300
void computePassResetable()
Definition: ConfigurationHandler.java:315
void refreshAcrPluginMapping()
Definition: ConfigurationHandler.java:330
Logger logger
Definition: ConfigurationHandler.java:55
void scan()
Definition: ExtensionsManager.java:82
void setAppState(AppStateEnum state)
Definition: ConfigurationHandler.java:269
AppStateEnum appState
Definition: ConfigurationHandler.java:90
void compute2FAEnforcementPolicy()
Definition: ConfigurationHandler.java:324
Set< String > retrieveAcrs()
Definition: ConfigurationHandler.java:135
ExtensionsManager extManager
Definition: ConfigurationHandler.java:70
boolean initialize()
Definition: OxdService.java:80

◆ refreshAcrPluginMapping()

void org.gluu.credmanager.core.ConfigurationHandler.refreshAcrPluginMapping ( )
inlineprivate
330  {
331 
332  Map<String, String> mapping = settings.getAcrPluginMap();
333 
334  if (Utils.isEmpty(mapping)) {
335  Set<String> acrs = extManager.getAuthnMethodExts().stream().map(AuthnMethod::getAcr).collect(Collectors.toSet());
336  acrs.addAll(DEFAULT_SUPPORTED_METHODS);
337 
338  //Try to build the map by inspecting system extensions
339  mapping = new HashMap<>();
340  for (String acr : acrs) {
341  if (extManager.pluginImplementsAuthnMethod(acr, null)) {
342  mapping.put(acr, null);
343  }
344  }
345  settings.setAcrPluginMap(mapping);
346  } else {
347  Map<String, String> newMap = new HashMap<>();
348  for (String acr : mapping.keySet()) {
349  //Is there a current runtime impl for this acr?
350  String plugId = mapping.get(acr);
351  if (extManager.pluginImplementsAuthnMethod(acr, plugId)) {
352  newMap.put(acr, plugId);
353  } else {
354  if (plugId == null) {
355  logger.warn("There is no system extension that can work with acr '{}'", acr);
356  } else {
357  logger.warn("Plugin {} does not have extensions that can work with acr '{}' or plugin does not exist", plugId, acr);
358  }
359  logger.warn("acr removed from configuration file...");
360  }
361  }
362  settings.setAcrPluginMap(newMap);
363  try {
364  settings.save();
365  } catch (Exception e) {
366  logger.error(e.getMessage(), e);
367  }
368  }
369 
370  }
List< AuthnMethod > getAuthnMethodExts()
Definition: ExtensionsManager.java:180
void save()
Definition: MainSettings.java:85
Logger logger
Definition: ConfigurationHandler.java:55
void setAcrPluginMap(Map< String, String > acrPluginMap)
Definition: MainSettings.java:174
boolean pluginImplementsAuthnMethod(String acr, String plugId)
Definition: ExtensionsManager.java:155
Map< String, String > getAcrPluginMap()
Definition: MainSettings.java:110
MainSettings settings
Definition: ConfigurationHandler.java:58
ExtensionsManager extManager
Definition: ConfigurationHandler.java:70
static final List< String > DEFAULT_SUPPORTED_METHODS
Definition: ConfigurationHandler.java:47

◆ retrieveAcrs()

Set<String> org.gluu.credmanager.core.ConfigurationHandler.retrieveAcrs ( )
inline

Performs a GET to the OIDC metadata URL and extracts the ACR values supported by the server

戻り値
A Set of String values
例外
ExceptionIf an networking or parsing error occurs
135  {
136 
137  try {
138  String oidcEndpointURL = ldapService.getOIDCEndpoint();
139  logger.debug("Obtaining \"acr_values_supported\" from server {}", oidcEndpointURL);
140  JsonNode values = mapper.readTree(new URL(oidcEndpointURL)).get("acr_values_supported");
141 
142  //Store server's supported acr values in a set
143  serverAcrs = new HashSet<>();
144  values.forEach(node -> serverAcrs.add(node.asText()));
145  } catch (Exception e) {
146  logger.error("Could not retrieve the list of acrs supported by this server: {}", e.getMessage());
147  }
148  return serverAcrs;
149 
150  }
Set< String > serverAcrs
Definition: ConfigurationHandler.java:84
String getOIDCEndpoint()
Definition: LdapService.java:77
Logger logger
Definition: ConfigurationHandler.java:55
LdapService ldapService
Definition: ConfigurationHandler.java:61
ObjectMapper mapper
Definition: ConfigurationHandler.java:88

◆ setAppState()

void org.gluu.credmanager.core.ConfigurationHandler.setAppState ( AppStateEnum  state)
inlineprivate
269  {
270 
271  if (!state.equals(appState)) {
272  eventBus.post(new AppStateChangeEvent(state));
273  }
274  appState = state;
275 
276  }
AppStateEnum appState
Definition: ConfigurationHandler.java:90
EventBus eventBus
Definition: ConfigurationHandler.java:67

メンバ詳解

◆ acrQuartzJobName

String org.gluu.credmanager.core.ConfigurationHandler.acrQuartzJobName
private

◆ appState

AppStateEnum org.gluu.credmanager.core.ConfigurationHandler.appState
private

◆ BOUNDS_MINCREDS_2FA

final Pair<Integer, Integer> org.gluu.credmanager.core.ConfigurationHandler.BOUNDS_MINCREDS_2FA = new Pair<>(1, 3)
static

◆ DEFAULT_ACR

final String org.gluu.credmanager.core.ConfigurationHandler.DEFAULT_ACR = "credmanager"
static

◆ DEFAULT_SUPPORTED_METHODS

final List<String> org.gluu.credmanager.core.ConfigurationHandler.DEFAULT_SUPPORTED_METHODS = Arrays.asList("u2f", "otp", "super_gluu", "twilio_sms")
static

◆ devicesSweeper

TrustedDevicesSweeper org.gluu.credmanager.core.ConfigurationHandler.devicesSweeper
private

◆ eventBus

EventBus org.gluu.credmanager.core.ConfigurationHandler.eventBus
private

◆ extManager

ExtensionsManager org.gluu.credmanager.core.ConfigurationHandler.extManager
private

◆ ldapService

LdapService org.gluu.credmanager.core.ConfigurationHandler.ldapService
private

◆ logger

Logger org.gluu.credmanager.core.ConfigurationHandler.logger
private

◆ logService

LogService org.gluu.credmanager.core.ConfigurationHandler.logService
private

◆ mapper

ObjectMapper org.gluu.credmanager.core.ConfigurationHandler.mapper
private

◆ oxdService

OxdService org.gluu.credmanager.core.ConfigurationHandler.oxdService
private

◆ RETRIES

final int org.gluu.credmanager.core.ConfigurationHandler.RETRIES = 15
staticprivate

◆ RETRY_INTERVAL

final int org.gluu.credmanager.core.ConfigurationHandler.RETRY_INTERVAL = 20
staticprivate

◆ scriptsReloader

AuthnScriptsReloader org.gluu.credmanager.core.ConfigurationHandler.scriptsReloader
private

◆ serverAcrs

Set<String> org.gluu.credmanager.core.ConfigurationHandler.serverAcrs
private

◆ settings

MainSettings org.gluu.credmanager.core.ConfigurationHandler.settings
private

◆ timerService

TimerService org.gluu.credmanager.core.ConfigurationHandler.timerService
private

◆ TRUSTED_DEVICE_EXPIRATION_DAYS

final int org.gluu.credmanager.core.ConfigurationHandler.TRUSTED_DEVICE_EXPIRATION_DAYS = 30
staticprivate

◆ TRUSTED_LOCATION_EXPIRATION_DAYS

final int org.gluu.credmanager.core.ConfigurationHandler.TRUSTED_LOCATION_EXPIRATION_DAYS = 15
staticprivate

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