本文整理汇总了Java中org.apache.shiro.crypto.CipherService类的典型用法代码示例。如果您正苦于以下问题:Java CipherService类的具体用法?Java CipherService怎么用?Java CipherService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CipherService类属于org.apache.shiro.crypto包,在下文中一共展示了CipherService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
public static void main(String[] args) {
String base64="zGkG0zevFbnIioooS3MfnnbWeBUeiZrScKVJms0CZAdJ2MYTddPkvBHGmMhvgdKA5QJk8FSb9T1Y1tFlUnnCsIvcK+iX4cfrwD7voGdU5bW9AWjwNvl3BDrAgRf+hvjrI3T5nBTFeW7uI6GzfFrIx92qER9lQ97g19Dn555uwIzf0ULvc8jICZTraLLrf2avh1hy2kUJJblO6u5IHiBbAXBNitZ6W1yjLEWmSFnb+EsEWAGB3WwV1u1HZO045LB4G57UIH4QGM0xfJjWWeahiTS4j9IAEJBbghwfL1A5pdzFiXJzzA5GF85vtP+6jLwQfGaQJyv35PvNNsDmCqFe8eUSBLji5z5y/y+yKfZk9izXiEvFjKQ5kqMqKfLMp+Vn5OuO+syc4CfJL4PLI16vwVUPV1EWAzyxUhK7DtD5OMVcLPwVtwZ11dG88wkZtjXvBymLyGCj5/Tk8gTWYsdcNKD5i8WvbMLT45S4iWsZxa/5offIiCipkkqoqvxCppJLTzBoaR/wlqoa1Bc/cvpijiJTIbSCj+iFloQRdax1mMQ";
base64 = ensurePadding(base64);
byte[] decoded = Base64.decode(base64);
byte[] serialized = decoded;
CipherService cipherService = new AesCipherService();
if (cipherService != null) {
ByteSource byteSource = cipherService.decrypt(decoded, new byte[]{-112, -15, -2, 108, -116, 100, -28, 61, -99, 121, -104, -120, -59, -58, -102, 104});
serialized = byteSource.getBytes();
}
Serializer<PrincipalCollection> serializer = new DefaultSerializer<PrincipalCollection>();
;
System.out.println(serializer.deserialize(serialized));
SimplePrincipalCollection p=(SimplePrincipalCollection) serializer.deserialize(serialized);
System.out.println(p.getPrimaryPrincipal());
System.out.println(p.getRealmNames());
System.out.println(p);
}
开发者ID:ushelp,项目名称:EasyEE,代码行数:23,代码来源:ShiroTest.java
示例2: encode
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
@Override
public byte[] encode(final byte[] value) {
try {
final Key key = new SecretKeySpec(this.encryptionSecretKey.getBytes(),
this.secretKeyAlgorithm);
final CipherService cipher = new AesCipherService();
final byte[] result = cipher.encrypt(value, key.getEncoded()).getBytes();
return sign(result);
} catch (final Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:BinaryCipherExecutor.java
示例3: decode
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
@Override
public byte[] decode(final byte[] value) {
try {
final byte[] verifiedValue = verifySignature(value);
final Key key = new SecretKeySpec(this.encryptionSecretKey.getBytes(UTF8_ENCODING),
this.secretKeyAlgorithm);
final CipherService cipher = new AesCipherService();
final byte[] result = cipher.decrypt(verifiedValue, key.getEncoded()).getBytes();
return result;
} catch (final Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:15,代码来源:BinaryCipherExecutor.java
示例4: encode
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
@Override
public byte[] encode(final byte[] value) {
try {
final Key key = new SecretKeySpec(this.encryptionSecretKey.getBytes(StandardCharsets.UTF_8),
this.secretKeyAlgorithm);
final CipherService cipher = new AesCipherService();
final byte[] result = cipher.encrypt(value, key.getEncoded()).getBytes();
return sign(result);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
throw Throwables.propagate(e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:BaseBinaryCipherExecutor.java
示例5: decode
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
@Override
public byte[] decode(final byte[] value) {
try {
final byte[] verifiedValue = verifySignature(value);
final Key key = new SecretKeySpec(this.encryptionSecretKey.getBytes(StandardCharsets.UTF_8),
this.secretKeyAlgorithm);
final CipherService cipher = new AesCipherService();
final byte[] result = cipher.decrypt(verifiedValue, key.getEncoded()).getBytes();
return result;
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:BaseBinaryCipherExecutor.java
示例6: encrypt
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
/**
* Encrypts the byte array by using the configured {@link #getCipherService() cipherService}.
*
* @param serialized the serialized object byte array to be encrypted
* @return an encrypted byte array returned by the configured {@link #getCipherService () cipher}.
*/
protected byte[] encrypt(byte[] serialized) {
byte[] value = serialized;
CipherService cipherService = getCipherService();
if (cipherService != null) {
ByteSource byteSource = cipherService.encrypt(serialized, getEncryptionCipherKey());
value = byteSource.getBytes();
}
return value;
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:16,代码来源:AbstractRememberMeManager.java
示例7: decrypt
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
/**
* Decrypts the byte array using the configured {@link #getCipherService() cipherService}.
*
* @param encrypted the encrypted byte array to decrypt
* @return the decrypted byte array returned by the configured {@link #getCipherService () cipher}.
*/
protected byte[] decrypt(byte[] encrypted) {
byte[] serialized = encrypted;
CipherService cipherService = getCipherService();
if (cipherService != null) {
ByteSource byteSource = cipherService.decrypt(encrypted, getDecryptionCipherKey());
serialized = byteSource.getBytes();
}
return serialized;
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:16,代码来源:AbstractRememberMeManager.java
示例8: encrypt
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
public static ByteSource encrypt(ShiroSecurityToken securityToken, byte[] passPhrase, CipherService cipherService) throws Exception {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ObjectOutput serialStream = new ObjectOutputStream(stream);
try {
serialStream.writeObject(securityToken);
return cipherService.encrypt(stream.toByteArray(), passPhrase);
} finally {
close(serialStream);
IOHelper.close(stream);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:ShiroSecurityHelper.java
示例9: ShiroSecurityTokenInjector
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
public ShiroSecurityTokenInjector(ShiroSecurityToken securityToken, byte[] passPhrase, CipherService cipherService) {
this(securityToken, passPhrase);
this.cipherService = cipherService;
}
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:ShiroSecurityTokenInjector.java
示例10: getCipherService
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
public CipherService getCipherService() {
return cipherService;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ShiroSecurityTokenInjector.java
示例11: setCipherService
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
public void setCipherService(CipherService cipherService) {
this.cipherService = cipherService;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:ShiroSecurityTokenInjector.java
示例12: provideCipherService
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
@Provides
@Singleton
public CipherService provideCipherService(final AesCipherService cipherService) {
return cipherService;
}
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:6,代码来源:CryptographyModule.java
示例13: EncryptionServiceImpl
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
public EncryptionServiceImpl(@NonNull final CipherService cipherService, final Map<String, Key> secretKeys) {
checkSecretKeys(secretKeys);
this.cipherFunctions = cipherFunctions(cipherService, secretKeys);
}
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:5,代码来源:EncryptionServiceImpl.java
示例14: getCipherService
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
/**
* Returns the {@code CipherService} to use for encrypting and decrypting serialized identity data to prevent easy
* inspection of Subject identity data.
* <p/>
* Unless overridden by the {@link #setCipherService} method, the default instance is an {@link AesCipherService}.
*
* @return the {@code Cipher} to use for encrypting and decrypting serialized identity data to prevent easy
* inspection of Subject identity data
*/
public CipherService getCipherService() {
return cipherService;
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:13,代码来源:AbstractRememberMeManager.java
示例15: setCipherService
import org.apache.shiro.crypto.CipherService; //导入依赖的package包/类
/**
* Sets the {@code CipherService} to use for encrypting and decrypting serialized identity data to prevent easy
* inspection of Subject identity data.
* <p/>
* If the CipherService is a symmetric CipherService (using the same key for both encryption and decryption), you
* should set your key via the {@link #setCipherKey(byte[])} method.
* <p/>
* If the CipherService is an asymmetric CipherService (different keys for encryption and decryption, such as
* public/private key pairs), you should set your encryption and decryption key via the respective
* {@link #setEncryptionCipherKey(byte[])} and {@link #setDecryptionCipherKey(byte[])} methods.
* <p/>
* <b>N.B.</b> Unless overridden by this method, the default CipherService instance is an
* {@link AesCipherService}. This {@code RememberMeManager} implementation already has a configured symmetric key
* to use for encryption and decryption, but it is recommended to provide your own for added security. See the
* class-level JavaDoc for more information and why it might be good to provide your own.
*
* @param cipherService the {@code CipherService} to use for encrypting and decrypting serialized identity data to
* prevent easy inspection of Subject identity data.
*/
public void setCipherService(CipherService cipherService) {
this.cipherService = cipherService;
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:23,代码来源:AbstractRememberMeManager.java
注:本文中的org.apache.shiro.crypto.CipherService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论