@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())); } }; }
@Override public boolean isPasswordValid(String encPass, char[] rawPass, Object salt) { return digester.matches(toBytes(rawPass), Base64.decodeBase64(encPass.getBytes())); } };
@Override public String encodePassword(char[] rawPass, Object salt) { return new String(Base64.encodeBase64(digester.digest(toBytes(rawPass)))); }
/** * Creates a new instance of <tt>StrongPasswordEncryptor</tt> * */ public StrongPasswordEncryptor() { super(); this.digester = new StandardStringDigester(); this.digester.setAlgorithm("SHA-256"); this.digester.setIterations(100000); this.digester.setSaltSizeBytes(16); this.digester.initialize(); }
/** * Creates a new instance of <tt>RFC2307MD5PasswordEncryptor</tt> * */ public RFC2307MD5PasswordEncryptor() { super(); this.digester = new StandardStringDigester(); this.digester.setAlgorithm("MD5"); this.digester.setIterations(1); this.digester.setSaltSizeBytes(0); this.digester.setPrefix("{MD5}"); }
/** * Creates a new instance of <tt>ConfigurablePasswordEncryptor</tt> * */ public ConfigurablePasswordEncryptor() { super(); this.digester = new StandardStringDigester(); }
/** * Creates a new instance of <tt>BasicPasswordEncryptor</tt> * */ public BasicPasswordEncryptor() { super(); this.digester = new StandardStringDigester(); this.digester.initialize(); }
/** * Encrypts (digests) a password. * * @param password the password to be encrypted. * @return the resulting digest. * @see StandardStringDigester#digest(String) */ public String encryptPassword(final String password) { return this.digester.digest(password); }
/** * Creates a new instance of <tt>PooledStandardByteDigester</tt>. */ public PooledByteDigester() { super(); this.firstDigester = new StandardByteDigester(); }
/** * Encodes a password. This implementation completely ignores salt, as jasypt's * <tt>PasswordEncryptor</tt> and <tt>StringDigester</tt> normally use a random one. Thus, it * can be safely passed as <tt>null</tt>. * * @param rawPass The password to be encoded. * @param salt The salt, which will be ignored. It can be null. */ public String encodePassword(final String rawPass, final Object salt) { checkInitialization(); if (this.useEncryptor.booleanValue()) { return this.passwordEncryptor.encryptPassword(rawPass); } return this.stringDigester.digest(rawPass); }
/** * Checks a password's validity. This implementation completely ignores salt, as jasypt's * <tt>PasswordEncryptor</tt> and <tt>StringDigester</tt> normally use a random one. Thus, it * can be safely passed as <tt>null</tt>. * * @param encPass The encrypted password (digest) against which to check. * @param rawPass The password to be checked. * @param salt The salt, which will be ignored. It can be null. */ public boolean isPasswordValid(final String encPass, final String rawPass, final Object salt) { checkInitialization(); if (this.useEncryptor.booleanValue()) { return this.passwordEncryptor.checkPassword(rawPass, encPass); } return this.stringDigester.matches(rawPass, encPass); }
/** * <p> * Sets the salt generator to be used. If no salt generator is specified, * an instance of {@link org.jasypt.salt.RandomSaltGenerator} will be used. * </p> * * @param saltGenerator the salt generator to be used. */ public void setSaltGenerator(final SaltGenerator saltGenerator) { this.byteDigester.setSaltGenerator(saltGenerator); }
/** * Lets the user configure this encryptor with a {@link DigesterConfig} * object, like if he/she were using a {@link StandardStringDigester} object * directly. * * @param config the DigesterConfig object to be set for configuration. * @see StandardStringDigester#setConfig(DigesterConfig) */ public void setConfig(final DigesterConfig config) { this.digester.setConfig(config); }
/** * Creates a new instance of <tt>StrongPasswordEncryptor</tt> * */ public StrongPasswordEncryptor() { super(); this.digester = new StandardStringDigester(); this.digester.setAlgorithm("SHA-256"); this.digester.setIterations(100000); this.digester.setSaltSizeBytes(16); this.digester.initialize(); }
/** * Creates a new instance of <tt>PooledStandardStringDigester</tt>. */ public PooledStringDigester() { super(); this.firstDigester = new StandardStringDigester(); }
/** * Encrypts (digests) a password. * * @param password the password to be encrypted. * @return the resulting digest. * @see StandardStringDigester#digest(String) */ public String encryptPassword(final String password) { return this.digester.digest(password); }
/** * Creates a new instance of <tt>ConfigurablePasswordEncryptor</tt> * */ public ConfigurablePasswordEncryptor() { super(); this.digester = new StandardStringDigester(); }
/** * Encrypts (digests) a password. * * @param password the password to be encrypted. * @return the resulting digest. * @see StandardStringDigester#digest(String) */ public String encryptPassword(final String password) { return this.digester.digest(password); }
/** * Encrypts (digests) a password. * * @param password the password to be encrypted. * @return the resulting digest. * @see StandardStringDigester#digest(String) */ public String encryptPassword(final String password) { return this.digester.digest(password); }
/** * Encrypts (digests) a password. * * @param password the password to be encrypted. * @return the resulting digest. * @see StandardStringDigester#digest(String) */ public String encryptPassword(final String password) { return this.digester.digest(password); }