001: /*
002: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
003: *
004: * This file is part of TransferCM.
005: *
006: * TransferCM is free software; you can redistribute it and/or modify it under the
007: * terms of the GNU General Public License as published by the Free Software
008: * Foundation; either version 2 of the License, or (at your option) any later
009: * version.
010: *
011: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
014: * details.
015: *
016: * You should have received a copy of the GNU General Public License along with
017: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018: * Fifth Floor, Boston, MA 02110-1301 USA
019: */
020:
021: package com.methodhead.reg;
022:
023: import java.util.*;
024: import org.apache.struts.util.*;
025: import org.apache.commons.mail.*;
026: import com.methodhead.util.*;
027: import com.methodhead.auth.*;
028: import com.methodhead.mail.*;
029: import com.methodhead.sitecontext.*;
030:
031: public class TestPolicy implements RegPolicy {
032:
033: // constructors /////////////////////////////////////////////////////////////
034:
035: // constants ////////////////////////////////////////////////////////////////
036:
037: // classes //////////////////////////////////////////////////////////////////
038:
039: // methods //////////////////////////////////////////////////////////////////
040:
041: public User newRegUser() {
042: User user = new User();
043: user.setPasswordEncrypted(passwordEncrypted_);
044: return user;
045: }
046:
047: public List getRoleOptions(OperationContext op) {
048: List options = new ArrayList();
049: options.add(new LabelValueBean("ROLE1", "ROLE1"));
050: options.add(new LabelValueBean("ROLE2", "ROLE2"));
051: return options;
052: }
053:
054: public void sendPassword(User user, String password,
055: OperationContext op) {
056:
057: try {
058: Mail.send("test1@methodhead.com",
059: "webmaster@methodhead.com", user.getContact()
060: .getString("email")
061: + "'s Password Was Reset.",
062: "New password: " + password);
063: } catch (EmailException e) {
064: throw new RuntimeException("Unexpected EmailException:"
065: + e.toString());
066: }
067: }
068:
069: public String isListUsersAuthorized(OperationContext op) {
070: return null;
071: }
072:
073: public String isDeleteUserAuthorized(OperationContext op) {
074: return null;
075: }
076:
077: public String isSaveUserAuthorized(OperationContext op) {
078: return null;
079: }
080:
081: public String isSaveNewUserAuthorized(OperationContext op) {
082: return null;
083: }
084:
085: public String isEditUserAuthorized(OperationContext op) {
086: return null;
087: }
088:
089: public String isNewUserAuthorized(OperationContext op) {
090: return null;
091: }
092:
093: public String isRolesFormAuthorized(OperationContext op) {
094: return null;
095: }
096:
097: public String isRolesAuthorized(OperationContext op) {
098: return null;
099: }
100:
101: public AuthUser newUser() {
102: return new User();
103: }
104:
105: // properties ///////////////////////////////////////////////////////////////
106:
107: public static void setPasswordEncrypted(boolean passwordEncrypted) {
108:
109: passwordEncrypted_ = passwordEncrypted;
110: }
111:
112: // attributes ///////////////////////////////////////////////////////////////
113:
114: private static boolean passwordEncrypted_ = false;
115: }
|