Coverage Report - org.acegisecurity.providers.dao.salt.SystemWideSaltSource
 
Classes in this File Line Coverage Branch Coverage Complexity
SystemWideSaltSource
100% 
100% 
1.5
 
 1  
 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
 2  
  *
 3  
  * Licensed under the Apache License, Version 2.0 (the "License");
 4  
  * you may not use this file except in compliance with the License.
 5  
  * You may obtain a copy of the License at
 6  
  *
 7  
  *     http://www.apache.org/licenses/LICENSE-2.0
 8  
  *
 9  
  * 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  
 /**
 26  
  * Uses a static system-wide <code>String</code> as the salt.<P>Does not supply a different salt for each {@link
 27  
  * org.acegisecurity.userdetails.User}. This means users sharing the same password will still have the same digested
 28  
  * password. Of benefit is the digested passwords will at least be more protected than if stored without any salt.</p>
 29  
  *
 30  
  * @author Ben Alex
 31  
  * @version $Id: SystemWideSaltSource.java 1519 2006-05-29 15:06:32Z benalex $
 32  
  */
 33  5
 public class SystemWideSaltSource implements SaltSource, InitializingBean {
 34  
     //~ Instance fields ================================================================================================
 35  
 
 36  
     private String systemWideSalt;
 37  
 
 38  
     //~ Methods ========================================================================================================
 39  
 
 40  
     public void afterPropertiesSet() throws Exception {
 41  2
         if ((this.systemWideSalt == null) || "".equals(this.systemWideSalt)) {
 42  1
             throw new IllegalArgumentException("A systemWideSalt must be set");
 43  
         }
 44  1
     }
 45  
 
 46  
     public Object getSalt(UserDetails user) {
 47  2
         return this.systemWideSalt;
 48  
     }
 49  
 
 50  
     public String getSystemWideSalt() {
 51  1
         return this.systemWideSalt;
 52  
     }
 53  
 
 54  
     public void setSystemWideSalt(String systemWideSalt) {
 55  3
         this.systemWideSalt = systemWideSalt;
 56  3
     }
 57  
 }