1. /*
  2. * @(#)file SnmpSecuritySubSystem.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 1.18
  5. * @(#)date 04/09/15
  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. import com.sun.jmx.trace.Trace;
  13. import com.sun.jmx.snmp.SnmpTooBigException;
  14. import com.sun.jmx.snmp.SnmpStatusException;
  15. import com.sun.jmx.snmp.SnmpUnknownSecModelException;
  16. import com.sun.jmx.snmp.SnmpSecurityException;
  17. import com.sun.jmx.snmp.SnmpSecurityParameters;
  18. /**
  19. * Security sub system interface. To allow engine integration, a security sub system must implement this interface.
  20. * <p><b>This API is a Sun Microsystems internal API and is subject
  21. * to change without notice.</b></p>
  22. */
  23. public interface SnmpSecuritySubSystem extends SnmpSubSystem {
  24. /**
  25. * Instantiates an <CODE>SnmpSecurityCache</CODE> that is dependant to the model implementation. This call is routed to the dedicated model according to the model ID.
  26. * @param id The model ID.
  27. * @return The model dependant security cache.
  28. */
  29. public SnmpSecurityCache createSecurityCache(int id) throws SnmpUnknownSecModelException;
  30. /**
  31. * To release the previously created cache. This call is routed to the dedicated model according to the model ID.
  32. * @param id The model ID.
  33. * @param cache The security cache to release.
  34. */
  35. public void releaseSecurityCache(int id,
  36. SnmpSecurityCache cache) throws SnmpUnknownSecModelException;
  37. /**
  38. * Called when a request is to be sent to the network. It must be securized. This call is routed to the dedicated model according to the model ID.
  39. * <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
  40. * @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
  41. * @param version The SNMP protocol version.
  42. * @param msgID The current request id.
  43. * @param msgMaxSize The message max size.
  44. * @param msgFlags The message flags (reportable, Auth and Priv).
  45. * @param msgSecurityModel This current security model.
  46. * @param params The security parameters that contain the model dependant parameters.
  47. * @param contextEngineID The context engine ID.
  48. * @param contextName The context name.
  49. * @param data The marshalled varbind list
  50. * @param dataLength The marshalled varbind list length.
  51. * @param outputBytes The buffer to fill with securized request. This is a representation independant marshalled format. This buffer will be sent to the network.
  52. * @return The marshalled byte number.
  53. */
  54. public int generateRequestMsg(SnmpSecurityCache cache,
  55. int version,
  56. int msgID,
  57. int msgMaxSize,
  58. byte msgFlags,
  59. int msgSecurityModel,
  60. SnmpSecurityParameters params,
  61. byte[] contextEngineID,
  62. byte[] contextName,
  63. byte[] data,
  64. int dataLength,
  65. byte[] outputBytes)
  66. throws SnmpTooBigException, SnmpStatusException, SnmpSecurityException, SnmpUnknownSecModelException;
  67. /**
  68. * Called when a response is to be sent to the network. It must be securized. This call is routed to the dedicated model according to the model ID.
  69. * <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
  70. * @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
  71. * @param version The SNMP protocol version.
  72. * @param msgID The current request id.
  73. * @param msgMaxSize The message max size.
  74. * @param msgFlags The message flags (reportable, Auth and Priv).
  75. * @param msgSecurityModel This current security model.
  76. * @param params The security parameters that contain the model dependant parameters.
  77. * @param contextEngineID The context engine ID.
  78. * @param contextName The context name.
  79. * @param data The marshalled varbind list
  80. * @param dataLength The marshalled varbind list length.
  81. * @param outputBytes The buffer to fill with securized request. This is a representation independant marshalled format. This buffer will be sent to the network.
  82. * @return The marshalled byte number.
  83. */
  84. public int generateResponseMsg(SnmpSecurityCache cache,
  85. int version,
  86. int msgID,
  87. int msgMaxSize,
  88. byte msgFlags,
  89. int msgSecurityModel,
  90. SnmpSecurityParameters params,
  91. byte[] contextEngineID,
  92. byte[] contextName,
  93. byte[] data,
  94. int dataLength,
  95. byte[] outputBytes)
  96. throws SnmpTooBigException, SnmpStatusException,
  97. SnmpSecurityException, SnmpUnknownSecModelException;
  98. /**
  99. * Called when a request is received from the network. It handles authentication and privacy. This call is routed to the dedicated model according to the model ID.
  100. * <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
  101. * @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
  102. * @param version The SNMP protocol version.
  103. * @param msgID The current request id.
  104. * @param msgMaxSize The message max size.
  105. * @param msgFlags The message flags (reportable, Auth and Priv)
  106. * @param msgSecurityModel This current security model.
  107. * @param params The security parameters in a marshalled format. The informations cointained in this array are model dependant.
  108. * @param contextEngineID The context engine ID or null if encrypted.
  109. * @param contextName The context name or null if encrypted.
  110. * @param data The marshalled varbind list or null if encrypted.
  111. * @param encryptedPdu The encrypted pdu or null if not encrypted.
  112. * @param decryptedPdu The decrypted pdu. If no decryption is to be done, the passed context engine ID, context name and data could be used to fill this object.
  113. * @return The decoded security parameters.
  114. */
  115. public SnmpSecurityParameters
  116. processIncomingRequest(SnmpSecurityCache cache,
  117. int version,
  118. int msgID,
  119. int msgMaxSize,
  120. byte msgFlags,
  121. int msgSecurityModel,
  122. byte[] params,
  123. byte[] contextEngineID,
  124. byte[] contextName,
  125. byte[] data,
  126. byte[] encryptedPdu,
  127. SnmpDecryptedPdu decryptedPdu)
  128. throws SnmpStatusException, SnmpSecurityException, SnmpUnknownSecModelException;
  129. /**
  130. * Called when a response is received from the network. It handles authentication and privacy. This call is routed to the dedicated model according to the model ID.
  131. * <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
  132. * @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
  133. * @param version The SNMP protocol version.
  134. * @param msgID The current request id.
  135. * @param msgMaxSize The message max size.
  136. * @param msgFlags The message flags (reportable, Auth and Priv).
  137. * @param msgSecurityModel This current security model.
  138. * @param params The security parameters in a marshalled format. The informations cointained in this array are model dependant.
  139. * @param contextEngineID The context engine ID or null if encrypted.
  140. * @param contextName The context name or null if encrypted.
  141. * @param data The marshalled varbind list or null if encrypted.
  142. * @param encryptedPdu The encrypted pdu or null if not encrypted.
  143. * @param decryptedPdu The decrypted pdu. If no decryption is to be done, the passed context engine ID, context name and data could be used to fill this object.
  144. * @return The security parameters.
  145. */
  146. public SnmpSecurityParameters processIncomingResponse(SnmpSecurityCache cache,
  147. int version,
  148. int msgID,
  149. int msgMaxSize,
  150. byte msgFlags,
  151. int msgSecurityModel,
  152. byte[] params,
  153. byte[] contextEngineID,
  154. byte[] contextName,
  155. byte[] data,
  156. byte[] encryptedPdu,
  157. SnmpDecryptedPdu decryptedPdu)
  158. throws SnmpStatusException, SnmpSecurityException, SnmpUnknownSecModelException;
  159. }