当前位置: 首页>>代码示例>>Java>>正文


Java RandomStringUtils.randomAscii方法代码示例

本文整理汇总了Java中org.apache.commons.lang.RandomStringUtils.randomAscii方法的典型用法代码示例。如果您正苦于以下问题:Java RandomStringUtils.randomAscii方法的具体用法?Java RandomStringUtils.randomAscii怎么用?Java RandomStringUtils.randomAscii使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.RandomStringUtils的用法示例。


在下文中一共展示了RandomStringUtils.randomAscii方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceDefaultDBPassword

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public  void replaceDefaultDBPassword() throws Exception {
    try (Connection connection = getSQLConnection();
            PreparedStatement changePasswordStatement = connection.prepareStatement("ALTER USER " + this.connectionParams.getLogin().toUpperCase() + " SET PASSWORD ?")) {

        connection.setAutoCommit(false);

        String newPassword = RandomStringUtils.randomAscii(32);

        try {
            // change password in DB
            changePasswordStatement.setString(1, newPassword);
            changePasswordStatement.execute();

            // put password in keystore
            this.connectionParams.updatePassword(newPassword);

            connection.commit();
        } catch (Exception ex) {
            log.error("Error while changing DB password.", ex);

            try {
                connection.rollback();
            } catch (Exception he) {
                log.error("Error rolling back transaction", he);
            }

            throw ex;
        }
        EntityManagerFactory oldEmf = this.emf;
        // reinitialize session factory
        start(this.properties);

        try {
            oldEmf.close();
        } catch (PersistenceException pe) {
            // Ignore this
        }
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:40,代码来源:DBConnectionManager.java

示例2: randomHeaders

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
private static Header[] randomHeaders(final int maxNum, final int maxLen) {
	int n = RNG.nextInt(maxNum) + 1;
	Header[] ret = new Header[n];
	for (int i = 0; i < n; i++) {
		String name = "Random-" + RandomStringUtils.randomAlphabetic(RNG.nextInt(maxLen) + 1);
		String value = RandomStringUtils.randomAscii(RNG.nextInt(maxLen) + 1);
		ret[i] = new BasicHeader(name, value);
	}
	return ret;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:11,代码来源:RandomTestMocks.java

示例3: HttpResponse

import org.apache.commons.lang.RandomStringUtils; //导入方法依赖的package包/类
public HttpResponse(final int maxNumberOfHeaders, final int maxLenghtOfHeader, final int maxLengthOfBody, final int pos) {
	this.statusLine = new BasicStatusLine(PROTOCOL_VERSION, 200, "OK");
	Header[] headers = randomHeaders(maxNumberOfHeaders, maxLenghtOfHeader);
	headers[RNG.nextInt(headers.length)] = new BasicHeader("Position", Integer.toString(pos));
	this.setHeaders(headers);
	this.content = RandomStringUtils.randomAscii(RNG.nextInt(maxLengthOfBody) + 1);
	byte[] body = Util.toByteArray(content);
	this.addHeader("Content-Length", Integer.toString(body.length));
	this.entity = new ByteArrayEntity(body, ContentType.DEFAULT_BINARY);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:11,代码来源:RandomTestMocks.java


注:本文中的org.apache.commons.lang.RandomStringUtils.randomAscii方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。