Moving to root below branch label

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2005 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2005-12-08 07:13:07 +00:00
commit e1e6508fec
1095 changed files with 230566 additions and 0 deletions

View File

@@ -0,0 +1,253 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.filesys.smb.dcerpc.info;
import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
import org.alfresco.filesys.smb.dcerpc.DCEBufferException;
import org.alfresco.filesys.smb.dcerpc.DCEReadable;
/**
* Connection Information Class
* <p>
* Contains the details of a connection on a remote server.
*/
public class ConnectionInfo implements DCEReadable
{
// Information level
private int m_infoLevel;
// Connection id and type
private int m_connId;
private int m_connType;
// Count of open files
private int m_openFiles;
// Number of users
private int m_numUsers;
// Time connected, in minutes
private int m_connTime;
// User name
private String m_userName;
// Client name
private String m_clientName;
/**
* Default constructor
*/
public ConnectionInfo()
{
}
/**
* Class constructor
*
* @param infoLevel int
*/
public ConnectionInfo(int infoLevel)
{
m_infoLevel = infoLevel;
}
/**
* Get the information level
*
* @return int
*/
public final int getInformationLevel()
{
return m_infoLevel;
}
/**
* Get the connection id
*
* @return int
*/
public final int getConnectionId()
{
return m_connId;
}
/**
* Get the connection type
*
* @return int
*/
public final int getConnectionType()
{
return m_connType;
}
/**
* Get the number of open files on the connection
*
* @return int
*/
public final int getOpenFileCount()
{
return m_openFiles;
}
/**
* Return the number of users on the connection
*
* @return int
*/
public final int getNumberOfUsers()
{
return m_numUsers;
}
/**
* Return the connection time in seconds
*
* @return int
*/
public final int getConnectionTime()
{
return m_connTime;
}
/**
* Return the user name
*
* @return String
*/
public final String getUserName()
{
return m_userName;
}
/**
* Return the client name
*
* @return String
*/
public final String getClientName()
{
return m_clientName;
}
/**
* Read a connection information object from a DCE buffer
*
* @param buf DCEBuffer
* @throws DCEBufferException
*/
public void readObject(DCEBuffer buf) throws DCEBufferException
{
// Unpack the connection information
switch (getInformationLevel())
{
// Information level 0
case 0:
m_connId = buf.getInt();
m_userName = null;
m_clientName = null;
break;
// Information level 1
case 1:
m_connId = buf.getInt();
m_connType = buf.getInt();
m_openFiles = buf.getInt();
m_numUsers = buf.getInt();
m_connTime = buf.getInt();
m_userName = buf.getPointer() != 0 ? "" : null;
m_clientName = buf.getPointer() != 0 ? "" : null;
break;
}
}
/**
* Read the strings for this connection information from the DCE/RPC buffer
*
* @param buf DCEBuffer
* @exception DCEBufferException
*/
public void readStrings(DCEBuffer buf) throws DCEBufferException
{
// Read the strings for this connection information
switch (getInformationLevel())
{
// Information level 1
case 1:
if (getUserName() != null)
m_userName = buf.getString(DCEBuffer.ALIGN_INT);
if (getClientName() != null)
m_clientName = buf.getString(DCEBuffer.ALIGN_INT);
break;
}
}
/**
* Return the connection information as a string
*
* @return String
*/
public String toString()
{
StringBuffer str = new StringBuffer();
str.append("[ID=");
str.append(getConnectionId());
str.append(":Level=");
str.append(getInformationLevel());
str.append(":");
if (getInformationLevel() == 1)
{
str.append("Type=");
str.append(getConnectionType());
str.append(",OpenFiles=");
str.append(getOpenFileCount());
str.append(",NumUsers=");
str.append(getNumberOfUsers());
str.append(",Connected=");
str.append(getConnectionTime());
str.append(",User=");
str.append(getUserName());
str.append(",Client=");
str.append(getClientName());
}
str.append("]");
return str.toString();
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.filesys.smb.dcerpc.info;
import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
import org.alfresco.filesys.smb.dcerpc.DCEBufferException;
import org.alfresco.filesys.smb.dcerpc.DCEList;
import org.alfresco.filesys.smb.dcerpc.DCEReadable;
/**
* Connection Information List Class
*/
public class ConnectionInfoList extends DCEList
{
/**
* Default constructor
*/
public ConnectionInfoList()
{
super();
}
/**
* Class constructor
*
* @param buf DCEBuffer
* @exception DCEBufferException
*/
public ConnectionInfoList(DCEBuffer buf) throws DCEBufferException
{
super(buf);
}
/**
* Create a new connection information object
*
* @return DCEReadable
*/
protected DCEReadable getNewObject()
{
return new ConnectionInfo(getInformationLevel());
}
}

View File

@@ -0,0 +1,338 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.filesys.smb.dcerpc.info;
import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
import org.alfresco.filesys.smb.dcerpc.DCEBufferException;
import org.alfresco.filesys.smb.dcerpc.DCEReadable;
import org.alfresco.filesys.smb.dcerpc.DCEWriteable;
/**
* Server Information Class
*/
public class ServerInfo implements DCEWriteable, DCEReadable
{
// Information levels supported
public static final int InfoLevel0 = 0;
public static final int InfoLevel1 = 1;
public static final int InfoLevel101 = 101;
public static final int InfoLevel102 = 102;
// Server platform ids
public final static int PLATFORM_OS2 = 400;
public final static int PLATFORM_NT = 500;
// Information level
private int m_infoLevel;
// Server information
private int m_platformId;
private String m_name;
private int m_verMajor;
private int m_verMinor;
private int m_srvType;
private String m_comment;
/**
* Default constructor
*/
public ServerInfo()
{
}
/**
* Class constructor
*
* @param lev int
*/
public ServerInfo(int lev)
{
m_infoLevel = lev;
}
/**
* Get the information level
*
* @return int
*/
public final int getInformationLevel()
{
return m_infoLevel;
}
/**
* Get the server name
*
* @return String
*/
public final String getServerName()
{
return m_name;
}
/**
* Get the server comment
*
* @return String
*/
public final String getComment()
{
return m_comment;
}
/**
* Get the server platform id
*
* @return int
*/
public final int getPlatformId()
{
return m_platformId;
}
/**
* Get the servev major version
*
* @return int
*/
public final int getMajorVersion()
{
return m_verMajor;
}
/**
* Get the server minor version
*
* @return int
*/
public final int getMinorVersion()
{
return m_verMinor;
}
/**
* Get the server type flags
*
* @return int
*/
public final int getServerType()
{
return m_srvType;
}
/**
* Set the server name
*
* @param name String
*/
public final void setServerName(String name)
{
m_name = name;
}
/**
* Set the server comment
*
* @param comment String
*/
public final void setComment(String comment)
{
m_comment = comment;
}
/**
* Set the information level
*
* @param lev int
*/
public final void setInformationLevel(int lev)
{
m_infoLevel = lev;
}
/**
* Set the server platform id
*
* @param id int
*/
public final void setPlatformId(int id)
{
m_platformId = id;
}
/**
* Set the server type flags
*
* @param typ int
*/
public final void setServerType(int typ)
{
m_srvType = typ;
}
/**
* Set the server version
*
* @param verMajor int
* @param verMinor int
*/
public final void setVersion(int verMajor, int verMinor)
{
m_verMajor = verMajor;
m_verMinor = verMinor;
}
/**
* Clear the string values
*/
protected final void clearStrings()
{
// Clear the string values
m_name = null;
m_comment = null;
}
/**
* Read the server information from the DCE/RPC buffer
*
* @param buf DCEBuffer
* @exception DCEBufferException
*/
public void readObject(DCEBuffer buf) throws DCEBufferException
{
// Clear the string values
clearStrings();
// Read the server information details
m_infoLevel = buf.getInt();
buf.skipPointer();
// Unpack the server information
switch (getInformationLevel())
{
// Information level 0
case InfoLevel0:
if (buf.getPointer() != 0)
m_name = buf.getString(DCEBuffer.ALIGN_INT);
break;
// Information level 101/1
case InfoLevel1:
case InfoLevel101:
m_platformId = buf.getInt();
buf.skipPointer();
m_verMajor = buf.getInt();
m_verMinor = buf.getInt();
m_srvType = buf.getInt();
buf.skipPointer();
m_name = buf.getString(DCEBuffer.ALIGN_INT);
m_comment = buf.getString();
break;
// Level 102
case InfoLevel102:
break;
}
}
/**
* Read the strings for this object from the DCE/RPC buffer
*
* @param buf DCEBuffer
* @exception DCEBufferException
*/
public void readStrings(DCEBuffer buf) throws DCEBufferException
{
// Not required
}
/**
* Write a server information structure
*
* @param buf DCEBuffer
* @param strBuf DCEBuffer
*/
public void writeObject(DCEBuffer buf, DCEBuffer strBuf)
{
// Output the server information structure
buf.putInt(getInformationLevel());
buf.putPointer(true);
// Output the required information level
switch (getInformationLevel())
{
// Information level 0
case InfoLevel0:
buf.putPointer(getServerName() != null);
if (getServerName() != null)
strBuf.putString(getServerName(), DCEBuffer.ALIGN_INT, true);
break;
// Information level 101/1
case InfoLevel1:
case InfoLevel101:
buf.putInt(getPlatformId());
buf.putPointer(true);
buf.putInt(getMajorVersion());
buf.putInt(getMinorVersion());
buf.putInt(getServerType());
buf.putPointer(true);
strBuf.putString(getServerName(), DCEBuffer.ALIGN_INT, true);
strBuf.putString(getComment() != null ? getComment() : "", DCEBuffer.ALIGN_INT, true);
break;
// Level 102
case InfoLevel102:
break;
}
}
/**
* Return the server information as a string
*
* @return String
*/
public String toString()
{
return "";
}
}

View File

@@ -0,0 +1,610 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.filesys.smb.dcerpc.info;
import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
import org.alfresco.filesys.smb.dcerpc.DCEBufferException;
import org.alfresco.filesys.smb.dcerpc.DCEReadable;
import org.alfresco.filesys.smb.dcerpc.DCEWriteable;
/**
* Share Information Class
* <p>
* Holds the details of a share from a DCE/RPC request/response.
*/
public class ShareInfo implements DCEWriteable, DCEReadable
{
// Information levels supported
public static final int InfoLevel0 = 0;
public static final int InfoLevel1 = 1;
public static final int InfoLevel2 = 2;
public static final int InfoLevel502 = 502;
public static final int InfoLevel1005 = 1005;
// Share types
public static final int Disk = 0x00000000;
public static final int PrintQueue = 0x00000001;
public static final int Device = 0x00000002;
public static final int IPC = 0x00000003;
public static final int Hidden = 0x80000000;
// Share permission flags
public static final int Read = 0x01;
public static final int Write = 0x02;
public static final int Create = 0x04;
public static final int Execute = 0x08;
public static final int Delete = 0x10;
public static final int Attrib = 0x20;
public static final int Perm = 0x40;
public static final int All = 0x7F;
// Information level
private int m_infoLevel;
// Share details
private String m_name;
private int m_type;
private String m_comment;
private int m_permissions;
private int m_maxUsers;
private int m_curUsers;
private String m_path;
private String m_password;
private int m_flags;
/**
* Class constructor
*/
public ShareInfo()
{
}
/**
* Class constructor
*
* @param lev int
*/
public ShareInfo(int lev)
{
m_infoLevel = lev;
}
/**
* Class constructor
*
* @param lev int
* @param name String
* @param typ int
* @param comment String
*/
public ShareInfo(int lev, String name, int typ, String comment)
{
m_infoLevel = lev;
m_name = name;
m_type = typ;
m_comment = comment;
}
/**
* Return the information level
*
* @return int
*/
public final int getInformationLevel()
{
return m_infoLevel;
}
/**
* Return the share name
*
* @return String
*/
public final String getName()
{
return m_name;
}
/**
* Return the share type
*
* @return int
*/
public final int getType()
{
return m_type;
}
/**
* Get the share flags
*
* @return int
*/
public final int getFlags()
{
return m_flags;
}
/**
* Check if this share is a hidden/admin share
*
* @return boolean
*/
public final boolean isHidden()
{
return (m_type & Hidden) != 0 ? true : false;
}
/**
* Check if this is a disk share
*
* @return boolean
*/
public final boolean isDisk()
{
return (m_type & 0x0000FFFF) == Disk ? true : false;
}
/**
* Check if this is a printer share
*
* @return boolean
*/
public final boolean isPrinter()
{
return (m_type & 0x0000FFFF) == PrintQueue ? true : false;
}
/**
* Check if this is a device share
*
* @return boolean
*/
public final boolean isDevice()
{
return (m_type & 0x0000FFFF) == Device ? true : false;
}
/**
* Check if this is a named pipe share
*
* @return boolean
*/
public final boolean isNamedPipe()
{
return (m_type & 0x0000FFFF) == IPC ? true : false;
}
/**
* Return the share permissions
*
* @return int
*/
public final int getPermissions()
{
return m_permissions;
}
/**
* Return the maximum number of users allowed
*
* @return int
*/
public final int getMaximumUsers()
{
return m_maxUsers;
}
/**
* Return the current number of users
*
* @return int
*/
public final int getCurrentUsers()
{
return m_curUsers;
}
/**
* Return the share local path
*
* @return String
*/
public final String getPath()
{
return m_path;
}
/**
* Return the share password
*
* @return String
*/
public final String getPassword()
{
return m_password;
}
/**
* Return the share type as a string
*
* @return String
*/
public final String getTypeAsString()
{
String typ = "";
switch (getType() & 0xFF)
{
case Disk:
typ = "Disk";
break;
case PrintQueue:
typ = "Printer";
break;
case Device:
typ = "Device";
break;
case IPC:
typ = "IPC";
break;
}
return typ;
}
/**
* Return the comment
*
* @return String
*/
public final String getComment()
{
return m_comment;
}
/**
* Set the information level
*
* @param lev int
*/
public final void setInformationLevel(int lev)
{
m_infoLevel = lev;
}
/**
* Set the share type
*
* @param int typ
*/
public final void setType(int typ)
{
m_type = typ;
}
/**
* Set the share flags
*
* @param flags int
*/
public final void setFlags(int flags)
{
m_flags = flags;
}
/**
* Set the share name
*
* @param name String
*/
public final void setName(String name)
{
m_name = name;
}
/**
* Set the share comment
*
* @param str String
*/
public final void setComment(String str)
{
m_comment = str;
}
/**
* Set the share permissions
*
* @param perm int
*/
public final void setPermissions(int perm)
{
m_permissions = perm;
}
/**
* Set the maximum number of users
*
* @param maxUsers int
*/
public final void setMaximumUsers(int maxUsers)
{
m_maxUsers = maxUsers;
}
/**
* Set the current number of users
*
* @param curUsers int
*/
public final void setCurrentUsers(int curUsers)
{
m_curUsers = curUsers;
}
/**
* Set the local path
*
* @param path String
*/
public final void setPath(String path)
{
m_path = path;
}
/**
* Clear all string values
*/
protected final void clearStrings()
{
// Clear the string values
m_name = null;
m_comment = null;
m_path = null;
m_password = null;
}
/**
* Read the share information from the DCE/RPC buffer
*
* @param buf DCEBuffer
* @exception DCEBufferException
*/
public void readObject(DCEBuffer buf) throws DCEBufferException
{
// Clear all existing strings
clearStrings();
// Unpack the share information
switch (getInformationLevel())
{
// Information level 0
case InfoLevel0:
m_name = buf.getPointer() != 0 ? "" : null;
break;
// Information level 1
case InfoLevel1:
m_name = buf.getPointer() != 0 ? "" : null;
m_type = buf.getInt();
m_comment = buf.getPointer() != 0 ? "" : null;
break;
// Information level 2
case InfoLevel2:
m_name = buf.getPointer() != 0 ? "" : null;
m_type = buf.getInt();
m_comment = buf.getPointer() != 0 ? "" : null;
m_permissions = buf.getInt();
m_maxUsers = buf.getInt();
m_curUsers = buf.getInt();
m_path = buf.getPointer() != 0 ? "" : null;
m_password = buf.getPointer() != 0 ? "" : null;
break;
// Information level 502
case InfoLevel502:
m_name = buf.getPointer() != 0 ? "" : null;
m_type = buf.getInt();
m_comment = buf.getPointer() != 0 ? "" : null;
m_permissions = buf.getInt();
m_maxUsers = buf.getInt();
m_curUsers = buf.getInt();
m_path = buf.getPointer() != 0 ? "" : null;
m_password = buf.getPointer() != 0 ? "" : null;
buf.skipBytes(4); // Reserved value
// Security descriptor
break;
}
}
/**
* Read the strings for this share from the DCE/RPC buffer
*
* @param buf DCEBuffer
* @exception DCEBufferException
*/
public void readStrings(DCEBuffer buf) throws DCEBufferException
{
// Read the strings for this share information
switch (getInformationLevel())
{
// Information level 0
case InfoLevel0:
if (getName() != null)
m_name = buf.getString(DCEBuffer.ALIGN_INT);
break;
// Information level 1
case InfoLevel1:
if (getName() != null)
m_name = buf.getString(DCEBuffer.ALIGN_INT);
if (getComment() != null)
m_comment = buf.getString(DCEBuffer.ALIGN_INT);
break;
// Information level 2 and 502
case InfoLevel2:
case InfoLevel502:
if (getName() != null)
m_name = buf.getString(DCEBuffer.ALIGN_INT);
if (getComment() != null)
m_comment = buf.getString(DCEBuffer.ALIGN_INT);
if (getPath() != null)
m_path = buf.getString(DCEBuffer.ALIGN_INT);
if (getPassword() != null)
m_password = buf.getString(DCEBuffer.ALIGN_INT);
break;
}
}
/**
* Write the share information to the DCE buffer
*
* @param buf DCEBuffer
* @param strBuf DCEBuffer
*/
public void writeObject(DCEBuffer buf, DCEBuffer strBuf)
{
// Pack the share information
switch (getInformationLevel())
{
// Information level 0
case InfoLevel0:
buf.putPointer(true);
strBuf.putString(getName(), DCEBuffer.ALIGN_INT, true);
break;
// Information level 1
case InfoLevel1:
buf.putPointer(true);
buf.putInt(getType());
buf.putPointer(true);
strBuf.putString(getName(), DCEBuffer.ALIGN_INT, true);
strBuf.putString(getComment() != null ? getComment() : "", DCEBuffer.ALIGN_INT, true);
break;
// Information level 2
case InfoLevel2:
buf.putPointer(true);
buf.putInt(getType());
buf.putPointer(true);
buf.putInt(getPermissions());
buf.putInt(getMaximumUsers());
buf.putInt(getCurrentUsers());
buf.putPointer(getPath() != null);
buf.putPointer(getPassword() != null);
strBuf.putString(getName(), DCEBuffer.ALIGN_INT, true);
strBuf.putString(getComment() != null ? getComment() : "", DCEBuffer.ALIGN_INT, true);
if (getPath() != null)
strBuf.putString(getPath(), DCEBuffer.ALIGN_INT, true);
if (getPassword() != null)
strBuf.putString(getPassword(), DCEBuffer.ALIGN_INT, true);
break;
// Information level 502
case InfoLevel502:
buf.putPointer(true);
buf.putInt(getType());
buf.putPointer(true);
buf.putInt(getPermissions());
buf.putInt(getMaximumUsers());
buf.putInt(getCurrentUsers());
buf.putPointer(getPath() != null);
buf.putPointer(getPassword() != null);
buf.putInt(0); // Reserved, must be zero
buf.putPointer(false); // Security descriptor
strBuf.putString(getName(), DCEBuffer.ALIGN_INT, true);
strBuf.putString(getComment() != null ? getComment() : "", DCEBuffer.ALIGN_INT, true);
if (getPath() != null)
strBuf.putString(getPath(), DCEBuffer.ALIGN_INT, true);
if (getPassword() != null)
strBuf.putString(getPassword(), DCEBuffer.ALIGN_INT, true);
break;
// Information level 1005
case InfoLevel1005:
buf.putInt(getFlags());
break;
}
}
/**
* Return the share information as a string
*
* @return String
*/
public String toString()
{
StringBuffer str = new StringBuffer();
str.append("[");
str.append(getName());
str.append(":");
str.append(getInformationLevel());
str.append(":");
if (getInformationLevel() == 1)
{
str.append("0x");
str.append(Integer.toHexString(getType()));
str.append(",");
str.append(getComment());
}
str.append("]");
return str.toString();
}
}

View File

@@ -0,0 +1,111 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.filesys.smb.dcerpc.info;
import java.util.Vector;
import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
import org.alfresco.filesys.smb.dcerpc.DCEBufferException;
import org.alfresco.filesys.smb.dcerpc.DCEList;
import org.alfresco.filesys.smb.dcerpc.DCEReadable;
/**
* Server Share Information List Class
* <p>
* Holds the details for a DCE/RPC share enumeration request or response.
*/
public class ShareInfoList extends DCEList
{
/**
* Default constructor
*/
public ShareInfoList()
{
super();
}
/**
* Class constructor
*
* @param buf DCEBuffer
* @exception DCEBufferException
*/
public ShareInfoList(DCEBuffer buf) throws DCEBufferException
{
super(buf);
}
/**
* Class constructor
*
* @param infoLevel int
*/
public ShareInfoList(int infoLevel)
{
super(infoLevel);
}
/**
* Return share information object from the list
*
* @param idx int
* @return ShareInfo
*/
public final ShareInfo getShare(int idx)
{
return (ShareInfo) getElement(idx);
}
/**
* Create a new share information object
*
* @return DCEReadable
*/
protected DCEReadable getNewObject()
{
return new ShareInfo(getInformationLevel());
}
/**
* Add a share to the list
*
* @param share ShareInfo
*/
public final void addShare(ShareInfo share)
{
// Check if the share list is valid
if (getList() == null)
setList(new Vector());
// Add the share
getList().add(share);
}
/**
* Set the share information list
*
* @param list Vector
*/
public final void setShareList(Vector list)
{
setList(list);
}
}

View File

@@ -0,0 +1,773 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.filesys.smb.dcerpc.info;
import java.util.BitSet;
import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
import org.alfresco.filesys.smb.dcerpc.DCEBufferException;
import org.alfresco.filesys.smb.dcerpc.DCEReadable;
/**
* User Information Class
* <p>
* Contains the details of a user account on a remote server.
*/
public class UserInfo implements DCEReadable
{
// Information levels supported
public static final int InfoLevel1 = 1;
public static final int InfoLevel3 = 3;
public static final int InfoLevel21 = 21;
// public static final int InfoLevel2 = 2;
// public static final int InfoLevel4 = 4;
// public static final int InfoLevel5 = 5;
// public static final int InfoLevel6 = 6;
// public static final int InfoLevel7 = 7;
// public static final int InfoLevel8 = 8;
// public static final int InfoLevel9 = 9;
// public static final int InfoLevel10 = 10;
// public static final int InfoLevel11 = 11;
// public static final int InfoLevel12 = 12;
// public static final int InfoLevel13 = 13;
// public static final int InfoLevel14 = 14;
// public static final int InfoLevel16 = 16;
// public static final int InfoLevel17 = 17;
// public static final int InfoLevel20 = 20;
// Account privilege levels
public static final int PrivGuest = 0;
public static final int PrivUser = 1;
public static final int PrivAdmin = 2;
// Account operator privileges
public static final int OperPrint = 0;
public static final int OperComm = 1;
public static final int OperServer = 2;
public static final int OperAccounts = 3;
// Account flags
private static final int AccountDisabled = 0x0001;
private static final int AccountHomeDirRequired = 0x0002;
private static final int AccountPasswordNotRequired = 0x0004;
private static final int AccountTemporaryDuplicate = 0x0008;
private static final int AccountNormal = 0x0010;
private static final int AccountMNSUser = 0x0020;
private static final int AccountDomainTrust = 0x0040;
private static final int AccountWorkstationTrust = 0x0080;
private static final int AccountServerTrust = 0x0100;
private static final int AccountPasswordNotExpire = 0x0200;
private static final int AccountAutoLocked = 0x0400;
// Information level
private int m_infoLevel;
// User information
private String m_userName;
private int m_pwdAge;
private int m_priv;
private String m_homeDir;
private String m_comment;
private String m_description;
private String m_accComment;
private int m_flags;
private String m_scriptPath;
// private int m_authFlags;
private String m_fullName;
private String m_appParam;
private String m_workStations;
private long m_lastLogon;
private long m_lastLogoff;
private long m_acctExpires;
private long m_lastPwdChange;
private long m_pwdCanChange;
private long m_pwdMustchange;
// private int m_maxStorage;
private int m_unitsPerWeek;
private byte[] m_logonHoursRaw;
private BitSet m_logonHours;
private int m_badPwdCount;
private int m_numLogons;
private String logonSrv;
private int m_countryCode;
private int m_codePage;
private int m_userRID;
private int m_groupRID;
// private SID m_userSID;
private String m_profile;
private String m_homeDirDrive;
private int m_pwdExpired;
private String m_callBack;
private String m_unknown1;
private String m_unknown2;
private String m_unknown3;
/**
* Default constructor
*/
public UserInfo()
{
}
/**
* Class constructor
*
* @param lev int
*/
public UserInfo(int lev)
{
m_infoLevel = lev;
}
/**
* Get the information level
*
* @return int
*/
public final int getInformationLevel()
{
return m_infoLevel;
}
/**
* Return the logon server name
*
* @return String
*/
public final String getLogonServer()
{
return logonSrv;
}
/**
* Return the date/time the account expires, or NTTime.Infinity if it does not expire
*
* @return long
*/
public final long getAccountExpires()
{
return m_acctExpires;
}
/**
* Return the application parameter string
*
* @return String
*/
public final String getApplicationParameter()
{
return m_appParam;
}
/**
* Return the bad password count
*
* @return int
*/
public final int getBadPasswordCount()
{
return m_badPwdCount;
}
/**
* Return the code page
*
* @return int
*/
public final int getCodePage()
{
return m_codePage;
}
/**
* Return the account comment
*
* @return String
*/
public final String getComment()
{
return m_comment;
}
/**
* Return the account description
*
* @return String
*/
public final String getDescription()
{
return m_description;
}
/**
* Return the country code
*
* @return int
*/
public final int getCountryCode()
{
return m_countryCode;
}
/**
* Return the account flags
*
* @return int
*/
public final int getFlags()
{
return m_flags;
}
/**
* Check if the account is disabled
*
* @return boolean
*/
public final boolean isDisabled()
{
return (m_flags & AccountDisabled) != 0 ? true : false;
}
/**
* Check if the account does not require a home directory
*
* @return boolean
*/
public final boolean requiresHomeDirectory()
{
return (m_flags & AccountHomeDirRequired) != 0 ? true : false;
}
/**
* Check if the account does not require a password
*
* @return boolean
*/
public final boolean requiresPassword()
{
return (m_flags & AccountPasswordNotRequired) != 0 ? false : true;
}
/**
* Check if the account is a normal user account
*
* @return boolean
*/
public final boolean isNormalUser()
{
return (m_flags & AccountNormal) != 0 ? true : false;
}
/**
* Check if the account is a domain trust account
*
* @return boolean
*/
public final boolean isDomainTrust()
{
return (m_flags & AccountDomainTrust) != 0 ? true : false;
}
/**
* Check if the account is a workstation trust account
*
* @return boolean
*/
public final boolean isWorkstationTrust()
{
return (m_flags & AccountWorkstationTrust) != 0 ? true : false;
}
/**
* Check if the account is a server trust account
*
* @return boolean
*/
public final boolean isServerTrust()
{
return (m_flags & AccountServerTrust) != 0 ? true : false;
}
/**
* Check if the account password expires
*
* @return boolean
*/
public final boolean passwordExpires()
{
return (m_flags & AccountPasswordNotExpire) != 0 ? false : true;
}
/**
* Check if the account is auto locked
*
* @return boolean
*/
public final boolean isAutoLocked()
{
return (m_flags & AccountAutoLocked) != 0 ? true : false;
}
/**
* Return the full account name
*
* @return String
*/
public final String getFullName()
{
return m_fullName;
}
/**
* Return the group resource id
*
* @return int
*/
public final int getGroupRID()
{
return m_groupRID;
}
/**
* Return the home directory path
*
* @return String
*/
public final String getHomeDirectory()
{
return m_homeDir;
}
/**
* Return the home drive
*
* @return String
*/
public final String getHomeDirectoryDrive()
{
return m_homeDirDrive;
}
/**
* Return the date/time of last logoff
*
* @return long
*/
public final long getLastLogoff()
{
return m_lastLogoff;
}
/**
* Return the date/time of last logon, to this server
*
* @return long
*/
public final long getLastLogon()
{
return m_lastLogon;
}
/**
* Return the allowed logon hours bit set
*
* @return BitSet
*/
public final BitSet getLogonHours()
{
return m_logonHours;
}
/**
* Return the number of logons for the account, to this server
*
* @return int
*/
public final int numberOfLogons()
{
return m_numLogons;
}
/**
* Return the account provileges
*
* @return int
*/
public final int getPrivileges()
{
return m_priv;
}
/**
* Return the profile path
*
* @return String
*/
public final String getProfile()
{
return m_profile;
}
/**
* Return the password expired flag
*
* @return int
*/
public final int getPasswordExpired()
{
return m_pwdExpired;
}
/**
* Return the logon script path
*
* @return String
*/
public final String getLogonScriptPath()
{
return m_scriptPath;
}
/**
* Return the allowed units per week
*
* @return int
*/
public final int getUnitsPerWeek()
{
return m_unitsPerWeek;
}
/**
* Return the account name
*
* @return String
*/
public final String getUserName()
{
return m_userName;
}
/**
* Return the user resource id
*
* @return int
*/
public final int getUserRID()
{
return m_userRID;
}
/**
* Return the workstations that the account is allowed to logon from
*
* @return String
*/
public final String getWorkStations()
{
return m_workStations;
}
/**
* Return the date/time of the last password change
*
* @return long
*/
public final long getLastPasswordChange()
{
return m_lastPwdChange;
}
/**
* Return the date/time that the password must be changed by
*
* @return long
*/
public final long getPasswordMustChangeBy()
{
return m_pwdMustchange;
}
/**
* Clear all string values
*/
private final void clearStrings()
{
// Clear the string values
m_appParam = null;
m_comment = null;
m_fullName = null;
m_homeDir = null;
m_homeDirDrive = null;
m_profile = null;
m_scriptPath = null;
m_userName = null;
m_workStations = null;
m_description = null;
m_accComment = null;
}
/**
* Read the user information from the DCE buffer
*
* @param buf DCEBuffer
* @throws DCEBufferException
*/
public void readObject(DCEBuffer buf) throws DCEBufferException
{
// clear all existing string values
clearStrings();
// Unpack the user information
int ival = 0;
int pval = 0;
switch (getInformationLevel())
{
// Information level 1
case InfoLevel1:
m_userName = buf.getCharArrayPointer();
m_fullName = buf.getCharArrayPointer();
m_groupRID = buf.getInt();
m_description = buf.getCharArrayPointer();
m_comment = buf.getCharArrayPointer();
break;
// Information level 3
case InfoLevel3:
m_userName = buf.getCharArrayPointer();
m_fullName = buf.getCharArrayPointer();
m_userRID = buf.getInt();
m_groupRID = buf.getInt();
m_homeDir = buf.getCharArrayPointer();
m_homeDirDrive = buf.getCharArrayPointer();
m_scriptPath = buf.getCharArrayPointer();
m_profile = buf.getCharArrayPointer();
m_workStations = buf.getCharArrayPointer();
m_lastLogon = buf.getNTTime();
m_lastLogoff = buf.getNTTime();
m_lastPwdChange = buf.getNTTime();
buf.skipBytes(8); // allow password change NT time
buf.skipBytes(8); // force password change NT time
ival = buf.getShort(DCEBuffer.ALIGN_INT);
pval = buf.getPointer();
if (ival != 0 && pval != 0)
m_logonHoursRaw = new byte[ival / 8];
m_badPwdCount = buf.getShort();
m_numLogons = buf.getShort();
m_flags = buf.getInt();
break;
// Information level 21
case InfoLevel21:
m_lastLogon = buf.getNTTime();
m_lastLogoff = buf.getNTTime();
m_lastPwdChange = buf.getNTTime();
m_acctExpires = buf.getNTTime();
m_pwdCanChange = buf.getNTTime();
m_pwdMustchange = buf.getNTTime();
m_userName = buf.getCharArrayPointer();
m_fullName = buf.getCharArrayPointer();
m_homeDir = buf.getCharArrayPointer();
m_homeDirDrive = buf.getCharArrayPointer();
m_scriptPath = buf.getCharArrayPointer();
m_profile = buf.getCharArrayPointer();
m_description = buf.getCharArrayPointer();
m_workStations = buf.getCharArrayPointer();
m_accComment = buf.getCharArrayPointer();
m_callBack = buf.getCharArrayPointer();
m_unknown1 = buf.getCharArrayPointer();
m_unknown2 = buf.getCharArrayPointer();
m_unknown3 = buf.getCharArrayPointer();
buf.skipBytes(8); // buffer length and pointer
m_userRID = buf.getInt();
m_groupRID = buf.getInt();
m_flags = buf.getInt();
buf.getInt(); // fields present flags
ival = buf.getShort(DCEBuffer.ALIGN_INT);
pval = buf.getPointer();
if (ival != 0 && pval != 0)
m_logonHoursRaw = new byte[ival / 8];
m_badPwdCount = buf.getShort();
m_numLogons = buf.getShort();
m_countryCode = buf.getShort();
m_codePage = buf.getShort();
buf.skipBytes(2); // NT and LM pwd set flags
m_pwdExpired = buf.getByte(DCEBuffer.ALIGN_INT);
break;
}
}
/**
* Read the strings for this user information from the DCE buffer
*
* @param buf DCEBuffer
* @throws DCEBufferException
*/
public void readStrings(DCEBuffer buf) throws DCEBufferException
{
// Read the strings/structures for this user information
switch (getInformationLevel())
{
// Information level 1
case InfoLevel1:
m_userName = buf.getCharArrayNotNull(m_userName, DCEBuffer.ALIGN_INT);
m_fullName = buf.getCharArrayNotNull(m_fullName, DCEBuffer.ALIGN_INT);
m_description = buf.getCharArrayNotNull(m_description, DCEBuffer.ALIGN_INT);
m_comment = buf.getCharArrayNotNull(m_comment, DCEBuffer.ALIGN_INT);
break;
// Information level 3
case InfoLevel3:
m_userName = buf.getCharArrayNotNull(m_userName, DCEBuffer.ALIGN_INT);
m_fullName = buf.getCharArrayNotNull(m_fullName, DCEBuffer.ALIGN_INT);
m_homeDir = buf.getCharArrayNotNull(m_homeDir, DCEBuffer.ALIGN_INT);
m_homeDirDrive = buf.getCharArrayNotNull(m_homeDirDrive, DCEBuffer.ALIGN_INT);
m_scriptPath = buf.getCharArrayNotNull(m_scriptPath, DCEBuffer.ALIGN_INT);
m_profile = buf.getCharArrayNotNull(m_profile, DCEBuffer.ALIGN_INT);
m_workStations = buf.getCharArrayNotNull(m_workStations, DCEBuffer.ALIGN_INT);
m_logonHoursRaw = buf.getByteStructure(m_logonHoursRaw);
break;
// Information level 21
case InfoLevel21:
m_userName = buf.getCharArrayNotNull(m_userName, DCEBuffer.ALIGN_INT);
m_fullName = buf.getCharArrayNotNull(m_fullName, DCEBuffer.ALIGN_INT);
m_homeDir = buf.getCharArrayNotNull(m_homeDir, DCEBuffer.ALIGN_INT);
m_homeDirDrive = buf.getCharArrayNotNull(m_homeDirDrive, DCEBuffer.ALIGN_INT);
m_scriptPath = buf.getCharArrayNotNull(m_scriptPath, DCEBuffer.ALIGN_INT);
m_profile = buf.getCharArrayNotNull(m_profile, DCEBuffer.ALIGN_INT);
m_description = buf.getCharArrayNotNull(m_description, DCEBuffer.ALIGN_INT);
m_workStations = buf.getCharArrayNotNull(m_workStations, DCEBuffer.ALIGN_INT);
m_accComment = buf.getCharArrayNotNull(m_profile, DCEBuffer.ALIGN_INT);
m_callBack = buf.getCharArrayNotNull(m_callBack, DCEBuffer.ALIGN_INT);
m_unknown1 = buf.getCharArrayNotNull(m_unknown1, DCEBuffer.ALIGN_INT);
m_unknown2 = buf.getCharArrayNotNull(m_unknown2, DCEBuffer.ALIGN_INT);
m_unknown3 = buf.getCharArrayNotNull(m_unknown3, DCEBuffer.ALIGN_INT);
m_logonHoursRaw = buf.getByteStructure(m_logonHoursRaw);
break;
}
}
/**
* Return an account type as a string
*
* @param typ int
* @return String
*/
public final static String getAccountTypeAsString(int typ)
{
String ret = "";
switch (typ)
{
case PrivGuest:
ret = "Guest";
break;
case PrivUser:
ret = "User";
break;
case PrivAdmin:
ret = "Administrator";
break;
}
return ret;
}
/**
* Return the user information as a string
*
* @return String
*/
public String toString()
{
StringBuffer str = new StringBuffer();
str.append("[");
str.append(getUserName());
str.append(":");
str.append(getInformationLevel());
str.append(":");
str.append("]");
return str.toString();
}
}

View File

@@ -0,0 +1,337 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.
*/
package org.alfresco.filesys.smb.dcerpc.info;
import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
import org.alfresco.filesys.smb.dcerpc.DCEWriteable;
/**
* Workstation Information Class
*/
public class WorkstationInfo implements DCEWriteable
{
// Supported information levels
public static final int InfoLevel100 = 100;
// Information level
private int m_infoLevel;
// Server information
private int m_platformId;
private String m_name;
private String m_domain;
private int m_verMajor;
private int m_verMinor;
private String m_userName;
private String m_logonDomain;
private String m_otherDomain;
/**
* Default constructor
*/
public WorkstationInfo()
{
}
/**
* Class constructor
*
* @param lev int
*/
public WorkstationInfo(int lev)
{
m_infoLevel = lev;
}
/**
* Get the information level
*
* @return int
*/
public final int getInformationLevel()
{
return m_infoLevel;
}
/**
* Get the workstation name
*
* @return String
*/
public final String getWorkstationName()
{
return m_name;
}
/**
* Get the domain/workgroup
*
* @return String
*/
public final String getDomain()
{
return m_domain;
}
/**
* Get the workstation platform id
*
* @return int
*/
public final int getPlatformId()
{
return m_platformId;
}
/**
* Get the workstation major version
*
* @return int
*/
public final int getMajorVersion()
{
return m_verMajor;
}
/**
* Get the workstation minor version
*
* @return int
*/
public final int getMinorVersion()
{
return m_verMinor;
}
/**
* Reutrn the user name
*
* @return String
*/
public final String getUserName()
{
return m_userName;
}
/**
* Return the workstations logon domain.
*
* @return java.lang.String
*/
public String getLogonDomain()
{
return m_logonDomain;
}
/**
* Return the list of domains that the workstation is enlisted in.
*
* @return java.lang.String
*/
public String getOtherDomains()
{
return m_otherDomain;
}
/**
* Set the logon domain name.
*
* @param logdom java.lang.String
*/
public void setLogonDomain(String logdom)
{
m_logonDomain = logdom;
}
/**
* Set the other domains that this workstation is enlisted in.
*
* @param othdom java.lang.String
*/
public void setOtherDomains(String othdom)
{
m_otherDomain = othdom;
}
/**
* Set the workstation name
*
* @param name String
*/
public final void setWorkstationName(String name)
{
m_name = name;
}
/**
* Set the domain/workgroup
*
* @param domain String
*/
public final void setDomain(String domain)
{
m_domain = domain;
}
/**
* Set the information level
*
* @param lev int
*/
public final void setInformationLevel(int lev)
{
m_infoLevel = lev;
}
/**
* Set the platform id
*
* @param id int
*/
public final void setPlatformId(int id)
{
m_platformId = id;
}
/**
* Set the version
*
* @param verMajor int
* @param verMinor int
*/
public final void setVersion(int verMajor, int verMinor)
{
m_verMajor = verMajor;
m_verMinor = verMinor;
}
/**
* Set the logged in user name
*
* @param user String
*/
public final void setUserName(String user)
{
m_userName = user;
}
/**
* Clear the string values
*/
protected final void clearStrings()
{
// Clear the string values
m_userName = null;
m_domain = null;
m_logonDomain = null;
m_otherDomain = null;
}
/**
* Write a workstation information structure
*
* @param buf DCEBuffer
* @param strBuf DCEBuffer
*/
public void writeObject(DCEBuffer buf, DCEBuffer strBuf)
{
// Output the workstation information structure
buf.putInt(getInformationLevel());
buf.putPointer(true);
// Output the required information level
switch (getInformationLevel())
{
// Level 100
case InfoLevel100:
buf.putInt(getPlatformId());
buf.putPointer(true);
buf.putPointer(true);
buf.putInt(getMajorVersion());
buf.putInt(getMinorVersion());
strBuf.putString(getWorkstationName(), DCEBuffer.ALIGN_INT, true);
strBuf.putString(getDomain() != null ? getDomain() : "", DCEBuffer.ALIGN_INT, true);
break;
// Level 101
case 101:
break;
// Level 102
case 102:
break;
}
}
/**
* Return the workstation information as a string
*
* @return String
*/
public String toString()
{
StringBuffer str = new StringBuffer();
str.append("[");
str.append(getWorkstationName());
str.append(":Domain=");
str.append(getDomain());
str.append(":User=");
str.append(getUserName());
str.append(":Id=");
str.append(getPlatformId());
str.append(":v");
str.append(getMajorVersion());
str.append(".");
str.append(getMinorVersion());
// Optional strings
if (getLogonDomain() != null)
{
str.append(":Logon=");
str.append(getLogonDomain());
}
if (getOtherDomains() != null)
{
str.append(":Other=");
str.append(getOtherDomains());
}
// Return the workstation information as a string
str.append("]");
return str.toString();
}
}