1 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 37 39 41 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 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 ( "Unexpected EmailException:" + e.toString() ); 71 } 72 } 73 74 public String isListUsersAuthorized( 75 OperationContext op ) { 76 return null; 77 } 78 79 public String isDeleteUserAuthorized( 80 OperationContext op ) { 81 return null; 82 } 83 84 public String isSaveUserAuthorized( 85 OperationContext op ) { 86 return null; 87 } 88 89 public String isSaveNewUserAuthorized( 90 OperationContext op ) { 91 return null; 92 } 93 94 public String isEditUserAuthorized( 95 OperationContext op ) { 96 return null; 97 } 98 99 public String isNewUserAuthorized( 100 OperationContext op ) { 101 return null; 102 } 103 104 public String isRolesFormAuthorized( 105 OperationContext op ) { 106 return null; 107 } 108 109 public String isRolesAuthorized( 110 OperationContext op ) { 111 return null; 112 } 113 114 public AuthUser newUser() { 115 return new User(); 116 } 117 118 120 public static void setPasswordEncrypted( 121 boolean passwordEncrypted ) { 122 123 passwordEncrypted_ = passwordEncrypted; 124 } 125 126 128 private static boolean passwordEncrypted_ = false; 129 } 130 | Popular Tags |