⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 securityinfoproxy.java

📁 计算机技术的快速发展
💻 JAVA
字号:
package com.suninformation.user;

import java.sql.*;
import com.suninformation.database.DBManager;

public class SecurityInfoProxy {
	private static final String DELETE_SECURITYINFO = "DELETE FROM psecurityinfo WHERE username=?";

	/**
	 * createSecurityInfo
	 * 
	 * @param userName
	 *            String
	 * @param securityEmail
	 *            String
	 * @param securityCode
	 *            String
	 * @param question
	 *            String
	 * @param answer
	 *            String
	 * @return securityInfo
	 * @throws UserAlreadyExistsException
	 * @throws UnacceptableException
	 */
	public SecurityInfo createSecurityInfo(String userName,
			String securityEmail, String securityCode, String question,
			String answer) throws UserAlreadyExistsException,
			UnacceptableException {
		return new SecurityInfo(userName, securityEmail, securityCode,
				question, answer);
	}

	/**
	 * getSecurityInfo
	 * 
	 * @param userName
	 *            String
	 * @return securityInfo
	 * @throws UserNotFoundException
	 * @throws UnacceptableException
	 */
	public SecurityInfo getSecurityInfo(String userName)
			throws UserNotFoundException, UnacceptableException {
		return new SecurityInfo(userName);
	}

	/**
	 * 删除用户安全信息
	 * 
	 * @param userName
	 *            String
	 * @throws UserNotFoundException
	 * @throws UnacceptableException
	 */
	public void deleteUserInfo(String userName) throws UserNotFoundException,
			UnacceptableException {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		try {
			getSecurityInfo(userName);
			try {
				conn = DBManager.getConnection();
				pstmt = conn.prepareStatement(DELETE_SECURITYINFO);
				pstmt.setString(1, userName);
				pstmt.execute();
			} catch (Exception e) {
				throw new UnacceptableException("删除用户安全信息数据失败!", e);
			} finally {
				DBManager.closeObject(conn, pstmt, rs);
			}
		} catch (UserNotFoundException unfe) {
			throw new UserNotFoundException("用户安全信息不存在。", unfe);
		}
	}

	/**
	 * sendMailForPWD
	 * 
	 * @param userName
	 *            String
	 * @param securityEmail
	 *            String
	 * @throws UserNotFoundException
	 * @throws UnacceptableException
	 */
	public void sendMailForPWD(String userName, String securityEmail)
			throws UserNotFoundException, UnacceptableException {
		SecurityInfo si = getSecurityInfo(userName);
		if (securityEmail.equals(si.getSecurityEmail())) {
			/** @todo 进行email的发送操作 */
			si.setSendMailTime(new java.sql.Date(System.currentTimeMillis()));
		} else {
			throw new UnacceptableException("安全邮件地址输入不符。");
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -