Coverage Report - org.kuali.rice.core.api.security.credentials.CredentialsSourceFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
CredentialsSourceFactory
0%
0/11
0%
0/4
1.667
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.api.security.credentials;
 17  
 
 18  
 import java.util.HashMap;
 19  
 import java.util.List;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.apache.commons.logging.Log;
 23  
 import org.apache.commons.logging.LogFactory;
 24  
 import org.springframework.beans.factory.InitializingBean;
 25  
 
 26  
 /**
 27  
  * CredentialsSourceFactory constructs or returns an existing instance of a
 28  
  * CredentialsSource based on the type of Credentials requested.
 29  
  * <p>
 30  
  * It will return null if it cannot find or create an instance of the required
 31  
  * type.
 32  
  * 
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  * @since 0.9
 35  
  * 
 36  
  */
 37  0
 public final class CredentialsSourceFactory implements InitializingBean {
 38  
 
 39  0
         private final Log log = LogFactory.getLog(this.getClass());
 40  
 
 41  
         private List<CredentialsSource> credentialsSources;
 42  
 
 43  0
         private Map<CredentialsType, CredentialsSource> credentialsSourcesByType = new HashMap<CredentialsType, CredentialsSource>();
 44  
 
 45  
         public CredentialsSource getCredentialsForType(
 46  
                         final CredentialsType credentialsType) {
 47  0
                 return credentialsSourcesByType.get(credentialsType);
 48  
         }
 49  
 
 50  
         public void afterPropertiesSet() throws Exception {
 51  0
                 if (credentialsSources != null) {
 52  0
                         for (final CredentialsSource credentialsSource : this.credentialsSources) {
 53  0
                                 this.credentialsSourcesByType.put(credentialsSource
 54  
                                                 .getSupportedCredentialsType(), credentialsSource);
 55  
                         }
 56  
                 } else {
 57  0
                         log
 58  
                                         .warn("No CredentialsSources set.  No security will be provided on the bus.");
 59  
                 }
 60  0
         }
 61  
 
 62  
         public void setCredentialsSources(
 63  
                         final List<CredentialsSource> credentialsSources) {
 64  0
                 this.credentialsSources = credentialsSources;
 65  0
         }
 66  
 }