1 53 54 106 107 package com.Yasna.forum.tags; 108 109 import java.util.*; 110 import javax.servlet.*; 111 import javax.servlet.jsp.*; 112 import javax.servlet.jsp.tagext.*; 113 import javax.servlet.http.*; 114 import com.Yasna.forum.*; 115 import com.Yasna.forum.tags.*; 116 117 144 public class AdminUserTag extends TagSupport 145 { 146 private Authorization auth = null; 147 private YazdState js = null; 148 private YazdRequest jr = null; 149 private User user = null; 150 151 162 public final int doStartTag() throws JspException 163 { 164 js = (YazdState)pageContext.getAttribute("yazdUserState", 166 PageContext.SESSION_SCOPE); 167 if( js == null ) { 168 throw new JspException("Yazd admin tag could not get yazd state."); 169 } 170 171 jr = (YazdRequest)pageContext.getAttribute("yazdUserRequest", 173 PageContext.REQUEST_SCOPE); 174 if( jr == null ) { 175 throw new JspException("Yazd admin tag could not get yazd request."); 176 } 177 178 String username = TagPropertyManager.getTagProperty("yazd.admin.username"); 180 String password = TagPropertyManager.getTagProperty("yazd.admin.password"); 181 if( username == null || username.length() == 0 || 182 password == null || password.length() == 0 ) 183 return SKIP_BODY; 184 185 try { 187 auth = AuthorizationFactory.getAuthorization( username, password ); 188 } 189 catch( UnauthorizedException ue ) { 190 return SKIP_BODY; 191 } 192 193 ServletRequest req = pageContext.getRequest(); 195 String tmp; 196 if( (tmp = req.getParameter("username")) != null ) 197 return SKIP_BODY; 198 199 try { 200 ForumFactory ff = ForumFactory.getInstance(auth); 201 ProfileManager pm = ff.getProfileManager(); 202 user = pm.getUser(tmp); 203 } 204 catch( Exception e) { } 205 206 if( user == null ) { 207 jr.addError("User \"" + tmp + "\" not found"); 208 return SKIP_BODY; 209 } 210 211 return EVAL_BODY_INCLUDE; 212 } 213 214 219 public final User getUser() 220 { 221 return user; 222 } 223 } 224 | Popular Tags |