本文整理汇总了Java中org.snmp4j.security.PrivDES.ID属性的典型用法代码示例。如果您正苦于以下问题:Java PrivDES.ID属性的具体用法?Java PrivDES.ID怎么用?Java PrivDES.ID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.snmp4j.security.PrivDES
的用法示例。
在下文中一共展示了PrivDES.ID属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertPrivacyProtocol
private OID convertPrivacyProtocol(String privacyProtocol) {
if (privacyProtocol == null) {
return null;
}
if ("DES".equals(privacyProtocol)) {
return PrivDES.ID;
} else if ("TRIDES".equals(privacyProtocol)) {
return Priv3DES.ID;
} else if ("AES128".equals(privacyProtocol)) {
return PrivAES128.ID;
} else if ("AES192".equals(privacyProtocol)) {
return PrivAES192.ID;
} else if ("AES256".equals(privacyProtocol)) {
return PrivAES256.ID;
} else {
throw new IllegalArgumentException("Unknown privacy protocol: " + privacyProtocol);
}
}
示例2: privType
private OID privType(SnmpV3Target v3Target) {
switch (v3Target.getPrivType()) {
case DES:
return PrivDES.ID;
case DES3:
return Priv3DES.ID;
case AES128:
return PrivAES128.ID;
case AES192:
return PrivAES192.ID;
case AES256:
return PrivAES256.ID;
default:
throw new IllegalArgumentException("unrecognized privacy type");
}
}
示例3: getTargetV3
private Target getTargetV3() {
//logger.info("Use SNMP v3, "+this.privacyprotocol +"="+this.password+", "+this.privacyprotocol+"="+this.privacypassphrase);
OID authOID = AuthMD5.ID;
if("SHA".equals(this.authprotocol))
authOID = AuthSHA.ID;
OID privOID = PrivDES.ID;
if(this.privacyprotocol == null || this.privacyprotocol.isEmpty())
privOID = null;
UsmUser user = new UsmUser(new OctetString(this.username),
authOID, new OctetString(this.password), //auth
privOID, this.privacypassphrase!=null?new OctetString(this.privacypassphrase):null); //enc
snmp.getUSM().addUser(new OctetString(this.username), user);
Address targetAddress = GenericAddress.parse(address);
UserTarget target = new UserTarget();
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1500);
target.setVersion(this.getVersionInt());
if(privOID != null)
target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
else
target.setSecurityLevel(SecurityLevel.AUTH_NOPRIV);
target.setSecurityName(new OctetString(this.username));
return target;
}
示例4: convertPrivProtocol
private OID convertPrivProtocol(String privProtocol) {
/*
* Returning null here is okay because the SNMP4J library supports
* this value as null when creating the SNMP session.
*/
if (StringUtils.isBlank(privProtocol)) {
return null;
}
if (privProtocol.equals("DES")) {
return PrivDES.ID;
} else if ((privProtocol.equals("AES128")) || (privProtocol.equals("AES"))) {
return PrivAES128.ID;
} else if (privProtocol.equals("AES192")) {
return PrivAES192.ID;
} else if (privProtocol.equals("AES256")) {
return PrivAES256.ID;
} else {
throw new IllegalArgumentException("Privacy protocol " + privProtocol + " not supported");
}
}
示例5: convertPrivProtocol
private OID convertPrivProtocol(String privProtocol) {
/*
* Returning null here is okay because the SNMP4J library supports
* this value as null when creating the SNMP session.
*/
if (privProtocol == null) {
return null;
}
if (privProtocol.equals("DES")) {
return PrivDES.ID;
} else if ((privProtocol.equals("AES128")) || (privProtocol.equals("AES"))) {
return PrivAES128.ID;
} else if (privProtocol.equals("AES192")) {
return PrivAES192.ID;
} else if (privProtocol.equals("AES256")) {
return PrivAES256.ID;
} else {
throw new IllegalArgumentException("Privacy protocol " + privProtocol + " not supported");
}
}
示例6: privProtocol
private OID privProtocol() {
PrivProtocol pp = PrivProtocol.valueOf(conf("privProtocol", PrivProtocol.NONE));
switch (pp) {
case DES: return PrivDES.ID;
case AES128: return PrivAES128.ID;
case AES192: return PrivAES192.ID;
case AES256: return PrivAES256.ID;
case _3DES: return Priv3DES.ID;
default: return null;
}
}
示例7: setUpTarget
/**
* Helper method that initializes the snmp target to listening mode. This
* method is explicitly for V3 messages. This method will create and set up
* the TransportMapping and target for SNMP V3. It creates a
* TransportMapping and puts it in the listening mode. Also Creates
* CommunityTarget object and sets SNMP target properties.
*
* @param targetIP
* IP address of Target machine
* @param portNumber
* Port number
* @param userName
* The security name of the user
* @param authenticatePassword
* The authentication password
* @param privacyPassword
* The privacy password
* @return The created UserTarget
* @throws IOException
* IOException
*/
private UserTarget setUpTarget( final String targetIP, final int portNumber, final String userName,
final String authenticatePassword, final String privacyPassword ) throws IOException
{
// Creates a TransportMapping and puts the transport mapping in to
// listen mode
final TransportMapping transportMapping = new DefaultUdpTransportMapping();
snmp = new Snmp( transportMapping );
transportMapping.listen();
// Creating a USM with the support for the supplied security protocols
final SecurityProtocols securityProtocols = SecurityProtocols.getInstance();
securityProtocols.addDefaultProtocols();
final OctetString engineId = new OctetString( MPv3.createLocalEngineID() );
final USM usm = new USM( securityProtocols, engineId, DEFAULT_ENGINE_REBOOTS );
SecurityModels.getInstance().addSecurityModel( usm );
final OctetString username = new OctetString( userName );
final OctetString authenticationPassphrase = new OctetString( authenticatePassword );
final OctetString privacyPassphrase = new OctetString( privacyPassword );
// Creating UsmUser and adds the UsmUser to the internal user name table
// TODO Need to confirm, whether AuthMD5 and PrivDES needs to be changed
final UsmUser usmuser = new UsmUser( username, AuthMD5.ID, authenticationPassphrase, PrivDES.ID,
privacyPassphrase );
snmp.getUSM().addUser( username, usmuser );
// Create a target for a user based security model target and setting
// its properties
final UserTarget userTarget = new UserTarget();
final InetAddress inetAddress = InetAddress.getByName( targetIP );
final Address address = new UdpAddress( inetAddress, portNumber );
userTarget.setAddress( address );
// TODO Need to confirm, whether this value needs to be configures
userTarget.setRetries( SnmpManager.DEFAULT_RETRIES );
// TODO Need to confirm, whether this value needs to be configures
userTarget.setTimeout( SnmpManager.DEFAULT_TIMEOUT );
userTarget.setVersion( SnmpConstants.version3 );
// TODO Need to confirm, whether this value needs to be configures
userTarget.setSecurityLevel( SecurityLevel.AUTH_PRIV );
userTarget.setSecurityName( username );
return userTarget;
}
示例8: SnmpClient
/**
* Create a new SnmpClient for the passed NetworkDevice.
*
* @param targetDevice
* NetworkDevice that will be used for SNMP message exchange.
*/
public SnmpClient(NetworkDevice targetDevice) {
this.targetDevice = targetDevice;
// Create a new logger with name jnetman.snmp.device_name
logger = Logger.getLogger("snmp.snmpClient." + targetDevice.getName());
// If activated SNMP4J will show a huge amount of low level debug info
if (SnmpPref.isSnmp4jLogEnabled())
LogFactory.setLogFactory(new Log4jLogFactory());
try {
DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping();
// Creates Snmp istance for that transport channel
snmpInstance = new Snmp(transport);
logger.debug("New SNMP Client crated");
// Creates v3 SNMP USM
USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(
MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(usm);
// Adds 'jnetman' usm using MD5 authentication and DES encryption
UsmUser jnetmanUser = new UsmUser(
new OctetString(SnmpPref.getUser()), AuthMD5.ID,
new OctetString(SnmpPref.getPassword()), PrivDES.ID,
new OctetString(SnmpPref.getPassword()));
snmpInstance.getUSM().addUser(new OctetString(SnmpPref.getUser()),
jnetmanUser);
logger.debug("New USM User added >> " + jnetmanUser.getSecurityName());
// Enables listening for incoming SNMP packet
transport.listen();
} catch (IOException e) {
logger.fatal(
"IOException while creating a new DefaultUdpTransportMapping()",
e);
System.exit(-1);
}
}