1 20 21 22 23 24 25 package org.snmp4j; 26 27 import org.snmp4j.smi.OctetString; 28 import org.snmp4j.security.SecurityModel; 29 import org.snmp4j.security.SecurityLevel; 31 import org.snmp4j.smi.Address; 32 33 39 public class UserTarget extends SecureTarget { 40 41 private static final long serialVersionUID = -1426511355567423746L; 42 43 private OctetString authoritativeEngineID = new OctetString(); 44 45 48 public UserTarget() { 49 } 50 51 62 public UserTarget(Address address, OctetString securityName, 63 byte[] authoritativeEngineID) { 64 super(address, securityName); 65 setAuthoritativeEngineID(authoritativeEngineID); 66 } 67 68 82 public UserTarget(Address address, OctetString securityName, 83 byte[] authoritativeEngineID, int securityLevel) { 84 super(address, securityName); 85 setAuthoritativeEngineID(authoritativeEngineID); 86 setSecurityLevel(securityLevel); 87 } 88 89 94 public void setAuthoritativeEngineID(byte[] authoritativeEngineID) { 95 this.authoritativeEngineID.setValue(authoritativeEngineID); 96 } 97 98 103 public byte[] getAuthoritativeEngineID() { 104 return authoritativeEngineID.getValue(); 105 } 106 107 113 public int getSecurityModel() { 114 return SecurityModel.SECURITY_MODEL_USM; 115 } 116 117 124 public void setSecurityModel(int securityModel) { 125 if (securityModel != SecurityModel.SECURITY_MODEL_USM) { 126 throw new IllegalArgumentException ("The UserTarget target can only be " + 127 "used with the User Based Security " + 128 "Model (USM)"); 129 } 130 } 131 132 } 133 134 | Popular Tags |