View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  /**
17   * 
18   */
19  package org.kuali.student.lum.kim;
20  
21  import java.security.GeneralSecurityException;
22  
23  import javax.jws.WebService;
24  
25  import org.kuali.rice.core.service.EncryptionService;
26  import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo;
27  import org.kuali.rice.kim.service.IdentityService;
28  import org.kuali.rice.kim.service.impl.IdentityServiceImpl;
29  import org.kuali.rice.kim.util.KIMWebServiceConstants;
30  import org.kuali.rice.kns.service.KNSServiceLocator;
31  import org.kuali.rice.kns.service.impl.DocumentServiceImpl;
32  
33  /**
34   * This service override is used to facilitate a fix to the encrypted passwords in the
35   * Rice database.
36   * 
37   * @author delyea
38   *
39   */
40  @WebService(endpointInterface = KIMWebServiceConstants.IdentityService.INTERFACE_CLASS, serviceName = KIMWebServiceConstants.IdentityService.WEB_SERVICE_NAME, portName = KIMWebServiceConstants.IdentityService.WEB_SERVICE_PORT, targetNamespace = KIMWebServiceConstants.MODULE_TARGET_NAMESPACE)
41  public class StudentIdentityServiceImpl extends IdentityServiceImpl implements IdentityService {
42      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentServiceImpl.class);
43  
44  	/* (non-Javadoc)
45  	 * @see org.kuali.rice.kim.service.impl.IdentityServiceImpl#getPrincipalByPrincipalNameAndPassword(java.lang.String, java.lang.String)
46  	 */
47  	@Override
48  	public KimPrincipalInfo getPrincipalByPrincipalNameAndPassword(String principalName, String password) {
49  		try {
50  		    String finalPassword = KNSServiceLocator.getEncryptionService().hash(password)+ EncryptionService.HASH_POST_PREFIX;
51  			return super.getPrincipalByPrincipalNameAndPassword(principalName, finalPassword);
52  		} catch (GeneralSecurityException e) {
53  			String message = "Caught Exception attempting to encrypt password (with length " + password.length() + ") for principalName: " + principalName;
54  			LOG.error(message, e);
55  			throw new RuntimeException(e);
56  		}
57  	}
58  
59  }