本文整理汇总了Java中org.openyu.commons.security.SecurityType类的典型用法代码示例。如果您正苦于以下问题:Java SecurityType类的具体用法?Java SecurityType怎么用?Java SecurityType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SecurityType类属于org.openyu.commons.security包,在下文中一共展示了SecurityType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToXml
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
// round: 0.69 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+-
// 0.00], GC.calls: 0, GC.time: 0.00, time.total: 0.69, time.warmup: 0.00,
// time.bench: 0.69
public void writeToXml() {
SecurityProcessor processor = new SecurityProcessorImpl();
//
processor.setSecurity(true);
processor.setSecurityType(SecurityType.DES_ECB_PKCS5Padding);
processor.setSecurityKey("NotFarAway");
//
String result = CollectorHelper.writeToXml(SecurityProcessorImpl.class,
processor);
System.out.println(result);
assertNotNull(result);
//
SecurityProcessor compare = new SecurityProcessorImpl();
assertTrue(processor.getSecurityTypes() == compare.getSecurityTypes());
}
示例2: unmarshal
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
public SecurityType unmarshal(SecurityTypeEntry value) throws Exception {
SecurityType result = null;
//
if (value != null) {
result = SecurityType.valueOf(value.key);
}
return result;
}
示例3: marshal
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
public SecurityTypeEntry marshal(SecurityType value) throws Exception {
SecurityTypeEntry result = null;
//
if (value != null) {
result = new SecurityTypeEntry(value.name(), value.getValue());
}
return result;
}
示例4: getSecurityTypes
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
/**
* 安全性類別列舉
*
* @return
*/
public Set<SecurityType> getSecurityTypes() {
if (securityTypes == null) {
securityTypes = new LinkedHashSet<SecurityType>();
}
return securityTypes;
}
示例5: writeToXml
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
@Test
@Deprecated
/**
* 只是為了模擬用,有正式xml後,不應再使用,以免覆蓋掉正式的xml
*/
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void writeToXml() {
RoleCollector collector = RoleCollector.getInstance(false);
String result = null;
//
collector.setRetryNumber(3);
collector.setRetryPauseMills(1 * 1000L);
collector.setUnsaveDir("custom/role/unsave");
collector.setListenMills(3 * 60 * 1000L);// 3分鐘
//
collector.getSerializeProcessor().setSerialize(true);
collector.getSerializeProcessor().setSerializeType(SerializeType.FST);
//
collector.getSecurityProcessor().setSecurity(true);
collector.getSecurityProcessor().setSecurityType(SecurityType.AES_ECB_PKCS5Padding);
collector.getSecurityProcessor().setSecurityKey("Girls, LongTimeNoSee");
//
collector.getCompressProcessor().setCompress(true);
collector.getCompressProcessor().setCompressType(CompressType.SNAPPY);
//
result = CollectorHelper.writeToXml(RoleCollector.class, collector);
//
System.out.println(result);
assertNotNull(result);
}
示例6: writeToXml
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
@Test
@Deprecated
/**
* 只是為了模擬用,有正式xml後,不應再使用,以免覆蓋掉正式的xml
*/
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void writeToXml() {
String result = null;
ChatCollector collector = ChatCollector.getInstance(false);
//
collector.setRetryNumber(3);
collector.setRetryPauseMills(1 * 1000L);
collector.setUnsaveDir("custom/chat/unsave");
collector.setListenMills(3 * 60 * 1000L + 10000L);// 3分鐘又10秒
//
//
collector.getSerializeProcessor().setSerialize(true);
collector.getSerializeProcessor().setSerializeType(SerializeType.FST);
//
collector.getSecurityProcessor().setSecurity(true);
collector.getSecurityProcessor().setSecurityType(SecurityType.AES_ECB_PKCS5Padding);
collector.getSecurityProcessor().setSecurityKey("Girls, LongTimeNoSee");
//
collector.getCompressProcessor().setCompress(true);
collector.getCompressProcessor().setCompressType(CompressType.SNAPPY);
//
result = CollectorHelper.writeToXml(ChatCollector.class, collector);
//
System.out.println(result);
assertNotNull(result);
}
示例7: setSecurityType
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
public void setSecurityType(SecurityType securityType) {
this.securityType = securityType;
}
示例8: setSecurityTypes
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
public void setSecurityTypes(Set<SecurityType> securityTypes) {
SecurityProcessorImpl.securityTypes = securityTypes;
}
示例9: setSecurityType
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
@Override
public void setSecurityType(SecurityType securityType) {
securityProcessor.setSecurityType(securityType);
}
示例10: createService
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
/**
* 建構
*
* @return
*/
protected AuthKeyService createService() throws Exception {
AuthKeyServiceImpl result = null;
try {
result = new AuthKeyServiceImpl();
//
result.setApplicationContext(applicationContext);
result.setBeanFactory(beanFactory);
result.setResourceLoader(resourceLoader);
//
result.setCreateInstance(true);
/**
* extendedProperties
*/
result.setAliveMills(extendedProperties.getLong(ALIVE_MILLS, DEFAULT_ALIVE_MILLS));
result.setListenMills(extendedProperties.getLong(LISTEN_MILLS, DEFAULT_LISTEN_MILLS));
// security
result.setSecurity(extendedProperties.getBoolean(SECURITY, DEFAULT_SECURITY));
String securityTypeValue = extendedProperties.getString(SECURITY_TYPE, DEFAULT_SECURITY_TYPE.getValue());
SecurityType securityType = EnumHelper.valueOf(SecurityType.class, securityTypeValue);
result.setSecurityType(securityType);
result.setSecurityKey(extendedProperties.getString(SECURITY_KEY, DEFAULT_SECURITY_KEY));
/**
* injectiion
*/
result.setThreadService(threadService);
// 啟動
result.start();
} catch (Exception e) {
LOGGER.error(new StringBuilder("Exception encountered during createService()").toString(), e);
try {
result = (AuthKeyServiceImpl) shutdownService();
} catch (Exception sie) {
throw sie;
}
throw e;
}
return result;
}
示例11: getSecurityType
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
public static SecurityType getSecurityType() {
return EnumHelper.valueOf(SecurityType.class, getString(SECURITY_TYPE, null));
}
示例12: encrypt
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void encrypt() {
SecurityProcessor processor = new SecurityProcessorImpl();
processor.setSecurity(true);
processor.setSecurityType(SecurityType.DES_CBC_PKCS5Padding);
processor.setSecurityKey("12345678");
//
byte[] value = ByteHelper.toByteArray("中文測試abcdef");
byte[] result = null;
// DES
result = processor.encrypt(value);
//
System.out.println(result.length);
assertEquals(24, result.length);
//
processor.setSecurityType(SecurityType.DES_ECB_PKCS5Padding);
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(24, result.length);
//
processor.setSecurityType(SecurityType.DES);
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(24, result.length);
//
result = processor.encrypt("DES/ECB/PKCS5Padding", value);
System.out.println(result.length);
assertEquals(24, result.length);
// DESede
processor.setSecurityType(SecurityType.DESede_CBC_PKCS5Padding);
processor.setSecurityKey("123456781234567812345678");
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(24, result.length);
//
processor.setSecurityType(SecurityType.DESede_ECB_PKCS5Padding);
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(24, result.length);
//
processor.setSecurityType(SecurityType.DESede);
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(24, result.length);
// AES
processor.setSecurityType(SecurityType.AES_CBC_PKCS5Padding);
processor.setSecurityKey("1234567890123456");
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(32, result.length);
//
processor.setSecurityType(SecurityType.AES_ECB_PKCS5Padding);
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(32, result.length);
//
processor.setSecurityType(SecurityType.AES);
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(32, result.length);
// MD
processor.setSecurityType(SecurityType.MD5);
processor.setSecurityKey("1234567890123456");
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(16, result.length);
// MAC
processor.setSecurityType(SecurityType.HmacSHA1);
processor.setSecurityKey("1234567890123456");
result = processor.encrypt(value);
System.out.println(result.length);
assertEquals(20, result.length);
}
示例13: decrypt
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
@Test
@BenchmarkOptions(benchmarkRounds = 1, warmupRounds = 0, concurrency = 1)
public void decrypt() {
SecurityProcessor processor = new SecurityProcessorImpl();
processor.setSecurity(true);
processor.setSecurityType(SecurityType.DES_ECB_PKCS5Padding);
processor.setSecurityKey("12345678");
//
String value = "中文測試abcdef";
byte[] encrypt = processor.encrypt(ByteHelper.toByteArray(value));
byte[] result = null;
int count = 1;
long beg = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
// DES
result = processor.decrypt(encrypt);
}
//
long end = System.currentTimeMillis();
System.out.println(count + " times: " + (end - beg) + " mills. ");
//
System.out.println(result.length);
String stringValue = ByteHelper.toString(result);
System.out.println(stringValue);// 中文測試abcdef
assertEquals(value, stringValue);
// DESede
processor.setSecurityType(SecurityType.DESede_ECB_PKCS5Padding);
processor.setSecurityKey("123456781234567812345678");
encrypt = processor.encrypt(ByteHelper.toByteArray(value));
result = processor.decrypt(encrypt);
System.out.println(result.length);
stringValue = ByteHelper.toString(result);
System.out.println(stringValue);// 中文測試abcdef
assertEquals(value, stringValue);
// AES
processor.setSecurityType(SecurityType.AES_ECB_PKCS5Padding);
processor.setSecurityKey("1234567890123456");
encrypt = processor.encrypt(ByteHelper.toByteArray(value));
result = processor.decrypt(encrypt);
System.out.println(result.length);
stringValue = ByteHelper.toString(result);
System.out.println(stringValue);// 中文測試abcdef
assertEquals(value, stringValue);
}
示例14: setSecurityType
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
public void setSecurityType(SecurityType securityType) {
securityable.setSecurityType(securityType);
}
示例15: setSecurityTypes
import org.openyu.commons.security.SecurityType; //导入依赖的package包/类
public void setSecurityTypes(Set<SecurityType> securityTypes) {
securityable.setSecurityTypes(securityTypes);
}