/** * Default constructor that initializes a {@link DefaultSerializer} as the {@link #getSerializer() serializer} and * an {@link AesCipherService} as the {@link #getCipherService() cipherService}. */ public AbstractRememberMeManager() { this.serializer = new DefaultSerializer<PrincipalCollection>(); AesCipherService cipherService = new AesCipherService(); this.cipherService = cipherService; setCipherKey(cipherService.generateNewKey().getEncoded()); }
/** * Default constructor that initializes a {@link DefaultSerializer} as the {@link #getSerializer() serializer} and * an {@link AesCipherService} as the {@link #getCipherService() cipherService}. */ public AbstractRememberMeManager() { this.serializer = new DefaultSerializer<PrincipalCollection>(); AesCipherService cipherService = new AesCipherService(); this.cipherService = cipherService; setCipherKey(cipherService.generateNewKey().getEncoded()); }
public ShiroSecurityTokenInjector() { this.passPhrase = bits128; // Set up AES encryption based cipher service, by default cipherService = new AesCipherService(); }
public ShiroSecurityPolicy() { this.passPhrase = bits128; // Set up AES encryption based cipher service, by default cipherService = new AesCipherService(); permissionsList = new ArrayList<>(); rolesList = new ArrayList<>(); alwaysReauthenticate = true; }
Key key = new AesCipherService().generateNewKey(128); AesCipherService cipher = new AesCipherService(); for (int i = 0; i <20; ++i) { System.out.println(Hex.encode(cipher.encrypt("abcde".getBytes(StandardCharsets.UTF_8), key.getEncoded()).getBytes())); }
protected ShiroStorageHandler(byte[] kek) { hashService = new DefaultHashService(); cipherService = new AesCipherService(); cipherService.setMode(OperationMode.ECB); saltedCipherService = new AesCipherService(); this.kek = kek; }
@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); } }
@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); } }
@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); } }
@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); } }
/** * Encrypts the given text using all Shiro defaults: 128 bit size, CBC mode, PKCS5 padding scheme. * * @param key The key to use * @param initialText The text to encrypt * @return The encrypted text */ private static byte[] encrypt(Key key, byte[] initialText) { AesCipherService cipherService = new AesCipherService(); ByteSource cipherText = cipherService.encrypt(initialText, key.getEncoded()); return cipherText.getBytes(); }
private static byte[] decrypt(Key key, byte[] ciphertext) { AesCipherService cipherService = new AesCipherService(); ByteSource plainText = cipherService.decrypt(ciphertext, key.getEncoded()); return plainText.getBytes(); }
import org.apache.commons.codec.binary.Base64; import org.apache.shiro.crypto.AesCipherService; public class Test { public static void main(String[] args) throws Exception { System.out.println(encrypt("Hello")); } static String encrypt(String input) throws Exception { AesCipherService aesCipher = new AesCipherService(); aesCipher.setModeName("ECB"); byte[] bytes = aesCipher.encrypt(input.getBytes("UTF-8"), "0123456789abcdef".getBytes()).getBytes(); byte[] bytesEncoded = Base64.encodeBase64(bytes); return new String(bytesEncoded); } }
public AES(byte[] key) { super(); this.key = key; cipher = new AesCipherService(); cipher.setMode(OperationMode.ECB); cipher.setPaddingScheme(PaddingScheme.NONE); }
/** * Default constructor that initializes a {@link DefaultSerializer} as the {@link #getSerializer() serializer} and * an {@link AesCipherService} as the {@link #getCipherService() cipherService}. */ public AbstractRememberMeManager() { this.serializer = new DefaultSerializer<PrincipalCollection>(); this.cipherService = new AesCipherService(); setCipherKey(DEFAULT_CIPHER_KEY_BYTES); }
public static void main(String[] args) throws Exception { if ("-crypt".equals(args[0])) { Debug.logInfo(HashCrypt.cryptUTF8(args[1], null, args[2]), module); } else if ("-digest".equals(args[0])) { String digest = HashCrypt.digestHash("SHA", null, args[1]); Debug.logInfo(digest, module); } else if ("-kek".equals(args[0])) { AesCipherService cs = new AesCipherService(); Debug.logInfo(Base64.encodeBase64String(cs.generateNewKey().getEncoded()), module); } else if ("-kek-old".equals(args[0])) { Debug.logInfo(Base64.encodeBase64String(DesCrypt.generateKey().getEncoded()), module); } } }
private static byte[] encrypt(byte[] serialized) { byte[] value = serialized; CipherService cipherService = new AesCipherService(); if (cipherService != null) { ByteSource byteSource = cipherService.encrypt(serialized, Base64.decode("kPH+bIxk5D2deZiIxcaaaA==")); value = byteSource.getBytes(); } return value; } }
public byte[] decrypt(byte[] ciphertext, final byte[] key) { AesCipherService cipher = new AesCipherService(); cipher.setMode(OperationMode.ECB); cipher.setPaddingScheme(PaddingScheme.NONE); ByteSource plaintext = cipher.decrypt(ciphertext, key); return padding.removePadding(plaintext.getBytes()); }
public byte[] encrypt(byte[] plaintext, final byte[] key) { AesCipherService cipher = new AesCipherService(); cipher.setMode(OperationMode.ECB); cipher.setPaddingScheme(PaddingScheme.NONE); byte[] paddedPlaintext = padding.padPkcsN7(plaintext, getBlockSize()); ByteSource ciphertext = cipher.encrypt(paddedPlaintext, key); return ciphertext.getBytes(); }
AesCipherService cipherService = new AesCipherService(); try { List<GenericValue> rows = EntityQuery.use(delegator).from("EntityKeyStore").queryList();