1 /*
   2  * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.jmx.snmp.agent;
  27 
  28 // jmx imports
  29 //
  30 import com.sun.jmx.snmp.SnmpValue;
  31 import com.sun.jmx.snmp.SnmpStatusException;
  32 
  33 /**
  34  * <p>
  35  * This interface defines the methods that must be implemented by an
  36  * SNMP metadata object that needs to interact with an
  37  * {@link com.sun.jmx.snmp.agent.SnmpGenericObjectServer} object.
  38  * </p>
  39  *
  40  * <p>
  41  * All these methods are usually generated by <code>mibgen</code> when
  42  * run in generic-metadata mode.
  43  * </p>
  44  *
  45  * <p><b><i>
  46  * This interface is used internally between the generated Metadata and
  47  * the SNMP runtime and you shouldn't need to worry about it, because
  48  * you will never have to use it directly.
  49  * </b></i></p>
  50  *
  51  * <p><b>This API is a Sun Microsystems internal API  and is subject
  52  * to change without notice.</b></p>
  53  **/
  54 public interface SnmpGenericMetaServer {
  55 
  56     /**
  57      * Construct an attribute value (as returned by Attribute::getValue())
  58      * from an SnmpValue. The returned attribute value can be used to
  59      * construct an Attribute object.
  60      *
  61      * @param id The OID arc identifying the variable for which the
  62      *           value is constructed.
  63      * @param value The SnmpValue from which the Attribute::value will be
  64      *              constructed.
  65      * @return The attribute value built from the given <code>value</code>.
  66      * @exception SnmpStatusException if the attribute value cannot be built
  67      *            from the given SnmpValue <code>value</code>.
  68      *
  69      */
  70     Object buildAttributeValue(long id, SnmpValue value)
  71         throws SnmpStatusException;
  72 
  73     /**
  74      * Construct an SnmpValue from an Attribute value as returned by
  75      * Attribute::getValue().
  76      *
  77      * @param id The OID arc identifying the variable for which the
  78      *           value is constructed.
  79      * @param value The attribute value as returned by Attribute::getValue().
  80      *
  81      * @return The SnmpValue built from the given <code>value</code>.
  82      * @exception SnmpStatusException if the SnmpValue cannot be built from
  83      *            the given <code>value</code>.
  84      **/
  85     SnmpValue buildSnmpValue(long id, Object value)
  86         throws SnmpStatusException;
  87 
  88     /**
  89      * Return the name of the attribute corresponding to the
  90      * SNMP variable identified by the given <code>id</code>.
  91      *
  92      * @param id The OID arc identifying the variable.
  93      *
  94      * @return The name of the variable identified by the given
  95      *         <code>id</code>.
  96      *
  97      * @exception SnmpStatusException if the given <code>id</code> does not
  98      *            correspond to a known variable.
  99      */
 100     String getAttributeName(long id)
 101         throws SnmpStatusException;
 102 
 103     /**
 104      * Check the access rights for a SET operation.
 105      *
 106      * @param x  The new requested value.
 107      * @param id The OID arc identifying the variable for which the SET is
 108      *           requested.
 109      * @param data A contextual object containing user-data.
 110      *           This object is allocated through the <code>
 111      *           {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 112      *           for each incoming SNMP request.
 113      * @exception SnmpStatusException if the SET operation must be rejected.
 114      */
 115     void checkSetAccess(SnmpValue x, long id, Object data)
 116         throws SnmpStatusException;
 117 
 118     /**
 119      * Check the access rights for a GET operation.
 120      *
 121      * @param id The OID arc identifying the variable for which the SET is
 122      *           requested.
 123      * @param data A contextual object containing user-data.
 124      *           This object is allocated through the <code>
 125      *           {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}</code>
 126      *           for each incoming SNMP request.
 127      * @exception SnmpStatusException if the SET operation must be rejected.
 128      */
 129     void checkGetAccess(long id, Object data)
 130         throws SnmpStatusException;
 131 
 132 }