List of usage examples for org.apache.commons.lang RandomStringUtils randomAlphanumeric
public static String randomAlphanumeric(int count)
Creates a random string whose length is the number of characters specified.
Characters will be chosen from the set of alpha-numeric characters.
From source file:fr.fg.server.action.player.CloseAccount.java
@Override protected String execute(Player player, Map<String, Object> params, Session session) throws Exception { String password = (String) params.get("password"); String reason = (String) params.get("reason"); if (!player.getPassword().equals(Utilities.encryptPassword(password))) throw new IllegalOperationException("Mot de passe invalide."); // Gnre un hash pour confirmer la fermeture du compte String hash;//from w ww. j ava2 s. com do { hash = RandomStringUtils.randomAlphanumeric(32); } while (DataAccess.getPlayerByCloseAccountHash(hash) != null); try { Mailer.sendMail(player.getEmail(), Messages.getString("common.closeAccountSubject"), Messages.getString( "common.closeAccountContent", player.getLogin(), Config.getServerURL() + "delete/" + hash)); } catch (MessagingException e) { LoggingSystem.getServerLogger().error("Could not send recover email.", e); throw new IllegalOperationException(Messages.getString("common.emailSentFailed")); } synchronized (player.getLock()) { player = DataAccess.getEditable(player); player.setCloseAccountHash(hash); player.setCloseAccountReason(reason); player.save(); } return FORWARD_SUCCESS; }
From source file:elaborate.editor.model.SessionService.java
public String startSession(User user) { String sessionId = RandomStringUtils.randomAlphanumeric(SESSIONID_SIZE); sessionMap.put(sessionId, new Session(user.getId())); // Log.info("sessionMap={}", sessionMap); return sessionId; }
From source file:com.amazonaws.codepipeline.jenkinsplugin.ValidationTest.java
@Test(expected = IllegalArgumentException.class) public void projectNameTooLongNameFailure() { Validation.validateProjectName(RandomStringUtils.randomAlphanumeric(Validation.MAX_PROJECT_NAME_LENGTH * 2), null);//from w ww .j a v a 2 s . com }
From source file:com.xtructure.xutil.coll.UTestMapBuilder.java
public void getImmutableMapReturnsExpectedObject() { Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i < 10; i++) { map.put(RandomStringUtils.randomAlphanumeric(10), // RandomStringUtils.randomAlphanumeric(10)); }//from www .j a va2 s . co m Map<String, String> newMap = new MapBuilder<String, String>(map).newImmutableInstance(); assertThat("", // map, isNotSameAs(newMap)); assertThat("", // map, isEqualTo(newMap)); }
From source file:com.cfitzarl.cfjwed.service.impl.AdminRegistrationServiceImpl.java
/** {@inheritDoc} **/ @Override//w ww. ja v a2s .c o m public void register(Account account) { String activationToken = RandomStringUtils.randomAlphanumeric(32); // Send registration email String subject = localizationService.getMessage("email.activation.admin.subject"); Map<String, Object> attrs = getCommonEmailAttrs(activationToken, account); emailDispatcher.send(account.getEmail(), subject, "admin-activation", attrs); // Save the account accountService.save(account); // Create activation for account createActivation(activationToken, account); }
From source file:com.adobe.acs.commons.social.linkedin.LinkedInApi20.java
/** * Create an API instance with a random state and no scopes. */ public LinkedInApi20() { this(RandomStringUtils.randomAlphanumeric(10)); }
From source file:edu.htwm.vsp.phoebook.rest.client.HttpComponentsClient.java
/** * Testet das Anlegen und Lschen von Telefonnummern *//*from w w w. jav a 2 s.com*/ @Test public void addAndDeleteNumber() throws Exception { // Nutzer anlegen PhoneUser user = new PhoneUser("dieter"); PhoneUser fetchedUser = verifyAddUser(user.getName(), HTTP_CREATED, xml); // zufllige Nummer anlegen String phoneCaption = RandomStringUtils.randomAlphanumeric(10); String phoneNumber = RandomStringUtils.randomAlphanumeric(8); PhoneNumber newNumber = new PhoneNumber(phoneCaption, phoneNumber); user.setNumber(phoneCaption, phoneNumber); String userId = Integer.toString(fetchedUser.getId()); // Nummer zu User speichern und prfen, dass dies enthalten ist fetchedUser = verifyAddNumber(userId, phoneCaption, phoneNumber, 201, xml); assertThat(fetchedUser.getPhoneNumbers().contains(newNumber), is(true)); assertEquals(user.getPhoneNumbers(), fetchedUser.getPhoneNumbers()); // Diese Nummer wieder lschen verifyDeleteNumber(userId, phoneCaption, HTTP_OK, xml); // ein weiteres Lschen sollte fehlschlagen verifyDeleteNumber(userId, phoneCaption, HTTP_NOT_FOUND, xml); // Nutzer wieder lschen verifyDeleteUser(userId, HTTP_OK); }
From source file:net.noday.core.utils.Captcha.java
private static String randText() { String text = RandomStringUtils.randomAlphanumeric(4).toUpperCase().replace('0', 'A').replace('O', 'E') .replace('1', 'V').replace('I', 'R'); return text;//from w w w.j av a 2 s . co m }
From source file:io.dataplay.test.TupleUtil.java
/** * Generate a generic tuple with random data. * * @return A mock data tuple with random data. *///from w ww . j a va 2 s .com public static Tuple mockDataTuple() { List<String> fieldData = new ArrayList<>(); List<Object> valueData = new ArrayList<>(); for (int i = 0; i < 10; i++) { fieldData.add(RandomStringUtils.randomAlphanumeric(5)); valueData.add(RandomStringUtils.randomAlphanumeric(10)); } return mockTuple(Constants.SYSTEM_EXECUTOR_ID.toString(), Utils.DEFAULT_STREAM_ID, new Fields(fieldData), valueData); }
From source file:com.comcast.viper.flume2storm.event.F2SEventFactory.java
/** * @return An event with a payload containing a random alpha-numeric string * (and no headers)/*from www. j av a2s . com*/ */ public F2SEvent createRandom() { return create(RandomStringUtils.randomAlphanumeric(random.nextInt(128) + 1)); }