• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ConcurrentMessageDigest类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.tomcat.util.security.ConcurrentMessageDigest的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentMessageDigest类的具体用法?Java ConcurrentMessageDigest怎么用?Java ConcurrentMessageDigest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ConcurrentMessageDigest类属于org.apache.tomcat.util.security包,在下文中一共展示了ConcurrentMessageDigest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generateNonce

点赞 3

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
/**
 * Generate a unique token. The token is generated according to the
 * following pattern. NOnceToken = Base64 ( MD5 ( client-IP ":" time-stamp
 * ":" private-key ) ).
 *
 * @param request
 *            HTTP Servlet request
 */
protected String generateNonce(Request request) {

	long currentTime = System.currentTimeMillis();

	synchronized (lastTimestampLock) {
		if (currentTime > lastTimestamp) {
			lastTimestamp = currentTime;
		} else {
			currentTime = ++lastTimestamp;
		}
	}

	String ipTimeKey = request.getRemoteAddr() + ":" + currentTime + ":" + getKey();

	byte[] buffer = ConcurrentMessageDigest.digestMD5(ipTimeKey.getBytes(B2CConverter.ISO_8859_1));
	String nonce = currentTime + ":" + MD5Encoder.encode(buffer);

	NonceInfo info = new NonceInfo(currentTime, getNonceCountWindowSize());
	synchronized (nonces) {
		nonces.put(nonce, info);
	}

	return nonce;
}
 

开发者ID:how2j,
项目名称:lazycat,
代码行数:33,
代码来源:DigestAuthenticator.java

示例2: setUp

点赞 3

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    ConcurrentMessageDigest.init("MD5");

    // Configure the Realm
    MapRealm realm = new MapRealm();
    realm.addUser(USER, PWD);
    realm.addUserRole(USER, ROLE);

    // Add the Realm to the Context
    Context context = new StandardContext();
    context.setName(CONTEXT_PATH);
    context.setRealm(realm);

    // Make the Context and Realm visible to the Authenticator
    authenticator.setContainer(context);
    authenticator.setNonceCountWindowSize(8 * 1024);

    authenticator.start();
}
 

开发者ID:liaokailin,
项目名称:tomcat7,
代码行数:22,
代码来源:TesterDigestAuthenticatorPerformance.java

示例3: generateNonce

点赞 3

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
/**
 * Generate a unique token. The token is generated according to the
 * following pattern. NOnceToken = Base64 ( MD5 ( client-IP ":"
 * time-stamp ":" private-key ) ).
 *
 * @param request HTTP Servlet request
 */
protected String generateNonce(Request request) {

    long currentTime = System.currentTimeMillis();

    synchronized (lastTimestampLock) {
        if (currentTime > lastTimestamp) {
            lastTimestamp = currentTime;
        } else {
            currentTime = ++lastTimestamp;
        }
    }

    String ipTimeKey =
        request.getRemoteAddr() + ":" + currentTime + ":" + getKey();

    byte[] buffer = ConcurrentMessageDigest.digestMD5(
            ipTimeKey.getBytes(B2CConverter.ISO_8859_1));
    String nonce = currentTime + ":" + MD5Encoder.encode(buffer);

    NonceInfo info = new NonceInfo(currentTime, getNonceCountWindowSize());
    synchronized (nonces) {
        nonces.put(nonce, info);
    }

    return nonce;
}
 

开发者ID:sunmingshuai,
项目名称:apache-tomcat-7.0.73-with-comment,
代码行数:34,
代码来源:DigestAuthenticator.java

示例4: authenticate

点赞 2

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
public Principal authenticate(Realm realm) {
    // Second MD5 digest used to calculate the digest :
    // MD5(Method + ":" + uri)
    String a2 = method + ":" + uri;

    byte[] buffer = ConcurrentMessageDigest.digestMD5(
            a2.getBytes(B2CConverter.ISO_8859_1));
    String md5a2 = MD5Encoder.encode(buffer);

    return realm.authenticate(userName, response, nonce, nc, cnonce,
            qop, realmName, md5a2);
}
 

开发者ID:liaokailin,
项目名称:tomcat7,
代码行数:13,
代码来源:DigestAuthenticator.java

示例5: buildDigestResponse

点赞 2

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
private String buildDigestResponse(String nonce) {

            String ncString = String.format("%1$08x",
                    Integer.valueOf(nonceCount.incrementAndGet()));
            String cnonce = "cnonce";

            String response = MD5A1 + ":" + nonce + ":" + ncString + ":" +
                    cnonce + ":" + QOP + ":" + MD5A2;

            String md5response = MD5Encoder.encode(
                    ConcurrentMessageDigest.digest("MD5", response.getBytes()));

            StringBuilder auth = new StringBuilder();
            auth.append("Digest username=\"");
            auth.append(USER);
            auth.append("\", realm=\"");
            auth.append(REALM);
            auth.append("\", nonce=\"");
            auth.append(nonce);
            auth.append("\", uri=\"");
            auth.append(CONTEXT_PATH + URI);
            auth.append("\", opaque=\"");
            auth.append(authenticator.getOpaque());
            auth.append("\", response=\"");
            auth.append(md5response);
            auth.append("\"");
            auth.append(", qop=");
            auth.append(QOP);
            auth.append(", nc=");
            auth.append(ncString);
            auth.append(", cnonce=\"");
            auth.append(cnonce);
            auth.append("\"");

            return auth.toString();
        }
 

开发者ID:liaokailin,
项目名称:tomcat7,
代码行数:37,
代码来源:TesterDigestAuthenticatorPerformance.java

示例6: authenticate

点赞 2

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
public Principal authenticate(Realm realm) {
	// Second MD5 digest used to calculate the digest :
	// MD5(Method + ":" + uri)
	String a2 = method + ":" + uri;

	byte[] buffer = ConcurrentMessageDigest.digestMD5(a2.getBytes(B2CConverter.ISO_8859_1));
	String md5a2 = MD5Encoder.encode(buffer);

	return realm.authenticate(userName, response, nonce, nc, cnonce, qop, realmName, md5a2);
}
 

开发者ID:how2j,
项目名称:lazycat,
代码行数:11,
代码来源:DigestAuthenticator.java

示例7: getWebSocketAccept

点赞 2

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
private static String getWebSocketAccept(String key) {
    byte[] digest = ConcurrentMessageDigest.digestSHA1(
            key.getBytes(StandardCharsets.ISO_8859_1), WS_ACCEPT);
    return Base64.encodeBase64String(digest);
}
 

开发者ID:liaokailin,
项目名称:tomcat7,
代码行数:6,
代码来源:UpgradeUtil.java

示例8: digest

点赞 2

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
private static String digest(String input) {
    return MD5Encoder.encode(
            ConcurrentMessageDigest.digestMD5(input.getBytes()));
}
 

开发者ID:liaokailin,
项目名称:tomcat7,
代码行数:5,
代码来源:TestSSOnonLoginAndDigestAuthenticator.java

示例9: getWebSocketAccept

点赞 2

import org.apache.tomcat.util.security.ConcurrentMessageDigest; //导入依赖的package包/类
private static String getWebSocketAccept(String key) {
	byte[] digest = ConcurrentMessageDigest.digestSHA1(key.getBytes(StandardCharsets.ISO_8859_1), WS_ACCEPT);
	return Base64.encodeBase64String(digest);
}
 

开发者ID:how2j,
项目名称:lazycat,
代码行数:5,
代码来源:UpgradeUtil.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)