Java tutorial
/* @(#) * * Project:PFConsole * * Modify Information: * ============================================================================= * Author Date Description * ------------ --------- --------------------------------------------------- * Gavin 2011-7-7 first release * * * Copyright Notice: * ============================================================================= * Copyright 2011 allinfinance, Inc. All rights reserved. * * This software is the confidential and proprietary information of * Shanghai allinfinance Co., Ltd. ("Confidential Information"). * You shall not disclose such Confidential Information and shall use it * only in accordance with the terms of the license agreement you entered * into with allinfinance. * * Warning: * ============================================================================= * */ package com.allinfinance.struts.system.action; import java.util.List; import org.apache.commons.lang.StringUtils; import com.allinfinance.common.Constants; import com.allinfinance.common.StringUtil; import com.allinfinance.dao.iface.base.TblOprInfoDAO; import com.allinfinance.po.TblOprInfo; import com.allinfinance.system.util.CommonFunction; import com.allinfinance.system.util.ContextUtil; import com.allinfinance.system.util.Encryption; /** * Title: * * File: AuthoriseAction.java * * Description: * * Copyright: Copyright (c) 2011-7-7 * * Company: Shanghai allinfinance Co., Ltd. * * @author Gavin * * @version 1.0 */ public class AuthoriseAction extends BaseSupport { /** * */ private static final long serialVersionUID = 1L; public String authorise() { try { if (StringUtil.isNull(username)) { return returnService("???"); } if (StringUtil.isNull(pass)) { return returnService("???"); } if (StringUtil.isNull(txnCode)) { return returnService("??"); } //??? TblOprInfoDAO tblOprInfoDAO = (TblOprInfoDAO) ContextUtil.getBean("OprInfoDAO"); TblOprInfo user = tblOprInfoDAO.get(username); if (getOperator().getOprId().equals(username)) { return returnService("???????"); } // Step 1 :?? if (user == null) { return returnService("???"); } // ??? if ("1".equals(user.getOprSta().trim())) { return returnService("??????"); } // ?? if (Integer.parseInt(user.getPwdOutDate().trim()) <= Integer .parseInt(CommonFunction.getCurrentDate())) { return returnService("?????"); } // Step 2 :?? if (!getOperator().getOprBrhId().equals(user.getBrhId())) { return returnService( "????????"); } // Step 3 :????? String txn = "select KEY_ID from TBL_ROLE_FUNC_MAP " + "where KEY_ID = '" + user.getOprDegree().trim() + "' and VALUE_ID = '" + txnCode.trim() + "'"; List list = commQueryDAO.findBySQLQuery(txn); if (list != null && !list.isEmpty()) { // ?? String oprPassword = StringUtils.trim(user.getOprPwd()); pass = StringUtils.trim(Encryption.encrypt(pass)); if (pass.equals(oprPassword)) { return returnService(Constants.SUCCESS_CODE); } else { return returnService("????"); } } else { return returnService("?????"); } } catch (Exception e) { e.printStackTrace(); return returnService(rspCode, e); } } public String txnCode; public String username; public String pass; /** * @return the txnCode */ public String getTxnCode() { return txnCode; } /** * @param txnCode the txnCode to set */ public void setTxnCode(String txnCode) { this.txnCode = txnCode; } /** * @return the username */ public String getUsername() { return username; } /** * @param username the username to set */ public void setUsername(String username) { this.username = username; } /** * @return the pass */ public String getPass() { return pass; } /** * @param pass the pass to set */ public void setPass(String pass) { this.pass = pass; } public String getMsg() { return msg; } public boolean isSuccess() { return success; } }