1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.fatwire.gst.foundation.facade.runtag.user;
18
19 import COM.FutureTense.Interfaces.ICS;
20 import COM.FutureTense.Interfaces.Utilities;
21 import COM.FutureTense.Util.ftErrors;
22
23 import com.fatwire.gst.foundation.facade.runtag.AbstractTagRunner;
24 import com.fatwire.gst.foundation.facade.runtag.TagRunnerRuntimeException;
25
26
27
28
29
30
31
32 public final class Login extends AbstractTagRunner {
33 public Login() {
34 super("user.login");
35 }
36
37 public void setUsername(String s) {
38 if (!Utilities.goodString(s))
39 throw new IllegalArgumentException("Username cannot be null");
40 set("username", s);
41 }
42
43 public void setPassword(String s) {
44 if (!Utilities.goodString(s))
45 throw new IllegalArgumentException("Password cannot be null");
46 set("password", s);
47 }
48
49 public static boolean login(ICS ics, String username, String password) {
50 Login l = new Login();
51 l.setUsername(username);
52 l.setPassword(password);
53 try {
54 l.execute(ics);
55 } catch (TagRunnerRuntimeException e) {
56 if (e.getErrno() == ftErrors.badpassword || e.getErrno() == ftErrors.unknownuser) {
57 return false;
58 } else
59 throw e;
60 }
61 return true;
62 }
63
64 }