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


Java SecurityHelper.mac方法代码示例

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


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

示例1: ACCOUNT_AUTHORIZE_REQUEST

import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
public void ACCOUNT_AUTHORIZE_REQUEST() {
	final String ACCOUNT_ID = "TEST_ACCOUNT_1";
	final String ASSIGN_KEY = "FarFarAway";
	final String ALGORITHM = "HmacMD5";
	// b5f01d3a0898d8016b5633edfe6106b0
	SecretKey secretKey = SecurityHelper.createSecretKey(ASSIGN_KEY,
			ALGORITHM);
	byte[] buff = SecurityHelper.mac("1111", secretKey, ALGORITHM);
	final String PASSWORD = EncodingHelper.encodeHex(buff);
	System.out.println(PASSWORD);
	//
	Message message = messageService.createClient(ACCOUNT_ID,
			CoreMessageType.ACCOUNT_AUTHORIZE_REQUEST);
	message.addString(ACCOUNT_ID);
	message.addString(PASSWORD);
	accountSocklet.service(message);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:19,代码来源:AccountSockletTest.java

示例2: ACCOUNT_AUTHORIZE_REQUEST

import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
public void ACCOUNT_AUTHORIZE_REQUEST() {
	final String ACCOUNT_ID = "TEST_ACCOUNT_1";
	final String ASSIGN_KEY = "FarFarAway";
	final String ALGORITHM = "HmacMD5";
	// b5f01d3a0898d8016b5633edfe6106b0
	SecretKey secretKey = SecurityHelper.createSecretKey(ASSIGN_KEY,
			ALGORITHM);
	byte[] buff = SecurityHelper.mac("1111", secretKey, ALGORITHM);
	final String PASSWORD = EncodingHelper.encodeHex(buff);
	System.out.println(PASSWORD);
	//
	Message message = messageService.createClient(ACCOUNT_ID,
			CoreMessageType.ACCOUNT_AUTHORIZE_REQUEST);
	message.addString(ACCOUNT_ID);
	message.addString(PASSWORD);
	//
	javaConnector.send(message);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:20,代码来源:AccountSockletTest.java

示例3: mac

import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
// 1000000 times: 3981 mills.
// 1000000 times: 3787 mills.
// 1000000 times: 3979 mills.
public void mac() {
	// String value = "";
	String value = "中文測試abcdef";
	String algorithm = "HmacMD5";
	String assignKey = "中文key123";// HmacMD5 可中英文長度不拘
	SecretKey secretKey = SecurityHelper.createSecretKey(assignKey,
			algorithm);

	byte[] result = null;

	int count = 1;
	long beg = System.currentTimeMillis();
	for (int i = 0; i < count; i++) {
		result = SecurityHelper.mac(value, secretKey, algorithm);
	}
	long end = System.currentTimeMillis();
	System.out.println(count + " times: " + (end - beg) + " mills. ");

	SystemHelper.println(result);
	assertEquals(16, result.length);
	//
	algorithm = "HmacSHA1";
	assignKey = "FarFarAway";
	secretKey = SecurityHelper.createSecretKey(assignKey, algorithm);
	result = SecurityHelper.mac(value, secretKey, algorithm);
	SystemHelper.println(result);
	assertEquals(20, result.length);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:33,代码来源:SecurityHelperTest.java

示例4: authorize

import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
public void authorize() {
	final String ACCOUNT_ID = "TEST_ACCOUNT_1";
	final String ASSIGN_KEY = "FarFarAway";
	final String ALGORITHM = "HmacMD5";
	SecretKey secretKey = SecurityHelper.createSecretKey(ASSIGN_KEY, ALGORITHM);
	byte[] buff = SecurityHelper.mac("1111", secretKey, ALGORITHM);
	final String PASSWORD = EncodingHelper.encodeHex(buff);
	System.out.println(PASSWORD);
	//
	accountService.authorize(ACCOUNT_ID, PASSWORD);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:13,代码来源:AccountServiceImplTest.java

示例5: checkAccount

import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
public void checkAccount() {
	final String ACCOUNT_ID = "TEST_ACCOUNT_1";
	// b5f01d3a0898d8016b5633edfe6106b0
	final String ASSIGN_KEY = "FarFarAway";
	final String ALGORITHM = "HmacMD5";
	SecretKey secretKey = SecurityHelper.createSecretKey(ASSIGN_KEY, ALGORITHM);
	byte[] buff = SecurityHelper.mac("1111", secretKey, ALGORITHM);
	final String PASSWORD = EncodingHelper.encodeHex(buff);
	System.out.println(PASSWORD);
	//
	String authKey = accountService.checkAccount(ACCOUNT_ID, PASSWORD);
	System.out.println(authKey);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:15,代码来源:AccountServiceImplTest.java

示例6: authorize

import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
public void authorize() {
	final String ACCOUNT_ID = "TEST_ACCOUNT_1";
	final String ASSIGN_KEY = "FarFarAway";
	final String ALGORITHM = "HmacMD5";
	// b5f01d3a0898d8016b5633edfe6106b0
	SecretKey secretKey = SecurityHelper.createSecretKey(ASSIGN_KEY, ALGORITHM);
	byte[] buff = SecurityHelper.mac("1111", secretKey, ALGORITHM);
	final String PASSWORD = EncodingHelper.encodeHex(buff);
	System.out.println(PASSWORD);
	//
	accountService.authorize(ACCOUNT_ID, PASSWORD);
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:14,代码来源:AccountServiceImplTest.java

示例7: checkAccount

import org.openyu.commons.security.SecurityHelper; //导入方法依赖的package包/类
@Test
public void checkAccount() {
	final String ACCOUNT_ID = "TEST_ACCOUNT_1";
	final String ASSIGN_KEY = "FarFarAway";
	final String ALGORITHM = "HmacMD5";
	// b5f01d3a0898d8016b5633edfe6106b0
	SecretKey secretKey = SecurityHelper.createSecretKey(ASSIGN_KEY, ALGORITHM);
	byte[] buff = SecurityHelper.mac("1111", secretKey, ALGORITHM);
	final String PASSWORD = EncodingHelper.encodeHex(buff);
	System.out.println(PASSWORD);
	//
	String authKey = accountService.checkAccount(ACCOUNT_ID, PASSWORD);
	System.out.println(authKey);//
}
 
开发者ID:mixaceh,项目名称:openyu-mix,代码行数:15,代码来源:AccountServiceImplTest.java


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