1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.providers.dao.salt;
17
18 import org.acegisecurity.providers.dao.SaltSource;
19 import org.acegisecurity.userdetails.UserDetails;
20
21 import org.springframework.beans.factory.InitializingBean;
22
23
24 /***
25 * Uses a static system-wide <code>String</code> as the salt.
26 *
27 * <P>
28 * Does not supply a different salt for each {@link User}. This means users
29 * sharing the same password will still have the same digested password. Of
30 * benefit is the digested passwords will at least be more protected than if
31 * stored without any salt.
32 * </p>
33 *
34 * @author Ben Alex
35 * @version $Id: SystemWideSaltSource.java,v 1.6 2005/11/29 13:10:12 benalex Exp $
36 */
37 public class SystemWideSaltSource implements SaltSource, InitializingBean {
38
39
40 private String systemWideSalt;
41
42
43
44 public Object getSalt(UserDetails user) {
45 return this.systemWideSalt;
46 }
47
48 public void setSystemWideSalt(String systemWideSalt) {
49 this.systemWideSalt = systemWideSalt;
50 }
51
52 public String getSystemWideSalt() {
53 return this.systemWideSalt;
54 }
55
56 public void afterPropertiesSet() throws Exception {
57 if ((this.systemWideSalt == null) || "".equals(this.systemWideSalt)) {
58 throw new IllegalArgumentException("A systemWideSalt must be set");
59 }
60 }
61 }