本文整理匯總了Java中org.apache.commons.lang3.RandomStringUtils.randomAlphabetic方法的典型用法代碼示例。如果您正苦於以下問題:Java RandomStringUtils.randomAlphabetic方法的具體用法?Java RandomStringUtils.randomAlphabetic怎麽用?Java RandomStringUtils.randomAlphabetic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.RandomStringUtils
的用法示例。
在下文中一共展示了RandomStringUtils.randomAlphabetic方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: BaseBinaryCipherExecutor
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
/**
* Instantiates a new cryptic ticket cipher executor.
*
* @param encryptionSecretKey the encryption secret key
* @param signingSecretKey the signing key
* @param signingKeySize the signing key size
* @param encryptionKeySize the encryption key size
*/
public BaseBinaryCipherExecutor(final String encryptionSecretKey,
final String signingSecretKey,
final int signingKeySize,
final int encryptionKeySize) {
String signingKeyToUse = signingSecretKey;
if (StringUtils.isBlank(signingKeyToUse)) {
LOGGER.warn("Secret key for signing is not defined. CAS will attempt to auto-generate the signing key");
signingKeyToUse = generateOctetJsonWebKeyOfSize(signingKeySize);
LOGGER.warn("Generated signing key [{}] of size [{}]. The generated key MUST be added to CAS settings.",
signingKeyToUse, signingKeySize);
}
setSigningKey(signingKeyToUse);
if (StringUtils.isBlank(encryptionSecretKey)) {
LOGGER.warn("No encryption key is defined. CAS will attempt to auto-generate keys");
this.encryptionSecretKey = RandomStringUtils.randomAlphabetic(encryptionKeySize);
LOGGER.warn("Generated encryption key [{}] of size [{}]. The generated key MUST be added to CAS settings.",
this.encryptionSecretKey, encryptionKeySize);
} else {
this.encryptionSecretKey = encryptionSecretKey;
}
}
示例2: create
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Override
public synchronized IDevice create(_MatrixID user, String name) { // FIXME use RWLock
String id;
do {
id = RandomStringUtils.randomAlphabetic(12);
} while (devById.containsKey(id));
String token;
do {
token = RandomStringUtils.randomAlphanumeric(128);
} while (devByToken.containsKey(token));
IDevice dev = new Device(id, token, name, user);
devById.put(id, dev);
devByToken.put(token, dev);
log.info("Created new device {} for user {}", id, user.getId());
return dev;
}
示例3: generateRandomPostFrom
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public Post generateRandomPostFrom(Post post) {
Post _post = new Post();
_post.setUrl(post.getUrl());
_post.setDomain(post.getDomain());
_post.setUser(post.getUser());
_post.setContent(post.getContent());
_post.setStatus(PostStatus.PUBLIC);
String title = "";
for (int j = 0; j < 10; j++) {
title += " " + RandomStringUtils.randomAlphabetic((int) (Math.random() * 10) + 1);
}
_post.setTitle(title);
return _post;
}
示例4: getProfileByRoleKey
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Test
@Transactional
public void getProfileByRoleKey() throws Exception {
String userKey = RandomStringUtils.randomAlphabetic(5);
int databaseSizeBeforeCreate = profileService.findAllByUserKey(userKey).size();
profile.setUserKey(userKey);
profileService.saveAndFlush(profile);
// Get the profile by users key
List<Profile> profiles = profileService.findAllByUserKey(userKey);
assertThat(profiles).hasSize(databaseSizeBeforeCreate + 1);
Profile testProfile = profiles.get(profiles.size() - 1);
assertThat(testProfile.getUserKey()).isEqualTo(userKey);
}
示例5: getDefaultProfileByRoleKey
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Test
@Transactional
public void getDefaultProfileByRoleKey() throws Exception {
String randRoleKey = RandomStringUtils.randomAlphabetic(5);
int databaseSizeBeforeCreate = defaultProfileService.findAllByRoleKey(randRoleKey).size();
defaultProfile.setRoleKey(randRoleKey);
defaultProfileService.saveAndFlush(defaultProfile);
// Get the defaultProfile by roleKey
List<DefaultProfile> defaultProfiles = defaultProfileService.findAllByRoleKey(randRoleKey);
assertThat(defaultProfiles).hasSize(databaseSizeBeforeCreate + 1);
DefaultProfile testDefaultProfile = defaultProfiles.get(defaultProfiles.size() - 1);
assertThat(testDefaultProfile.getRoleKey()).isEqualTo(randRoleKey);
}
示例6: sendTokenNotification
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Override
public TokenStoreEntity sendTokenNotification(TokenStoreType type, UserEntity user) {
String token = RandomStringUtils.randomAlphabetic(24);
TokenStoreEntity tokenStoreEntity = new TokenStoreEntity()
.setToken(token)
.setUser(user)
.setType(type)
.setExpiryDate(DateTime.now().plusDays(15).toDate());
sendEmail(tokenStoreEntity, user);
return tokenStoreRepository.save(tokenStoreEntity);
}
示例7: saveCache
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public String saveCache(String bid, String format) {
if (TextUtils.isEmpty(bid)) {
return null;
}
String cacheId = "Prebid_" + RandomStringUtils.randomAlphabetic(8) + "_" + String.valueOf(System.currentTimeMillis());
if ("html".equals(format)) {
saveCacheForWeb(cacheId, bid);
} else if ("demand_sdk".equals(format)) {
saveCacheForSDK(cacheId, bid);
}
return cacheId;
}
示例8: getSemivalidSchemeHostPortPathPatternURIMalIntent
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public static MalIntent getSemivalidSchemeHostPortPathPatternURIMalIntent(IntentDataInfo datafield) {
MalIntent mal = new MalIntent(datafield);
String scheme = datafield.scheme;
String host = datafield.host;
host = host.replace("*", RandomStringUtils.randomAlphanumeric(10));
String pathPattern = datafield.pathPattern;
String semivalidPathPattern;
if (pathPattern.contains(".*") || pathPattern.contains("*")) {
semivalidPathPattern = pathPattern.replace(".*", RandomStringUtils.randomAlphabetic(10));
semivalidPathPattern = semivalidPathPattern.replace("*", RandomStringUtils.randomAlphanumeric(10));
if (pathPattern.charAt(0) == '/') {
mal.setData(Uri.parse(scheme + "://" + host + semivalidPathPattern));
}
mal.setData(Uri.parse(scheme + "://" + host + "/" + semivalidPathPattern));
} else {
semivalidPathPattern = RandomStringUtils.randomAlphabetic(10);
if (pathPattern.equals("") || pathPattern.charAt(0) == '/') {
mal.setData(Uri.parse(scheme + "://" + host + semivalidPathPattern));
}
mal.setData(Uri.parse(scheme + "://" + host + "/" + semivalidPathPattern));
}
return mal;
}
示例9: process
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Override
public Object process(AnnotationInfo ctx, Object value) throws Exception {
if (!ctx.isAnnotationPresent(Min.class)
&& !ctx.isAnnotationPresent(Max.class)) {
return value;
}
long minValue = 1;
if (ctx.isAnnotationPresent(Min.class)) {
minValue = ctx.getAnnotation(Min.class).value();
}
long maxValue = 50;
if (ctx.isAnnotationPresent(Max.class)) {
maxValue = ctx.getAnnotation(Max.class).value();
}
if (Number.class.isAssignableFrom(value.getClass())) {
return range(String.valueOf(minValue), String.valueOf(maxValue), value.getClass());
} else if (value instanceof String) {
String strVal = (String) value;
if (strVal.length() < minValue) {
strVal += RandomStringUtils.randomAlphabetic((int) minValue - strVal.length());
} else if (strVal.length() > maxValue) {
strVal = strVal.substring(0, (int) maxValue);
}
return strVal;
}
return value;
}
示例10: generate
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
@Override
public Object generate(DefaultContext ctx) throws Exception {
return RandomStringUtils.randomAlphabetic(150);
}
示例11: BufferedObjective
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public BufferedObjective(Scoreboard scoreboard) {
this.scoreboard = scoreboard;
this.title = RandomStringUtils.randomAlphabetic(4);
this.current = scoreboard.registerNewObjective("buffered", "dummy");
}
示例12: BufferedObjective
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public BufferedObjective(Scoreboard scoreboard) {
this.scoreboard = scoreboard;
this.title = RandomStringUtils.randomAlphabetic(4);
this.current = scoreboard.registerNewObjective("buffered", "dummy");
}
示例13: randomString
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public static String randomString() {
return RandomStringUtils.randomAlphabetic(10);
}
示例14: randomCompanyName
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
private static String randomCompanyName() {
return RandomStringUtils.randomAlphabetic(10);
}
示例15: createStream
import org.apache.commons.lang3.RandomStringUtils; //導入方法依賴的package包/類
public StreamId createStream(final String streamParamName) {
final String defaultStreamName = RandomStringUtils.randomAlphabetic(20);
StreamId streamId = flinkPravegaParams.createStreamFromParam(streamParamName, scope + "/" + defaultStreamName);
log.info("Created stream: {} with scope: {}", streamId.getName(), streamId.getScope());
return streamId;
}