removed almost all of UserBackend

This commit is contained in:
Eric J. Bowersox 2002-05-27 07:36:43 +00:00
parent 4162065c2b
commit e7857d5501
13 changed files with 215 additions and 165 deletions

View File

@ -163,12 +163,11 @@ class AdminOperationsImpl implements AdminOperations
base_role = env.getDefaultRole("Global.NewUser"); base_role = env.getDefaultRole("Global.NewUser");
// Create the user account. // Create the user account.
ReturnNewUser rnu = UserContextImpl.createAccount(env,env.getUser().userRemoteAddress(),username, ReturnNewUser rnu = UserContextImpl.createAccount(env,env.getRemoteAddress(),username,password,reminder,
password,reminder,verify_email,lockout,0,base_role, verify_email,lockout,0,base_role,description);
description);
// Need to create a normal user context here for just a minute to autojoin the communities. // Need to create a normal user context here for just a minute to autojoin the communities.
UserContextImpl rc = new UserContextImpl(env); UserContextImpl rc = new UserContextImpl(env.getGlobalSite(),env);
rc.loadNewUser("0.0.0.0",rnu.getUserID(),base_role.getLevel(),username,0,rnu.getCreationDate(), rc.loadNewUser("0.0.0.0",rnu.getUserID(),base_role.getLevel(),username,0,rnu.getCreationDate(),
rnu.getCreationDate()); rnu.getCreationDate());
rc.autoJoinCommunities(); rc.autoJoinCommunities();

View File

@ -2109,7 +2109,7 @@ class CommunityCoreData implements CommunityData, PropertyProvider
env.getEngine().registerNewCommunity(comm); env.getEngine().registerNewCommunity(comm);
// create an audit record indicating we were successful // create an audit record indicating we were successful
ar = new AuditRecord(AuditRecord.CREATE_COMMUNITY,host_uid,env.getUser().userRemoteAddress(),new_cid, ar = new AuditRecord(AuditRecord.CREATE_COMMUNITY,host_uid,env.getRemoteAddress(),new_cid,
"name=" + name,"alias=" + alias); "name=" + name,"alias=" + alias);
} // end try } // end try

View File

@ -110,7 +110,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
logger.debug("CommunityUserContextImpl constructor:ordinary"); logger.debug("CommunityUserContextImpl constructor:ordinary");
this.env = new EnvCommunity(env,this); this.env = new EnvCommunity(env,this);
this.cid = cid; this.cid = cid;
this.level = env.getUser().realBaseLevel(); this.level = env.getUserBaseLevel();
this.is_member = false; this.is_member = false;
this.show_admin = false; this.show_admin = false;
this.locked = false; this.locked = false;
@ -144,7 +144,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
logger.debug("setMemberValues(" + String.valueOf(granted_level) + ", " + String.valueOf(member) logger.debug("setMemberValues(" + String.valueOf(granted_level) + ", " + String.valueOf(member)
+ ", " + String.valueOf(locked) + ")"); + ", " + String.valueOf(locked) + ")");
this.level = Math.max(env.getUser().realBaseLevel(),granted_level); this.level = Math.max(env.getUserBaseLevel(),granted_level);
this.is_member = member; this.is_member = member;
this.show_admin = env.isLevelAdmin(granted_level); this.show_admin = env.isLevelAdmin(granted_level);
this.locked = locked; this.locked = locked;
@ -1219,7 +1219,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
public void sendInvitation(String address, String personal_message) public void sendInvitation(String address, String personal_message)
throws AccessError, DataException, EmailException throws AccessError, DataException, EmailException
{ {
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
throw new AccessError("You must be logged in to send an invitation."); throw new AccessError("You must be logged in to send an invitation.");
CommunityData my_comm = getData(); CommunityData my_comm = getData();
@ -1245,13 +1245,12 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
// Set the remaining variables and replace them. // Set the remaining variables and replace them.
vars.put("community.alias",my_comm.getAlias()); vars.put("community.alias",my_comm.getAlias());
vars.put("personal",personal_message); vars.put("personal",personal_message);
vars.put("fullname",env.getUser().realFullName()); vars.put("fullname",env.getUserProps().propGet("fullname"));
String uname = env.getUser().realUserName(); vars.put("username",env.getUserName());
vars.put("username",uname);
msg = StringUtil.replaceAllVariables(msg,vars); msg = StringUtil.replaceAllVariables(msg,vars);
// Get a MailSend object, set it up, and send it. // Get a MailSend object, set it up, and send it.
MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUser()); MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUserProps());
msend.addRecipient(MailSend.RECIP_TO,address); msend.addRecipient(MailSend.RECIP_TO,address);
msend.setSubject(subject); msend.setSubject(subject);
msend.setText(msg + "\n"); msend.setText(msg + "\n");
@ -1261,7 +1260,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
public boolean canSendInvitation() public boolean canSendInvitation()
{ {
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
return false; return false;
CommunityData d = getDataNE(); CommunityData d = getDataNE();
if (d==null) if (d==null)
@ -1404,7 +1403,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
buf.append("\n\n").append(StringUtil.replaceAllVariables(disklaimer,vars)); buf.append("\n\n").append(StringUtil.replaceAllVariables(disklaimer,vars));
// send the mail in the background! // send the mail in the background!
MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUser()); MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUserProps());
msend.setSubject(subject); msend.setSubject(subject);
msend.setText(buf.toString()); msend.setText(buf.toString());
MailerAgent agent = new MailerAgent(msend,mail_list); MailerAgent agent = new MailerAgent(msend,mail_list);

View File

@ -201,7 +201,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
this.cache = null; this.cache = null;
this.confdata = cdata; this.confdata = cdata;
recalcLevel(new_env.getDefaultRole("Conference.Creator").getLevel()); recalcLevel(new_env.getDefaultRole("Conference.Creator").getLevel());
this.pseud = env.getUser().userDefaultPseud(); this.pseud = env.getUserProps().propGet("default.pseud");
this.last_read = null; this.last_read = null;
this.last_post = null; this.last_post = null;
@ -308,7 +308,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
else else
{ // just default everything { // just default everything
settings_loaded = false; settings_loaded = false;
pseud = env.getUser().userDefaultPseud(); pseud = env.getUserProps().propGet("default.pseud");
last_read = null; last_read = null;
last_post = null; last_post = null;
@ -771,7 +771,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public void setDefaultPseud(String val) throws DataException public void setDefaultPseud(String val) throws DataException
{ {
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
return; // anonymous user can't change pseud return; // anonymous user can't change pseud
if (deleted) if (deleted)
throw new DataException("This conference has been deleted."); throw new DataException("This conference has been deleted.");
@ -824,7 +824,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public boolean anyUnread() public boolean anyUnread()
{ {
if (deleted || env.getUser().userIsAnonymous()) if (deleted || env.isAnonymous())
return false; return false;
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
Statement stmt = null; Statement stmt = null;
@ -1020,7 +1020,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end if } // end if
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
return; // anonymous user can't fixseen return; // anonymous user can't fixseen
Connection conn = null; Connection conn = null;
@ -1383,7 +1383,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public boolean canAddToHotlist() public boolean canAddToHotlist()
{ {
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
return false; return false;
return !(isInHotlist()); return !(isInHotlist());
@ -1620,7 +1620,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
buf.append("\n\n").append(StringUtil.replaceAllVariables(disklaimer,vars)); buf.append("\n\n").append(StringUtil.replaceAllVariables(disklaimer,vars));
// send the actual E-mail messages in the background // send the actual E-mail messages in the background
MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUser()); MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUserProps());
msend.setSubject(subject); msend.setSubject(subject);
msend.setText(buf.toString()); msend.setText(buf.toString());
MailerAgent agent = new MailerAgent(msend,rc); MailerAgent agent = new MailerAgent(msend,rc);
@ -1811,7 +1811,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public void touchRead(Connection conn) throws SQLException public void touchRead(Connection conn) throws SQLException
{ {
if (deleted || env.getUser().userIsAnonymous()) if (deleted || env.isAnonymous())
return; // anonymous user can't update squat return; // anonymous user can't update squat
Statement stmt = null; Statement stmt = null;
@ -1855,7 +1855,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
public void touchPost(Connection conn, java.util.Date post_date) throws SQLException public void touchPost(Connection conn, java.util.Date post_date) throws SQLException
{ {
if (deleted || env.getUser().userIsAnonymous()) if (deleted || env.isAnonymous())
return; // anonymous user can't update squat return; // anonymous user can't update squat
Statement stmt = null; Statement stmt = null;

View File

@ -22,6 +22,7 @@ import com.silverwrist.venice.core.internals.UserBackend;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
import com.silverwrist.venice.svc.internal.GlobalSite; import com.silverwrist.venice.svc.internal.GlobalSite;
import com.silverwrist.venice.util.MailSend; import com.silverwrist.venice.util.MailSend;
import com.silverwrist.venice.util.PropertyProvider;
class PersonalMailSend implements MailSend class PersonalMailSend implements MailSend
{ {
@ -38,14 +39,14 @@ class PersonalMailSend implements MailSend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
PersonalMailSend(MailSend inner, GlobalSite site, UserBackend user) throws DataException PersonalMailSend(MailSend inner, GlobalSite site, PropertyProvider user_props) throws DataException
{ {
this.inner = inner; this.inner = inner;
this.site = site; this.site = site;
try try
{ // set the "From" address in advance { // set the "From" address in advance
inner.setFrom(user.realFullName(),user.realEmailAddress()); inner.setFrom(user_props.propGet("fullname"),user_props.propGet("email"));
} // end try } // end try
catch (EmailException ee) catch (EmailException ee)
@ -55,8 +56,8 @@ class PersonalMailSend implements MailSend
} // end catch } // end catch
StringBuffer buf = new StringBuffer("uid "); StringBuffer buf = new StringBuffer("uid ");
buf.append(user.realUID()).append("; username \"").append(user.realUserName()).append("\"; ip ["); buf.append(user_props.propGet("id")).append("; username \"").append(user_props.propGet("name"));
buf.append(user.userRemoteAddress()).append("]"); buf.append("\"; ip [").append(user_props.propGet("ip.address")).append("]");
inner.addHeader("X-Venice-Sender-Info",buf.toString()); inner.addHeader("X-Venice-Sender-Info",buf.toString());
String[] headers = StringUtil.splitArray(site.getStockMessage("header-disclaimer"),"\r\n"); String[] headers = StringUtil.splitArray(site.getStockMessage("header-disclaimer"),"\r\n");
for (int i=0; i<headers.length; i++) for (int i=0; i<headers.length; i++)

View File

@ -490,14 +490,14 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public boolean canHide() public boolean canHide()
{ {
return ( ((creator_uid==env.getUserID()) && (!env.getUser().userIsAnonymous())) return ( ((creator_uid==env.getUserID()) && (!env.isAnonymous()))
|| env.getConference().userCanHide()); || env.getConference().userCanHide());
} // end canHide } // end canHide
public boolean canScribble() public boolean canScribble()
{ {
return ( ((creator_uid==env.getUserID()) && (!env.getUser().userIsAnonymous())) return ( ((creator_uid==env.getUserID()) && (!env.isAnonymous()))
|| env.getConference().userCanScribble()); || env.getConference().userCanScribble());
} // end canScribble } // end canScribble
@ -510,7 +510,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public void setHidden(boolean flag) throws DataException, AccessError public void setHidden(boolean flag) throws DataException, AccessError
{ {
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
return; // no-op return; // no-op
if ((creator_uid!=env.getUserID()) && !(env.getConference().userCanHide())) if ((creator_uid!=env.getUserID()) && !(env.getConference().userCanHide()))
{ // we can't change the hidden status! { // we can't change the hidden status!
@ -578,7 +578,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext
public void scribble() throws DataException, AccessError public void scribble() throws DataException, AccessError
{ {
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
return; // no-op return; // no-op
if ((creator_uid!=env.getUserID()) && !(env.getConference().userCanScribble())) if ((creator_uid!=env.getUserID()) && !(env.getConference().userCanScribble()))
{ // we can't scribble this post { // we can't scribble this post

View File

@ -417,7 +417,7 @@ class TopicUserContextImpl implements TopicContext
public void setHidden(boolean flag) throws DataException public void setHidden(boolean flag) throws DataException
{ {
if ((hidden==flag) || deleted || env.getUser().userIsAnonymous()) if ((hidden==flag) || deleted || env.isAnonymous())
return; // no-op return; // no-op
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
@ -496,7 +496,7 @@ class TopicUserContextImpl implements TopicContext
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("[raw] setUnreadMessages(" + count + ") entry"); logger.debug("[raw] setUnreadMessages(" + count + ") entry");
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
{ // this is effectively a no-op, but log it { // this is effectively a no-op, but log it
logger.debug("reject 1: anonymous user"); logger.debug("reject 1: anonymous user");
return; return;
@ -1150,7 +1150,7 @@ class TopicUserContextImpl implements TopicContext
public boolean isBozo(int other_uid) throws DataException public boolean isBozo(int other_uid) throws DataException
{ {
if (deleted || env.getUser().userIsAnonymous() || (other_uid==env.getUserID())) if (deleted || env.isAnonymous() || (other_uid==env.getUserID()))
return false; // no-op return false; // no-op
if (bozo_uids==null) if (bozo_uids==null)
@ -1182,7 +1182,7 @@ class TopicUserContextImpl implements TopicContext
public void setBozo(int other_uid, boolean bozo) throws DataException public void setBozo(int other_uid, boolean bozo) throws DataException
{ {
if (deleted || env.getUser().userIsAnonymous() || (other_uid==env.getUserID())) if (deleted || env.isAnonymous() || (other_uid==env.getUserID()))
return; // no-op return; // no-op
Connection conn = null; Connection conn = null;
@ -1249,13 +1249,13 @@ class TopicUserContextImpl implements TopicContext
// 1. You can't set bozo filters on a deleted topic. // 1. You can't set bozo filters on a deleted topic.
// 2. You can't set bozo filters if you're the anonymous user. // 2. You can't set bozo filters if you're the anonymous user.
// 3. You can't bozo-filter yourself, silly. // 3. You can't bozo-filter yourself, silly.
return !(deleted || env.getUser().userIsAnonymous() || (other_uid==env.getUserID())); return !(deleted || env.isAnonymous() || (other_uid==env.getUserID()));
} // end canSetBozoFilter } // end canSetBozoFilter
public List getBozos() throws DataException public List getBozos() throws DataException
{ {
if (deleted || env.getUser().userIsAnonymous()) if (deleted || env.isAnonymous())
return Collections.EMPTY_LIST; // no-op return Collections.EMPTY_LIST; // no-op
if (bozo_uids==null) if (bozo_uids==null)
@ -1293,7 +1293,7 @@ class TopicUserContextImpl implements TopicContext
public void setSubscribed(boolean flag) throws DataException public void setSubscribed(boolean flag) throws DataException
{ {
if ((subscribed==flag) || deleted || env.getUser().userIsAnonymous()) if ((subscribed==flag) || deleted || env.isAnonymous())
return; // no-op return; // no-op
Connection conn = null; // pooled database connection Connection conn = null; // pooled database connection
@ -1478,7 +1478,7 @@ class TopicUserContextImpl implements TopicContext
buf.append("\n\n").append(StringUtil.replaceAllVariables(disklaimer,vars)); buf.append("\n\n").append(StringUtil.replaceAllVariables(disklaimer,vars));
// send the actual E-mail messages in the background // send the actual E-mail messages in the background
MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUser()); MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUserProps());
msend.setSubject(subject); msend.setSubject(subject);
msend.setText(buf.toString()); msend.setText(buf.toString());
MailerAgent agent = new MailerAgent(msend,rc); MailerAgent agent = new MailerAgent(msend,rc);

View File

@ -28,9 +28,10 @@ import com.silverwrist.venice.db.*;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
import com.silverwrist.venice.security.*; import com.silverwrist.venice.security.*;
import com.silverwrist.venice.svc.ServiceControl; import com.silverwrist.venice.svc.ServiceControl;
import com.silverwrist.venice.util.MailSend; import com.silverwrist.venice.svc.internal.GlobalSite;
import com.silverwrist.venice.util.*;
class UserContextImpl implements UserContext, UserBackend class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider, UserBackend
{ {
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Static data members * Static data members
@ -57,6 +58,7 @@ class UserContextImpl implements UserContext, UserBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private GlobalSite globalsite; // the global site
private EnvUser env; // the environment store private EnvUser env; // the environment store
private String remote_addr; // remote address identifier private String remote_addr; // remote address identifier
private int uid = -1; // the user ID we're using private int uid = -1; // the user ID we're using
@ -82,9 +84,10 @@ class UserContextImpl implements UserContext, UserBackend
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
UserContextImpl(EnvEngine env) UserContextImpl(GlobalSite globalsite, EnvEngine env)
{ {
this.env = new EnvUser(env,this); this.globalsite = globalsite;
this.env = new EnvUser(env,this,this);
} // end constructor } // end constructor
@ -133,7 +136,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // call through to lower level function { // call through to lower level function
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM userprefs WHERE uid = " + uid + ";"); ResultSet rs = stmt.executeQuery("SELECT * FROM userprefs WHERE uid = " + uid + ";");
@ -185,7 +188,7 @@ class UserContextImpl implements UserContext, UserBackend
logger.debug("sendEmailConfirmation(): sending to \"" + my_email + "\""); logger.debug("sendEmailConfirmation(): sending to \"" + my_email + "\"");
// Create the message to be sent. // Create the message to be sent.
String message = env.getStockMessage("email-confirm"); String message = globalsite.getStockMessage("email-confirm");
if (message==null) if (message==null)
{ // no message defined? oy! { // no message defined? oy!
logger.error("internal error condition: email-confirm stock message not defined"); logger.error("internal error condition: email-confirm stock message not defined");
@ -199,12 +202,12 @@ class UserContextImpl implements UserContext, UserBackend
vars.put("confnum",String.valueOf(confirm_num)); vars.put("confnum",String.valueOf(confirm_num));
message = StringUtil.replaceAllVariables(message,vars); message = StringUtil.replaceAllVariables(message,vars);
String subject = env.getStockMessage("email-confirm-subject"); String subject = globalsite.getStockMessage("email-confirm-subject");
if (subject==null) if (subject==null)
subject = "Venice Email Confirmation"; subject = "Venice Email Confirmation";
// Create the emailer and send the message. // Create the emailer and send the message.
MailSend msend = env.getMailSender(); MailSend msend = (MailSend)(globalsite.queryService(MailSend.class));
msend.addRecipient(MailSend.RECIP_TO,my_email); msend.addRecipient(MailSend.RECIP_TO,my_email);
msend.setSubject(subject); msend.setSubject(subject);
msend.setText(message); msend.setText(message);
@ -245,8 +248,7 @@ class UserContextImpl implements UserContext, UserBackend
// Figure out which of those communities we haven't joined yet and set up to autojoin them. // Figure out which of those communities we haven't joined yet and set up to autojoin them.
sql.setLength(0); sql.setLength(0);
SecurityMonitor smon = SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class,"Community"));
(SecurityMonitor)(env.getGlobalSite().queryService(SecurityMonitor.class,"Community"));
int new_level = smon.getDefaultRole("Community.NewUser").getLevel(); int new_level = smon.getDefaultRole("Community.NewUser").getLevel();
for (int i=0; i<tmp_cid.size(); i++) for (int i=0; i<tmp_cid.size(); i++)
{ // see if the user is already a member of this community { // see if the user is already a member of this community
@ -292,7 +294,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a connection and create a statement { // get a connection and create a statement
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
@ -410,7 +412,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // look for a user name matching this user record { // look for a user name matching this user record
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE username = '" ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE username = '"
+ SQLUtil.encodeString(username) + "';"); + SQLUtil.encodeString(username) + "';");
@ -508,18 +510,19 @@ class UserContextImpl implements UserContext, UserBackend
{ // the confirmation number is wrong { // the confirmation number is wrong
logger.warn("...confirmation number incorrect"); logger.warn("...confirmation number incorrect");
ar = new AuditRecord(AuditRecord.VERIFY_FAIL,uid,remote_addr,"Invalid confirmation number"); ar = new AuditRecord(AuditRecord.VERIFY_FAIL,uid,remote_addr,"Invalid confirmation number");
ar.store(env.getGlobalSite()); ar.store(globalsite);
throw new AccessError("Confirmation number is incorrect. Please try again."); throw new AccessError("Confirmation number is incorrect. Please try again.");
} // end if } // end if
Connection conn = null; Connection conn = null;
Statement stmt = null; Statement stmt = null;
Role new_role = env.getDefaultRole("Global.AfterVerify"); SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class));
Role new_role = smon.getDefaultRole("Global.AfterVerify");
try try
{ // get a connection and set the user's status to reflect the verification { // get a connection and set the user's status to reflect the verification
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 1, base_lvl = "); StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 1, base_lvl = ");
sql.append(new_role.getLevel()).append(" WHERE uid = ").append(uid).append(';'); sql.append(new_role.getLevel()).append(" WHERE uid = ").append(uid).append(';');
@ -571,7 +574,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // need to change the user's email confirmation number first { // need to change the user's email confirmation number first
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
// generate new confirmation number // generate new confirmation number
@ -655,7 +658,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a database connection { // get a database connection
conn = env.getConnection(); conn = globalsite.getConnection(null);
Stashable obj = (Stashable)ci; Stashable obj = (Stashable)ci;
// save the contact information // save the contact information
@ -688,7 +691,8 @@ class UserContextImpl implements UserContext, UserBackend
// generate new confirmation number // generate new confirmation number
int new_confirm_num = Generator.get().getNewConfirmationNumber(); int new_confirm_num = Generator.get().getNewConfirmationNumber();
Role new_role = env.getDefaultRole("Global.Unverified"); SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class));
Role new_role = smon.getDefaultRole("Global.Unverified");
Statement stmt = null; Statement stmt = null;
try try
@ -752,7 +756,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
UserProfileImpl prof = new UserProfileImpl(env,conn,xusername); UserProfileImpl prof = new UserProfileImpl(env,conn,xusername);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("...found it!"); logger.debug("...found it!");
@ -781,7 +785,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
UserProfileImpl prof = new UserProfileImpl(env,conn,xuid); UserProfileImpl prof = new UserProfileImpl(env,conn,xuid);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("...found it!"); logger.debug("...found it!");
@ -817,7 +821,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
String hash_value = Generator.hashPassword(password); String hash_value = Generator.hashPassword(password);
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '"); StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
@ -859,7 +863,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET description = '"); StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';'); sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
@ -993,9 +997,8 @@ class UserContextImpl implements UserContext, UserBackend
boolean hide_search = (hide_mode==CommunityContext.HIDE_BOTH); boolean hide_search = (hide_mode==CommunityContext.HIDE_BOTH);
// Create the new community's database entries and internal data. // Create the new community's database entries and internal data.
CommunityData new_comm = CommunityCoreData.createCommunity(env.getGlobalSite(),env,name,alias,uid, CommunityData new_comm = CommunityCoreData.createCommunity(globalsite,env,name,alias,uid,language,
language,synopsis,rules,joinkey,hide_dir, synopsis,rules,joinkey,hide_dir,hide_search);
hide_search);
// Create the community context we return to the user. // Create the community context we return to the user.
CommunityContext rc = new CommunityUserContextImpl(env,new_comm); CommunityContext rc = new CommunityUserContextImpl(env,new_comm);
@ -1020,7 +1023,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
// retrieve the necessary rows from the sideboxes table // retrieve the necessary rows from the sideboxes table
@ -1063,7 +1066,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection { // retrieve a connection
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
stmt.executeUpdate("LOCK TABLES sideboxes WRITE;"); stmt.executeUpdate("LOCK TABLES sideboxes WRITE;");
@ -1147,7 +1150,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
// create the update statement // create the update statement
@ -1192,7 +1195,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
// create the update statement // create the update statement
@ -1237,7 +1240,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
StringBuffer sql = new StringBuffer("UPDATE users SET tokenauth = '"); StringBuffer sql = new StringBuffer("UPDATE users SET tokenauth = '");
sql.append(tokenauth).append("' WHERE uid = ").append(uid).append(';'); sql.append(tokenauth).append("' WHERE uid = ").append(uid).append(';');
@ -1365,7 +1368,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // look for a user record matching this user ID { // look for a user record matching this user ID
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE uid = " + pending_uid + ";"); ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE uid = " + pending_uid + ";");
@ -1516,7 +1519,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a database connection { // get a database connection
conn = env.getConnection(); conn = globalsite.getConnection(null);
TopicMessageFoundHelper helper = new TopicMessageFoundHelper(conn); TopicMessageFoundHelper helper = new TopicMessageFoundHelper(conn);
stmt = conn.createStatement(); stmt = conn.createStatement();
@ -1576,7 +1579,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a database connection { // get a database connection
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
// create the SQL statement // create the SQL statement
@ -1615,65 +1618,102 @@ class UserContextImpl implements UserContext, UserBackend
} // end getSearchPostCount } // end getSearchPostCount
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Implementations from interface UserBackend * Implementations from interface ServiceProvider
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
public int realUID() public Object queryService(Class klass)
{ {
return uid; if (klass==UserContext.class)
return ((UserContext)this);
if (klass==PropertyProvider.class)
return ((PropertyProvider)this);
throw new NoSuchServiceException("UserContext",klass);
} // end realUID } // end queryService
public int realBaseLevel() public Object queryService(Class klass, String serviceid)
{ {
return level; return this.queryService(klass);
} // end realBaseLevel } // end queryService
public String userRemoteAddress() /*--------------------------------------------------------------------------------
* Implementations from interface PropertyProvider
*--------------------------------------------------------------------------------
*/
public String propGet(String identifier)
{ {
return remote_addr; try
{ // these properties have to be retrieved specially
if (identifier.equals("fullname"))
{ // get the full name of the user
if (full_name==null)
getContactInfo();
return full_name;
} // end userRemoteAddress } // end if
else if (identifier.equals("email"))
{ // get the E-mail address
if (my_email==null)
getContactInfo();
return my_email;
public String userDefaultPseud() throws DataException } // end else if
else if (identifier.equals("default.pseud"))
{ // get the default pseud
if (my_pseud==null)
getContactInfo();
return my_pseud;
} // end else if
} // end try
catch (DataException de)
{ // if we hit a DataException, return an erroneous value
logger.error("DataException in propGet()",de);
return "<<error>>";
} // end catch
if (identifier.equals("id"))
return String.valueOf(uid);
else if (identifier.equals("name"))
return username;
else if (identifier.equals("ip.address"))
return remote_addr;
else if (identifier.equals("base.level"))
return String.valueOf(level);
else if (identifier.equals("is.anonymous"))
return String.valueOf(is_anon);
throw new PropertyNotFoundException("UserContext",identifier);
} // end propGet
public int propGetInt(String identifier)
{ {
if (logger.isDebugEnabled()) if (identifier.equals("id"))
logger.debug("userDefaultPseud() for UID " + uid); return uid;
if (my_pseud==null) else if (identifier.equals("base.level"))
getContactInfo(); return level;
return my_pseud; throw new PropertyNotFoundException("UserContext",identifier);
} // end userDefaultPseud } // end propGetInt
public boolean userIsAnonymous() public boolean propGetBoolean(String identifier)
{ {
return is_anon; if (identifier.equals("is.anonymous"))
return is_anon;
throw new PropertyNotFoundException("UserContext",identifier);
} // end userIsAnonymous } // end propGetBoolean
public String realUserName() /*--------------------------------------------------------------------------------
{ * Implementations from interface UserBackend
return username; *--------------------------------------------------------------------------------
*/
} // end realUserName
public String realEmailAddress() throws DataException
{
if (my_email==null)
getContactInfo();
return my_email;
} // end realEmailAddress
public String realFullName() throws DataException
{
if (full_name==null)
getContactInfo();
return full_name;
} // end realFullName
public void saveMRU(String tag, Object data) public void saveMRU(String tag, Object data)
{ {
@ -1695,7 +1735,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // retrieve a connection from the data pool { // retrieve a connection from the data pool
conn = env.getConnection(); conn = globalsite.getConnection(null);
stmt = conn.createStatement(); stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE is_anon = 1;"); ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE is_anon = 1;");
if (!(rs.next())) if (!(rs.next()))
@ -1749,7 +1789,7 @@ class UserContextImpl implements UserContext, UserBackend
try try
{ // get a database connection and call the internal function { // get a database connection and call the internal function
conn = env.getConnection(); conn = globalsite.getConnection(null);
autoJoinCommunities(conn); autoJoinCommunities(conn);
} // end try } // end try

View File

@ -182,7 +182,7 @@ class UserProfileImpl implements UserProfile
ResultSet rs = stmt.executeQuery(sql.toString()); ResultSet rs = stmt.executeQuery(sql.toString());
if (rs.next()) if (rs.next())
{ // load all the record data { // load all the record data
boolean me_anon = env.getUser().userIsAnonymous(); boolean me_anon = env.isAnonymous();
given_name = rs.getString("given_name"); given_name = rs.getString("given_name");
family_name = rs.getString("family_name"); family_name = rs.getString("family_name");
String blort = rs.getString("middle_init"); String blort = rs.getString("middle_init");
@ -437,7 +437,7 @@ class UserProfileImpl implements UserProfile
public boolean canSendQuickEmail() public boolean canSendQuickEmail()
{ {
return !is_anon && !(env.getUser().userIsAnonymous()); return !is_anon && !(env.isAnonymous());
} // end canSendQuickEmail } // end canSendQuickEmail
@ -446,7 +446,7 @@ class UserProfileImpl implements UserProfile
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Send Quick E-Mail (from uid " + env.getUserID() + " to uid " + uid + ")"); logger.debug("Send Quick E-Mail (from uid " + env.getUserID() + " to uid " + uid + ")");
if (env.getUser().userIsAnonymous()) if (env.isAnonymous())
{ // we can't send quick emails if we're anonymous! { // we can't send quick emails if we're anonymous!
logger.error("sending user is not logged in."); logger.error("sending user is not logged in.");
throw new AccessError("You must be logged in to send a quick E-mail message."); throw new AccessError("You must be logged in to send a quick E-mail message.");
@ -461,7 +461,7 @@ class UserProfileImpl implements UserProfile
} // end if } // end if
// create the emailer object, fill it in, and send it // create the emailer object, fill it in, and send it
MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUser()); MailSend msend = new PersonalMailSend(env.getMailSender(),env.getGlobalSite(),env.getUserProps());
msend.addRecipient(MailSend.RECIP_TO,real_email); msend.addRecipient(MailSend.RECIP_TO,real_email);
msend.setSubject(subject); msend.setSubject(subject);
msend.setText(text + "\n"); msend.setText(text + "\n");

View File

@ -650,7 +650,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
public UserContext createUserContext(String remote_addr) throws DataException public UserContext createUserContext(String remote_addr) throws DataException
{ {
checkInitialized(); checkInitialized();
UserContextImpl uci = new UserContextImpl(env); UserContextImpl uci = new UserContextImpl(globalsite,env);
uci.loadAnonymous(remote_addr); uci.loadAnonymous(remote_addr);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("createUserContext(): context loaded :-)"); logger.debug("createUserContext(): context loaded :-)");
@ -875,7 +875,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend
false,confirm_num,new_role,null); false,confirm_num,new_role,null);
// create a new context for the user (they're now effectively logged in) // create a new context for the user (they're now effectively logged in)
UserContextImpl rc = new UserContextImpl(env); UserContextImpl rc = new UserContextImpl(globalsite,env);
rc.loadNewUser(remote_addr,rnu.getUserID(),new_role.getLevel(),username,confirm_num,rnu.getCreationDate(), rc.loadNewUser(remote_addr,rnu.getUserID(),new_role.getLevel(),username,confirm_num,rnu.getCreationDate(),
rnu.getCreationDate()); rnu.getCreationDate());
rc.autoJoinCommunities(); // EJB 4/14/2001 rc.autoJoinCommunities(); // EJB 4/14/2001

View File

@ -86,34 +86,32 @@ public class EnvCommunity extends EnvUser
public AuditRecord newAudit(int type, String data1, String data2, String data3, String data4) public AuditRecord newAudit(int type, String data1, String data2, String data3, String data4)
{ {
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1, return new AuditRecord(type,super.getUserID(),super.getRemoteAddress(),getCommunityID(),data1,data2,
data2,data3,data4); data3,data4);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type, String data1, String data2, String data3) public AuditRecord newAudit(int type, String data1, String data2, String data3)
{ {
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1, return new AuditRecord(type,super.getUserID(),super.getRemoteAddress(),getCommunityID(),data1,data2,data3);
data2,data3);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type, String data1, String data2) public AuditRecord newAudit(int type, String data1, String data2)
{ {
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1, return new AuditRecord(type,super.getUserID(),super.getRemoteAddress(),getCommunityID(),data1,data2);
data2);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type, String data1) public AuditRecord newAudit(int type, String data1)
{ {
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID(),data1); return new AuditRecord(type,super.getUserID(),super.getRemoteAddress(),getCommunityID(),data1);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type) public AuditRecord newAudit(int type)
{ {
return new AuditRecord(type,super.getUserID(),super.getUser().userRemoteAddress(),getCommunityID()); return new AuditRecord(type,super.getUserID(),super.getRemoteAddress(),getCommunityID());
} // end newAudit } // end newAudit

View File

@ -22,6 +22,8 @@ import com.silverwrist.venice.except.AccessError;
import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.AuditRecord;
import com.silverwrist.venice.security.Role; import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.security.SecurityMonitor; import com.silverwrist.venice.security.SecurityMonitor;
import com.silverwrist.venice.util.PropertyProvider;
import com.silverwrist.venice.util.ServiceProvider;
public class EnvUser extends EnvEngine public class EnvUser extends EnvEngine
{ {
@ -48,17 +50,21 @@ public class EnvUser extends EnvEngine
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private UserBackend user; // the user backend object private ServiceProvider usersvc; // the user service provider
private SecurityMonitor sm; // security monitor at this level private PropertyProvider userprops; // the user property provider
private UserBackend user; // the user backend object
private SecurityMonitor sm; // security monitor at this level
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructors * Constructors
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
public EnvUser(EnvEngine parent, UserBackend user) public EnvUser(EnvEngine parent, ServiceProvider usersvc, UserBackend user)
{ {
super(parent); super(parent);
this.usersvc = usersvc;
this.userprops = (PropertyProvider)(usersvc.queryService(PropertyProvider.class));
this.user = user; this.user = user;
this.sm = (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class)); this.sm = (SecurityMonitor)(getGlobalSite().queryService(SecurityMonitor.class));
@ -67,6 +73,8 @@ public class EnvUser extends EnvEngine
protected EnvUser(EnvUser other) protected EnvUser(EnvUser other)
{ {
super(other); super(other);
this.usersvc = other.usersvc;
this.userprops = other.userprops;
this.user = other.user; this.user = other.user;
this.sm = other.sm; this.sm = other.sm;
@ -82,7 +90,7 @@ public class EnvUser extends EnvEngine
if (symbol.equals(PERM_CREATECOMMUNITY)) if (symbol.equals(PERM_CREATECOMMUNITY))
{ // the Create Community permission test { // the Create Community permission test
Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY); Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY);
if (r.isSatisfiedBy(user.realBaseLevel())) if (r.isSatisfiedBy(userprops.propGetInt("base.level")))
return true; return true;
logger.error("testPermission() fail for permission " + PERM_CREATECOMMUNITY); logger.error("testPermission() fail for permission " + PERM_CREATECOMMUNITY);
if (errormsg==null) if (errormsg==null)
@ -100,7 +108,7 @@ public class EnvUser extends EnvEngine
if (symbol.equals(PERM_CREATECOMMUNITY)) if (symbol.equals(PERM_CREATECOMMUNITY))
{ // do the "Create Community" test here { // do the "Create Community" test here
Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY); Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY);
return r.isSatisfiedBy(user.realBaseLevel()); return r.isSatisfiedBy(userprops.propGetInt("base.level"));
} // end if } // end if
@ -110,8 +118,9 @@ public class EnvUser extends EnvEngine
protected int levelSelf() protected int levelSelf()
{ {
return user.realBaseLevel(); return userprops.propGetInt("base.level");
}
} // end levelSelf
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* External operations * External operations
@ -120,31 +129,31 @@ public class EnvUser extends EnvEngine
public AuditRecord newAudit(int type, String data1, String data2, String data3, String data4) public AuditRecord newAudit(int type, String data1, String data2, String data3, String data4)
{ {
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1,data2,data3,data4); return new AuditRecord(type,getUserID(),userprops.propGet("ip.address"),data1,data2,data3,data4);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type, String data1, String data2, String data3) public AuditRecord newAudit(int type, String data1, String data2, String data3)
{ {
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1,data2,data3); return new AuditRecord(type,getUserID(),userprops.propGet("ip.address"),data1,data2,data3);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type, String data1, String data2) public AuditRecord newAudit(int type, String data1, String data2)
{ {
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1,data2); return new AuditRecord(type,getUserID(),userprops.propGet("ip.address"),data1,data2);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type, String data1) public AuditRecord newAudit(int type, String data1)
{ {
return new AuditRecord(type,getUserID(),user.userRemoteAddress(),data1); return new AuditRecord(type,getUserID(),userprops.propGet("ip.address"),data1);
} // end newAudit } // end newAudit
public AuditRecord newAudit(int type) public AuditRecord newAudit(int type)
{ {
return new AuditRecord(type,getUserID(),user.userRemoteAddress()); return new AuditRecord(type,getUserID(),userprops.propGet("ip.address"));
} // end newAudit } // end newAudit
@ -152,10 +161,11 @@ public class EnvUser extends EnvEngine
{ {
if (testPermissionDynamic(symbol,errormsg)) if (testPermissionDynamic(symbol,errormsg))
return true; return true;
int my_level = userprops.propGetInt("base.level");
if (symbol.equals(PERM_CREATECOMMUNITY)) if (symbol.equals(PERM_CREATECOMMUNITY))
{ // the Create Community permission test { // the Create Community permission test
Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY); Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY);
if (r.isSatisfiedBy(user.realBaseLevel())) if (r.isSatisfiedBy(my_level))
return true; return true;
logger.error("testPermission() fail for permission " + PERM_CREATECOMMUNITY); logger.error("testPermission() fail for permission " + PERM_CREATECOMMUNITY);
if (errormsg==null) if (errormsg==null)
@ -164,29 +174,36 @@ public class EnvUser extends EnvEngine
} // end if } // end if
return sm.testPermission(symbol,user.realBaseLevel(),errormsg); return sm.testPermission(symbol,my_level,errormsg);
} // end testPermission } // end testPermission
public boolean testPermission(String symbol) public boolean testPermission(String symbol)
{ {
int my_level = userprops.propGetInt("base.level");
if (symbol.equals(PERM_CREATECOMMUNITY)) if (symbol.equals(PERM_CREATECOMMUNITY))
{ // do the "Create Community" test here { // do the "Create Community" test here
Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY); Role r = getEngine().getParamRole(EngineBackend.ROLEP_CREATECOMMUNITY);
return r.isSatisfiedBy(user.realBaseLevel()); return r.isSatisfiedBy(my_level);
} // end if } // end if
return sm.testPermission(symbol,user.realBaseLevel()); return sm.testPermission(symbol,my_level);
} // end testPermission } // end testPermission
public boolean satisfy(Role role) public boolean satisfy(Role role)
{ {
return role.isSatisfiedBy(user.realBaseLevel()); return role.isSatisfiedBy(userprops.propGetInt("base.level"));
} // end satisfy } // end satisfy
public final PropertyProvider getUserProps()
{
return userprops;
} // end getProps
public final UserBackend getUser() public final UserBackend getUser()
{ {
return user; return user;
@ -195,20 +212,32 @@ public class EnvUser extends EnvEngine
public final int getUserID() public final int getUserID()
{ {
return user.realUID(); return userprops.propGetInt("id");
} // end getUserID } // end getUserID
public final String getUserName() public final String getUserName()
{ {
return user.realUserName(); return userprops.propGet("name");
} // end getUserName } // end getUserName
public final int getUserBaseLevel() public final int getUserBaseLevel()
{ {
return user.realBaseLevel(); return userprops.propGetInt("base.level");
} // end getUserBaseLevel } // end getUserBaseLevel
public final String getRemoteAddress()
{
return userprops.propGet("ip.address");
} // end getRemoteAddress
public final boolean isAnonymous()
{
return userprops.propGetBoolean("is.anonymous");
} // end isAnonymous
} // end class EnvUser } // end class EnvUser

View File

@ -21,22 +21,6 @@ import com.silverwrist.venice.except.DataException;
public interface UserBackend public interface UserBackend
{ {
public abstract int realUID();
public abstract int realBaseLevel();
public abstract String userRemoteAddress();
public abstract String userDefaultPseud() throws DataException;
public abstract boolean userIsAnonymous();
public abstract String realUserName();
public abstract String realEmailAddress() throws DataException;
public abstract String realFullName() throws DataException;
public abstract void saveMRU(String tag, Object data); public abstract void saveMRU(String tag, Object data);
} // end interface UserBackend } // end interface UserBackend