jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/internal/SnmpMsgProcessingSubSystem.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 5506 jdk/src/share/classes/com/sun/jmx/snmp/internal/SnmpMsgProcessingSubSystem.java@202f599c92aa
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package com.sun.jmx.snmp.internal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import com.sun.jmx.snmp.SnmpMsg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jmx.snmp.SnmpParams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import com.sun.jmx.snmp.SnmpPdu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import com.sun.jmx.snmp.SnmpVarBind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import com.sun.jmx.snmp.SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import com.sun.jmx.snmp.SnmpTooBigException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.jmx.snmp.SnmpPduFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import com.sun.jmx.snmp.SnmpSecurityParameters;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jmx.snmp.SnmpUnknownMsgProcModelException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Message processing sub system interface. To allow engine integration, a message processing sub system must implement this interface. This sub system is called by the dispatcher when receiving or sending calls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p><b>This API is a Sun Microsystems internal API  and is subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * to change without notice.</b></p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public interface SnmpMsgProcessingSubSystem extends SnmpSubSystem {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * Attaches the security sub system to this sub system. Message processing model are making usage of various security sub systems. This direct attachement avoid the need of accessing the engine to retrieve the Security sub system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * @param security The security sub system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public void setSecuritySubSystem(SnmpSecuritySubSystem security);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /** Gets the attached security sub system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * @return The security sub system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public SnmpSecuritySubSystem getSecuritySubSystem();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * This method is called when a call is received from the network.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @param model The model ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param factory The pdu factory to use to encode and decode pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @return The object that will handle every steps of the receiving (mainly unmarshalling and security).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public SnmpIncomingRequest getIncomingRequest(int model,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                                                  SnmpPduFactory factory)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        throws SnmpUnknownMsgProcModelException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * This method is called when a call is to be sent to the network. The sub system routes the call to the dedicated model according to the model ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @param model The model ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param factory The pdu factory to use to encode and decode pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @return The object that will handle every steps of the sending (mainly marshalling and security).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public SnmpOutgoingRequest getOutgoingRequest(int model,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                                                  SnmpPduFactory factory) throws SnmpUnknownMsgProcModelException ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * This method is called to instantiate a pdu according to the passed pdu type and parameters. The sub system routes the call to the dedicated model according to the model ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param model The model ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @param p The request parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param type The pdu type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @return The pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public SnmpPdu getRequestPdu(int model, SnmpParams p, int type) throws SnmpUnknownMsgProcModelException, SnmpStatusException ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * This method is called when a call is received from the network. The sub system routes the call to the dedicated model according to the model ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param model The model ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param factory The pdu factory to use to decode pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @return The object that will handle every steps of the receiving (mainly marshalling and security).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public SnmpIncomingResponse getIncomingResponse(int model,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                                    SnmpPduFactory factory) throws SnmpUnknownMsgProcModelException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * This method is called to encode a full scoped pdu that as not been encrypted. <CODE>contextName</CODE>, <CODE>contextEngineID</CODE> and data are known. It will be routed to the dedicated model according to the version value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param version The SNMP protocol version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param msgID The SNMP message ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param msgMaxSize The max message size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @param msgFlags The message flags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param msgSecurityModel The message security model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param params The security parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param contextEngineID The context engine ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param contextName The context name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param data The encoded data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @param dataLength The encoded data length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @param outputBytes The buffer containing the encoded message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @return The encoded bytes number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    public int encode(int version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                      int msgID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                      int msgMaxSize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                      byte msgFlags,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                      int msgSecurityModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                      SnmpSecurityParameters params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                      byte[] contextEngineID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                      byte[] contextName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                      byte[] data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                      int dataLength,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                      byte[] outputBytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        throws SnmpTooBigException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
               SnmpUnknownMsgProcModelException ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * This method is called to encode a full scoped pdu that as been encrypted. <CODE>contextName</CODE>, <CODE>contextEngineID</CODE> and data are not known. It will be routed to the dedicated model according to the version value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param version The SNMP protocol version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param msgID The SNMP message ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param msgMaxSize The max message size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @param msgFlags The message flags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param msgSecurityModel The message security model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param params The security parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param encryptedPdu The encrypted pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param outputBytes The buffer containing the encoded message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @return The encoded bytes number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public int encodePriv(int version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                          int msgID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                          int msgMaxSize,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                          byte msgFlags,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                          int msgSecurityModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                          SnmpSecurityParameters params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                          byte[] encryptedPdu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                          byte[] outputBytes) throws SnmpTooBigException, SnmpUnknownMsgProcModelException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * This method returns a decoded scoped pdu. This method decodes only the <CODE>contextEngineID</CODE>, <CODE>contextName</CODE> and data. It is needed by the <CODE>SnmpSecurityModel</CODE> after decryption. It will be routed to the dedicated model according to the version value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @param version The SNMP protocol version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param pdu The encoded pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @return the partialy scoped pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public SnmpDecryptedPdu decode(int version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                                   byte[] pdu)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        throws SnmpStatusException, SnmpUnknownMsgProcModelException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * This method returns an encoded scoped pdu. This method encodes only the <CODE>contextEngineID</CODE>, <CODE>contextName</CODE> and data. It is needed by the <CODE>SnmpSecurityModel</CODE> for decryption. It will be routed to the dedicated model according to the version value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param version The SNMP protocol version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param pdu The pdu to encode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param outputBytes The partialy scoped pdu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @return The encoded bytes number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public int encode(int version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                      SnmpDecryptedPdu pdu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                      byte[] outputBytes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        throws SnmpTooBigException, SnmpUnknownMsgProcModelException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}