Changeset 302:da9f9efbf4d9
- Timestamp:
- 09/05/11 21:47:01 (5 months ago)
- Branch:
- default
- Convert:
- svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2736
- Location:
- kraken-dom/src/main/java/org/krakenapps/dom
- Files:
-
- 2 edited
-
api/impl/AdminApiImpl.java (modified) (3 diffs)
-
msgbus/AdminPlugin.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kraken-dom/src/main/java/org/krakenapps/dom/api/impl/AdminApiImpl.java
r301 r302 18 18 import java.util.Date; 19 19 import java.util.List; 20 import java.util.Random; 20 21 21 22 import javax.persistence.EntityManager; … … 254 255 admin.setLoginLockCount(targetAdmin.getLoginLockCount()); 255 256 admin.setUseOtp(targetAdmin.isUseOtp()); 256 admin.setOtpSeed(targetAdmin.getOtpSeed()); 257 if (admin.isUseOtp()) { 258 if (targetAdmin.getOtpSeed() != null) 259 admin.setOtpSeed(targetAdmin.getOtpSeed()); 260 else if (admin.getOtpSeed() == null) 261 admin.setOtpSeed(createOtpSeed()); 262 } else 263 admin.setOtpSeed(null); 257 264 258 265 if (!admin.isEnabled() && targetAdmin.isEnabled()) … … 268 275 } 269 276 } 277 278 private static final char[] chars = new char[62]; 279 static { 280 int i = 0; 281 char c = 'a'; 282 for (; i < 26; i++) 283 chars[i] = c++; 284 c = 'A'; 285 for (; i < 52; i++) 286 chars[i] = c++; 287 c = '0'; 288 for (; i < 62; i++) 289 chars[i] = c++; 290 } 291 292 private String createOtpSeed() { 293 Random random = new Random(); 294 StringBuilder sb = new StringBuilder(); 295 for (int i = 0; i < 10; i++) 296 sb.append(chars[random.nextInt(62)]); 297 return sb.toString(); 298 } 270 299 } -
kraken-dom/src/main/java/org/krakenapps/dom/msgbus/AdminPlugin.java
r294 r302 153 153 throw new IllegalArgumentException("admin not found"); 154 154 155 if (admin.isUseOtp()) 156 admin.setOtpSeed(createOtpSeed()); 157 else 158 admin.setOtpSeed(null); 155 admin.setOtpSeed(createOtpSeed()); 159 156 160 157 adminApi.updateAdmin(req.getOrgId(), req.getAdminId(), admin); … … 184 181 admin.setEnabled(req.getBoolean("is_enabled")); 185 182 admin.setUseOtp(req.getBoolean("use_otp")); 186 if (admin.isUseOtp()) {187 if (admin.getOtpSeed() == null)188 admin.setOtpSeed(createOtpSeed());189 } else190 admin.setOtpSeed(null);191 183 192 184 admin.validate();
Note: See TracChangeset
for help on using the changeset viewer.
