KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > reg > TestPolicy


1 /*
2  * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
3  *
4  * This file is part of TransferCM.
5  *
6  * TransferCM is free software; you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation; either version 2 of the License, or (at your option) any later
9  * version.
10  *
11  * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18  * Fifth Floor, Boston, MA 02110-1301 USA
19  */

20
21 package com.methodhead.reg;
22
23 import java.util.*;
24 import org.apache.struts.util.*;
25 import org.apache.commons.mail.*;
26 import com.methodhead.util.*;
27 import com.methodhead.auth.*;
28 import com.methodhead.mail.*;
29 import com.methodhead.sitecontext.*;
30
31 public class TestPolicy
32 implements
33   RegPolicy {
34
35   // constructors /////////////////////////////////////////////////////////////
36

37   // constants ////////////////////////////////////////////////////////////////
38

39   // classes //////////////////////////////////////////////////////////////////
40

41   // methods //////////////////////////////////////////////////////////////////
42

43   public User newRegUser() {
44     User user = new User();
45     user.setPasswordEncrypted( passwordEncrypted_ );
46     return user;
47   }
48
49   public List getRoleOptions(
50     OperationContext op ) {
51     List options = new ArrayList();
52     options.add( new LabelValueBean( "ROLE1", "ROLE1" ) );
53     options.add( new LabelValueBean( "ROLE2", "ROLE2" ) );
54     return options;
55   }
56
57   public void sendPassword(
58     User user,
59     String JavaDoc password,
60     OperationContext op ) {
61
62     try {
63       Mail.send(
64         "test1@methodhead.com",
65         "webmaster@methodhead.com",
66         user.getContact().getString( "email" ) + "'s Password Was Reset.",
67         "New password: " + password );
68     }
69     catch ( EmailException e ) {
70       throw new RuntimeException JavaDoc( "Unexpected EmailException:" + e.toString() );
71     }
72   }
73
74   public String JavaDoc isListUsersAuthorized(
75     OperationContext op ) {
76     return null;
77   }
78
79   public String JavaDoc isDeleteUserAuthorized(
80     OperationContext op ) {
81     return null;
82   }
83
84   public String JavaDoc isSaveUserAuthorized(
85     OperationContext op ) {
86     return null;
87   }
88
89   public String JavaDoc isSaveNewUserAuthorized(
90     OperationContext op ) {
91     return null;
92   }
93
94   public String JavaDoc isEditUserAuthorized(
95     OperationContext op ) {
96     return null;
97   }
98
99   public String JavaDoc isNewUserAuthorized(
100     OperationContext op ) {
101     return null;
102   }
103
104   public String JavaDoc isRolesFormAuthorized(
105     OperationContext op ) {
106     return null;
107   }
108
109   public String JavaDoc isRolesAuthorized(
110     OperationContext op ) {
111     return null;
112   }
113
114   public AuthUser newUser() {
115     return new User();
116   }
117
118   // properties ///////////////////////////////////////////////////////////////
119

120   public static void setPasswordEncrypted(
121     boolean passwordEncrypted ) {
122
123     passwordEncrypted_ = passwordEncrypted;
124   }
125
126   // attributes ///////////////////////////////////////////////////////////////
127

128   private static boolean passwordEncrypted_ = false;
129 }
130
Popular Tags