本文整理汇总了Java中org.snmp4j.security.AuthSHA类的典型用法代码示例。如果您正苦于以下问题:Java AuthSHA类的具体用法?Java AuthSHA怎么用?Java AuthSHA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthSHA类属于org.snmp4j.security包,在下文中一共展示了AuthSHA类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTargetV3
import org.snmp4j.security.AuthSHA; //导入依赖的package包/类
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;
}
示例2: convertAuthProtocol
import org.snmp4j.security.AuthSHA; //导入依赖的package包/类
private OID convertAuthProtocol(String authProtocol) {
/*
* Returning null here is okay because the SNMP4J library supports
* this value as null when creating the SNMP session.
*/
if (StringUtils.isBlank(authProtocol)) {
return null;
}
if (authProtocol.equals("MD5")) {
return AuthMD5.ID;
} else if (authProtocol.equals("SHA")) {
return AuthSHA.ID;
} else {
throw new IllegalArgumentException("Authentication protocol unsupported: " + authProtocol);
}
}
示例3: convertAuthProtocol
import org.snmp4j.security.AuthSHA; //导入依赖的package包/类
private OID convertAuthProtocol(String authProtocol) {
/*
* Returning null here is okay because the SNMP4J library supports
* this value as null when creating the SNMP session.
*/
if (authProtocol == null) {
return null;
}
if (authProtocol.equals("MD5")) {
return AuthMD5.ID;
} else if (authProtocol.equals("SHA")) {
return AuthSHA.ID;
} else {
throw new IllegalArgumentException("Authentication protocol unsupported: " + authProtocol);
}
}
示例4: convertAuthenticationProtocol
import org.snmp4j.security.AuthSHA; //导入依赖的package包/类
private OID convertAuthenticationProtocol(String authenticationProtocol) {
if (authenticationProtocol == null) {
return null;
}
if ("MD5".equals(authenticationProtocol)) {
return AuthMD5.ID;
} else if ("SHA1".equals(authenticationProtocol)) {
return AuthSHA.ID;
} else {
throw new IllegalArgumentException("Unknown authentication protocol: " + authenticationProtocol);
}
}
示例5: authType
import org.snmp4j.security.AuthSHA; //导入依赖的package包/类
private OID authType(SnmpV3Target v3Target) {
switch (v3Target.getAuthType()) {
case SHA:
return AuthSHA.ID;
case MD5:
return AuthMD5.ID;
default:
throw new IllegalArgumentException("unrecognized auth type");
}
}
示例6: authProtocol
import org.snmp4j.security.AuthSHA; //导入依赖的package包/类
private OID authProtocol() {
AuthProtocol ap = AuthProtocol.valueOf(conf("authProtocol", AuthProtocol.NONE));
switch (ap) {
case MD5: return AuthMD5.ID;
case SHA: return AuthSHA.ID;
default: return null;
}
}