/** * <p> * Returns true if the digester has already been initialized, false if * not.<br/> * Initialization happens: * </p> * <ul> * <li>When <tt>initialize</tt> is called.</li> * <li>When <tt>digest</tt> or <tt>matches</tt> are called for the * first time, if <tt>initialize</tt> has not been called before.</li> * </ul> * <p> * Once a digester has been initialized, trying to * change its configuration will result in an * <tt>AlreadyInitializedException</tt> * being thrown. * </p> * * @return true if the digester has already been initialized, false if * not. */ public boolean isInitialized() { return this.byteDigester.isInitialized(); }
/** * <p> * Returns true if the digester has already been initialized, false if * not.<br/> * Initialization happens: * </p> * <ul> * <li>When <tt>initialize</tt> is called.</li> * <li>When <tt>digest</tt> or <tt>matches</tt> are called for the * first time, if <tt>initialize</tt> has not been called before.</li> * </ul> * <p> * Once a digester has been initialized, trying to * change its configuration will result in an * <tt>AlreadyInitializedException</tt> * being thrown. * </p> * * @return true if the digester has already been initialized, false if * not. */ public boolean isInitialized() { return this.byteDigester.isInitialized(); }
/** * <p> * Returns true if the digester has already been initialized, false if * not.<br/> * Initialization happens: * </p> * <ul> * <li>When <tt>initialize</tt> is called.</li> * <li>When <tt>digest</tt> or <tt>matches</tt> are called for the * first time, if <tt>initialize</tt> has not been called before.</li> * </ul> * <p> * Once a digester has been initialized, trying to * change its configuration will result in an * <tt>AlreadyInitializedException</tt> * being thrown. * </p> * * @return true if the digester has already been initialized, false if * not. */ public boolean isInitialized() { return this.byteDigester.isInitialized(); }
final boolean invertPositionOfSaltInMessageBeforeDigesting) { if (isInitialized()) { throw new AlreadyInitializedException();
/** * <p> * Whether the plain (not hashed) salt bytes are to * be appended after the digest operation result bytes. The default behaviour is * to insert them before the digest result, but setting this configuration * item to <tt>true</tt> allows compatibility with some external systems * and specifications (e.g. LDAP {SSHA}). * </p> * <p> * If this parameter is not explicitly set, the default behaviour * (insertion of plain salt before digest result) will be applied. * </p> * * @since 1.7 * * @param invertPositionOfPlainSaltInEncryptionResults * whether plain salt will be appended after the digest operation * result instead of inserted before it (which is the * default). */ public synchronized void setInvertPositionOfPlainSaltInEncryptionResults( final boolean invertPositionOfPlainSaltInEncryptionResults) { if (isInitialized()) { throw new AlreadyInitializedException(); } this.invertPositionOfPlainSaltInEncryptionResults = invertPositionOfPlainSaltInEncryptionResults; this.invertPositionOfPlainSaltInEncryptionResultsSet = true; }
final boolean invertPositionOfSaltInMessageBeforeDigesting) { if (isInitialized()) { throw new AlreadyInitializedException();
/** * <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> * * @since 1.2 * * @param saltGenerator the salt generator to be used. */ public synchronized void setSaltGenerator(final SaltGenerator saltGenerator) { CommonUtils.validateNotNull(saltGenerator, "Salt generator cannot be set null"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.saltGenerator = saltGenerator; this.saltGeneratorSet = true; }
/** * <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> * * @since 1.2 * * @param saltGenerator the salt generator to be used. */ public synchronized void setSaltGenerator(final SaltGenerator saltGenerator) { CommonUtils.validateNotNull(saltGenerator, "Salt generator cannot be set null"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.saltGenerator = saltGenerator; this.saltGeneratorSet = true; }
/** * <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> * * @since 1.2 * * @param saltGenerator the salt generator to be used. */ public synchronized void setSaltGenerator(final SaltGenerator saltGenerator) { CommonUtils.validateNotNull(saltGenerator, "Salt generator cannot be set null"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.saltGenerator = saltGenerator; this.saltGeneratorSet = true; }
/** * <p> * Set the number of times the hash function will be applied recursively. * <br/> * The hash function will be applied to its own results as many times as * specified: <i>h(h(...h(x)...))</i> * </p> * <p> * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * @param iterations the number of iterations. */ public synchronized void setIterations(final int iterations) { CommonUtils.validateIsTrue(iterations > 0, "Number of iterations must be greater than zero"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.iterations = iterations; this.iterationsSet = true; }
/** * <p> * Set the number of times the hash function will be applied recursively. * <br/> * The hash function will be applied to its own results as many times as * specified: <i>h(h(...h(x)...))</i> * </p> * <p> * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * @param iterations the number of iterations. */ public synchronized void setIterations(final int iterations) { CommonUtils.validateIsTrue(iterations > 0, "Number of iterations must be greater than zero"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.iterations = iterations; this.iterationsSet = true; }
/** * <p> * Sets the size of the salt to be used to compute the digest. * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * <p> * If salt size is set to zero, then no salt will be used. * </p> * * @param saltSizeBytes the size of the salt to be used, in bytes. */ public synchronized void setSaltSizeBytes(final int saltSizeBytes) { CommonUtils.validateIsTrue(saltSizeBytes >= 0, "Salt size in bytes must be non-negative"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.saltSizeBytes = saltSizeBytes; this.useSalt = (saltSizeBytes > 0); this.saltSizeBytesSet = true; }
/** * <p> * Sets the security provider to be asked for the digest algorithm. * The provider does not have to be registered at the security * infrastructure beforehand, and its being used here will not result in * its being registered. * </p> * <p> * If this method is called, calling {@link #setProviderName(String)} * becomes unnecessary. * </p> * <p> * If no provider name / provider is explicitly set, the default JVM * provider will be used. * </p> * * @since 1.3 * * @param provider the provider to be asked for the chosen algorithm */ public synchronized void setProvider(final Provider provider) { CommonUtils.validateNotNull(provider, "Provider cannot be set null"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.provider = provider; this.providerSet = true; }
/** * <p> * Sets the size of the salt to be used to compute the digest. * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * <p> * If salt size is set to zero, then no salt will be used. * </p> * * @param saltSizeBytes the size of the salt to be used, in bytes. */ public synchronized void setSaltSizeBytes(final int saltSizeBytes) { CommonUtils.validateIsTrue(saltSizeBytes >= 0, "Salt size in bytes must be non-negative"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.saltSizeBytes = saltSizeBytes; this.useSalt = (saltSizeBytes > 0); this.saltSizeBytesSet = true; }
/** * <p> * Sets the security provider to be asked for the digest algorithm. * The provider does not have to be registered at the security * infrastructure beforehand, and its being used here will not result in * its being registered. * </p> * <p> * If this method is called, calling {@link #setProviderName(String)} * becomes unnecessary. * </p> * <p> * If no provider name / provider is explicitly set, the default JVM * provider will be used. * </p> * * @since 1.3 * * @param provider the provider to be asked for the chosen algorithm */ public synchronized void setProvider(final Provider provider) { CommonUtils.validateNotNull(provider, "Provider cannot be set null"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.provider = provider; this.providerSet = true; }
/** * <p> * Set the number of times the hash function will be applied recursively. * <br/> * The hash function will be applied to its own results as many times as * specified: <i>h(h(...h(x)...))</i> * </p> * <p> * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * @param iterations the number of iterations. */ public synchronized void setIterations(final int iterations) { CommonUtils.validateIsTrue(iterations > 0, "Number of iterations must be greater than zero"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.iterations = iterations; this.iterationsSet = true; }
/** * <p> * Sets the size of the salt to be used to compute the digest. * This mechanism is explained in * <a href="http://www.rsasecurity.com/rsalabs/node.asp?id=2127" * target="_blank">PKCS #5: Password-Based Cryptography Standard</a>. * </p> * * <p> * If salt size is set to zero, then no salt will be used. * </p> * * @param saltSizeBytes the size of the salt to be used, in bytes. */ public synchronized void setSaltSizeBytes(final int saltSizeBytes) { CommonUtils.validateIsTrue(saltSizeBytes >= 0, "Salt size in bytes must be non-negative"); if (isInitialized()) { throw new AlreadyInitializedException(); } this.saltSizeBytes = saltSizeBytes; this.useSalt = (saltSizeBytes > 0); this.saltSizeBytesSet = true; }
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; }