OW2 Consortium joram

Rev

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