OW2 Consortium joram

Rev

Rev 2795 | Rev 2889 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
861 fmaistre 1
/*
2
 * JORAM: Java(TM) Open Reliable Asynchronous Messaging
2634 afreyssin 3
 * Copyright (C) 2004 - 2008 ScalAgent Distributed Technologies
1669 afreyssin 4
 * Copyright (C) 2004 Bull SA
861 fmaistre 5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19
 * USA.
20
 *
1669 afreyssin 21
 * Initial developer(s): Frederic Maistre (Bull SA)
22
 * Contributor(s): ScalAgent Distributed Technologies
861 fmaistre 23
 */
24
package org.objectweb.joram.client.jms.admin;
25
 
2663 tachker 26
import java.net.ConnectException;
861 fmaistre 27
import java.util.Hashtable;
1331 tachker 28
import java.util.List;
2751 afreyssin 29
import java.util.Properties;
2663 tachker 30
import java.util.Vector;
861 fmaistre 31
 
1254 afreyssin 32
import javax.jms.JMSException;
2663 tachker 33
import javax.naming.NamingException;
34
import javax.naming.Reference;
35
import javax.naming.StringRefAddr;
861 fmaistre 36
 
1254 afreyssin 37
import org.objectweb.joram.client.jms.Message;
1669 afreyssin 38
import org.objectweb.joram.shared.JoramTracing;
2663 tachker 39
import org.objectweb.joram.shared.admin.AdminReply;
40
import org.objectweb.joram.shared.admin.ClearSubscription;
41
import org.objectweb.joram.shared.admin.CreateUserReply;
42
import org.objectweb.joram.shared.admin.CreateUserRequest;
43
import org.objectweb.joram.shared.admin.DeleteSubscriptionMessage;
44
import org.objectweb.joram.shared.admin.DeleteUser;
45
import org.objectweb.joram.shared.admin.GetSubscription;
46
import org.objectweb.joram.shared.admin.GetSubscriptionMessage;
47
import org.objectweb.joram.shared.admin.GetSubscriptionMessageIds;
48
import org.objectweb.joram.shared.admin.GetSubscriptionMessageIdsRep;
49
import org.objectweb.joram.shared.admin.GetSubscriptionMessageRep;
50
import org.objectweb.joram.shared.admin.GetSubscriptionRep;
51
import org.objectweb.joram.shared.admin.GetSubscriptions;
52
import org.objectweb.joram.shared.admin.GetSubscriptionsRep;
53
import org.objectweb.joram.shared.admin.Monitor_GetDMQSettings;
54
import org.objectweb.joram.shared.admin.Monitor_GetDMQSettingsRep;
55
import org.objectweb.joram.shared.admin.Monitor_GetNbMaxMsg;
56
import org.objectweb.joram.shared.admin.Monitor_GetNbMaxMsgRep;
57
import org.objectweb.joram.shared.admin.SetNbMaxMsg;
58
import org.objectweb.joram.shared.admin.SetUserDMQ;
59
import org.objectweb.joram.shared.admin.SetUserThreshold;
60
import org.objectweb.joram.shared.admin.UpdateUser;
61
import org.objectweb.joram.shared.security.Identity;
2813 afreyssin 62
import org.objectweb.joram.shared.security.SimpleIdentity;
1331 tachker 63
import org.objectweb.util.monolog.api.BasicLevel;
64
 
2663 tachker 65
import fr.dyade.aaa.util.management.MXWrapper;
66
 
861 fmaistre 67
/**
68
 * The <code>User</code> class is a utility class needed for administering
69
 * JORAM users.
70
 */
1669 afreyssin 71
public class User extends AdministeredObject implements UserMBean {
1977 tachker 72
  /**
73
   *
74
   */
75
  private static final long serialVersionUID = 1L;
861 fmaistre 76
  /** The name of the user. */
904 fmaistre 77
  String name;
861 fmaistre 78
  /** Identifier of the user's proxy agent. */
904 fmaistre 79
  String proxyId;
861 fmaistre 80
 
1254 afreyssin 81
  // Used by jndi2 SoapObjectHelper
82
  public User() {}
861 fmaistre 83
 
84
  /**
85
   * Constructs an <code>User</code> instance.
86
   *
87
   * @param name  The name of the user.
88
   * @param proxyId  Identifier of the user's proxy agent.
89
   */
1254 afreyssin 90
  public User(String name, String proxyId) {
861 fmaistre 91
    this.name = name;
92
    this.proxyId = proxyId;
93
  }
94
 
95
 
96
  /** Returns a string view of this <code>User</code> instance. */
1788 afreyssin 97
  public String toString() {
861 fmaistre 98
    return "User[" + name + "]:" + proxyId;
99
  }
100
 
883 fmaistre 101
 
102
  /** Returns the user name. */
1788 afreyssin 103
  public String getName() {
883 fmaistre 104
    return name;
105
  }
106
 
107
  /** Provides a reliable way to compare <code>User</code> instances. */
1788 afreyssin 108
  public boolean equals(Object o) {
883 fmaistre 109
    if (! (o instanceof User))
110
      return false;
111
 
112
    User other = (User) o;
113
 
114
    return other.proxyId ==proxyId;
115
  }
861 fmaistre 116
 
117
  /**
2795 surrel 118
   * Admin method creating a user for a given server and instantiating the
861 fmaistre 119
   * corresponding <code>User</code> object.
120
   * <p>
121
   * If the user has already been set on this server, the method simply
122
   * returns the corresponding <code>User</code> object. Its fails if the
123
   * target server does not belong to the platform, or if a proxy could not
124
   * be deployed server side for a new user.
125
   *
126
   * @param name  Name of the user.
127
   * @param password  Password of the user.
128
   * @param serverId  The identifier of the user's server.
129
   *
130
   * @exception ConnectException  If the connection fails.
131
   * @exception AdminException  If the request fails.
132
   */
133
  public static User create(String name, String password, int serverId)
1331 tachker 134
    throws ConnectException, AdminException {
2813 afreyssin 135
    return create(name, password, serverId, SimpleIdentity.class.getName());
861 fmaistre 136
  }
137
 
138
  /**
2795 surrel 139
   * Admin method creating a user on the local server and instantiating the
861 fmaistre 140
   * corresponding <code>User</code> object.
141
   * <p>
142
   * If the user has already been set on this server, the method simply
143
   * returns the corresponding <code>User</code> object. It fails if a
144
   * proxy could not be deployed server side for a new user.
145
   *
146
   * @param name  Name of the user.
147
   * @param password  Password of the user.
148
   *
149
   * @exception ConnectException  If the connection fails.
150
   * @exception AdminException  If the request fails.
151
   */
152
  public static User create(String name, String password)
1788 afreyssin 153
         throws ConnectException, AdminException {
2813 afreyssin 154
    return create(name, password, AdminModule.getLocalServerId(), SimpleIdentity.class.getName());
861 fmaistre 155
  }
156
 
157
  /**
2795 surrel 158
   * Admin method creating a user for a given server and instantiating the
2663 tachker 159
   * corresponding <code>User</code> object.
160
   * <p>
161
   * If the user has already been set on this server, the method simply
162
   * returns the corresponding <code>User</code> object. Its fails if the
163
   * target server does not belong to the platform, or if a proxy could not
164
   * be deployed server side for a new user.
165
   *
166
   * @param name  Name of the user.
167
   * @param password  Password of the user.
168
   * @param serverId  The identifier of the user's server.
2795 surrel 169
   * @param identityClassName user/password or JAAS... (default SimpleIdentity).
2663 tachker 170
   *
171
   * @exception ConnectException  If the connection fails.
172
   * @exception AdminException  If the request fails.
173
   */
174
  public static User create(String name, String password, int serverId, String identityClassName)
175
    throws ConnectException, AdminException {
176
    Identity identity = createIdentity(name, password, identityClassName);
177
    AdminReply reply = AdminModule.doRequest(
178
      new CreateUserRequest(identity, serverId));
179
    User user = new User(name, ((CreateUserReply) reply).getProxId());
180
    try {
181
      MXWrapper.registerMBean(user,
182
                              "joramClient",
183
                              "type=User,name="+ name + "[" + user.getProxyId() + "]");
184
    } catch (Exception e) {
185
      JoramTracing.dbgClient.log(BasicLevel.WARN, "registerMBean",e);
186
    }
187
    return user;
188
  }
189
 
190
  /**
191
   * Create a user Identity.
192
   *
193
   * @param user              Name of the user.
194
   * @param passwd            Password of the user.
195
   * @param identityClassName identity class name (simple, jaas).
196
   * @return identity user Identity.
197
   * @throws AdminException
198
   */
199
  private static Identity createIdentity(String user, String passwd, String identityClassName) throws AdminException {
200
    Identity identity = null;
201
    try {
202
      Class clazz = Class.forName(identityClassName);
203
      identity = (Identity) clazz.newInstance();
204
      if (passwd != null)
205
        identity.setIdentity(user, passwd);
206
      else
207
        identity.setUserName(user);
208
    } catch (Exception e) {
209
      throw new AdminException(e.getMessage());
210
    }
211
    return identity;
212
  }
213
 
214
  /**
861 fmaistre 215
   * Admin method updating this user identification.
216
   * <p>
217
   * The request fails if the user does not exist server side, or if the new
218
   * identification is already taken by a user on the same server.
219
   *
220
   * @param newName  The new name of the user.
221
   * @param newPassword  The new password of the user.
222
   *
223
   * @exception ConnectException  If the connection fails.
224
   * @exception AdminException  If the request fails.
225
   */
226
  public void update(String newName, String newPassword)
1331 tachker 227
    throws ConnectException, AdminException {
2813 afreyssin 228
    update(newName, newPassword, SimpleIdentity.class.getName());
2663 tachker 229
  }
230
 
231
  /**
232
   * Admin method updating this user identification.
233
   * <p>
234
   * The request fails if the user does not exist server side, or if the new
235
   * identification is already taken by a user on the same server.
236
   *
237
   * @param newName  The new name of the user.
238
   * @param newPassword  The new password of the user.
2795 surrel 239
   * @param identityClassName user/password or JAAS... (default SimpleIdentity).
2663 tachker 240
   *
241
   * @exception ConnectException  If the connection fails.
242
   * @exception AdminException  If the request fails.
243
   */
244
  public void update(String newName, String newPassword, String identityClassName)
245
    throws ConnectException, AdminException {
246
    Identity newIdentity = createIdentity(newName, newPassword, identityClassName);
247
    AdminModule.doRequest(new UpdateUser(name, proxyId, newIdentity));
861 fmaistre 248
    name = newName;
249
  }
250
 
251
  /**
252
   * Removes this user.
253
   *
254
   * @exception ConnectException  If the connection fails.
255
   * @exception AdminException  Never thrown.
256
   */
1331 tachker 257
  public void delete() throws ConnectException, AdminException {
861 fmaistre 258
    AdminModule.doRequest(new DeleteUser(name, proxyId));
1331 tachker 259
    try {
260
      MXWrapper.unregisterMBean("joramClient",
261
                                "type=User,name="+name+
262
                                "["+proxyId+"]");
263
    } catch (Exception e) {
264
      if (JoramTracing.dbgClient.isLoggable(BasicLevel.DEBUG))
265
        JoramTracing.dbgClient.log(BasicLevel.DEBUG,
266
                                   "unregisterMBean",e);
267
    }
861 fmaistre 268
  }
269
 
270
  /**
271
   * Admin method setting a given dead message queue for this user.
272
   * <p>
273
   * The request fails if the user is deleted server side.
274
   *
275
   * @param dmq  The dead message queue to be set.
276
   *
277
   * @exception ConnectException  If the connection fails.
278
   * @exception AdminException  If the request fails.
279
   */
1788 afreyssin 280
  public void setDMQ(DeadMQueue dmq) throws ConnectException, AdminException {
1873 tachker 281
    setDMQId(dmq.getName());
861 fmaistre 282
  }
283
 
284
  /**
1873 tachker 285
   * Admin method setting a given dead message queue for this user.
286
   * <p>
287
   * The request fails if the user is deleted server side.
288
   *
289
   * @param dmqId  The dead message queue Id to be set.
290
   *
291
   * @exception ConnectException  If the connection fails.
292
   * @exception AdminException  If the request fails.
293
   */
294
  public void setDMQId(String dmqId) throws ConnectException, AdminException {
295
    AdminModule.doRequest(new SetUserDMQ(proxyId, dmqId));
296
  }
297
 
298
  /**
861 fmaistre 299
   * Admin method setting a given value as the threshold for this user.
300
   * <p>
301
   * The request fails if the user is deleted server side.
302
   *
2746 afreyssin 303
   * @param threshold  The threshold value to be set (-1 for unsetting
304
   *                   previous value).
861 fmaistre 305
   *
306
   * @exception ConnectException  If the connection fails.
307
   * @exception AdminException  If the request fails.
308
   */
1788 afreyssin 309
  public void setThreshold(int thresh) throws ConnectException, AdminException {
861 fmaistre 310
    AdminModule.doRequest(new SetUserThreshold(proxyId, thresh));
311
  }
312
 
313
  /**
314
   * Returns the dead message queue for this user, null if not set.
315
   * <p>
316
   * The request fails if the user is deleted server side.
317
   *
318
   * @exception ConnectException  If the connection fails.
319
   * @exception AdminException  If the request fails.
320
   */
1788 afreyssin 321
  public DeadMQueue getDMQ() throws ConnectException, AdminException {
861 fmaistre 322
    Monitor_GetDMQSettings request;
323
    request = new Monitor_GetDMQSettings(proxyId);
324
    Monitor_GetDMQSettingsRep reply;
325
    reply = (Monitor_GetDMQSettingsRep) AdminModule.doRequest(request);
326
 
327
    if (reply.getDMQName() == null)
328
      return null;
329
    else
330
      return new DeadMQueue(reply.getDMQName());
331
  }
332
 
333
  /**
1873 tachker 334
   * Returns the dead message queue Id for this user, null if not set.
335
   * <p>
336
   * The request fails if the user is deleted server side.
337
   *
338
   * @exception ConnectException  If the connection fails.
339
   * @exception AdminException  If the request fails.
340
   */
341
  public String getDMQId() throws ConnectException, AdminException {
342
    DeadMQueue dmq = getDMQ();
343
    if (dmq == null)
344
      return null;
345
    else
346
      return dmq.getName();
347
  }
348
 
349
  /**
861 fmaistre 350
   * Returns the threshold for this user, -1 if not set.
351
   * <p>
352
   * The request fails if the user is deleted server side.
353
   *
354
   * @exception ConnectException  If the connection fails.
355
   * @exception AdminException  If the request fails.
356
   */
1788 afreyssin 357
  public int getThreshold() throws ConnectException, AdminException {
861 fmaistre 358
    Monitor_GetDMQSettings request;
359
    request = new Monitor_GetDMQSettings(proxyId);
360
    Monitor_GetDMQSettingsRep reply;
361
    reply = (Monitor_GetDMQSettingsRep) AdminModule.doRequest(request);
362
 
363
    if (reply.getThreshold() == null)
364
      return -1;
365
    else
366
      return reply.getThreshold().intValue();
367
  }
368
 
1254 afreyssin 369
  /**
1331 tachker 370
   * Admin method setting nbMaxMsg for this subscription.
371
   * <p>
372
   * The request fails if the sub is deleted server side.
373
   *
374
   * @param subName the name of the subscription.
375
   * @param nbMaxMsg  nb Max of Message (-1 no limit).
376
   *
377
   * @exception ConnectException  If the admin connection is closed or broken.
378
   * @exception AdminException  If the request fails.
379
   */
380
  public void setNbMaxMsg(String subName, int nbMaxMsg)
381
    throws ConnectException, AdminException {
2587 afreyssin 382
//  TODO: Subscription sub = getSubscription(subName);
1331 tachker 383
    AdminModule.doRequest(new SetNbMaxMsg(proxyId, nbMaxMsg, subName));
384
  }
385
 
386
  /**
387
   * Monitoring method returning the nbMaxMsg of this subscription, -1 if no limit.
388
   * <p>
389
   * The request fails if the sub is deleted server side.
390
   *
391
   * @param subName the name of the subscription.
392
   *
393
   * @exception ConnectException  If the admin connection is closed or broken.
394
   * @exception AdminException  If the request fails.
395
   */
396
  public int getNbMaxMsg(String subName)
397
    throws ConnectException, AdminException {
2587 afreyssin 398
//  TODO: Subscription sub = getSubscription(subName);
1331 tachker 399
    Monitor_GetNbMaxMsg request = new Monitor_GetNbMaxMsg(proxyId, subName);
400
    Monitor_GetNbMaxMsgRep reply;
401
    reply = (Monitor_GetNbMaxMsgRep) AdminModule.doRequest(request);
402
    return reply.getNbMaxMsg();
403
  }
404
 
405
  /**
1254 afreyssin 406
   * Returns the subscriptions owned by a user.
407
   *
408
   * @param serverId the identifier of the server where the user has been
409
   *        created.
410
   *
411
   * @param userName name of the user.
412
   *
413
   * @exception AdminException If an error is raised by the
414
   *                           administration operation.
415
   *
416
   * @exception ConnectException  If the admin connection is not established.
417
   */
418
  public Subscription[] getSubscriptions()
419
    throws AdminException, ConnectException {
420
    GetSubscriptionsRep reply =
421
      (GetSubscriptionsRep)AdminModule.doRequest(
422
        new GetSubscriptions(proxyId));
423
    String[] subNames = reply.getSubNames();
424
    String[] topicIds = reply.getTopicIds();
425
    int[] messageCounts = reply.getMessageCounts();
426
    boolean[] durable = reply.getDurable();
427
    Subscription[] res = new Subscription[subNames.length];
428
    for (int i = 0; i < res.length; i++) {
429
      res[i] = new Subscription(subNames[i],
430
                                topicIds[i],
431
                                messageCounts[i],
432
                                durable[i]);
433
    }
434
    return res;
435
  }
436
 
1331 tachker 437
  /** used by MBean jmx */
438
  public List getSubscriptionList()
439
    throws AdminException, ConnectException {
440
    Vector list = new Vector();
441
    Subscription[] sub = getSubscriptions();
442
    for (int i = 0; i < sub.length; i++) {
443
      list.add(sub[i].toString());
444
    }
445
    return list;
446
  }
447
 
1254 afreyssin 448
  /**
449
   * Returns a subscription.
450
   *
451
   * @param serverId the identifier of the server where the user
452
   * owner of the subscription has been created.
453
   *
454
   * @param userName name of the user that owns the subscription.
455
   *
456
   * @param subName the name of the subscription.
457
   *
458
   * @exception AdminException If an error is raised by the
459
   *                           administration operation.
460
   *
461
   * @exception ConnectException  If the admin connection is not established.
462
   */
2587 afreyssin 463
  public Subscription getSubscription(String subName) throws AdminException, ConnectException {
464
    GetSubscriptionRep reply = (GetSubscriptionRep) AdminModule.doRequest(new GetSubscription(proxyId, subName));
465
    return new Subscription(subName,
466
                            reply.getTopicId(),
467
                            reply.getMessageCount(),
468
                            reply.getDurable());
1254 afreyssin 469
  }
470
 
2587 afreyssin 471
  public String getSubscriptionString(String subName) throws AdminException, ConnectException {
472
    return getSubscription(subName).toString();
1331 tachker 473
  }
474
 
2587 afreyssin 475
  public String[] getMessageIds(String subName) throws AdminException, ConnectException {
2751 afreyssin 476
    GetSubscriptionMessageIdsRep reply =
477
      (GetSubscriptionMessageIdsRep) AdminModule.doRequest(new GetSubscriptionMessageIds(proxyId, subName));
1254 afreyssin 478
    return reply.getMessageIds();
479
  }
480
 
2751 afreyssin 481
  public Message getMessage(String subName,
482
                            String msgId) throws AdminException, ConnectException, JMSException {
483
    GetSubscriptionMessageRep reply =
484
      (GetSubscriptionMessageRep) AdminModule.doRequest(new GetSubscriptionMessage(proxyId, subName, msgId, true));
485
    return Message.wrapMomMessage(null, reply.getMessage());
486
  }
487
 
488
  public String getMessageDigest(String subName,
489
                                 String msgId) throws AdminException, ConnectException, JMSException {
490
    GetSubscriptionMessageRep reply =
491
      (GetSubscriptionMessageRep) AdminModule.doRequest(new GetSubscriptionMessage(proxyId, subName, msgId, true));
492
    Message msg =  Message.wrapMomMessage(null, reply.getMessage());
493
 
494
    StringBuffer strbuf = new StringBuffer();
495
    strbuf.append("Message: ").append(msg.getJMSMessageID());
496
    strbuf.append("\n\tTo: ").append(msg.getJMSDestination());
497
    strbuf.append("\n\tCorrelationId: ").append(msg.getJMSCorrelationID());
498
    strbuf.append("\n\tDeliveryMode: ").append(msg.getJMSDeliveryMode());
499
    strbuf.append("\n\tExpiration: ").append(msg.getJMSExpiration());
500
    strbuf.append("\n\tPriority: ").append(msg.getJMSPriority());
501
    strbuf.append("\n\tRedelivered: ").append(msg.getJMSRedelivered());
502
    strbuf.append("\n\tReplyTo: ").append(msg.getJMSReplyTo());
503
    strbuf.append("\n\tTimestamp: ").append(msg.getJMSTimestamp());
504
    strbuf.append("\n\tType: ").append(msg.getJMSType());
505
    return strbuf.toString();
506
}
507
 
508
  public Properties getMessageHeader(String subName,
509
                                     String msgId) throws AdminException, ConnectException, JMSException {
510
    GetSubscriptionMessageRep reply =
511
      (GetSubscriptionMessageRep) AdminModule.doRequest(new GetSubscriptionMessage(proxyId, subName, msgId, false));
512
    Message msg =  Message.wrapMomMessage(null, reply.getMessage());
513
 
514
    Properties prop = new Properties();
515
    prop.setProperty("JMSMessageID", msg.getJMSMessageID());
516
    prop.setProperty("JMSDestination", msg.getJMSDestination().toString());
517
    if (msg.getJMSCorrelationID() != null)
518
      prop.setProperty("JMSCorrelationID", msg.getJMSCorrelationID());
519
    prop.setProperty("JMSDeliveryMode",
520
                     new Integer(msg.getJMSDeliveryMode()).toString());
521
    prop.setProperty("JMSExpiration",
522
                     new Long(msg.getJMSExpiration()).toString());
523
    prop.setProperty("JMSPriority",
524
                     new Integer(msg.getJMSPriority()).toString());
525
    prop.setProperty("JMSRedelivered",
526
                     new Boolean(msg.getJMSRedelivered()).toString());
527
    if (msg.getJMSReplyTo() != null)
528
      prop.setProperty("JMSReplyTo", msg.getJMSReplyTo().toString());
529
    prop.setProperty("JMSTimestamp",
530
                     new Long(msg.getJMSTimestamp()).toString());
531
    if (msg.getJMSType() != null)
532
      prop.setProperty("JMSType", msg.getJMSType());
533
 
534
    // Adds optional header properties
535
    msg.getOptionalHeader(prop);
536
 
537
    return prop;
538
}
539
 
540
public Properties getMessageProperties(String subName,
541
                                       String msgId)
542
  throws AdminException, ConnectException, JMSException {
543
  GetSubscriptionMessageRep reply =
544
    (GetSubscriptionMessageRep) AdminModule.doRequest(new GetSubscriptionMessage(proxyId, subName, msgId, false));
545
  Message msg =  Message.wrapMomMessage(null, reply.getMessage());
546
 
547
  Properties prop = new Properties();
548
  msg.getProperties(prop);
549
 
550
  return prop;
551
}
552
 
553
  /**
554
   * @deprecated
555
   * @see org.objectweb.joram.client.jms.admin.UserMBean#readMessage(java.lang.String, java.lang.String)
556
   */
1669 afreyssin 557
  public Message readMessage(String subName,
558
                             String msgId) throws AdminException, ConnectException, JMSException {
2751 afreyssin 559
    return getMessage(subName, msgId);
1254 afreyssin 560
  }
561
 
562
  public void deleteMessage(
563
    String subName,
564
    String msgId)
565
    throws AdminException, ConnectException {
566
    AdminModule.doRequest(
567
      new DeleteSubscriptionMessage(proxyId,
568
                                    subName,
569
                                    msgId));
570
  }
571
 
572
  public void clearSubscription(String subName)
573
    throws AdminException, ConnectException {
574
    AdminModule.doRequest(
575
      new ClearSubscription(proxyId,
576
                            subName));
577
  }
578
 
861 fmaistre 579
 
580
  /** Returns the identifier of the user's proxy. */
1788 afreyssin 581
  public String getProxyId() {
861 fmaistre 582
    return proxyId;
583
  }
584
 
1788 afreyssin 585
  /** Sets the naming reference of a connection factory. */
586
  public void toReference(Reference ref) throws NamingException {
861 fmaistre 587
    ref.add(new StringRefAddr("user.name", name));
588
    ref.add(new StringRefAddr("user.id", proxyId));
589
  }
590
 
1788 afreyssin 591
  /** Restores the administered object from a naming reference. */
592
  public void fromReference(Reference ref) throws NamingException {
593
    name = (String) ref.get("user.name").getContent();
594
    proxyId = (String) ref.get("user.id").getContent();
595
  }
596
 
861 fmaistre 597
  /**
2795 surrel 598
   * Codes an <code>User</code> instance as a Hashtable for traveling
861 fmaistre 599
   * through the SOAP protocol.
600
   */
601
  public Hashtable code() {
1254 afreyssin 602
    Hashtable h = new Hashtable();
861 fmaistre 603
    h.put("name",name);
604
    h.put("proxyId",proxyId);
605
    return h;
606
  }
607
 
608
  /**
2795 surrel 609
   * Decodes an <code>User</code> which traveled through the SOAP protocol.
861 fmaistre 610
   */
1254 afreyssin 611
  public void decode(Hashtable h) {
612
    name = (String) h.get("name");
613
    proxyId = (String) h.get("proxyId");
861 fmaistre 614
  }
615
}