Java Code Examples for org.apache.commons.lang.RandomStringUtils#randomNumeric()
The following examples show how to use
org.apache.commons.lang.RandomStringUtils#randomNumeric() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VerifyCodeServiceImpl.java From cms with Apache License 2.0 | 6 votes |
@Override public void sendMail(String email) { String code = RandomStringUtils.randomNumeric(6); String subject = VerifyCodeScenes.EMAIL_CHANGE.getName(); String content = null; try { Template template = configuration.getTemplate("email/reset_email.html"); StringWriter result = new StringWriter(); template.process(MapUtils.create().set("code", code), result); content = result.toString(); // FreeMarkerTemplateUtils.processTemplateIntoString(template,) } catch (IOException | TemplateException e) { e.printStackTrace(); } VerifyCode verifyCode = this.save(email, code, VerifyCodeScenes.EMAIL_CHANGE, VerifyCodeType.EMAIL, null); applicationContext.publishEvent(EmailEvent.EmailEventBuilder .builder() .setSubject(subject) .setContent(content) .setTo(email) .build()); // timedDestruction(verifyCode); }
Example 2
Source File: AppSmsController.java From charging_pile_cloud with MIT License | 5 votes |
@ApiOperation(notes = "发送验证码 :\n" + "\n account账号," + " codeType:1 注册 2 重置密码 3 安全验证 4 支付密码设置 5 提币 6手机号绑定 7手机号验证", value = "发送验证码") @RequestMapping(value = "getTelCode", method = RequestMethod.GET) @ResponseBody public Map<String, Object> getTelVcode(TelCodeTypeVO telCodeTypeVO, HttpServletRequest request, HttpServletResponse response) { String account = telCodeTypeVO.getAccount(); Byte codeType = telCodeTypeVO.getCodeType(); if (StringUtils.isBlank(account) ||!TelCodeTypeEnum.CODES.contains(codeType) ) { throw new CommonException(ResponseMsg.MISS_PARAM); } //短信存储到redis if(!redisUtils.isCanSendTwoSms(account,codeType)){ throw new CommonException(ResponseMsg.SMS_NO_TIME_MINUTE_1); } //检查验证码类型 checkTelCodeType(telCodeTypeVO); // 获取随机码 String telVcode = RandomStringUtils.randomNumeric(myConfiguration.getCodeLength()); telVcode = "123456"; try { NetWordBuildParam netWordBuildParam = new NetWordBuildParam(); netWordBuildParam.setMobile(account); netWordBuildParam.setCode(telVcode); // 发送短信 String yzm = "1";//NetWordBuildSendUtil.send(netWordBuildParam); // 判断短信发送状态 if (Integer.parseInt(yzm) == 1) { redisUtils.setSmsRedisHashValue(codeType,account,telVcode); return ResponseUtil.getSuccessMap("验证码发送成功"); } else { return ResponseUtil.getNotNormalMap(ChinaToBuild.map.get(yzm)); } } catch (Exception e) { throw new CommonException("短信发送失败:" + e.getMessage()); } }
Example 3
Source File: AsyncController.java From imooc-security with Apache License 2.0 | 5 votes |
@RequestMapping("/order") public DeferredResult<String> order() throws Exception { logger.info("主线程开始"); String orderNumber = RandomStringUtils.randomNumeric(8); //设置订单号 mockQueue.setPlaceOrder(orderNumber); DeferredResult<String> result = new DeferredResult<>(); //订单号和返回结果绑定 deferredResultHolder.getMap().put(orderNumber,result); logger.info("主线程返回"); return result; }
Example 4
Source File: CrudOrderB.java From mango with Apache License 2.0 | 5 votes |
public static CrudOrderB createRandomCrudOrder(int userId) { CrudOrderB co = new CrudOrderB(); String id = RandomStringUtils.randomNumeric(10); int price = 100; co.setId(id); co.setUserId(userId); co.setPrice(price); return co; }
Example 5
Source File: CrudOrder.java From mango with Apache License 2.0 | 5 votes |
public static CrudOrder createRandomCrudOrder() { CrudOrder co = new CrudOrder(); String id = RandomStringUtils.randomNumeric(10); int userId = Randoms.randomInt(10000); int price = 100; co.setId(id); co.setUserId(userId); co.setPrice(price); return co; }
Example 6
Source File: WebDriverLegacyITBase.java From rice with Educational Community License v2.0 | 5 votes |
protected void testAddingBrownGroupSaveSubmit() throws Exception { selectFrameIframePortlet(); waitAndCreateNew(); String docId = waitForDocId(); String random = RandomStringUtils.randomNumeric(4); String organizationDocumentNumber = "ORD" + random; String groupDescription = "GD" + random; String groupName = "BrownGroup " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars(); String nameSpace = "KR-IDM"; String today = getDateToday(); Calendar nextYearCal = Calendar.getInstance(); nextYearCal.add(Calendar.YEAR, 1); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); String nextYear = sdf.format(nextYearCal.getTime()); //Enter details for BrownGroup. waitAndTypeByName("document.documentHeader.documentDescription", "Adding Brown Group"); waitAndTypeByName("document.documentHeader.explanation", "I want to add Brown Group to test KIM"); waitAndTypeByName("document.documentHeader.organizationDocumentNumber", organizationDocumentNumber); selectOptionByName("document.groupNamespace", nameSpace); waitAndTypeByName("document.groupName", groupName); waitAndTypeByName("document.groupDescription", groupDescription); waitAndClickByXpath(SAVE_XPATH_2); waitForTextPresent("Document was successfully saved."); waitAndClickByXpath(SUBMIT_XPATH); waitForTextPresent("Document was successfully submitted."); }
Example 7
Source File: WebDriverLegacyITBase.java From rice with Educational Community License v2.0 | 5 votes |
protected void testAddingBrownGroupSubmit() throws Exception { selectFrameIframePortlet(); waitAndCreateNew(); String docId = waitForDocId(); String random = RandomStringUtils.randomNumeric(4); String organizationDocumentNumber = "ORD" + random; String groupDescription = "GD" + random; String groupName = "BrownGroup " + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars(); String nameSpace = "KR-IDM"; String today = getDateToday(); acceptAlertIfPresent(); Calendar nextYearCal = Calendar.getInstance(); nextYearCal.add(Calendar.YEAR, 1); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); String nextYear = sdf.format(nextYearCal.getTime()); //Enter details for BrownGroup. waitAndTypeByName("document.documentHeader.documentDescription", "Adding Brown Group"); waitAndTypeByName("document.documentHeader.explanation", "I want to add Brown Group to test KIM"); waitAndTypeByName("document.documentHeader.organizationDocumentNumber", organizationDocumentNumber); selectOptionByName("document.groupNamespace", nameSpace); waitAndTypeByName("document.groupName", groupName); waitAndTypeByName("document.groupDescription", groupDescription); checkByName("document.active"); waitAndClickByXpath(SUBMIT_XPATH); }
Example 8
Source File: AWSCodePipelineSCMTest.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 5 votes |
@Test public void versionCheckShouldFailWithTooLongValue() { final String version = RandomStringUtils.randomNumeric(Validation.MAX_VERSION_LENGTH + 1); assertContainsIgnoreCase( "Version can only be " + Validation.MAX_VERSION_LENGTH + " characters in length, you entered " + version.length(), descriptor.doCheckVersion(version).toString()); assertValidationMessage(FormValidation.error(""), descriptor.doCheckVersion(version)); }
Example 9
Source File: AWSCodePipelineSCMTest.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 4 votes |
@Test public void versionCheckShouldSucceedWithMaxNumber() { final String version = RandomStringUtils.randomNumeric(Validation.MAX_VERSION_LENGTH); assertEquals(FormValidation.ok(), descriptor.doCheckVersion(version)); }
Example 10
Source File: SmsValidateCodeGenerator.java From codeway_service with GNU General Public License v3.0 | 4 votes |
@Override public ValidateCode generate(ServletWebRequest request) { String code = RandomStringUtils.randomNumeric(securityProperties.getCode().getSms().getLength()); return new ValidateCode(code, securityProperties.getCode().getSms().getExpireIn()); }
Example 11
Source File: AzureStorageBaseTestIT.java From components with Apache License 2.0 | 4 votes |
public static String getRandomTestUID() { return RandomStringUtils.randomNumeric(10); }
Example 12
Source File: RandomUtil.java From OpenIoE with Apache License 2.0 | 2 votes |
/** * Generates a reset key. * * @return the generated reset key */ public static String generateResetKey() { return RandomStringUtils.randomNumeric(DEF_COUNT); }
Example 13
Source File: RandomUtil.java From gpmr with Apache License 2.0 | 2 votes |
/** * Generates a reset key. * * @return the generated reset key */ public static String generateResetKey() { return RandomStringUtils.randomNumeric(DEF_COUNT); }
Example 14
Source File: DefaultProvisioningHandler.java From carbon-identity with Apache License 2.0 | 2 votes |
/** * Generates (random) password for user to be provisioned * * @return */ protected String generatePassword() { return RandomStringUtils.randomNumeric(12); }
Example 15
Source File: RandomUtil.java From expper with GNU General Public License v3.0 | 2 votes |
/** * Generates a reset key. * * @return the generated reset key */ public static String generateResetKey() { return RandomStringUtils.randomNumeric(DEF_COUNT); }
Example 16
Source File: RandomUtil.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 2 votes |
/** * Generates a reset key. * * @return the generated reset key */ public static String generateResetKey() { return RandomStringUtils.randomNumeric(DEF_COUNT); }
Example 17
Source File: RandomUtil.java From klask-io with GNU General Public License v3.0 | 2 votes |
/** * Generates an activation key. * * @return the generated activation key */ public static String generateActivationKey() { return RandomStringUtils.randomNumeric(DEF_COUNT); }
Example 18
Source File: SmsCodeGenerator.java From paascloud-master with Apache License 2.0 | 2 votes |
/** * Generate validate code. * * @param request the request * * @return the validate code */ @Override public ValidateCode generate(ServletWebRequest request) { String code = RandomStringUtils.randomNumeric(securityProperties.getCode().getSms().getLength()); return new ValidateCode(code, securityProperties.getCode().getSms().getExpireIn()); }
Example 19
Source File: RandomUtil.java From angularjs-springboot-bookstore with MIT License | 2 votes |
/** * Generates an activation key. * * @return the generated activation key */ public static String generateActivationKey() { return RandomStringUtils.randomNumeric(DEF_COUNT); }
Example 20
Source File: RandomUtil.java From angularjs-springboot-bookstore with MIT License | 2 votes |
/** * Generates a reset key. * * @return the generated reset key */ public static String generateResetKey() { return RandomStringUtils.randomNumeric(DEF_COUNT); }