當前位置: 首頁>>代碼示例>>Java>>正文


Java SecurityType類代碼示例

本文整理匯總了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());
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:21,代碼來源:SecurityProcessorImplTest.java

示例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;
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:9,代碼來源:SecurityTypeXmlAdapter.java

示例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;
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:9,代碼來源:SecurityTypeXmlAdapter.java

示例4: getSecurityTypes

import org.openyu.commons.security.SecurityType; //導入依賴的package包/類
/**
 * 安全性類別列舉
 * 
 * @return
 */
public Set<SecurityType> getSecurityTypes() {
	if (securityTypes == null) {
		securityTypes = new LinkedHashSet<SecurityType>();
	}
	return securityTypes;
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:12,代碼來源:SecurityProcessorImpl.java

示例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);
}
 
開發者ID:mixaceh,項目名稱:openyu-mix,代碼行數:31,代碼來源:RoleCollectorTest.java

示例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);
}
 
開發者ID:mixaceh,項目名稱:openyu-mix,代碼行數:32,代碼來源:ChatCollectorTest.java

示例7: setSecurityType

import org.openyu.commons.security.SecurityType; //導入依賴的package包/類
public void setSecurityType(SecurityType securityType) {
	this.securityType = securityType;
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:4,代碼來源:SecurityProcessorImpl.java

示例8: setSecurityTypes

import org.openyu.commons.security.SecurityType; //導入依賴的package包/類
public void setSecurityTypes(Set<SecurityType> securityTypes) {
	SecurityProcessorImpl.securityTypes = securityTypes;
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:4,代碼來源:SecurityProcessorImpl.java

示例9: setSecurityType

import org.openyu.commons.security.SecurityType; //導入依賴的package包/類
@Override
public void setSecurityType(SecurityType securityType) {
	securityProcessor.setSecurityType(securityType);
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:5,代碼來源:AuthKeyServiceImpl.java

示例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;
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:47,代碼來源:AuthKeyServiceFactoryBean.java

示例11: getSecurityType

import org.openyu.commons.security.SecurityType; //導入依賴的package包/類
public static SecurityType getSecurityType() {
	return EnumHelper.valueOf(SecurityType.class, getString(SECURITY_TYPE, null));
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:4,代碼來源:ConfigHelper2.java

示例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);
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:80,代碼來源:SecurityProcessorImplTest.java

示例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);
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:49,代碼來源:SecurityProcessorImplTest.java

示例14: setSecurityType

import org.openyu.commons.security.SecurityType; //導入依賴的package包/類
public void setSecurityType(SecurityType securityType) {
	securityable.setSecurityType(securityType);
}
 
開發者ID:mixaceh,項目名稱:openyu-socklet,代碼行數:4,代碼來源:ProtocolServiceImplBak.java

示例15: setSecurityTypes

import org.openyu.commons.security.SecurityType; //導入依賴的package包/類
public void setSecurityTypes(Set<SecurityType> securityTypes) {
	securityable.setSecurityTypes(securityTypes);
}
 
開發者ID:mixaceh,項目名稱:openyu-socklet,代碼行數:4,代碼來源:ProtocolServiceImplBak.java


注:本文中的org.openyu.commons.security.SecurityType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。