Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1014 → Rev 1015

/hostadmiral/trunk/src/ak/hostadmiral/core/model/Mailbox.java
1,6 → 1,9
package ak.hostadmiral.core.model;
 
import ak.hostadmiral.util.Digest;
import java.util.Iterator;
import java.util.Collection;
import java.util.HashSet;
 
import ak.hostadmiral.util.ModelException;
import ak.hostadmiral.util.ModelSecurityException;
 
12,7 → 15,7
extends GeneralModelObject
{
private String login;
private String password;
private Collection passwords; // Collection(PasswordStore)
private InetDomain domain;
private User owner;
private Boolean virusCheck;
28,7 → 31,12
{
super(origin);
this.login = origin.login;
this.password = origin.password;
 
if(origin.passwords == null)
this.passwords = null;
else
this.passwords = new HashSet(origin.passwords);
 
this.domain = origin.domain;
this.owner = origin.owner;
this.virusCheck = origin.virusCheck;
71,30 → 79,47
this.login = login;
}
 
/**
*
* @hibernate.property
*/
protected String getPassword()
protected void addPasswordStore(PasswordStore ps)
{
return password;
if(passwords == null) passwords = new HashSet();
passwords.add(ps);
}
 
protected void setPassword(String password)
{
this.password = password;
}
 
public void setPassword(User editor, String password)
throws ModelException
{
if(!editableBy(editor))
throw new ModelSecurityException();
 
if(password == null)
throw new NullPointerException("Null password");
 
backupMe();
this.password = Digest.encode(password);
 
for(Iterator i = passwords.iterator(); i.hasNext(); ) {
Object o = i.next();
if(!(o instanceof PasswordStore))
throw new ModelException("It's not a password store");
((PasswordStore)o).setNewPassword(password);
}
}
 
/**
*
* @hibernate.set cascade="all"
* @hibernate.collection-key column="obj"
* @hibernate.collection-one-to-many class="ak.hostadmiral.core.model.PasswordStoreAbstract"
*/
protected Collection getPasswords()
{
return passwords;
}
 
protected void setPasswords(Collection passwords)
{
this.passwords = passwords;
}
 
/**
*
* @hibernate.many-to-one