Class User
- java.lang.Object
-
- org.objectweb.joram.client.jms.admin.AdministeredObject
-
- org.objectweb.joram.client.jms.admin.User
-
- All Implemented Interfaces:
Serializable,Referenceable,UserMBean
public class User extends AdministeredObject implements UserMBean
TheUserclass is a utility class needed for administering Joram users.The User class is a factory for Joram's users through the create static methods, the User object provides Joram specific administration and monitoring methods.
The User object provides methods to add and remove Interceptors, such an interceptor can handle each incoming and outgoing message. Interceptors can read and also modify the messages. This enables filtering, transformation or content enrichment, for example adding a property into the message. Also Interceptors can stop the Interceptor chain by simply returning false to their intercept method invocation, in this case the transmission of the message is stopped.
There is two distinct chains of interceptors:
- The first one "interceptors_in" handles each message that's entering the server (result of a send method on a connection from the selected user).
- The second one "interceptors_out" handles each message that's exiting the server (result of a receive method on a connection from the selected user).
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected StringJMXBeanNamestatic org.objectweb.util.monolog.api.Loggerlogger(package private) StringnameThe name of the user.(package private) StringproxyIdIdentifier of the user's proxy agent.static StringREDELIVERY_DELAYprivate static longserialVersionUIDdefine serialVersionUID for interoperability(package private) AdminWrapperwrapperAdministration wrapper used to perform administration stuff.-
Fields inherited from class org.objectweb.joram.client.jms.admin.AdministeredObject
rand
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddInterceptorIN(String interceptor, Properties properties)Add interceptorvoidaddInterceptorOUT(String interceptor, Properties properties)Add interceptorvoidaddInterceptorsIN(String interceptors)Add interceptorsvoidaddInterceptorsOUT(String interceptors)Add interceptorsvoidclearSubscription(String subName)static Usercreate(String name, String password)Admin method creating a user on the local server and instantiating the correspondingUserobject.static Usercreate(String name, String password, int serverId)Admin method creating a user for a given server and instantiating the correspondingUserobject.static Usercreate(String name, String password, int serverId, String identityClassName)Admin method creating a user for a given server and instantiating the correspondingUserobject.static Usercreate(String name, String password, int serverId, String identityClassName, Properties prop)Admin method creating a user for a given server and instantiating the correspondingUserobject.private static org.objectweb.joram.shared.security.IdentitycreateIdentity(String user, String passwd, String identityClassName)Create a user Identity.voiddelete()Removes this user.voiddeleteMessage(String subName, String msgId)private org.objectweb.joram.shared.admin.AdminReplydoRequest(org.objectweb.joram.shared.admin.AdminRequest request)Method actually sending anAdminRequestinstance to the platform and getting anAdminReplyinstance.booleanequals(Object o)Returnstrueif the parameter object is a Joram user wrapping the same Joram's User.voidfromReference(Reference ref)Restores the administered object from a naming reference.QueuegetDMQ()Monitoring method returning the dead message queue of this user, null if not set.StringgetDMQId()Monitoring method returning the dead message queue id of this user, null if not set.StringgetInterceptorsIN()Get interceptors.StringgetInterceptorsOUT()Get interceptors.static StringgetJMXBeanName(String base, User user)MessagegetMessage(String subName, String msgId)Returns a copy of a message of the subscription.StringgetMessageDigest(String subName, String msgId)PropertiesgetMessageHeader(String subName, String msgId)String[]getMessageIds(String subName)PropertiesgetMessageProperties(String subName, String msgId)StringgetName()Returns the user name.intgetNbMaxMsg(String subName)Monitoring method returning the nbMaxMsg of this subscription, -1 if no limit.StringgetProxyId()Returns the identifier of the user's proxy.SubscriptiongetSubscription(String subName)Returns a subscription.List<String>getSubscriptionList()used by MBean jmxSubscription[]getSubscriptions()Returns the subscriptions owned by a user.StringgetSubscriptionString(String subName)used by MBean jmxintgetThreshold()Returns the threshold for this user, -1 if not set.intgetThreshold(String subname)Returns the threshold for a particular subscription of this user, -1 if not set.protected AdminWrappergetWrapper()Returns the administration wrapper to use.inthashCode()MessagereadMessage(String subName, String msgId)Deprecated.StringregisterMBean(String base)voidremoveInterceptorsIN(String interceptors)Remove interceptorsvoidremoveInterceptorsOUT(String interceptors)Remove interceptorsvoidreplaceInterceptorIN(String newInterceptor, String oldInterceptor)Replace interceptor INvoidreplaceInterceptorIN(String newInterceptor, String oldInterceptor, Properties properties)Replace interceptor INvoidreplaceInterceptorOUT(String newInterceptor, String oldInterceptor)Replace interceptor OUTvoidreplaceInterceptorOUT(String newInterceptor, String oldInterceptor, Properties properties)Replace interceptor OUTvoidsetDMQ(Queue dmq)Admin method setting a given dead message queue for this user.voidsetDMQId(String dmqId)Admin method setting a given dead message queue for this user.voidsetNbMaxMsg(String subName, int nbMaxMsg)Admin method setting nbMaxMsg for this subscription.voidsetRedeliveryDelay(int redeliveryDelay)Set redeliveryDelay attribute.voidsetThreshold(int threshold)Admin method setting a given value as the threshold for this user.voidsetThreshold(String subname, int threshold)Admin method setting a given value as the threshold for a particular subscription of this user.voidsetWrapper(AdminWrapper wrapper)Sets the administration wrapper to use.voidtoReference(Reference ref)Sets the naming reference of a connection factory.StringtoString()Returns a string view of thisUserinstance.voidunregisterMBean()voidupdate(String newName, String newPassword)Admin method updating this user identification.voidupdate(String newName, String newPassword, String identityClassName)Admin method updating this user identification.-
Methods inherited from class org.objectweb.joram.client.jms.admin.AdministeredObject
getReference
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
REDELIVERY_DELAY
public static final String REDELIVERY_DELAY
- See Also:
- Constant Field Values
-
logger
public static org.objectweb.util.monolog.api.Logger logger
-
name
String name
The name of the user.
-
proxyId
String proxyId
Identifier of the user's proxy agent.
-
wrapper
AdminWrapper wrapper
Administration wrapper used to perform administration stuff.It is defined through AdminModule element, it is closed at the end of the script. if it is not defined the wrapper set at creation is used, if none the static AdminModule connection is used.
-
JMXBeanName
protected transient String JMXBeanName
-
-
Constructor Detail
-
User
public User()
-
User
public User(String name)
Constructs anUserinstance.- Parameters:
name- The name of the user.
-
-
Method Detail
-
toString
public String toString()
Returns a string view of thisUserinstance.
-
equals
public boolean equals(Object o)
Returnstrueif the parameter object is a Joram user wrapping the same Joram's User.
-
getWrapper
protected final AdminWrapper getWrapper() throws ConnectException
Returns the administration wrapper to use.- Returns:
- The wrapper to use.
- Throws:
ConnectException- if no wrapper is defined.
-
setWrapper
public void setWrapper(AdminWrapper wrapper)
Sets the administration wrapper to use. If not set the AdminModule static connection is used by default.- Parameters:
wrapper- The wrapper to use or null to unset.
-
doRequest
private final org.objectweb.joram.shared.admin.AdminReply doRequest(org.objectweb.joram.shared.admin.AdminRequest request) throws AdminException, ConnectExceptionMethod actually sending anAdminRequestinstance to the platform and getting anAdminReplyinstance.- Parameters:
request- the administration request to send- Returns:
- the reply message
- Throws:
ConnectException- If the connection to the platform fails.AdminException- If the platform's reply is invalid, or if the request failed.
-
create
public static User create(String name, String password, int serverId) throws ConnectException, AdminException
Admin method creating a user for a given server and instantiating the correspondingUserobject.If the user has already been set on this server, the method simply returns the corresponding
Userobject. Its fails if the target server does not belong to the platform, or if a proxy could not be deployed server side for a new user.Be careful this method use the static AdminModule connection.
- Parameters:
name- Name of the user.password- Password of the user.serverId- The identifier of the user's server.- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
create
public static User create(String name, String password) throws ConnectException, AdminException
Admin method creating a user on the local server and instantiating the correspondingUserobject.If the user has already been set on this server, the method simply returns the corresponding
Userobject. It fails if a proxy could not be deployed server side for a new user.Be careful this method use the static AdminModule connection.
- Parameters:
name- Name of the user.password- Password of the user.- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
create
public static User create(String name, String password, int serverId, String identityClassName) throws ConnectException, AdminException
Admin method creating a user for a given server and instantiating the correspondingUserobject.If the user has already been set on this server, the method simply returns the corresponding
Userobject. Its fails if the target server does not belong to the platform, or if a proxy could not be deployed server side for a new user.Be careful this method use the static AdminModule connection.
- Parameters:
name- Name of the user.password- Password of the user.serverId- The identifier of the user's server.identityClassName- user/password or JAAS... (default SimpleIdentity).- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
create
public static User create(String name, String password, int serverId, String identityClassName, Properties prop) throws ConnectException, AdminException
Admin method creating a user for a given server and instantiating the correspondingUserobject.If the user has already been set on this server, the method simply returns the corresponding
Userobject. Its fails if the target server does not belong to the platform, or if a proxy could not be deployed server side for a new user.Be careful this method use the static AdminModule connection.
- Parameters:
name- Name of the user.password- Password of the user.serverId- The identifier of the user's server.identityClassName- user/password or JAAS... (default SimpleIdentity).prop- properties- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
unregisterMBean
public void unregisterMBean()
-
createIdentity
private static org.objectweb.joram.shared.security.Identity createIdentity(String user, String passwd, String identityClassName) throws AdminException
Create a user Identity.- Parameters:
user- Name of the user.passwd- Password of the user.identityClassName- identity class name (simple, jaas).- Returns:
- identity user Identity.
- Throws:
AdminException
-
update
public void update(String newName, String newPassword) throws ConnectException, AdminException
Admin method updating this user identification.The request fails if the user does not exist server side, or if the new identification is already taken by a user on the same server.
- Parameters:
newName- The new name of the user.newPassword- The new password of the user.- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
update
public void update(String newName, String newPassword, String identityClassName) throws ConnectException, AdminException
Admin method updating this user identification.The request fails if the user does not exist server side, or if the new identification is already taken by a user on the same server.
- Parameters:
newName- The new name of the user.newPassword- The new password of the user.identityClassName- user/password or JAAS... (default SimpleIdentity).- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
delete
public void delete() throws ConnectException, AdminExceptionRemoves this user.- Specified by:
deletein interfaceUserMBean- Throws:
ConnectException- If the connection fails.AdminException- Never thrown.
-
setDMQ
public void setDMQ(Queue dmq) throws ConnectException, AdminException
Admin method setting a given dead message queue for this user.The request fails if the user is deleted server side.
- Parameters:
dmq- The dead message queue to be set.- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
setDMQId
public void setDMQId(String dmqId) throws ConnectException, AdminException
Admin method setting a given dead message queue for this user.The request fails if the user is deleted server side.
- Specified by:
setDMQIdin interfaceUserMBean- Parameters:
dmqId- The dead message queue Id to be set.- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
getDMQ
public Queue getDMQ() throws ConnectException, AdminException
Monitoring method returning the dead message queue of this user, null if not set.The request fails if the user is deleted server side.
- Throws:
ConnectException- If the administration connection is closed or broken.AdminException- If the request fails.
-
getDMQId
public String getDMQId() throws ConnectException, AdminException
Monitoring method returning the dead message queue id of this user, null if not set.The request fails if the destination is deleted server side.
- Specified by:
getDMQIdin interfaceUserMBean- Throws:
ConnectException- If the administration connection is closed or broken.AdminException- If the request fails.
-
setThreshold
public void setThreshold(int threshold) throws ConnectException, AdminExceptionAdmin method setting a given value as the threshold for this user.The request fails if the user is deleted server side.
- Specified by:
setThresholdin interfaceUserMBean- Parameters:
threshold- The threshold value to be set (-1 for unsetting previous value).- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
setThreshold
public void setThreshold(String subname, int threshold) throws ConnectException, AdminException
Admin method setting a given value as the threshold for a particular subscription of this user.The request fails if the user is deleted server side.
- Parameters:
subname- The subscription name.threshold- The threshold value to be set (-1 for unsetting previous value).- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
getThreshold
public int getThreshold() throws ConnectException, AdminExceptionReturns the threshold for this user, -1 if not set.The request fails if the user is deleted server side.
- Specified by:
getThresholdin interfaceUserMBean- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
getThreshold
public int getThreshold(String subname) throws ConnectException, AdminException
Returns the threshold for a particular subscription of this user, -1 if not set.The request fails if the user is deleted server side.
- Parameters:
subname- The subscription name.- Throws:
ConnectException- If the connection fails.AdminException- If the request fails.
-
setNbMaxMsg
public void setNbMaxMsg(String subName, int nbMaxMsg) throws ConnectException, AdminException
Admin method setting nbMaxMsg for this subscription.The request fails if the sub is deleted server side.
- Specified by:
setNbMaxMsgin interfaceUserMBean- Parameters:
subName- the name of the subscription.nbMaxMsg- nb Max of Message (-1 no limit).- Throws:
ConnectException- If the admin connection is closed or broken.AdminException- If the request fails.
-
getNbMaxMsg
public int getNbMaxMsg(String subName) throws ConnectException, AdminException
Monitoring method returning the nbMaxMsg of this subscription, -1 if no limit.The request fails if the sub is deleted server side.
- Specified by:
getNbMaxMsgin interfaceUserMBean- Parameters:
subName- the name of the subscription.- Throws:
ConnectException- If the admin connection is closed or broken.AdminException- If the request fails.
-
getSubscriptions
public Subscription[] getSubscriptions() throws AdminException, ConnectException
Returns the subscriptions owned by a user.- Specified by:
getSubscriptionsin interfaceUserMBean- Returns:
- The subscriptions owned by the user.
- Throws:
AdminException- If an error is raised by the administration operation.ConnectException- If the admin connection is not established.
-
getSubscriptionList
public List<String> getSubscriptionList() throws AdminException, ConnectException
used by MBean jmx- Throws:
AdminExceptionConnectException
-
getSubscription
public Subscription getSubscription(String subName) throws AdminException, ConnectException
Returns a subscription.- Specified by:
getSubscriptionin interfaceUserMBean- Parameters:
subName- the name of the subscription.- Returns:
- The subscription.
- Throws:
AdminException- If an error is raised by the administration operation.ConnectException- If the admin connection is not established.
-
getSubscriptionString
public String getSubscriptionString(String subName) throws AdminException, ConnectException
used by MBean jmx- Specified by:
getSubscriptionStringin interfaceUserMBean- Throws:
AdminExceptionConnectException
-
getMessageIds
public String[] getMessageIds(String subName) throws AdminException, ConnectException
- Specified by:
getMessageIdsin interfaceUserMBean- Throws:
AdminExceptionConnectException
-
getMessage
public Message getMessage(String subName, String msgId) throws AdminException, ConnectException, JMSException
Returns a copy of a message of the subscription.- Parameters:
subName- The name of the related subscription.msgId- The identifier of the message.- Returns:
- The message
- Throws:
AdminExceptionConnectExceptionJMSException
-
getMessageDigest
public String getMessageDigest(String subName, String msgId) throws AdminException, ConnectException, JMSException
- Specified by:
getMessageDigestin interfaceUserMBean- Throws:
AdminExceptionConnectExceptionJMSException
-
getMessageHeader
public Properties getMessageHeader(String subName, String msgId) throws AdminException, ConnectException, JMSException
- Specified by:
getMessageHeaderin interfaceUserMBean- Throws:
AdminExceptionConnectExceptionJMSException
-
getMessageProperties
public Properties getMessageProperties(String subName, String msgId) throws AdminException, ConnectException, JMSException
- Specified by:
getMessagePropertiesin interfaceUserMBean- Throws:
AdminExceptionConnectExceptionJMSException
-
addInterceptorsIN
public void addInterceptorsIN(String interceptors) throws ConnectException, AdminException
Add interceptors- Specified by:
addInterceptorsINin interfaceUserMBean- Parameters:
interceptors- list of string className interceptor (separate with ",")- Throws:
ConnectExceptionAdminException
-
addInterceptorIN
public void addInterceptorIN(String interceptor, Properties properties) throws ConnectException, AdminException
Add interceptor- Parameters:
interceptor- the className interceptorproperties- the interceptor properties- Throws:
ConnectExceptionAdminException
-
getInterceptorsIN
public String getInterceptorsIN() throws ConnectException, AdminException
Get interceptors.- Specified by:
getInterceptorsINin interfaceUserMBean- Returns:
- list of string className interceptor (separate with ",")
- Throws:
ConnectExceptionAdminException
-
removeInterceptorsIN
public void removeInterceptorsIN(String interceptors) throws ConnectException, AdminException
Remove interceptors- Specified by:
removeInterceptorsINin interfaceUserMBean- Parameters:
interceptors- list of string className interceptor (separate with ",")- Throws:
ConnectExceptionAdminException
-
addInterceptorsOUT
public void addInterceptorsOUT(String interceptors) throws ConnectException, AdminException
Add interceptors- Specified by:
addInterceptorsOUTin interfaceUserMBean- Parameters:
interceptors- list of string className interceptor (separate with ",")- Throws:
ConnectExceptionAdminException
-
addInterceptorOUT
public void addInterceptorOUT(String interceptor, Properties properties) throws ConnectException, AdminException
Add interceptor- Parameters:
interceptor- the className interceptorproperties- the interceptor properties- Throws:
ConnectExceptionAdminException
-
getInterceptorsOUT
public String getInterceptorsOUT() throws ConnectException, AdminException
Get interceptors.- Specified by:
getInterceptorsOUTin interfaceUserMBean- Returns:
- list of string className interceptor (separate with ",")
- Throws:
ConnectExceptionAdminException
-
removeInterceptorsOUT
public void removeInterceptorsOUT(String interceptors) throws ConnectException, AdminException
Remove interceptors- Specified by:
removeInterceptorsOUTin interfaceUserMBean- Parameters:
interceptors- list of string className interceptor (separate with ",")- Throws:
ConnectExceptionAdminException
-
replaceInterceptorIN
public void replaceInterceptorIN(String newInterceptor, String oldInterceptor) throws ConnectException, AdminException
Replace interceptor IN- Parameters:
newInterceptor- the new className interceptor.oldInterceptor- the old className interceptor.- Throws:
ConnectExceptionAdminException
-
replaceInterceptorIN
public void replaceInterceptorIN(String newInterceptor, String oldInterceptor, Properties properties) throws ConnectException, AdminException
Replace interceptor IN- Parameters:
newInterceptor- the new className interceptor.oldInterceptor- the old className interceptor.properties- the new interceptor properties- Throws:
ConnectExceptionAdminException
-
replaceInterceptorOUT
public void replaceInterceptorOUT(String newInterceptor, String oldInterceptor) throws ConnectException, AdminException
Replace interceptor OUT- Parameters:
newInterceptor- the new className interceptor.oldInterceptor- the old className interceptor.- Throws:
ConnectExceptionAdminException
-
replaceInterceptorOUT
public void replaceInterceptorOUT(String newInterceptor, String oldInterceptor, Properties properties) throws ConnectException, AdminException
Replace interceptor OUT- Parameters:
newInterceptor- the new className interceptor.oldInterceptor- the old className interceptor.properties- the new interceptor properties- Throws:
ConnectExceptionAdminException
-
setRedeliveryDelay
public void setRedeliveryDelay(int redeliveryDelay) throws ConnectException, AdminExceptionSet redeliveryDelay attribute.- Parameters:
redeliveryDelay- The delay use to wait before re-delivering messages after a deny.- Throws:
ConnectExceptionAdminException
-
readMessage
public Message readMessage(String subName, String msgId) throws AdminException, ConnectException, JMSException
Deprecated.
-
deleteMessage
public void deleteMessage(String subName, String msgId) throws AdminException, ConnectException
- Specified by:
deleteMessagein interfaceUserMBean- Throws:
AdminExceptionConnectException
-
clearSubscription
public void clearSubscription(String subName) throws AdminException, ConnectException
- Specified by:
clearSubscriptionin interfaceUserMBean- Throws:
AdminExceptionConnectException
-
getProxyId
public String getProxyId()
Returns the identifier of the user's proxy.- Specified by:
getProxyIdin interfaceUserMBean
-
toReference
public void toReference(Reference ref) throws NamingException
Sets the naming reference of a connection factory.- Specified by:
toReferencein classAdministeredObject- Throws:
NamingException
-
fromReference
public void fromReference(Reference ref) throws NamingException
Restores the administered object from a naming reference.- Specified by:
fromReferencein classAdministeredObject- Throws:
NamingException
-
-