@Override protected CharArrayPasswordEncoder createCharEncoder() { return new CharArrayPasswordEncoder() { StandardByteDigester digester = new StandardByteDigester(); { digester.setAlgorithm("SHA-256"); digester.setIterations(100000); digester.setSaltSizeBytes(16); digester.initialize(); } @Override public String encodePassword(char[] rawPass, Object salt) { return new String(Base64.encodeBase64(digester.digest(toBytes(rawPass)))); } @Override public boolean isPasswordValid(String encPass, char[] rawPass, Object salt) { return digester.matches(toBytes(rawPass), Base64.decodeBase64(encPass.getBytes())); } }; }
/** * <p> * Sets the algorithm to be used for digesting, like <tt>MD5</tt> * or <tt>SHA-1</tt>. * </p> * <p> * This algorithm has to be supported by your security infrastructure, and * it should be allowed as an algorithm for creating * java.security.MessageDigest instances. * </p> * <p> * If you are specifying a security provider with {@link #setProvider(Provider)} or * {@link #setProviderName(String)}, this algorithm should be * supported by your specified provider. * </p> * <p> * If you are not specifying a provider, you will be able to use those * algorithms provided by the default security provider of your JVM vendor. * For valid names in the Sun JVM, see <a target="_blank" * href="http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html#AppA">Java * Cryptography Architecture API Specification & * Reference</a>. * </p> * * @param algorithm the name of the algorithm to be used. */ public void setAlgorithm(final String algorithm) { this.byteDigester.setAlgorithm(algorithm); }
/** * <p> * Sets the algorithm to be used for digesting, like <tt>MD5</tt> * or <tt>SHA-1</tt>. * </p> * <p> * This algorithm has to be supported by your security infrastructure, and * it should be allowed as an algorithm for creating * java.security.MessageDigest instances. * </p> * <p> * If you are specifying a security provider with {@link #setProvider(Provider)} or * {@link #setProviderName(String)}, this algorithm should be * supported by your specified provider. * </p> * <p> * If you are not specifying a provider, you will be able to use those * algorithms provided by the default security provider of your JVM vendor. * For valid names in the Sun JVM, see <a target="_blank" * href="http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html#AppA">Java * Cryptography Architecture API Specification & * Reference</a>. * </p> * * @param algorithm the name of the algorithm to be used. */ public void setAlgorithm(final String algorithm) { this.byteDigester.setAlgorithm(algorithm); }
/** * <p> * Sets the algorithm to be used for digesting, like <tt>MD5</tt> * or <tt>SHA-1</tt>. * </p> * <p> * This algorithm has to be supported by your security infrastructure, and * it should be allowed as an algorithm for creating * java.security.MessageDigest instances. * </p> * <p> * If you are specifying a security provider with {@link #setProvider(Provider)} or * {@link #setProviderName(String)}, this algorithm should be * supported by your specified provider. * </p> * <p> * If you are not specifying a provider, you will be able to use those * algorithms provided by the default security provider of your JVM vendor. * For valid names in the Sun JVM, see <a target="_blank" * href="http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html#AppA">Java * Cryptography Architecture API Specification & * Reference</a>. * </p> * * @param algorithm the name of the algorithm to be used. */ public synchronized void setAlgorithm(final String algorithm) { this.firstDigester.setAlgorithm(algorithm); }
/** * <p> * Sets the algorithm to be used for digesting, like <tt>MD5</tt> * or <tt>SHA-1</tt>. * </p> * <p> * This algorithm has to be supported by your security infrastructure, and * it should be allowed as an algorithm for creating * java.security.MessageDigest instances. * </p> * <p> * If you are specifying a security provider with {@link #setProvider(Provider)} or * {@link #setProviderName(String)}, this algorithm should be * supported by your specified provider. * </p> * <p> * If you are not specifying a provider, you will be able to use those * algorithms provided by the default security provider of your JVM vendor. * For valid names in the Sun JVM, see <a target="_blank" * href="http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html#AppA">Java * Cryptography Architecture API Specification & * Reference</a>. * </p> * * @param algorithm the name of the algorithm to be used. */ public synchronized void setAlgorithm(final String algorithm) { this.firstDigester.setAlgorithm(algorithm); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> */ public Digester(final String algorithm) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> */ public Digester(final String algorithm) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> */ public Digester(final String algorithm) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); }
private static StandardByteDigester newStandardByteDigester(String algorithm, int iterations, int saltSizeBytes) { final StandardByteDigester standardByteDigester = new StandardByteDigester(); standardByteDigester.setAlgorithm(algorithm); standardByteDigester.setIterations(iterations); standardByteDigester.setSaltSizeBytes(saltSizeBytes); standardByteDigester.initialize(); return standardByteDigester; } }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> * * @since 1.3 */ public Digester(final String algorithm, final String providerName) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); this.digester.setProviderName(providerName); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> * * @since 1.3 */ public Digester(final String algorithm, final String providerName) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); this.digester.setProviderName(providerName); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> * * @since 1.3 */ public Digester(final String algorithm, final Provider provider) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); this.digester.setProvider(provider); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> * * @since 1.3 */ public Digester(final String algorithm, final Provider provider) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); this.digester.setProvider(provider); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> * * @since 1.3 */ public Digester(final String algorithm, final String providerName) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); this.digester.setProviderName(providerName); }
/** * <p> * Creates a new instance of <tt>Digester</tt>, specifying * the algorithm to be used. * </p> * * @since 1.3 */ public Digester(final String algorithm, final Provider provider) { super(); this.digester = new StandardByteDigester(); this.digester.setIterations(ITERATIONS); this.digester.setSaltSizeBytes(SALT_SIZE_BYTES); this.digester.setAlgorithm(algorithm); this.digester.setProvider(provider); }
private LegacyJasyptPasswordEncryptor() { this.digester = new StandardByteDigester(); this.digester.setAlgorithm("SHA-256"); this.digester.setIterations(100000); this.digester.setSaltSizeBytes(16); this.digester.initialize(); this.base64 = new Base64(); }
@Override protected CharArrayPasswordEncoder createCharEncoder() { return new CharArrayPasswordEncoder() { StandardByteDigester digester = new StandardByteDigester(); { digester.setAlgorithm("SHA-256"); digester.setIterations(100000); digester.setSaltSizeBytes(16); digester.initialize(); } @Override public String encodePassword(char[] rawPass, Object salt) { return new String(Base64.encodeBase64(digester.digest(toBytes(rawPass)))); } @Override public boolean isPasswordValid(String encPass, char[] rawPass, Object salt) { return digester.matches(toBytes(rawPass), Base64.decodeBase64(encPass.getBytes())); } }; }
StandardByteDigester cloneDigester() { // Check initialization if (!isInitialized()) { initialize(); } final StandardByteDigester cloned = new StandardByteDigester(); if (CommonUtils.isNotEmpty(this.algorithm)) { cloned.setAlgorithm(this.algorithm); } cloned.setInvertPositionOfPlainSaltInEncryptionResults(this.invertPositionOfPlainSaltInEncryptionResults); cloned.setInvertPositionOfSaltInMessageBeforeDigesting(this.invertPositionOfSaltInMessageBeforeDigesting); cloned.setIterations(this.iterations); if (this.provider != null) { cloned.setProvider(this.provider); } if (this.providerName != null) { cloned.setProviderName(this.providerName); } if (this.saltGenerator != null) { cloned.setSaltGenerator(this.saltGenerator); } cloned.setSaltSizeBytes(this.saltSizeBytes); cloned.setUseLenientSaltSizeCheck(this.useLenientSaltSizeCheck); return cloned; }
StandardByteDigester cloneDigester() { // Check initialization if (!isInitialized()) { initialize(); } final StandardByteDigester cloned = new StandardByteDigester(); if (CommonUtils.isNotEmpty(this.algorithm)) { cloned.setAlgorithm(this.algorithm); } cloned.setInvertPositionOfPlainSaltInEncryptionResults(this.invertPositionOfPlainSaltInEncryptionResults); cloned.setInvertPositionOfSaltInMessageBeforeDigesting(this.invertPositionOfSaltInMessageBeforeDigesting); cloned.setIterations(this.iterations); if (this.provider != null) { cloned.setProvider(this.provider); } if (this.providerName != null) { cloned.setProviderName(this.providerName); } if (this.saltGenerator != null) { cloned.setSaltGenerator(this.saltGenerator); } cloned.setSaltSizeBytes(this.saltSizeBytes); cloned.setUseLenientSaltSizeCheck(this.useLenientSaltSizeCheck); return cloned; }
StandardByteDigester cloneDigester() { // Check initialization if (!isInitialized()) { initialize(); } final StandardByteDigester cloned = new StandardByteDigester(); if (CommonUtils.isNotEmpty(this.algorithm)) { cloned.setAlgorithm(this.algorithm); } cloned.setInvertPositionOfPlainSaltInEncryptionResults(this.invertPositionOfPlainSaltInEncryptionResults); cloned.setInvertPositionOfSaltInMessageBeforeDigesting(this.invertPositionOfSaltInMessageBeforeDigesting); cloned.setIterations(this.iterations); if (this.provider != null) { cloned.setProvider(this.provider); } if (this.providerName != null) { cloned.setProviderName(this.providerName); } if (this.saltGenerator != null) { cloned.setSaltGenerator(this.saltGenerator); } cloned.setSaltSizeBytes(this.saltSizeBytes); cloned.setUseLenientSaltSizeCheck(this.useLenientSaltSizeCheck); return cloned; }