ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filter/KeyManager.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filter/KeyManager.java (file contents):
Revision 1.1 by tdb, Thu Mar 21 17:44:51 2002 UTC vs.
Revision 1.2 by tdb, Fri Mar 22 14:22:58 2002 UTC

# Line 29 | Line 29 | public class KeyManager {
29      private final char[] KEYSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
30      
31      /**
32 <     * The length of our keys
32 >     * Default key length
33       */
34 <    public static final int KEYLEN = 15;
34 >    public static final int DEFKEYLEN = 15;
35      
36   //---STATIC METHODS---
37  
# Line 52 | Line 52 | public class KeyManager {
52       * Private constructor to avoid external construction.
53       */
54      private KeyManager() {
55 <        // do nothing
55 >        try {
56 >            String keylen = ConfigurationProxy.getInstance().getProperty("Filter." + FilterMain.NAME, "Filter.KeyLength");
57 >            _keylen = Integer.parseInt(keylen);
58 >        }
59 >        catch (PropertyNotFoundException e) {
60 >            _keylen = DEFKEYLEN;
61 >            _logger.write(toString(), Logger.WARNING, "No key length found, using default of " +_keylen+ " : " + e);
62 >        }
63 >        catch (NumberFormatException e) {
64 >            _keylen = DEFKEYLEN;
65 >            _logger.write(toString(), Logger.WARNING, "Malformed key length found, using default of " +_keylen+ " : " + e);
66 >        }
67      }
68  
69   //---PUBLIC METHODS---
# Line 116 | Line 127 | public class KeyManager {
127      public String genKey() {
128          Random r = new Random();
129          StringBuffer s = new StringBuffer();
130 <        for(int i=0; i < KEYLEN; i++) {
130 >        for(int i=0; i < _keylen; i++) {
131              s.append(KEYSET[r.nextInt(KEYSET.length)]);
132          }
133          return s.toString();
# Line 149 | Line 160 | public class KeyManager {
160       * the hosts we're authenticating
161       */
162      private HashMap _keys = new HashMap();
163 +
164 +    /**
165 +     * The length of our keys
166 +     */
167 +    private int _keylen;
168      
169      /**
170       * This holds a reference to the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines