01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.providers.dao.salt;
17:
18: import org.acegisecurity.providers.dao.SaltSource;
19:
20: import org.acegisecurity.userdetails.UserDetails;
21:
22: import org.springframework.beans.factory.InitializingBean;
23:
24: /**
25: * Uses a static system-wide <code>String</code> as the salt.<P>Does not supply a different salt for each {@link
26: * org.acegisecurity.userdetails.User}. This means users sharing the same password will still have the same digested
27: * password. Of benefit is the digested passwords will at least be more protected than if stored without any salt.</p>
28: *
29: * @author Ben Alex
30: * @version $Id: SystemWideSaltSource.java 1519 2006-05-29 15:06:32Z benalex $
31: */
32: public class SystemWideSaltSource implements SaltSource,
33: InitializingBean {
34: //~ Instance fields ================================================================================================
35:
36: private String systemWideSalt;
37:
38: //~ Methods ========================================================================================================
39:
40: public void afterPropertiesSet() throws Exception {
41: if ((this .systemWideSalt == null)
42: || "".equals(this .systemWideSalt)) {
43: throw new IllegalArgumentException(
44: "A systemWideSalt must be set");
45: }
46: }
47:
48: public Object getSalt(UserDetails user) {
49: return this .systemWideSalt;
50: }
51:
52: public String getSystemWideSalt() {
53: return this .systemWideSalt;
54: }
55:
56: public void setSystemWideSalt(String systemWideSalt) {
57: this.systemWideSalt = systemWideSalt;
58: }
59: }
|