/hostadmiral/trunk/src/ak/hostadmiral/core/model/PasswordStore.java |
---|
13,6 → 13,11 |
public String getDigest(); |
/** |
* returns true if the store is able to return the original password |
*/ |
public boolean getReversable(); |
/** |
* to store to persistent store |
*/ |
public String getPassword(); |
30,4 → 35,10 |
public boolean checkPassword(String password) |
throws ModelException; |
/** |
* return the password in plain text if possible |
*/ |
public String getOriginalPassword() |
throws UnsupportedOperationException; |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/Mailbox.java |
---|
90,6 → 90,26 |
passwords.add(ps); |
} |
public String getPassword(User editor, String digest) |
throws ModelException |
{ |
if(!editableBy(editor)) |
throw new ModelSecurityException(); |
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 ps = (PasswordStore)o; |
if(ps.getDigest().equals(digest)) { |
return ps.getPassword(); |
} |
} |
throw new ModelException("Digest " + digest + " not found"); |
} |
public void setPassword(User editor, String password) |
throws ModelException |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/PasswordStoreAbstract.java |
---|
112,4 → 112,15 |
theClone.password = password; |
return theClone; |
} |
public boolean getReversable() |
{ |
return false; |
} |
public String getOriginalPassword() |
throws UnsupportedOperationException |
{ |
throw new UnsupportedOperationException("Not able to restore original password"); |
} |
} |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/User.java |
---|
124,6 → 124,26 |
return getDefaultPasswordStore().getPassword(); |
} |
public String getPassword(User editor, String digest) |
throws ModelException |
{ |
if(!partEditableBy(editor)) |
throw new ModelSecurityException(); |
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 ps = (PasswordStore)o; |
if(ps.getDigest().equals(digest)) { |
return ps.getPassword(); |
} |
} |
throw new ModelException("Digest " + digest + " not found"); |
} |
public void setPassword(User editor, String password) |
throws ModelException |
{ |
/hostadmiral/trunk/src/ak/hostadmiral/core/model/PasswordStorePlain.java |
---|
20,4 → 20,15 |
{ |
return password; |
} |
public boolean getReversable() |
{ |
return true; |
} |
public String getOriginalPassword() |
throws UnsupportedOperationException |
{ |
return password; |
} |
} |