本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);//
}