KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > snmp > internal > SnmpIncomingRequest


1 /*
2  * @(#)file SnmpIncomingRequest.java
3  * @(#)author Sun Microsystems, Inc.
4  * @(#)version 1.20
5  * @(#)date 08/02/09
6  *
7  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
8  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
9  *
10  */

11 package com.sun.jmx.snmp.internal;
12
13 import java.net.InetAddress JavaDoc;
14
15 import com.sun.jmx.snmp.SnmpSecurityParameters;
16 import com.sun.jmx.snmp.SnmpTooBigException;
17 import com.sun.jmx.snmp.SnmpStatusException;
18 import com.sun.jmx.snmp.SnmpPdu;
19 import com.sun.jmx.snmp.SnmpMsg;
20
21 import com.sun.jmx.snmp.SnmpUnknownSecModelException;
22 import com.sun.jmx.snmp.SnmpBadSecurityLevelException;
23
24 /**
25 <P> An <CODE>SnmpIncomingRequest</CODE> handles both sides of an incoming SNMP request:
26 <ul>
27 <li> The request. Unmarshalling of the received message. </li>
28 <li> The response. Marshalling of the message to send. </li>
29 </ul>
30  * <p><b>This API is a Sun Microsystems internal API and is subject
31  * to change without notice.</b></p>
32  * @since 1.5
33  */

34 public interface SnmpIncomingRequest {
35     /**
36      * Once the incoming request decoded, returns the decoded security parameters.
37      * @return The decoded security parameters.
38      */

39     public SnmpSecurityParameters getSecurityParameters();
40      /**
41      * Tests if a report is expected.
42      * @return boolean indicating if a report is to be sent.
43      */

44     public boolean isReport();
45     /**
46      * Tests if a response is expected.
47      * @return boolean indicating if a response is to be sent.
48      */

49     public boolean isResponse();
50     
51     /**
52      * Tells this request that no response will be sent.
53      */

54     public void noResponse();
55     /**
56      * Gets the incoming request principal.
57      * @return The request principal.
58      **/

59     public String JavaDoc getPrincipal();
60     /**
61      * Gets the incoming request security level. This level is defined in {@link com.sun.jmx.snmp.SnmpEngine SnmpEngine}.
62      * @return The security level.
63      */

64     public int getSecurityLevel();
65     /**
66      * Gets the incoming request security model.
67      * @return The security model.
68      */

69     public int getSecurityModel();
70     /**
71      * Gets the incoming request context name.
72      * @return The context name.
73      */

74     public byte[] getContextName();
75     /**
76      * Gets the incoming request context engine Id.
77      * @return The context engine Id.
78      */

79     public byte[] getContextEngineId();
80     /**
81      * Gets the incoming request context name used by Access Control Model in order to allow or deny the access to OIDs.
82      */

83     public byte[] getAccessContext();
84     /**
85      * Encodes the response message to send and puts the result in the specified byte array.
86      *
87      * @param outputBytes An array to receive the resulting encoding.
88      *
89      * @exception ArrayIndexOutOfBoundsException If the result does not fit
90      * into the specified array.
91      */

92     public int encodeMessage(byte[] outputBytes)
93     throws SnmpTooBigException;
94     
95     /**
96      * Decodes the specified bytes and initializes the request with the incoming message.
97      *
98      * @param inputBytes The bytes to be decoded.
99      *
100      * @exception SnmpStatusException If the specified bytes are not a valid encoding or if the security applied to this request failed and no report is to be sent (typically trap PDU).
101      */

102     public void decodeMessage(byte[] inputBytes,
103                   int byteCount,
104                   InetAddress JavaDoc address,
105                   int port)
106         throws SnmpStatusException, SnmpUnknownSecModelException,
107            SnmpBadSecurityLevelException;
108
109      /**
110      * Initializes the response to send with the passed Pdu.
111      * <P>
112      * If the encoding length exceeds <CODE>maxDataLength</CODE>,
113      * the method throws an exception.
114      *
115      * @param p The PDU to be encoded.
116      * @param maxDataLength The maximum length permitted for the data field.
117      *
118      * @exception SnmpStatusException If the specified <CODE>pdu</CODE>
119      * is not valid.
120      * @exception SnmpTooBigException If the resulting encoding does not fit
121      * into <CODE>maxDataLength</CODE> bytes.
122      * @exception ArrayIndexOutOfBoundsException If the encoding exceeds
123      * <CODE>maxDataLength</CODE>.
124      */

125     public SnmpMsg encodeSnmpPdu(SnmpPdu p,
126                  int maxDataLength)
127         throws SnmpStatusException, SnmpTooBigException;
128
129     /**
130      * Gets the request PDU encoded in the received message.
131      * <P>
132      * This method decodes the data field and returns the resulting PDU.
133      *
134      * @return The resulting PDU.
135      * @exception SnmpStatusException If the encoding is not valid.
136      */

137     public SnmpPdu decodeSnmpPdu()
138     throws SnmpStatusException;
139     
140     /**
141      * Returns a stringified form of the received message.
142      * @return The message state string.
143      */

144     public String JavaDoc printRequestMessage();
145     /**
146      * Returns a stringified form of the message to send.
147      * @return The message state string.
148      */

149     public String JavaDoc printResponseMessage();
150 }
151
Popular Tags