Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.service.security.crypto

File InstanceSecureKeyGenerator.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
4
3
1
28
21
3
0.75
1.33
3
1

Classes

Class Line # Actions
InstanceSecureKeyGenerator 12 4 3
1.0100%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.service.security.crypto;
2   
3    import io.sunshower.model.core.vault.KeyProvider;
4    import java.security.SecureRandom;
5    import java.util.Base64;
6    import javax.inject.Singleton;
7    import org.springframework.stereotype.Service;
8   
9    /** Created by haswell on 10/20/16. */
10    @Service
11    @Singleton
 
12    public class InstanceSecureKeyGenerator implements KeyProvider {
13   
14    static final String key = generateKey();
15   
 
16  2 toggle public InstanceSecureKeyGenerator() {}
17   
 
18  1 toggle @Override
19    public String getKey() {
20  1 return key;
21    }
22   
 
23  1 toggle static final String generateKey() {
24  1 final SecureRandom random = new SecureRandom();
25  1 final byte[] bytes = random.generateSeed(32);
26  1 return Base64.getEncoder().encodeToString(bytes);
27    }
28    }