當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。