001/**
002 * Copyright 2010 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 */
015
016/**
017 *
018 */
019package org.kuali.student.lum.kim;
020
021import java.security.GeneralSecurityException;
022
023import javax.jws.WebService;
024
025import org.kuali.rice.core.api.CoreApiServiceLocator;
026import org.kuali.rice.core.api.encryption.EncryptionService;
027import org.kuali.rice.kim.api.KimApiConstants;
028import org.kuali.rice.kim.api.identity.IdentityService;
029import org.kuali.rice.kim.api.identity.principal.Principal;
030import org.kuali.rice.kim.impl.identity.IdentityServiceImpl;
031import org.kuali.rice.krad.service.impl.DocumentServiceImpl;
032
033/**
034 * This service override is used to facilitate a fix to the encrypted passwords in the
035 * Rice database.
036 *
037 * @author delyea
038 *
039 */
040
041// TODO: RICE=M9 UPGRADE Check that the values for the portName and targetNamespace still make sense for rice-2.0
042// @see org.kuali.rice.kim.api.KimApiConstants.KIM_NAMESPACE_PREFIX
043@WebService(endpointInterface = KimIdentityServiceConstants.INTERFACE_CLASS, serviceName = KimApiConstants.ServiceNames.IDENTITY_SERVICE_SOAP, portName = KimIdentityServiceConstants.WEB_SERVICE_PORT, targetNamespace = KimIdentityServiceConstants.MODULE_TARGET_NAMESPACE)
044public class StudentIdentityServiceImpl extends IdentityServiceImpl implements IdentityService {
045    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentServiceImpl.class);
046
047        /* (non-Javadoc)
048         * @see org.kuali.rice.kim.service.impl.IdentityServiceImpl#getPrincipalByPrincipalNameAndPassword(java.lang.String, java.lang.String)
049         */
050        @Override
051        public Principal getPrincipalByPrincipalNameAndPassword(String principalName, String password) {
052                try {
053                    String finalPassword = CoreApiServiceLocator.getEncryptionService().hash(password)+ EncryptionService.HASH_POST_PREFIX;
054                        return super.getPrincipalByPrincipalNameAndPassword(principalName, finalPassword);
055                } catch (GeneralSecurityException e) {
056                        String message = "Caught Exception attempting to encrypt password (with length " + password.length() + ") for principalName: " + principalName;
057                        LOG.error(message, e);
058                        throw new RuntimeException(e);
059                }
060        }
061
062}