Java Code Examples for com.sun.jmx.snmp.SnmpDefinitions#privMask()

The following examples show how to use com.sun.jmx.snmp.SnmpDefinitions#privMask() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnmpEngineImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 2
Source File: SnmpEngineImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 3
Source File: SnmpEngineImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 4
Source File: SnmpEngineImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 5
Source File: SnmpEngineImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 6
Source File: SnmpEngineImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 7
Source File: SnmpEngineImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 8
Source File: SnmpEngineImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 9
Source File: SnmpEngineImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 10
Source File: SnmpEngineImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks the passed msg flags according to the rules specified in RFC 2572.
 * @param msgFlags The msg flags.
 */
public static void checkSecurityLevel(byte msgFlags)
    throws SnmpBadSecurityLevelException {
    int secLevel = msgFlags & SnmpDefinitions.authPriv;
    if((secLevel & SnmpDefinitions.privMask) != 0)
        if((secLevel & SnmpDefinitions.authMask) == 0) {
            throw new SnmpBadSecurityLevelException("Security level:"+
                                                    " noAuthPriv!!!");
        }
}
 
Example 11
Source File: SnmpV3Message.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 12
Source File: SnmpV3Message.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 13
Source File: SnmpV3Message.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 14
Source File: SnmpV3Message.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 15
Source File: SnmpV3Message.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 16
Source File: SnmpV3Message.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 17
Source File: SnmpV3Message.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 18
Source File: SnmpV3Message.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 19
Source File: SnmpV3Message.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}
 
Example 20
Source File: SnmpV3Message.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Decodes the specified bytes and initializes this message.
 * For internal use only.
 *
 * @param inputBytes The bytes to be decoded.
 *
 * @exception SnmpStatusException If the specified bytes are not a valid encoding.
 */
public void decodeMessage(byte[] inputBytes, int byteCount)
    throws SnmpStatusException {

    try {
        BerDecoder bdec = new BerDecoder(inputBytes);
        bdec.openSequence();
        version = bdec.fetchInteger();
        bdec.openSequence();
        msgId = bdec.fetchInteger();
        msgMaxSize = bdec.fetchInteger();
        msgFlags = bdec.fetchOctetString()[0];
        msgSecurityModel =bdec.fetchInteger();
        bdec.closeSequence();
        msgSecurityParameters = bdec.fetchOctetString();
        if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
            bdec.openSequence();
            contextEngineId = bdec.fetchOctetString();
            contextName = bdec.fetchOctetString();
            data = bdec.fetchAny();
            dataLength = data.length;
            bdec.closeSequence();
        }
        else {
            encryptedPdu = bdec.fetchOctetString();
        }
        bdec.closeSequence() ;
    }
    catch(BerException x) {
        x.printStackTrace();
        throw new SnmpStatusException("Invalid encoding") ;
    }

    if (SNMP_LOGGER.isLoggable(Level.FINER)) {
        final StringBuilder strb = new StringBuilder()
        .append("Unmarshalled message : \n")
        .append("version : ").append(version)
        .append("\n")
        .append("msgId : ").append(msgId)
        .append("\n")
        .append("msgMaxSize : ").append(msgMaxSize)
        .append("\n")
        .append("msgFlags : ").append(msgFlags)
        .append("\n")
        .append("msgSecurityModel : ").append(msgSecurityModel)
        .append("\n")
        .append("contextEngineId : ").append(contextEngineId == null ? null :
            SnmpEngineId.createEngineId(contextEngineId))
        .append("\n")
        .append("contextName : ").append(contextName)
        .append("\n")
        .append("data : ").append(data)
        .append("\n")
        .append("dat len : ").append((data == null) ? 0 : data.length)
        .append("\n")
        .append("encryptedPdu : ").append(encryptedPdu)
        .append("\n");
        SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
                "decodeMessage", strb.toString());
    }
}