smbutils.java

来自「opennms得相关源码 请大家看看」· Java 代码 · 共 389 行 · 第 1/2 页

JAVA
389
字号
//// This file is part of the OpenNMS(R) Application.//// OpenNMS(R) is Copyright (C) 2002-2003 The OpenNMS Group, Inc.  All rights reserved.// OpenNMS(R) is a derivative work, containing both original code, included code and modified// code that was published under the GNU General Public License. Copyrights for modified // and included code are below.//// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.//// Modifications://// 2003 Jan 31: Cleaned up some unused imports.//// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.                                                            //// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//       // For more information contact: //      OpenNMS Licensing       <license@opennms.org>//      http://www.opennms.org///      http://www.opennms.com///package org.opennms.netmgt.capsd;import jcifs.netbios.NbtAddress;import org.opennms.netmgt.config.capsd.SmbAuth;/** * This class contains several static convience methods utilized by Capsd while * doing data collection via jCIFS and the SMB (Server Message Block) protocol. *  * @author <A HREF="mailto:mike@opennms.org">Mike </A> * @author <A HREF="http://www.opennms.org/">OpenNMS </A> *  *  */public class SmbUtils {    // NetBIOS Node Name Suffix Codes    //    public static final int WORKSTATION_SERVICE = 0x00; // <computername>    public static final int MESSENGER_SERVICE_A = 0x01; // <computername>    public static final int MASTER_BROWSER_G = 0x01; // \\--__MSBROWSE__    public static final int MESSENGER_SERVICE_B = 0x03; // <computername>    public static final int RAS_SERVER_SERVICE = 0x06; // <computername>    public static final int NETDDE_SERVICE = 0x1F; // <computername>    public static final int FILE_SERVER_SERVICE = 0x20; // <computername>    public static final int RAS_CLIENT_SERVICE = 0x21; // <computername>    public static final int MS_EXCHANGE_INTERCHANGE = 0x22; // <computername>    public static final int MS_EXCHANGE_STORE = 0x23; // <computername>    public static final int MS_EXCHANGE_DIRECTORY = 0x24; // <computername>    public static final int MODEM_SHARING_SERVER_SERVICE = 0x30; // <computername>    public static final int MODEM_SHARING_CLIENT_SERVICE = 0x31; // <computername>    public static final int SMS_CLIENT_REMOTE_CONTROL = 0x43; // <computername>    public static final int SMS_ADMIN_REMOTE_CONTROL_TOOL = 0x44; // <computername>    public static final int SMS_CLIENTS_REMOTE_CHAT = 0x45; // <computername>    public static final int SMS_CLIENTS_REMOTE_TRANSFER = 0x46; // <computername>    public static final int DEC_PATHWORKS_TCPIP_SERVICE_A = 0x4C; // <computername>    public static final int DEC_PATHWORKS_TCPIP_SERVICE_B = 0x52; // <computername>    public static final int MS_EXCHANGE_MTA = 0x87; // <computername>    public static final int MS_EXCHANGE_IMC = 0x6A; // <computername>    public static final int NETWORK_MONITOR_AGENT = 0xBE; // <computername>    public static final int NETWORK_MONITOR_APPLICATION = 0xBF; // <computername>    public static final int MESSENGER_SERVICE = 0x03; // <username>    public static final int DOMAIN_NAME = 0x00; // <domain>    public static final int DOMAIN_MASTER_BROWSER = 0x1B; // <domain>    public static final int DOMAIN_CONTROLLERS = 0x1C; // <domain>    public static final int MASTER_BROWSER_U = 0x1D; // <domain>    public static final int BROWSER_SERVICE_ELECTIONS = 0x1E; // <domain>    public static final int INTERNET_INFORMATION_SERVER_G = 0x1C; // INET~SERVICES                                                                    // (GROUP)    public static final int INTERNET_INFORMATION_SERVER_U = 0x00; // IS~<computername>                                                                    // (UNIQUE)    public static final int LOTUS_NOTES_SERVER_SERVICE = 0x2B; // <computername>    public static final int LOTUS_NOTES_IRIS_MULTICAST = 0x2F; // IRISMULTICAST    public static final int LOTUS_NOTES_IRIS_NAME_SERVER = 0x33; // IRISNAMESERVER    public static final int DCA_IRMALAN_GATEWAY_SERVER_SERVICE = 0x20; // FORTE_$ND800ZA    /**     * This method attempts to determine the authentication domain for a remote     * host. The list of NbtAddress objects is processed in order to find an     * entry with a DOMAIN_NAME (0x00) suffix. WORKSTATION_SERVICE and     * INTERNET_INFORMATION_SERVER share the same 0x00 suffix so these entries     * must be ignored while processing the address list.     *      * @param addresses     *            List of NbtAddress objects associated with the remote host.     * @param cname     *            NetBIOS name of the remote host.     *      * @return remote host's authentication domain or null if unavailable.     */    static String getAuthenticationDomainName(NbtAddress[] addresses, String cname) {        String domain = null;        if (addresses != null) {            for (int i = 0; i < addresses.length && domain == null; i++) {                NbtAddress addr = addresses[i];                // look at the domain name type and search for                // anything that returns 0x00. Then check other                // criteria to eliminate IIS and other nondesired                // elements from the list                //                if (addr.getNameType() == DOMAIN_NAME) {                    // the 0x00 suffic can be one of the following types:                    //                    // WORKSTATION_SERVICE                    // INTERNET_INFORMATION_SERVER                    // DOMAIN_NAME                    //                    // Eliminate the Workstation service by verifying that                    // the NetBIOS name does not equal the current                    // computer name.                    //                    // Eliminate the IIS servers hits by checking for the                    // string prefix IS~ in the NetBIOS name.                    //                    if (!addr.getHostName().equals(cname) && !addr.getHostName().startsWith("IS~")) {                        domain = addr.getHostName();                    }                }            }        }        return domain;    }    /**     * Returns the operating system label to be associated with a node in 'node'     * table in the databse. This call should be made after an attempt to     * determine if the interface supports Microsoft Exchange. This is     * determined by the {@link MSExchangePlugin MSExchangePlugin}class.     *      * @param nativeOS     *            OS string returned by jCIFS following SMB session     *            establishment with the remote host.     * @param addresses     *            array of NbtAddress objects associated with the remote host     *            being tested.     * @param isSamba     *            <em>true</em> if it has been derived that the remote system     *            is running Samba.     * @param hasExchange     *            <em>true</em> if the service supports microsoft exhange.     *      * @return The Operating system label     */    static String getOsLabel(String nativeOS, NbtAddress[] addresses, boolean isSamba, boolean hasExchange) {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?