/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainManager.java |
---|
26,7 → 26,7 |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"/ak/hostadmiral/core/model/InetDomain.hbm.xml"); |
"ak/hostadmiral/core/model/InetDomain.hbm.xml"); |
inetDomainManager = new InetDomainManager(); |
} |
/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxManager.java |
---|
29,7 → 29,7 |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"/ak/hostadmiral/core/model/Mailbox.hbm.xml"); |
"ak/hostadmiral/core/model/Mailbox.hbm.xml"); |
mailboxManager = new MailboxManager(); |
} |
/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasManager.java |
---|
18,7 → 18,7 |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"/ak/hostadmiral/core/model/MailAlias.hbm.xml"); |
"ak/hostadmiral/core/model/MailAlias.hbm.xml"); |
} |
catch(Exception ex) { |
ex.printStackTrace(); |
/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailAliasDestinationManager.java |
---|
17,7 → 17,7 |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"/ak/hostadmiral/core/model/MailAliasDestination.hbm.xml"); |
"ak/hostadmiral/core/model/MailAliasDestination.hbm.xml"); |
} |
catch(Exception ex) { |
ex.printStackTrace(); |
/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/UserManager.java |
---|
26,9 → 26,9 |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"/ak/hostadmiral/core/model/User.hbm.xml"); |
"ak/hostadmiral/core/model/User.hbm.xml"); |
HibernateUtil.getConfiguration().addResource( |
"/ak/hostadmiral/core/model/UserLogin.hbm.xml"); |
"ak/hostadmiral/core/model/UserLogin.hbm.xml"); |
userManager = new UserManager(); |
} |
44,6 → 44,7 |
} |
private Collection beforeDeleteListeners = new ArrayList(); |
private Map loggedinUsers = new WeakHashMap(); |
private UserManager() |
{ |
128,7 → 129,7 |
public void save(User editor, User user) |
throws ModelException |
{ |
if(!user.editableBy(editor) && !user.mayChangePassword(editor) |
if(!user.editableBy(editor) && !user.partEditableBy(editor) |
&& !user.mayChangeSuperuser(editor)) |
{ |
throw new ModelSecurityException(); |
143,7 → 144,14 |
{ |
throw new ModelException(ex); |
} |
// update user if he is logged in |
for(Iterator i = loggedinUsers.keySet().iterator(); i.hasNext(); ) { |
User u = (User)i.next(); |
if(u.equals(user)) |
u.update(user); |
} |
} |
public void addBeforeDeleteListener(UserBeforeDeleteListener listener) |
{ |
242,11 → 250,14 |
throw new ModelException(ex); |
} |
if(success) |
if(success) { |
loggedinUsers.put(user, Boolean.TRUE); |
return user; |
else |
} |
else { |
return null; // wrong login or password |
} |
} |
public Collection listFailedLogins(User editor) |
throws ModelException |
/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/SystemUserManager.java |
---|
26,7 → 26,7 |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"/ak/hostadmiral/core/model/SystemUser.hbm.xml"); |
"ak/hostadmiral/core/model/SystemUser.hbm.xml"); |
systemUserManager = new SystemUserManager(); |
} |
/sun/hostadmiral/trunk/src/ak/hostadmiral/core/model/User.java |
---|
2,6 → 2,8 |
import java.util.Collection; |
import java.util.Collections; |
import java.util.Locale; |
import java.util.StringTokenizer; |
import ak.hostadmiral.util.Digest; |
import ak.hostadmiral.util.ModelException; |
18,6 → 20,7 |
private String password; |
private User boss; |
private Boolean superuser; |
private Locale locale = Locale.getDefault(); |
private Collection loginHistory; |
protected User() |
64,7 → 67,7 |
public void setPassword(User editor, String password) |
throws ModelException |
{ |
if(!mayChangePassword(editor)) |
if(!partEditableBy(editor)) |
throw new ModelSecurityException(); |
if(password == null) |
139,6 → 142,57 |
/** |
* |
* @hibernate.property column="locale" |
*/ |
protected String getLocaleName() |
{ |
return locale.toString(); |
} |
protected void setLocaleName(String localeName) |
{ |
String language = null; |
String country = null; |
if(localeName != null) { |
StringTokenizer t = new StringTokenizer(localeName, "_"); |
if(t.hasMoreTokens()) language = t.nextToken(); |
if(t.hasMoreTokens()) country = t.nextToken(); |
} |
if(language == null) |
this.locale = Locale.getDefault(); |
else if(country == null) |
this.locale = new Locale(language); |
else |
this.locale = new Locale(language, country); |
} |
public void setLocaleName(User editor, String localeName) |
throws ModelException |
{ |
if(!partEditableBy(editor)) |
throw new ModelSecurityException(); |
setLocaleName(localeName); |
} |
public Locale getLocale() |
{ |
return locale; |
} |
public void setLocale(User editor, Locale locale) |
throws ModelException |
{ |
if(!partEditableBy(editor)) |
throw new ModelSecurityException(); |
this.locale = locale; |
} |
/** |
* |
* @hibernate.set lazy="true" |
* @hibernate.collection-key column="usr" |
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.UserLogin" |
166,6 → 220,14 |
return (getId() != null) && (u.getId() != null) && (getId().equals(u.getId())); |
} |
protected void update(User origin) |
{ |
this.login = origin.login; |
this.boss = origin.boss; |
this.superuser = origin.superuser; |
this.locale = origin.locale; |
} |
public int hashCode() |
{ |
if(getId() == null) |
204,7 → 266,8 |
return !user.equals(this) && (user.isSuperuser() || user.equals(boss)); |
} |
public boolean mayChangePassword(User user) |
// editor is allowed to change some additional properties |
public boolean partEditableBy(User user) |
{ |
return user.isSuperuser() || user.equals(boss) || user.equals(this); |
} |