Package tigase.vhosts
Class VHostItemImpl
java.lang.Object
tigase.db.comp.RepositoryItemAbstract
tigase.vhosts.VHostItemImpl
- All Implemented Interfaces:
Comparable<VHostItem>,RepositoryItem,VHostItem
Objects of this class represent virtual host with all hosts configuration settings. In most cases simple domain name
string is not enough to deal with the virtual host. VHost can be enabled/disabled. Can be available to selected
server components only and so on. Therefore every time there is a detailed information needed for a vhost this
classed must be used.
This class has it's own XML representation which can be used for creating an instance of the class or can be exported to the XML form for permanent storage:
From the init.property file it is also possible to set additional parameters for the vhost. By default everything is enabled and max accounts set to unlimited. In the example below we configure 2 domains: devel.tigase.org and test.tigase.org. For the first domain there are no additional settings, hence the domain has everything on by default, whereas the second has everything switched off and max user accounts set to 100.
It also possible to set forwarding for the domain:
Please note, forwarding address set this way cannot contain any of characters: [,:=] The order features are set for domain is unimportant.
Created: 22 Nov 2008
This class has it's own XML representation which can be used for creating an instance of the class or can be exported to the XML form for permanent storage:
<vhost hostname="vhost.something.com" enabled="true" anon="true" register="true" max-users="99999999999L">
<comps/> <other/>
From the init.property file it is also possible to set additional parameters for the vhost. By default everything is enabled and max accounts set to unlimited. In the example below we configure 2 domains: devel.tigase.org and test.tigase.org. For the first domain there are no additional settings, hence the domain has everything on by default, whereas the second has everything switched off and max user accounts set to 100.
--virt-hosts = devel.tigase.org,test.tigase.org:-anon:-register:max-users=100
It also possible to set forwarding for the domain:
--virt-hosts = test.tigase.org:pres-forw=lpart@domain/res:mess-forw=lpart@domain/res
Please note, forwarding address set this way cannot contain any of characters: [,:=] The order features are set for domain is unimportant.
Created: 22 Nov 2008
- Author:
- Artur Hefczyc
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringElement name for the VHostItem XML child keeping list of the server component which can handle packets for this domain.protected static final Map<String, VHostItemImpl.DataType> static final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final DomainFilterPolicyprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Booleanprotected static final Stringprotected static final String[]static final Stringprotected static final Longprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String[]protected static final Stringprotected static final Stringprotected static final Booleanprotected static final Stringprotected static final Booleanprotected static final StringFields inherited from class tigase.db.comp.RepositoryItemAbstract
ADMINS_ATT, ADMINS_LABEL, OWNER_ATT, OWNER_LABELFields inherited from interface tigase.vhosts.VHostItem
DEF_VHOST_KEY -
Constructor Summary
ConstructorsConstructorDescriptionVHostItemImpl(String vhost) The constructor creates theVHostIteminstance for a given domain name with default values for all other parameters.VHostItemImpl(Element elem) The constructor creates theVHostIteminstance from a given XML element.VHostItemImpl(JID vhost) The constructor creates theVHostIteminstance for a given domain name with default values for all other parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommandFields(Packet packet) The method is used for handling ad-hoc commands.booleanint[]Returns an array with ports on which C2S connections for this VHosts are allowed.String[]getComps()Returns an array with the server components names which should process packets sent to this domain ornull(default) if there is no specific component assigned to this domain.<T> TDeprecated.String[]<T extends VHostItemExtension>
TgetExtension(Class<T> clazz) Set<Class<? extends VHostItemExtension>> <T extends VHostItemExtension>
Set<T> getKey()Returns a unique key for the item in the repository.This method allows to access the virtual domain other configuration parameters.String[]getVhost()inthashCode()protected VHostItemExtensioninitExtension(VHostItemExtension extension) voidinitFromCommand(Packet packet) The method used for handling ad-hoc commands.voidinitFromElement(Element elem) The item can be also initialized from a more complex repositories: XML repository or SQL database.voidinitFromPropertyString(String propString) The item can be initialized based on the data loaded from a configuration file.protected voidinitializeFromDefaults(VHostItemDefaults vhostDefaults) booleanbooleanDeprecated.protected booleanbooleanbooleanbooleanvoidparseDataValue(String key, String valueStr) static voidregisterData(List<VHostItemImpl.DataType> types) Deprecated.voidsetAnonymousEnabled(boolean value) voidsetC2SPortsAllowed(int[] ports) voidSets an array with the server component names by which packets to this domain can be processed.voidvoidsetDomainFilter(DomainFilterPolicy domainFilter) This method allow configure DomainFilterPolicy to be applied during packet filtering.voidsetDomainFilterDomains(String[] domainFilterDomains) This method allow specify list of domains that will be used for packet filtering when DomainFilteringPolicy is set to either LIST or BLACKLIST.voidsetEnabled(boolean value) protected voidsetExtensionManager(VHostItemExtensionManager extensionManager) voidvoidsetMaxUsersNumber(long maxUsersNumber) voidsetMessageForward(JID messageForward) voidsetOtherDomainParams(String otherParams) This method allows to set extra configuration parameters for the virtual domain.voidsetPresenceForward(JID presenceForward) voidsetRegisterEnabled(boolean value) voidsetS2sSecret(String s2sSecret) voidsetSaslAllowedMechanisms(String[] saslAllowedMechanisms) voidsetTlsRequired(boolean value) voidvoidItem data can be stored in a more complex form than a simple property string.The item can be initialized based on the data loaded from a configuration file.toString()protected static StringBuilderMethods inherited from class tigase.db.comp.RepositoryItemAbstract
getAdmins, getOwner, isAdmin, isOwner, setAdmins, setOwnerMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface tigase.db.comp.RepositoryItem
getAdmins, getOwner, isOwner, setAdmins, setOwnerMethods inherited from interface tigase.vhosts.VHostItem
compareTo, isAdmin, isTrustedJID
-
Field Details
-
ANONYMOUS_ENABLED_ATT
- See Also:
-
ANONYMOUS_ENABLED_LABEL
- See Also:
-
SASL_MECHANISM_ATT
- See Also:
-
SASL_MECHANISM_LABEL
- See Also:
-
COMPONENTS_ATT
- See Also:
-
COMPONENTS_ELEM
Element name for the VHostItem XML child keeping list of the server component which can handle packets for this domain. In most cases this element should be empty.- See Also:
-
C2S_PORTS_ALLOWED_ATT
- See Also:
-
C2S_PORTS_ALLOWED_LABEL
- See Also:
-
DOMAIN_FILTER_POLICY_ATT
- See Also:
-
DOMAIN_FILTER_POLICY_DOMAINS_ATT
- See Also:
-
DOMAIN_FILTER_POLICY_LABEL
- See Also:
-
DOMAIN_FILTER_POLICY_DOMAINS_LABEL
- See Also:
-
ENABLED_ATT
- See Also:
-
ENABLED_LABEL
- See Also:
-
HOSTNAME_ATT
- See Also:
-
HOSTNAME_LABEL
- See Also:
-
MAX_USERS_NUMBER_ATT
- See Also:
-
MAX_USERS_NUMBER_LABEL
- See Also:
-
MESSAGE_FORWARD_ADDRESS_ATT
- See Also:
-
MESSAGE_FORWARD_ADDRESS_LABEL
- See Also:
-
OTHER_PARAMS_ELEM
- See Also:
-
OTHER_PARAMS_LABEL
- See Also:
-
PRESENCE_FORWARD_ADDRESS_ATT
- See Also:
-
PRESENCE_FORWARD_ADDRESS_LABEL
- See Also:
-
REGISTER_ENABLED_ATT
- See Also:
-
REGISTER_ENABLED_LABEL
- See Also:
-
S2S_SECRET_ATT
- See Also:
-
S2S_SECRET_LABEL
- See Also:
-
TLS_REQUIRED_ATT
- See Also:
-
TLS_REQUIRED_LABEL
- See Also:
-
TRUSTED_JIDS_LABEL
- See Also:
-
VHOST_ELEM
- See Also:
-
DOMAIN_FILTER_POLICY_PROP_KEY
- See Also:
-
S2S_SECRET_PROP_DEF
-
S2S_SECRET_PROP_KEY
- See Also:
-
VHOST_ANONYMOUS_ENABLED_PROP_KEY
- See Also:
-
VHOST_ANONYMOUS_ENABLED_PROP_DEF
-
VHOST_MAX_USERS_PROP_KEY
- See Also:
-
VHOST_MAX_USERS_PROP_DEF
-
VHOST_MESSAGE_FORWARD_PROP_DEF
-
VHOST_MESSAGE_FORWARD_PROP_KEY
- See Also:
-
VHOST_PRESENCE_FORWARD_PROP_DEF
-
VHOST_PRESENCE_FORWARD_PROP_KEY
- See Also:
-
VHOST_REGISTER_ENABLED_PROP_KEY
- See Also:
-
VHOST_REGISTER_ENABLED_PROP_DEF
-
VHOST_TLS_REQUIRED_PROP_KEY
- See Also:
-
VHOST_TLS_REQUIRED_PROP_DEF
-
DOMAIN_FILTER_POLICY_PROP_DEF
-
VHOST_OTHER_PARAMS_PATH
-
VHOST_COMPONENTS_PATH
-
dataTypes
-
-
Constructor Details
-
VHostItemImpl
public VHostItemImpl() -
VHostItemImpl
The constructor creates theVHostIteminstance from a given XML element. Please refer to the class documentation for more details of the XML element.- Parameters:
elem- is anElementobject with virtual domain settings.
-
VHostItemImpl
The constructor creates theVHostIteminstance for a given domain name with default values for all other parameters. By the default all domain parameters are set to true.- Parameters:
vhost- is aStringvalue with a domain name.
-
VHostItemImpl
The constructor creates theVHostIteminstance for a given domain name with default values for all other parameters. By the default all domain parameters are set to true.- Parameters:
vhost- is aStringvalue with a domain name.- Throws:
TigaseStringprepException- if the provided string causes stringprep processing errors.
-
-
Method Details
-
registerData
Deprecated. -
isDefault
protected boolean isDefault() -
setExtensionManager
-
addCommandFields
Description copied from interface:RepositoryItemThe method is used for handling ad-hoc commands. The 'empty' ad-hoc command packet is provided and the Item should fill it with fields for the user.- Specified by:
addCommandFieldsin interfaceRepositoryItem- Overrides:
addCommandFieldsin classRepositoryItemAbstract- Parameters:
packet- with empty ad-hoc command to fill with fields
-
equals
-
hashCode
public int hashCode() -
initFromCommand
Description copied from interface:RepositoryItemThe method used for handling ad-hoc commands. After a user fills all given field the ad-hoc command packet is passed back to the item to initialize it with data. Similar method to initFromElement(), but the data source is different.- Specified by:
initFromCommandin interfaceRepositoryItem- Overrides:
initFromCommandin classRepositoryItemAbstract- Parameters:
packet- with ad-hoc command filled by the user.
-
initFromElement
Description copied from interface:RepositoryItemThe item can be also initialized from a more complex repositories: XML repository or SQL database. In such a case more complex representation is prefered, possibly carrying more information about the item. The method is called to initialize the item with a data parsed from an XML representation of the repository.- Specified by:
initFromElementin interfaceRepositoryItem- Overrides:
initFromElementin classRepositoryItemAbstract- Parameters:
elem- XML Element with all the item initialization data.
-
initExtension
-
setKey
- Specified by:
setKeyin interfaceVHostItem- Specified by:
setKeyin classRepositoryItemAbstract
-
initFromPropertyString
Description copied from interface:RepositoryItemThe item can be initialized based on the data loaded from a configuration file. In such a case the item representation is usually very simplified as a list of parameters separated by a marker. Please note, usually each item is separated from another with a comma, therefore do not use a comma in the item property string. Double collon is commonly used alternative.- Specified by:
initFromPropertyStringin interfaceRepositoryItem- Parameters:
propString- is a property string to initialize the RepositoryItem.
-
toElement
Description copied from interface:RepositoryItemItem data can be stored in a more complex form than a simple property string. The XML Element can contain much more detailed information about the element than the simplified form and is used to store the repository item in more advanced repositories then just property file. XML repository or SQL database can keep many records for repository item with as much detailed information as needed.- Specified by:
toElementin interfaceRepositoryItem- Overrides:
toElementin classRepositoryItemAbstract- Returns:
- an XML Element with all the item initialization data.
-
toPropertyString
Description copied from interface:RepositoryItemThe item can be initialized based on the data loaded from a configuration file. In such a case the item representation is usually very simplified as a list of parameters separated by a marker. Please note, usually each item is separated from another with a comma, therefore do not use a comma in the item property string. Double collon is commonly used alternative.- Specified by:
toPropertyStringin interfaceRepositoryItem- Returns:
- a property string representing the repository item in a simplified form.
-
toString
-
toString
-
getComps
Returns an array with the server components names which should process packets sent to this domain ornull(default) if there is no specific component assigned to this domain. -
setComps
Sets an array with the server component names by which packets to this domain can be processed. Every local domain will be handled byVHostListenerwhich returnstrueforhandlesLocalDomains()method call and by all components set via this method.- Parameters:
comps- is anString[]array with server component names.
-
getC2SPortsAllowed
public int[] getC2SPortsAllowed()Returns an array with ports on which C2S connections for this VHosts are allowed.- Specified by:
getC2SPortsAllowedin interfaceVHostItem- Returns:
- a
int[]object with allowed C2S ports.
-
setC2SPortsAllowed
public void setC2SPortsAllowed(int[] ports) -
getData
Deprecated. -
getDomainFilter
- Specified by:
getDomainFilterin interfaceVHostItem
-
setDomainFilter
This method allow configure DomainFilterPolicy to be applied during packet filtering.- Parameters:
domainFilter- name of the DomainFilterPolicy to be applied
-
getDomainFilterDomains
- Specified by:
getDomainFilterDomainsin interfaceVHostItem
-
setDomainFilterDomains
This method allow specify list of domains that will be used for packet filtering when DomainFilteringPolicy is set to either LIST or BLACKLIST.- Parameters:
domainFilterDomains- array of domains to be applied during filtering
-
getElemName
- Specified by:
getElemNamein classRepositoryItemAbstract
-
getExtension
- Specified by:
getExtensionin interfaceVHostItem
-
getExtensions
- Specified by:
getExtensionsin interfaceVHostItem
-
getExtensionClasses
- Specified by:
getExtensionClassesin interfaceVHostItem
-
getKey
Description copied from interface:RepositoryItemReturns a unique key for the item in the repository. All items are stored in a memory cache which is a Map. And the key returned by this method is the item identifier in the Map.- Specified by:
getKeyin interfaceRepositoryItem- Returns:
- an Item key.
-
getMaxUsersNumber
- Specified by:
getMaxUsersNumberin interfaceVHostItem
-
setMaxUsersNumber
public void setMaxUsersNumber(long maxUsersNumber) -
getMessageForward
- Specified by:
getMessageForwardin interfaceVHostItem
-
setMessageForward
-
getMessageForwardAddress
- Specified by:
getMessageForwardAddressin interfaceVHostItem
-
getOtherDomainParams
This method allows to access the virtual domain other configuration parameters. This is future feature API and it is not used right now. It allows to access configuration parameters which are not specified at the time of API definition.- Specified by:
getOtherDomainParamsin interfaceVHostItem- Returns:
- a
Stringvalue with domain extra parameters.
-
setOtherDomainParams
This method allows to set extra configuration parameters for the virtual domain. This is future feature API and it is not used right now. It allows to access configuration parameters which are not specified at the time of API definition.- Parameters:
otherParams- is aStringvalue with domain extra parameters.
-
getPresenceForward
- Specified by:
getPresenceForwardin interfaceVHostItem
-
setPresenceForward
-
getPresenceForwardAddress
- Specified by:
getPresenceForwardAddressin interfaceVHostItem
-
getS2sSecret
- Specified by:
getS2sSecretin interfaceVHostItem
-
setS2sSecret
-
getTrustedJIDs
- Specified by:
getTrustedJIDsin interfaceVHostItem
-
getVhost
-
isAnonymousEnabled
public boolean isAnonymousEnabled()- Specified by:
isAnonymousEnabledin interfaceVHostItem
-
setAnonymousEnabled
public void setAnonymousEnabled(boolean value) -
isData
Deprecated. -
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean value) -
isRegisterEnabled
public boolean isRegisterEnabled()- Specified by:
isRegisterEnabledin interfaceVHostItem
-
setRegisterEnabled
public void setRegisterEnabled(boolean value) -
isTlsRequired
public boolean isTlsRequired()- Specified by:
isTlsRequiredin interfaceVHostItem
-
setTlsRequired
public void setTlsRequired(boolean value) -
setData
-
parseDataValue
-
setVHost
- Throws:
TigaseStringprepException
-
setVHost
-
getSaslAllowedMechanisms
- Specified by:
getSaslAllowedMechanismsin interfaceVHostItem
-
setSaslAllowedMechanisms
-
initializeFromDefaults
-