KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > test > xmlrpc > SignMeUp


1 /******************************************************************************
2  * SignMeUp.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.test.xmlrpc;
11
12 //import org.openlaszlo.data.LZXMLRPC;
13
import java.io.*;
14 import java.net.*;
15 import java.util.*;
16 import javax.servlet.*;
17 import javax.servlet.http.*;
18 import org.apache.log4j.*;
19
20 public class SignMeUp
21 {
22     private static Logger mLogger = Logger.getLogger(SignMeUp.class);
23
24     private String JavaDoc mAlias = "SignMeUp";
25
26     public String JavaDoc[] getUniqueUsername(String JavaDoc username, String JavaDoc first, String JavaDoc last,
27                                       HttpServletRequest req, HttpServletResponse res) {
28         mLogger.debug("getUniqueUsername");
29         String JavaDoc[] names = { "one", "two", "three", "four", "five", "six" };
30         return names;
31     }
32
33     public int register(String JavaDoc username, String JavaDoc password, String JavaDoc name,
34                         String JavaDoc occupation, String JavaDoc email,
35                         HttpServletRequest req, HttpServletResponse res) {
36         mLogger.debug("register");
37         req.getSession().setAttribute("sessioned", "true");
38         return 1;
39     }
40
41     public boolean isEmailRegistered(String JavaDoc email, HttpServletRequest req,
42                                      HttpServletResponse res) {
43         mLogger.debug("isEmailRegistered");
44         return ("one@foo.com".equals(email));
45     }
46
47     public boolean isSessioned(HttpServletRequest req, HttpServletResponse res) {
48         return "true".equals(req.getSession().getAttribute("sessioned"));
49     }
50
51
52     public boolean logout(HttpServletRequest req, HttpServletResponse res)
53         throws IllegalStateException JavaDoc {
54         req.getSession().invalidate();
55         return true;
56     }
57
58     public boolean login(String JavaDoc username, String JavaDoc password,
59                          HttpServletRequest req, HttpServletResponse res) {
60         mLogger.debug("login");
61         boolean ok = ("fluffy".equals(username) && "pass1".equals(password));
62         if (ok) {
63             req.getSession().setAttribute("sessioned", "true");
64         }
65         return ok;
66     }
67
68     public boolean getUsernamePassword(String JavaDoc email, HttpServletRequest req,
69                                        HttpServletResponse res) {
70         mLogger.debug("getUsernamePassword");
71         return false;
72     }
73
74     public void initialize(Properties prop)
75     {
76         mLogger.debug("initialize");
77     }
78 }
79
Popular Tags