/*
Copyright 2005-2007 Matthew J. Battey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
This software implements a Java interface to SAFMQ (see http://safmq.sourceforge.net).
Created on Mar 21, 2005
*/
package com.safmq;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.URI;
import java.util.Vector;
/**
* This class provides an interface to communicate with a SAFMQ message queue
* server. Typically instances of this class are constructed by the
* <code>MQBuilder</code> class, however constructing the class directly
* is also allowed.
*
* <p>Once constructed, this class may be used to construct
* instances of the class <code>MessageQueue</code> to abstract the connection
* interface to the message queue level.</p>
*
* <p><b>Note:</b> This class is not thread safe, and applications should
* take precautions to not initiate communications with a message queue via
* more than one (1) thread simultaneously.</p>
*
* @author Matt
* @see MQBuilder#buildConnection(URI,String,String)
* @see MessageQueue
*/
public class MQConnection {
final static String FORWARD_QUEUE_NAME = "_FORWARD_";
Socket s;
DataInputStream in;
DataOutputStream out;
int server_major_protocol_version;
int server_minor_protocol_version;
/**
* Result data from a call to <code>MQConnection.EnumerateQueues(Vector)</code>.
* Instances of this class are placed into the vector passed to
* <code>EnumerateQueues()</code> to detail the specifics of the queue.
*
* @author matt
* @see MQConnection#EnumerateQueues(Vector) MQConnection.EnumerateQueues(Vector)
*/
public class QueueData {
String name;
String owner;
/**
* Constructs the QueueData object from the queue's name and owner.
* @param name The name of the queue.
* @param owner The name of the queue's owner.
*/
QueueData(String name, String owner) {
this.name = name;
this.owner = owner;
}
/**
* Provides the queue's name.
* @return The queue's name.
*/
public String getName() {
return name;
}
/**
* Provides the queue's owner's name.
* @return The queue's owner's name.
*/
public String getOwner() {
return owner;
}
}
/**
* Contains an entity's permisison when accessing a queue.
*
* @author Matt
*/
public class QueuePermissions {
String entityName;
boolean isgroup;
boolean read;
boolean write;
boolean destroy;
boolean changeSecurity;
/**
* Constructs the QueuePermissions from the name of the entity and
* flags regarding its relationsihp with the queried queue. This object
* is used as a result to
* <code>MQConnection.queueEnumeratePermissions(String,Vector)</code>.
*
* @param entityName The name of the entity these permissions pertain to
* @param isgroup A flag indicating this entity is a group (otherwise
* a user)
* @param read A flag indicating whether this entity may read from
* the queue
* @param write A flag indicating whether this entity may write to
* the queue
* @param destroy A flag indicating whether this entity may remove the
* queue from the server
* @param changeSecurity A flag indicating whether this entity may change
* the security permissions of the queue
*/
QueuePermissions(String entityName, boolean isgroup, boolean read, boolean write, boolean destroy, boolean changeSecurity) {
this.entityName = entityName;
this.isgroup = isgroup;
this.read = read;
this.write = write;
this.destroy = destroy;
this.changeSecurity = changeSecurity;
}
/**
* Provides the name of the entity these permissions pertain to.
* @return Returns the name of the entity these permissions pertain to.
*/
public String getEntityName() {
return entityName;
}
/**
* Provides the flag whether this entity may remove the queue from the server.
*
* @return Returns the flag whether this entity may remove the queue from the server.
*/
public boolean getDestroy() {
return destroy;
}
/**
* Provids a flag whether this entity is a group.
* @return Returns a flag whether this entity is a group.
*/
public boolean getIsGroup() {
return isgroup;
}
/**
* Provides a flag whether this entity is allowed to read from the queue.
* @return Returns a flag whether this entity is allowed to read from the queue.
*/
public boolean getRead() {
return read;
}
/**
* Provides a flag whether this entity is allowed to write to the queue.
* @return Returns a flag whether this entity is allowed to write to the queue.
*/
public boolean getWrite() {
return write;
}
/**
* Provides a flag whether the entity is allowed to change the security for the queue.
* @return The a flag whether the entity is allowed to change the security for the queue.
*/
public boolean getChangeSecurity() {
return changeSecurity;
}
}
/**
* Result data from a call to <code>MQConnection.EnumerateUsers(Vector)</code>.
* Instances of this class are placed into the vector passed to
* <code>EnumerateUsers()</code> to detail the specifics of the user.
*
* @author matt
*/
public class UserDescription {
String name;
String description;
/**
* Constructs the object from the user's name and description.
*
* @param name The name of the user
* @param description The description of the user
*/
UserDescription(String name, String description) {
this.name = name;
this.description = description;
}
/**
* Provides the name of the user
* @return The name of the user
*/
public String getName() {
return name;
}
/**
* Provides the description of the user
* @return The description of the user
*/
public String getDescription() {
return description;
}
public boolean equals(Object o) {
return o != null && (this==o || ((o instanceof UserDescription) && ((UserDescription)o).getName().equals(getName())) || o.equals(getName()));
}
public String toString() {
return getClass().getName()+":["+getName()+"]";
}
}
/**
* For external use of UserDescriptions.
*
* @param name Name of the account
* @param desc Description of the account
* @return A newly allocated <code>UserDescription</code> object.
*/
public UserDescription genDesc(String name, String desc) {
return new UserDescription(name,desc);
}
/**
* Constructs the object from the name of the server, the tcp/ip port to be used
* the user's name and password.
*
* @param s A socket connected to the server.
* @param user The name of the user wishing to connect to the server
* @param password The password of the user wishing to connect to the server
* @throws MQException In the case that the supplied credentials are not accepted by
* the SAFMQ server. The value of <code>MQException.getErrorCode()</code>
* could be but is not limited to:
*<table border=0 cellpadding=3 cellspacing=0>
*<tr><td><code>Safmq.EC_LOGIN</code></td>
* <td>The login credentials supplied w
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
save and forward message queue (SAFMQ) (412个子文件)
java.policy.applet 141B
qmanager.bat 84B
strip_32.bmp 21KB
strip_16.bmp 5KB
openfolder.bmp 3KB
safmq_32.bmp 3KB
group_32.bmp 2KB
safmq_manager_32.bmp 2KB
user_32.bmp 2KB
queue_16.bmp 1KB
user_16.bmp 1KB
server_dc_16.bmp 1KB
server_u_16.bmp 1KB
group_16.bmp 1KB
server_c_16.bmp 1KB
safmq_manager_16.bmp 1KB
safmq_16.bmp 822B
groupedi.bmp 246B
uuidgen.c 8KB
mac_addr_dlpi.c 5KB
_getopt_long.c 4KB
uuidgenwin.c 970B
clean_cert 29B
safmq.conf 4KB
safmq-test.conf 4KB
safmq.conf 3KB
safmq-win.conf 3KB
app.config 74B
configure 11KB
safmq.cpp 83KB
MQConnection.cpp 48KB
safmqc.cpp 43KB
sslsocket.cpp 32KB
SafmqTest.cpp 31KB
QStorage.cpp 27KB
safmqclient.cpp 26KB
QAccessControl.cpp 25KB
Actor.cpp 22KB
tcpsocket.cpp 19KB
Folder.cpp 18KB
SAFMQLocalSettingsEditor.cpp 18KB
utilities.cpp 12KB
ntservice.cpp 11KB
logger.cpp 11KB
SafmqServerNode.cpp 10KB
ntservice.cpp 10KB
main.cpp 9KB
ServiceThread.cpp 9KB
NTSysLogger.cpp 9KB
MessageQueue.cpp 8KB
SysLogger.cpp 7KB
SAFMQManagerRoot.cpp 7KB
QManager.cpp 7KB
MQFactory.cpp 7KB
SSLServerThread.cpp 7KB
ForwardThread.cpp 6KB
ServerList.cpp 5KB
Log.cpp 5KB
CUserEditor.cpp 5KB
mptest.cpp 5KB
TransactionManager.cpp 5KB
ConfigData.cpp 5KB
GroupEditor.cpp 5KB
SystemDelivery.cpp 4KB
Command.cpp 4KB
ServiceLoginUtility.cpp 4KB
thdlib.cpp 4KB
GroupAddDialog.cpp 3KB
UserAddDialog.cpp 3KB
SafmqServiceInstaller.cpp 3KB
Signal.cpp 3KB
ServerThread.cpp 3KB
SAFMQManagerSnapin.cpp 3KB
AddActorDlg.cpp 3KB
param_config.cpp 3KB
DirectoryList.cpp 3KB
LocalSettings.cpp 3KB
PasswordDialog.cpp 2KB
SSLLockingWin32.cpp 2KB
SystemConnection.cpp 2KB
ActorPermsDlg.cpp 2KB
AddressParser.cpp 2KB
AssemblyInfo.cpp 2KB
NewServerDlg.cpp 2KB
ActorPerms.cpp 2KB
NewUserDlg.cpp 2KB
SSLLockingPthread.cpp 2KB
Mutex.cpp 2KB
NewGroupDlg.cpp 2KB
NewQueueDlg.cpp 2KB
ServerLoginDLg.cpp 1KB
AssemblyInfo.cpp 1KB
SafmqSecurityLogin.cpp 1KB
httpclient.cpp 1KB
server.cpp 1KB
StdAfx.cpp 1000B
safmq.clr++.cpp 948B
Stdafx.cpp 623B
Node.cpp 344B
stdafx.cpp 211B
共 412 条
- 1
- 2
- 3
- 4
- 5
qiubai1984
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0