Example usage for org.apache.shiro.crypto SecureRandomNumberGenerator setSeed

List of usage examples for org.apache.shiro.crypto SecureRandomNumberGenerator setSeed

Introduction

In this page you can find the example usage for org.apache.shiro.crypto SecureRandomNumberGenerator setSeed.

Prototype

public void setSeed(byte[] bytes) 

Source Link

Document

Seeds the backing SecureRandom SecureRandom instance with additional seed data.

Usage

From source file:com.azaptree.services.security.domain.config.impl.HashServiceConfig.java

License:Apache License

@Override
public HashService getHashService() {
    if (hashService != null) {
        return hashService;
    }//from w  w w .  ja va 2  s  .com
    final DefaultHashService service = new DefaultHashService();
    service.setGeneratePublicSalt(true);
    service.setPrivateSalt(ByteSource.Util.bytes(privateSalt));
    service.setHashAlgorithmName(hashAlgorithmName);
    service.setHashIterations(hashIterations);

    final SecureRandomNumberGenerator rng = new SecureRandomNumberGenerator();
    rng.setDefaultNextBytesSize(secureRandomNumberGeneratorNextBytesSize);
    final SecureRandom random = new SecureRandom();
    final byte rngSeed[] = new byte[20];
    random.nextBytes(rngSeed);
    rng.setSeed(rngSeed);

    service.setRandomNumberGenerator(rng);
    hashService = service;
    return service;
}