public String getCookieValue(
HttpServletRequest request,
String cookieName) {
// if (cookieValues == null || cookieValues.isEmpty()){
Cookie[] cookies = request.getCookies();
//System.out.println(" cookies "+cookies.toString());
cookieValues = new HashMap();
// cookies[0]=new Cookie(LoginConstants.LOGIN_FLAG
// ,"aaaaaa");
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
cookieValues.put(cookie.getName(), cookie.getValue());
}
}
//}
logger.info("in cookie "+cookieValues.get("in"));
return (String) cookieValues.get(cookieName);
}
/**
* 验证用户(通过验证返回true,否则返回false)
* @param (String)uid 用户id
* @param (String)pwd 用户密码
* @return boolean ture or false
* @author skf4865
* @add date 2004-11-21
*/
private boolean validUser(String uid, String pwd) {
try {
UserManageDelegate umDelegate =
new UserManageDelegate(UserInfoBean.INTRANET_USER);
return umDelegate.checkPasswordValue(uid, pwd.getBytes());
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
/**
* 删除cookie
* @param request
* @param response
*/
private void killCookie(
HttpServletRequest request,
HttpServletResponse response) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
cookie.setValue(null);
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}
}
/**
* 导向登录页面,登陆服务器向用户浏览器中写入了
* lang cookie value :en
login_logFlag in /out
login_sid session id
login_uid 用户名
login_cip 客户IP
login_cname 客户名
login_sip 登陆服务器IP
JSESSIONID
* @param request
* @param response
* @throws IOException
*/
private void redirect2Login(HttpServletRequest request,HttpServletResponse response)throws IOException {
String url = request.getRequestURL().toString();
String queryStr = request.getQueryString();
if (queryStr != null){
url = url + "?" + queryStr;
}
if (url != null) {
//url = URLEncoder.encode(url,"UTF-8");
url = URLEncoder.encode(url);
response.sendRedirect("http://login.huawei.com/login/forwardLogin.do?redirect="+ url);
}
}
HttpServletRequest request,
String cookieName) {
// if (cookieValues == null || cookieValues.isEmpty()){
Cookie[] cookies = request.getCookies();
//System.out.println(" cookies "+cookies.toString());
cookieValues = new HashMap();
// cookies[0]=new Cookie(LoginConstants.LOGIN_FLAG
// ,"aaaaaa");
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
cookieValues.put(cookie.getName(), cookie.getValue());
}
}
//}
logger.info("in cookie "+cookieValues.get("in"));
return (String) cookieValues.get(cookieName);
}
/**
* 验证用户(通过验证返回true,否则返回false)
* @param (String)uid 用户id
* @param (String)pwd 用户密码
* @return boolean ture or false
* @author skf4865
* @add date 2004-11-21
*/
private boolean validUser(String uid, String pwd) {
try {
UserManageDelegate umDelegate =
new UserManageDelegate(UserInfoBean.INTRANET_USER);
return umDelegate.checkPasswordValue(uid, pwd.getBytes());
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
/**
* 删除cookie
* @param request
* @param response
*/
private void killCookie(
HttpServletRequest request,
HttpServletResponse response) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
Cookie cookie = cookies[i];
cookie.setValue(null);
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}
}
/**
* 导向登录页面,登陆服务器向用户浏览器中写入了
* lang cookie value :en
login_logFlag in /out
login_sid session id
login_uid 用户名
login_cip 客户IP
login_cname 客户名
login_sip 登陆服务器IP
JSESSIONID
* @param request
* @param response
* @throws IOException
*/
private void redirect2Login(HttpServletRequest request,HttpServletResponse response)throws IOException {
String url = request.getRequestURL().toString();
String queryStr = request.getQueryString();
if (queryStr != null){
url = url + "?" + queryStr;
}
if (url != null) {
//url = URLEncoder.encode(url,"UTF-8");
url = URLEncoder.encode(url);
response.sendRedirect("http://login.huawei.com/login/forwardLogin.do?redirect="+ url);
}
}