1 25 package org.ofbiz.shark.auth; 26 27 import org.ofbiz.entity.GenericDelegator; 28 import org.ofbiz.entity.GenericValue; 29 import org.ofbiz.entity.GenericEntityException; 30 import org.ofbiz.shark.container.SharkContainer; 31 import org.ofbiz.base.util.UtilMisc; 32 33 import org.enhydra.shark.api.internal.authentication.AuthenticationManager; 34 import org.enhydra.shark.api.internal.working.CallbackUtilities; 35 import org.enhydra.shark.api.RootException; 36 import org.enhydra.shark.api.UserTransaction; 37 38 45 public class GenericAuthenticationMgr implements AuthenticationManager { 46 47 protected CallbackUtilities callBack = null; 48 49 public void configure(CallbackUtilities callBack) throws RootException { 50 this.callBack = callBack; 51 } 52 53 public boolean validateUser(UserTransaction userTransaction, String userName, String password) throws RootException { 54 GenericDelegator delegator = SharkContainer.getDelegator(); 55 GenericValue sharkUser = null; 56 try { 57 sharkUser = delegator.findByPrimaryKey("SharkUser", UtilMisc.toMap("userName", userName)); 58 } catch (GenericEntityException e) { 59 throw new RootException(e); 60 } 61 62 if (sharkUser != null) { 63 String registeredPwd = sharkUser.getString("passwd"); 64 if (password.equals(registeredPwd)) { 65 return true; 66 } 67 } 68 69 return false; 70 } 71 } 72 | Popular Tags |