|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.abstracthorizon.mercury.common.SimpleStorageManager
public class SimpleStorageManager
This class is simple implementation of SMTPManager that uses properties file to read (and write) domain names to served, mail boxes that exist and aliases that point to existing mailboxes.
Format of properties file is as described in Properties
and
this class uses special prefixes and property names to denote domain names, mailboxes
and aliases:
"S\="
and "A\="
.
Nested Class Summary | |
---|---|
protected static class |
SimpleStorageManager.Entry
Entry |
protected static class |
SimpleStorageManager.URLNameFix
Fix for url name |
Field Summary | |
---|---|
protected boolean |
autosave
Shell changes in properties automatically trigger saving values back to the file |
protected boolean |
caseSensitive
Mail box is case sensitive flag |
protected static org.slf4j.Logger |
logger
Logger |
protected File |
propertiesFile
Properties file |
protected Properties |
props
Properties to keep all elements in |
protected javax.mail.Session |
session
Maildir session to work in |
Constructor Summary | |
---|---|
SimpleStorageManager()
Constructor |
Method Summary | |
---|---|
void |
addAlias(String mailbox,
String destMailbox)
Utility method that adds new alias to this manager. |
void |
addDomain(String domain)
Adds new domain to this manager. |
void |
addEntry(String mailbox,
String entry)
Adds new "raw" entry to properties. |
void |
addMailbox(String mailbox,
String store)
Utility method to add new mailbox to this manager. |
protected javax.mail.URLName |
createURLName(String username,
String password,
String storeString)
|
protected String |
decorateStoreString(String mailbox,
String domain,
String storeString)
|
javax.mail.Folder |
findInbox(String mailbox,
String domain,
char[] password)
Updates path parameter with local mailbox (folder from JavaMail if mailbox/alias exists. |
javax.mail.Store |
findStore(String mailbox,
String domain,
char[] password)
Returns local store if user is local or null otherwise. |
String[] |
getAliases()
Returns all aliases |
String[] |
getDomains()
Returns all domains that are served |
javax.mail.Session |
getJavaMailSession()
Returns java mail session |
String[] |
getMailboxNames()
Returns all mailbox urls |
String[] |
getMailboxNames(String domain)
Returns all mailbox urls |
String |
getMainDomain()
Returns main domain as it appears in HELO/EHLO command response |
File |
getPropertiesFile()
Returns properties file |
protected InputStream |
getPropertiesInputStream()
Returns input stream to read properties from |
protected OutputStream |
getPropertiesOutputStream()
Returns output stream to write properties to |
boolean |
hasDomain(String domain)
Returns true if domain is served by this server |
void |
init()
This method loads properties and sets the session if not already defined |
boolean |
isAutosave()
Returns autosave flag |
boolean |
isCaseSensitive()
Returns case senstive |
void |
load()
This method loads the properties |
protected String |
makeEntry(String mailbox,
String domain)
|
protected javax.mail.Store |
obtainStore(javax.mail.URLName urlName)
|
protected String |
obtainStoreString(String mailbox,
String domain)
|
void |
removeAlias(String mailbox)
Removes the alias. |
boolean |
removeDomain(String domain)
Deletes domain |
boolean |
removeMailbox(String mailbox,
String domain)
Removes mailbox |
void |
save()
This method saves the properties |
void |
setAutosave(boolean autosave)
Sets autosave flag |
void |
setCaseSensitive(boolean caseSensitive)
Sets case sensitive flag |
void |
setJavaMailSession(javax.mail.Session session)
Sets java mail session |
void |
setMainDomain(String domain)
Sets main domain name |
void |
setPropertiesFile(File propertiesFile)
Setter for file |
protected void |
toLowerCase()
Converts all entries to lower case |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean caseSensitive
protected Properties props
protected javax.mail.Session session
protected File propertiesFile
protected boolean autosave
protected static final org.slf4j.Logger logger
Constructor Detail |
---|
public SimpleStorageManager()
Method Detail |
---|
public void setPropertiesFile(File propertiesFile)
propertiesFile
- filepublic File getPropertiesFile()
public void setAutosave(boolean autosave)
autosave
- autosave flagautosave
public boolean isAutosave()
autosave
public void setCaseSensitive(boolean caseSensitive)
caseSensitive
- case sensitivecaseSensitive
public boolean isCaseSensitive()
caseSensitive
public javax.mail.Session getJavaMailSession()
public void setJavaMailSession(javax.mail.Session session)
session
- java mail sessionpublic void init() throws IOException
IOException
public void load() throws IOException
IOException
public void save()
IOException
protected InputStream getPropertiesInputStream() throws IOException
IOException
protected OutputStream getPropertiesOutputStream() throws IOException
IOException
public String getMainDomain()
getMainDomain
in interface StorageManager
public void setMainDomain(String domain)
domain
- main domain namepublic boolean hasDomain(String domain)
true
if domain is served by this server
hasDomain
in interface StorageManager
true
- if domain is served by this server
true
in case supplied domain is local for this SMTP serverpublic javax.mail.Store findStore(String mailbox, String domain, char[] password) throws UserRejectedException, javax.mail.MessagingException
StorageManager
null
otherwise. In
case that user is to be rejected an exception is thrown.
findStore
in interface StorageManager
mailbox
- user's mailboxdomain
- user's domain
UserRejectedException
- in case that user is rejected for any reason
javax.mail.MessagingException
- in case there is a problem accessing user's mailboxpublic javax.mail.Folder findInbox(String mailbox, String domain, char[] password) throws UserRejectedException, javax.mail.MessagingException
findInbox
in interface StorageManager
mailbox
- mailbox to be accessesdomain
- domaindomain
- domain where mailbox is supposed ot be defined.
UserRejectedException
- thrown in user is rejected
javax.mail.MessagingException
- if error happens while accessing the folderprotected String obtainStoreString(String mailbox, String domain) throws javax.mail.MessagingException
javax.mail.MessagingException
protected String decorateStoreString(String mailbox, String domain, String storeString)
protected javax.mail.Store obtainStore(javax.mail.URLName urlName) throws javax.mail.MessagingException
javax.mail.MessagingException
protected javax.mail.URLName createURLName(String username, String password, String storeString)
public void addMailbox(String mailbox, String store)
autosave
is on.
mailbox
- mailbox (name@domain).store
- url
IOException
public void addAlias(String mailbox, String destMailbox) throws IOException
autosave
is on.
mailbox
- mailbox (name@domain)destMailbox
- destination mailbox (name@domain)
IOException
public void removeAlias(String mailbox)
mailbox
- removes the aliaspublic void addDomain(String domain)
autosave
is on.
domain
- domain name.
IOException
public void addEntry(String mailbox, String entry) throws IOException
mailbox
- key that is automatically prefixed with "-"entry
- entry
IOException
public boolean removeMailbox(String mailbox, String domain)
mailbox
- mailbox
IOException
public boolean removeDomain(String domain)
domain
- domain name
IOException
public String[] getDomains()
public String[] getMailboxNames()
public String[] getMailboxNames(String domain)
domain
- domain name
public String[] getAliases()
protected void toLowerCase()
protected String makeEntry(String mailbox, String domain)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |