1 package fr.in2p3.jsaga.adaptor.security;
2
3 import fr.in2p3.jsaga.Base;
4
5 import java.io.*;
6 import java.security.Key;
7 import java.security.KeyStore;
8
9
10
11
12
13
14
15
16
17
18
19
20
21 public abstract class PasswordAbstract {
22 static final File KEYSTORE_FILE = new File(Base.JSAGA_USER, "jce-keystore.dat");
23
24 protected static final String ALGORITHM = "AES";
25 private static final String MODE = "ECB";
26 private static final String PADDING = "PKCS5Padding";
27 protected static final String CIPHER = ALGORITHM+"/"+MODE+"/"+PADDING;
28
29 protected char[] m_storepass;
30 protected char[] m_keypass;
31 protected KeyStore m_keystore;
32 protected Key m_key;
33
34 protected PasswordAbstract() throws Exception {
35 m_storepass = System.getProperty("keystore.password", "changeit").toCharArray();
36 m_keypass = System.getProperty("key.password", "changeit").toCharArray();
37 m_keystore = KeyStore.getInstance("JCEKS");
38 if (KEYSTORE_FILE.exists()) {
39
40 InputStream in = new FileInputStream(KEYSTORE_FILE);
41 m_keystore.load(in, m_storepass);
42 in.close();
43 } else {
44
45 m_keystore.load(null, null);
46 }
47 }
48 }