Commits

cowboy  committed 512f1fa

17:50 2010/07/08

  • Participants
  • Parent commits 483a35d

Comments (0)

Files changed (6)

File src/info/mrchen/gae/blog/dao/UserInfoDao.java

 package info.mrchen.gae.blog.dao;
 
 import info.mrchen.gae.blog.Dao;
+import info.mrchen.gae.blog.pojo.UserInfo;
 
 import java.util.List;
 
 import com.google.appengine.api.users.User;
 
 @Component
-public class UserInfoDao extends Dao<Userinfo> {
+public class UserInfoDao extends Dao<UserInfo> {
 	public boolean checkPassword(String username, String password) {
 		String queryString = "from User where user=?";
 		List<UserInfo> l = this.getByQueryString(queryString);

File src/info/mrchen/gae/blog/pojo/SysConf.java

 import javax.jdo.annotations.PrimaryKey;
 
 @PersistenceCapable(identityType = IdentityType.APPLICATION)
-public class Sysconf {
+public class SysConf {
 	@PrimaryKey
 	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
 	private Long id;

File src/info/mrchen/gae/blog/pojo/UserInfo.java

+package info.mrchen.gae.blog.pojo;
+
+import javax.jdo.annotations.IdGeneratorStrategy;
+import javax.jdo.annotations.IdentityType;
+import javax.jdo.annotations.PersistenceCapable;
+import javax.jdo.annotations.Persistent;
+import javax.jdo.annotations.PrimaryKey;
+
+@PersistenceCapable(identityType = IdentityType.APPLICATION)
+public class UserInfo {
+	@PrimaryKey
+	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
+	private Long id;
+
+	@Persistent
+	private String username;
+	@Persistent
+	private String password;
+	public Long getId() {
+		return id;
+	}
+	public void setId(Long id) {
+		this.id = id;
+	}
+	public String getUsername() {
+		return username;
+	}
+	public void setUsername(String username) {
+		this.username = username;
+	}
+	public String getPassword() {
+		return password;
+	}
+	public void setPassword(String password) {
+		this.password = password;
+	}
+}

File war/WEB-INF/lib/urlrewrite-3.2.0.jar

Binary file added.

File war/WEB-INF/urlrewrite.xml

+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
+        "http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
+
+<!-- Configuration file for UrlRewriteFilter http://tuckey.org/urlrewrite/ -->
+<urlrewrite>
+	<rule>
+		<from>/test/status/</from>
+		<to type="redirect">%{context-path}/rewrite-status</to>
+	</rule>
+	<outbound-rule>
+		<from>/rewrite-status</from>
+		<to>/test/status/</to>
+	</outbound-rule>
+	<rule>
+		<from>_ah/login_required(.*)</from>
+		<to>/login.jsp$1</to>
+	</rule>
+
+</urlrewrite>
+

File war/login.jsp

+<%@ page contentType="text/html;charset=UTF-8" language="java"%>
+<%@page isELIgnored="false"%>
+<%@ include file="/WEB-INF/views/common/includes.jsp"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+<%@page import="com.google.appengine.api.users.*"%>
+<%@page import="java.util.*"%>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!-- The HTML 4.01 Transitional DOCTYPE declaration-->
+<!-- above set at the top of the file will set     -->
+<!-- the browser's rendering engine into           -->
+<!-- "Quirks Mode". Replacing this declaration     -->
+<!-- with a "Standards Mode" doctype is supported, -->
+<!-- but may lead to some differences in layout.   -->
+
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<link rel="icon" href="/Images/favicon.ico">
+<title>mrchen-gae-blog</title>
+<style type="text/css">
+input#openid_url {
+	text-indent: 18px;
+	background-image:
+		url("http://sample.openid-idp.com/img/openid_logo.png");
+	background-repeat: no-repeat;
+	background-position: left center;
+}
+</style>
+</head>
+
+<body>
+<%
+	String openid_url = request.getParameter("openid_url");
+	if (openid_url != null || openid_url.length() > 1) {
+		String return_url = request.getParameter("continue");
+		UserService userService = UserServiceFactory.getUserService();
+		User currentUser = userService.getCurrentUser();
+		if (currentUser != null) {
+			response.sendRedirect("/");
+		}
+		Set<String> attributesRequest = new HashSet<String>();
+		attributesRequest.add("openid.mode=checkid_immediate");
+		attributesRequest.add("openid.mode=checkid_immediate");
+		attributesRequest.add("openid.ns=http://specs.openid.net/auth/2.0");
+		attributesRequest.add("openid.return_to=" + return_url);
+
+		String loginUrl = userService.createLoginURL(return_url, request.getServerName(), openid_url, attributesRequest);
+		response.sendRedirect("loginUrl");
+	} else {
+%>
+<form id="openid_form" action="/login.jsp" method="post">
+	<fieldset><legend>Enter your OpenID URL</legend>
+	<input type="hidden" id="continue" name="continue" value="${param.continue}" />
+	<input type="text" id="openid_url" name="openid_url" value="" />
+	<input type="submit" id="openid_url_submit" name="openid_url_submit" value="LOGIN" />
+	</fieldset>
+</form>
+
+<%
+	}
+%>
+
+</body>
+</html>