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

公開メンバ関数

Response sendCode (@QueryParam("number") String number, @PathParam("userid") String userId)
 
Response validateCode (@QueryParam("code") String code, @PathParam("userid") String userId)
 
Response finishEnrollment (@QueryParam("nick") String nickName, @QueryParam("code") String code, @PathParam("userid") String userId)
 

非公開メンバ関数

void inited ()
 

非公開変数類

Logger logger
 
ILdapService ldapService
 
MobilePhoneService mobilePhoneService
 
ExpirationMap< String, String > recentCodes
 

静的非公開変数類

static final String SEPARATOR = ","
 

詳解

著者
jgomer

関数詳解

◆ finishEnrollment()

Response org.gluu.credmanager.plugins.authnmethod.rs.MobilePhoneEnrollingWS.finishEnrollment ( @QueryParam("nick") String  nickName,
@QueryParam("code") String  code,
@PathParam("userid") String  userId 
)
inline
128  {
129 
130  FinishCode result;
131  VerifiedMobile phone = null;
132  logger.trace("finishEnrollment WS operation called");
133 
134  if (Stream.of(nickName, code).anyMatch(Utils::isEmpty)) {
135  //One or more params are missing
136  result = FinishCode.MISSING_PARAMS;
137  } else {
138  String key = userId + SEPARATOR + code;
139  long now = System.currentTimeMillis();
140  Pair<String, Boolean> pair = recentCodes.getWithExpired(key, now);
141 
142  if (pair == null) {
143  //No match
144  result = FinishCode.NO_MATCH;
145  } else {
146  if (pair.getY()) {
147  //too much time elapsed to finish enrollment
148  result = FinishCode.EXPIRED;
149  } else {
150  //data still valid
151  phone = new VerifiedMobile();
152  phone.setNickName(nickName);
153  phone.setAddedOn(now);
154  phone.setNumber(pair.getX());
155 
156  if (mobilePhoneService.addPhone(userId, phone)) {
157  result = FinishCode.SUCCESS;
158  recentCodes.remove(key);
159  } else {
160  result = FinishCode.FAILED;
161  phone = null;
162  }
163  }
164  }
165  }
166  return result.getResponse(phone);
167 
168  }
ExpirationMap< String, String > recentCodes
Definition: MobilePhoneEnrollingWS.java:51
static boolean isEmpty(String string)
Definition: Utils.java:47
static final String SEPARATOR
Definition: MobilePhoneEnrollingWS.java:40
boolean addPhone(String userId, VerifiedMobile newPhone)
Definition: MobilePhoneService.java:152
V remove(K key)
Definition: ExpirationMap.java:49
Logger logger
Definition: MobilePhoneEnrollingWS.java:43
MobilePhoneService mobilePhoneService
Definition: MobilePhoneEnrollingWS.java:49
Pair< V, Boolean > getWithExpired(K key, long instant)
Definition: ExpirationMap.java:44

◆ inited()

void org.gluu.credmanager.plugins.authnmethod.rs.MobilePhoneEnrollingWS.inited ( )
inlineprivate
54  {
55  recentCodes = new ExpirationMap<>();
56  }
ExpirationMap< String, String > recentCodes
Definition: MobilePhoneEnrollingWS.java:51

◆ sendCode()

Response org.gluu.credmanager.plugins.authnmethod.rs.MobilePhoneEnrollingWS.sendCode ( @QueryParam("number") String  number,
@PathParam("userid") String  userId 
)
inline
62  {
63 
64  SendCode result;
65  logger.trace("sendCode WS operation called");
66 
67  if (Utils.isEmpty(number)) {
68  result = SendCode.NO_NUMBER;
69  } else if (mobilePhoneService.isNumberRegistered(number)
70  || mobilePhoneService.isNumberRegistered(number.replaceAll("[-\\+\\s]", ""))) {
71  result = SendCode.NUMBER_ALREADY_ENROLLED;
72  } else {
73  try {
74  String aCode = Integer.toString(new Double(100000 + Math.random() * 899999).intValue());
75  //Compose SMS body
76  String body = ldapService.getOrganization().getDisplayName();
77  body = Labels.getLabel("usr.mobile_sms_body", new String[]{ body, aCode });
78 
79  //Send message (service bean already knows all settings to perform this step)
80  result = mobilePhoneService.sendSMS(number, body);
81 
82  if (SendCode.SUCCESS.equals(result)) {
83  logger.trace("sendCode. code={}", aCode);
84  recentCodes.put(userId + SEPARATOR + aCode, number);
85  }
86  } catch (Exception e) {
87  logger.error(e.getMessage(), e);
88  result = SendCode.WS_SERVICE_ERROR;
89  }
90  }
91  return result.getResponse();
92 
93  }
ExpirationMap< String, String > recentCodes
Definition: MobilePhoneEnrollingWS.java:51
void put(K key, V value)
Definition: ExpirationMap.java:35
String getDisplayName()
Definition: gluuOrganization.java:56
SendCode sendSMS(String number, String body)
Definition: MobilePhoneService.java:82
static final String SEPARATOR
Definition: MobilePhoneEnrollingWS.java:40
Logger logger
Definition: MobilePhoneEnrollingWS.java:43
MobilePhoneService mobilePhoneService
Definition: MobilePhoneEnrollingWS.java:49
boolean isNumberRegistered(String number)
Definition: MobilePhoneService.java:73
ILdapService ldapService
Definition: MobilePhoneEnrollingWS.java:46

◆ validateCode()

Response org.gluu.credmanager.plugins.authnmethod.rs.MobilePhoneEnrollingWS.validateCode ( @QueryParam("code") String  code,
@PathParam("userid") String  userId 
)
inline
99  {
100 
101  ValidateCode result;
102  logger.trace("validateCode WS operation called");
103 
104  if (Utils.isEmpty(code)) {
105  result = ValidateCode.NO_CODE;
106  } else {
107  Pair<String, Boolean> pair = recentCodes.getWithExpired(userId + SEPARATOR + code, System.currentTimeMillis());
108  if (pair == null) {
109  //no match
110  result = ValidateCode.NO_MATCH;
111  } else {
112  if (pair.getY()) {
113  result = ValidateCode.EXPIRED;
114  } else {
115  result = ValidateCode.MATCH;
116  }
117  }
118  }
119  return result.getResponse();
120 
121  }
ExpirationMap< String, String > recentCodes
Definition: MobilePhoneEnrollingWS.java:51
static final String SEPARATOR
Definition: MobilePhoneEnrollingWS.java:40
Logger logger
Definition: MobilePhoneEnrollingWS.java:43
Pair< V, Boolean > getWithExpired(K key, long instant)
Definition: ExpirationMap.java:44

メンバ詳解

◆ ldapService

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

◆ logger

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

◆ mobilePhoneService

MobilePhoneService org.gluu.credmanager.plugins.authnmethod.rs.MobilePhoneEnrollingWS.mobilePhoneService
private

◆ recentCodes

ExpirationMap<String, String> org.gluu.credmanager.plugins.authnmethod.rs.MobilePhoneEnrollingWS.recentCodes
private

◆ SEPARATOR

final String org.gluu.credmanager.plugins.authnmethod.rs.MobilePhoneEnrollingWS.SEPARATOR = ","
staticprivate

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