gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS クラス
org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS 連携図
Collaboration graph

公開メンバ関数

Response computeRequest (@QueryParam("displayName") String name, @QueryParam("mode") String mode, @PathParam("userid") String userId)
 
Response validateCode (@QueryParam("code") String code, @QueryParam("key") String key, @QueryParam("mode") String mode, @PathParam("userid") String userId)
 
Response finishEnrollment (@QueryParam("nick") String nickName, @QueryParam("key") String key, @PathParam("userid") String userId)
 

非公開メンバ関数

void inited ()
 

非公開変数類

Logger logger
 
ILdapService ldapService
 
OTPService otpService
 
ExpirationMap< String, String > keyExternalUidMapping
 

詳解

著者
jgomer

関数詳解

◆ computeRequest()

Response org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.computeRequest ( @QueryParam("displayName") String  name,
@QueryParam("mode") String  mode,
@PathParam("userid") String  userId 
)
inline
64  {
65 
66  ComputeRequestCode result;
67  logger.trace("computeRequest WS operation called");
68 
69  if (Utils.isEmpty(name)) {
70  return ComputeRequestCode.NO_DISPLAY_NAME.getResponse();
71  } else {
72  try {
73  IOTPAlgorithm as = otpService.getAlgorithmService(OTPType.valueOf(mode.toUpperCase()));
74  byte[] secretKey = as.generateSecretKey();
75  String request = as.generateSecretKeyUri(secretKey, name);
76 
77  result = ComputeRequestCode.SUCCESS;
78  return result.getResponse(Base64.getEncoder().encodeToString(secretKey), request);
79  } catch (Exception e) {
80  return ComputeRequestCode.INVALID_MODE.getResponse();
81  }
82  }
83 
84  }
OTPService otpService
Definition: OTPEnrollingWS.java:50
Logger logger
Definition: OTPEnrollingWS.java:44
IOTPAlgorithm getAlgorithmService(OTPKey.OTPType type)
Definition: OTPService.java:161

◆ finishEnrollment()

Response org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.finishEnrollment ( @QueryParam("nick") String  nickName,
@QueryParam("key") String  key,
@PathParam("userid") String  userId 
)
inline
122  {
123 
124  FinishCode result;
125  OTPDevice device = null;
126  logger.trace("finishEnrollment WS operation called");
127 
128  if (Stream.of(nickName, key).anyMatch(Utils::isEmpty)) {
129  result = FinishCode.MISSING_PARAMS;
130  } else {
131  long now = System.currentTimeMillis();
132  Pair<String, Boolean> pair = keyExternalUidMapping.getWithExpired(key, now);
133  if (pair == null) {
134  result = FinishCode.NO_MATCH;
135  } else {
136  if (pair.getY()) {
137  result = FinishCode.EXPIRED;
138  } else {
139  device = new OTPDevice();
140  device.setUid(pair.getX());
141  device.setAddedOn(now);
142  device.setNickName(nickName);
143 
144  if (otpService.addDevice(userId, device)) {
145  result = FinishCode.SUCCESS;
147  } else {
148  result = FinishCode.FAILED;
149  device = null;
150  }
151  }
152  }
153  }
154  return result.getResponse(device);
155 
156  }
OTPService otpService
Definition: OTPEnrollingWS.java:50
static boolean isEmpty(String string)
Definition: Utils.java:47
ExpirationMap< String, String > keyExternalUidMapping
Definition: OTPEnrollingWS.java:52
V remove(K key)
Definition: ExpirationMap.java:49
boolean addDevice(String userId, OTPDevice newDevice)
Definition: OTPService.java:134
Logger logger
Definition: OTPEnrollingWS.java:44
Pair< V, Boolean > getWithExpired(K key, long instant)
Definition: ExpirationMap.java:44

◆ inited()

void org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.inited ( )
inlineprivate
55  {
56  keyExternalUidMapping = new ExpirationMap<>();
57  }
ExpirationMap< String, String > keyExternalUidMapping
Definition: OTPEnrollingWS.java:52

◆ validateCode()

Response org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.validateCode ( @QueryParam("code") String  code,
@QueryParam("key") String  key,
@QueryParam("mode") String  mode,
@PathParam("userid") String  userId 
)
inline
92  {
93 
94  ValidateCode result;
95  logger.trace("validateCode WS operation called");
96 
97  if (Stream.of(code, key).anyMatch(Utils::isEmpty)) {
98  result = ValidateCode.MISSING_PARAMS;
99  } else {
100  try {
101  IOTPAlgorithm as = otpService.getAlgorithmService(OTPType.valueOf(mode.toUpperCase()));
102  String uid = as.getExternalUid(Base64.getDecoder().decode(key), code);
103  if (uid == null) {
104  result = ValidateCode.NO_MATCH;
105  } else {
106  keyExternalUidMapping.put(key, uid);
107  result = ValidateCode.SUCCESS;
108  }
109  } catch (Exception e) {
110  return ComputeRequestCode.INVALID_MODE.getResponse();
111  }
112  }
113  return result.getResponse();
114 
115  }
void put(K key, V value)
Definition: ExpirationMap.java:35
OTPService otpService
Definition: OTPEnrollingWS.java:50
static boolean isEmpty(String string)
Definition: Utils.java:47
ExpirationMap< String, String > keyExternalUidMapping
Definition: OTPEnrollingWS.java:52
Logger logger
Definition: OTPEnrollingWS.java:44
IOTPAlgorithm getAlgorithmService(OTPKey.OTPType type)
Definition: OTPService.java:161

メンバ詳解

◆ keyExternalUidMapping

ExpirationMap<String, String> org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.keyExternalUidMapping
private

◆ ldapService

ILdapService org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.ldapService
private

◆ logger

Logger org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.logger
private

◆ otpService

OTPService org.gluu.credmanager.plugins.authnmethod.rs.OTPEnrollingWS.otpService
private

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