gluu
公開メンバ関数 | 関数 | 変数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.gluu.credmanager.plugins.authnmethod.service.FidoService クラス
org.gluu.credmanager.plugins.authnmethod.service.FidoService の継承関係図
Inheritance graph
org.gluu.credmanager.plugins.authnmethod.service.FidoService 連携図
Collaboration graph

公開メンバ関数

boolean updateDevice (FidoDevice device)
 
boolean removeDevice (FidoDevice device)
 
int getDevicesTotal (String appId, String userId, boolean active)
 

関数

public< T extends FidoDevice > T getLatestFidoDevice (String userId, long time, String oxApp, Class< T > clazz) throws Exception
 
private< T extends FidoDevice > List< T > getDevices (String userId, boolean active, String oxApplication, Class< T > clazz) throws Exception
 
< T extends FidoDevice > List< T > getSortedDevices (String userId, boolean active, String appId, Class< T > clazz)
 
private< T extends FidoDevice > T getRecentlyCreatedDevice (List< T > devices, long time)
 

変数

MainSettings settings
 
LdapService ldapService
 
ObjectMapper mapper
 

非公開メンバ関数

oxDeviceRegistration getDeviceRegistrationFor (FidoDevice device)
 
List< oxDeviceRegistrationgetRegistrations (String appId, String userId, boolean active)
 

非公開変数類

Logger logger
 
ObjectMapper codehausMapper = new ObjectMapper()
 

詳解

著者
jgomer

関数詳解

◆ getDeviceRegistrationFor()

oxDeviceRegistration org.gluu.credmanager.plugins.authnmethod.service.FidoService.getDeviceRegistrationFor ( FidoDevice  device)
inlineprivate
78  {
79 
80  String id = device.getId();
81  oxDeviceRegistration deviceRegistration = new oxDeviceRegistration();
82  deviceRegistration.setOxId(device.getId());
83  List<oxDeviceRegistration> list = ldapService.find(deviceRegistration, oxDeviceRegistration.class, ldapService.getPeopleDn());
84  if (list.size() == 1) {
85  return list.get(0);
86  } else {
87  logger.warn("Search for fido device rgistration with oxId {} returned {} results!", id, list.size());
88  return null;
89  }
90 
91  }
LdapService ldapService
Definition: BaseService.java:20
public< T > List< T > find(Class< T > clazz, String parentDn, String filter)
Definition: LdapService.java:222
String getPeopleDn()
Definition: LdapService.java:171

◆ getDevices()

private<T extends FidoDevice> List<T> org.gluu.credmanager.plugins.authnmethod.service.FidoService.getDevices ( String  userId,
boolean  active,
String  oxApplication,
Class< T >  clazz 
) throws Exception
inlinepackage

Returns a list of FidoDevice instances found under the given branch that matches the oxApplication value given and whose oxStatus attribute equals to "active"

引数
userId
oxApplicationValue to match for oxApplication attribute (see LDAP object class oxDeviceRegistration)
clazzAny subclass of FidoDevice
<T>
戻り値
List of FidoDevices
114  {
115 
116  List<T> devices = new ArrayList<>();
117  List<oxDeviceRegistration> list = getRegistrations(oxApplication, userId, active);
118 
119  for (oxDeviceRegistration deviceRegistration : list) {
120  T device = clazz.getConstructor().newInstance();
121 
122  if (clazz.equals(SuperGluuDevice.class)) {
123  //DeviceData class is annotated with org.codehaus and has no default constructor so using normal mapper gives trouble
124  DeviceData data = codehausMapper.readValue(deviceRegistration.getDeviceData(), DeviceData.class);
125  ((SuperGluuDevice) device).setDeviceData(data);
126  }
127  device.setApplication(deviceRegistration.getOxApplication());
128  device.setNickName(deviceRegistration.getDisplayName());
129  device.setStatus(deviceRegistration.getOxStatus());
130  device.setId(deviceRegistration.getOxId());
131  device.setCreationDate(deviceRegistration.getCreationDate());
132  device.setCounter(deviceRegistration.getOxCounter());
133 
134  devices.add(device);
135  }
136  return devices;
137 
138  }
List< oxDeviceRegistration > getRegistrations(String appId, String userId, boolean active)
Definition: FidoService.java:93
ObjectMapper codehausMapper
Definition: FidoService.java:35

◆ getDevicesTotal()

int org.gluu.credmanager.plugins.authnmethod.service.FidoService.getDevicesTotal ( String  appId,
String  userId,
boolean  active 
)
inline
60  {
61 
62  int total = 0;
63  try {
64  total = getRegistrations(appId, userId, active).size();
65  } catch (Exception e) {
66  logger.error(e.getMessage(), e);
67  }
68  return total;
69 
70  }
List< oxDeviceRegistration > getRegistrations(String appId, String userId, boolean active)
Definition: FidoService.java:93

◆ getLatestFidoDevice()

public<T extends FidoDevice> T org.gluu.credmanager.plugins.authnmethod.service.FidoService.getLatestFidoDevice ( String  userId,
long  time,
String  oxApp,
Class< T >  clazz 
) throws Exception
inlinepackage
72  {
73  List<T> list = getDevices(userId, true, oxApp, clazz);
74  logger.debug("getLatestFidoDevice. list is {}", list.stream().map(FidoDevice::getId).collect(Collectors.toList()).toString());
75  return getRecentlyCreatedDevice(list, time);
76  }
private< T extends FidoDevice > List< T > getDevices(String userId, boolean active, String oxApplication, Class< T > clazz)
Definition: FidoService.java:114
private< T extends FidoDevice > T getRecentlyCreatedDevice(List< T > devices, long time)
Definition: FidoService.java:162
String getId()
Definition: FidoDevice.java:18

◆ getRecentlyCreatedDevice()

private<T extends FidoDevice> T org.gluu.credmanager.plugins.authnmethod.service.FidoService.getRecentlyCreatedDevice ( List< T >  devices,
long  time 
)
inlinepackage

Chooses one device from a list of devices, such that its creation time is the closest to the timestamp given

引数
devicesA non-null list of fido devices
timeA timestamp as milliseconds elapsed from the "epoch"
<T>
戻り値
The best matching device (only devices added before the time supplied are considered). Null if no suitable device could be found
162  {
163 
164  long[] diffs = devices.stream().mapToLong(key -> time - key.getCreationDate().getTime()).toArray();
165 
166  logger.trace("getRecentlyCreatedDevice. diffs {}", Arrays.asList(diffs));
167  //Search for the smallest time difference
168  int i;
169  Pair<Long, Integer> min = new Pair<>(Long.MAX_VALUE, -1);
170  //it always holds that diffs.length==devices.size()
171  for (i = 0; i < diffs.length; i++) {
172  if (diffs[i] >= 0 && min.getX() > diffs[i]) { //Only search non-negative differences
173  min = new Pair<>(diffs[i], i);
174  }
175  }
176 
177  i = min.getY();
178  return i == -1 ? null : devices.get(i);
179 
180  }

◆ getRegistrations()

List<oxDeviceRegistration> org.gluu.credmanager.plugins.authnmethod.service.FidoService.getRegistrations ( String  appId,
String  userId,
boolean  active 
)
inlineprivate
93  {
94 
95  String parentDn = String.format("ou=fido,%s", ldapService.getPersonDn(userId));
96 
97  oxDeviceRegistration deviceRegistration = new oxDeviceRegistration();
98  deviceRegistration.setOxApplication(appId);
99  deviceRegistration.setOxStatus(active ? DeviceRegistrationStatus.ACTIVE.getValue() : DeviceRegistrationStatus.COMPROMISED.getValue());
100 
101  return ldapService.find(deviceRegistration, oxDeviceRegistration.class, parentDn);
102 
103  }
LdapService ldapService
Definition: BaseService.java:20
public< T > List< T > find(Class< T > clazz, String parentDn, String filter)
Definition: LdapService.java:222
String getPersonDn(String id)
Definition: LdapService.java:167

◆ getSortedDevices()

<T extends FidoDevice> List<T> org.gluu.credmanager.plugins.authnmethod.service.FidoService.getSortedDevices ( String  userId,
boolean  active,
String  appId,
Class< T >  clazz 
)
inlinepackage
140  {
141 
142  List<T> devices = new ArrayList<>();
143  try {
144  devices = getDevices(userId, active, appId, clazz).stream().sorted().collect(Collectors.toList());
145  logger.trace("getDevices. User '{}' has {}", userId, devices.stream().map(FidoDevice::getId).collect(Collectors.toList()));
146  } catch (Exception e) {
147  logger.error(e.getMessage(), e);
148  }
149  return devices;
150  }
private< T extends FidoDevice > List< T > getDevices(String userId, boolean active, String oxApplication, Class< T > clazz)
Definition: FidoService.java:114
String getId()
Definition: FidoDevice.java:18

◆ removeDevice()

boolean org.gluu.credmanager.plugins.authnmethod.service.FidoService.removeDevice ( FidoDevice  device)
inline
49  {
50 
51  boolean success = false;
52  oxDeviceRegistration deviceRegistration = getDeviceRegistrationFor(device);
53  if (deviceRegistration != null) {
54  success = ldapService.delete(deviceRegistration, oxDeviceRegistration.class);
55  }
56  return success;
57 
58  }
oxDeviceRegistration getDeviceRegistrationFor(FidoDevice device)
Definition: FidoService.java:78
LdapService ldapService
Definition: BaseService.java:20
public< T > boolean delete(T object, Class< T > clazz)
Definition: LdapService.java:283

◆ updateDevice()

boolean org.gluu.credmanager.plugins.authnmethod.service.FidoService.updateDevice ( FidoDevice  device)
inline
37  {
38 
39  boolean success = false;
40  oxDeviceRegistration deviceRegistration = getDeviceRegistrationFor(device);
41  if (deviceRegistration != null) {
42  deviceRegistration.setDisplayName(device.getNickName());
43  success = ldapService.modify(deviceRegistration, oxDeviceRegistration.class);
44  }
45  return success;
46 
47  }
oxDeviceRegistration getDeviceRegistrationFor(FidoDevice device)
Definition: FidoService.java:78
LdapService ldapService
Definition: BaseService.java:20
public< T > boolean modify(T object, Class< T > clazz)
Definition: LdapService.java:264

メンバ詳解

◆ codehausMapper

ObjectMapper org.gluu.credmanager.plugins.authnmethod.service.FidoService.codehausMapper = new ObjectMapper()
private

◆ ldapService

LdapService org.gluu.credmanager.plugins.authnmethod.service.BaseService.ldapService
packageinherited

◆ logger

Logger org.gluu.credmanager.plugins.authnmethod.service.FidoService.logger
private

◆ mapper

ObjectMapper org.gluu.credmanager.plugins.authnmethod.service.BaseService.mapper
packageinherited

◆ settings

MainSettings org.gluu.credmanager.plugins.authnmethod.service.FidoService.settings
package

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