0956403f759a3888523c99047f9d2da76b118d27
2 * NetXMS - open source network management system
3 * Copyright (C) 2003-2009 Victor Kirhenshtein
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 package org
.netxms
.client
.snmp
;
21 import org
.netxms
.base
.NXCPMessage
;
27 public class SnmpUsmCredential
30 private int authMethod
;
31 private int privMethod
;
32 private String authPassword
;
33 private String privPassword
;
36 * Create credentials object from data in NXCP message
38 * @param msg NXCP message
39 * @param baseId Base variable ID
41 public SnmpUsmCredential(NXCPMessage msg
, long baseId
)
43 name
= msg
.getFieldAsString(baseId
);
44 authMethod
= msg
.getFieldAsInt32(baseId
+ 1);
45 privMethod
= msg
.getFieldAsInt32(baseId
+ 2);
46 authPassword
= msg
.getFieldAsString(baseId
+ 3);
47 privPassword
= msg
.getFieldAsString(baseId
+ 4);
51 * Default constructor.
53 public SnmpUsmCredential()
63 * Fill NXCP message with object's data
65 * @param msg NXCP message
66 * @param baseId Base variable ID
68 public void fillMessage(final NXCPMessage msg
, long baseId
)
70 msg
.setField(baseId
, name
);
71 msg
.setFieldInt16(baseId
+ 1, authMethod
);
72 msg
.setFieldInt16(baseId
+ 2, privMethod
);
73 msg
.setField(baseId
+ 3, authPassword
);
74 msg
.setField(baseId
+ 4, privPassword
);
80 public String
getName()
86 * @param name the name to set
88 public void setName(String name
)
94 * @return the authMethod
96 public int getAuthMethod()
102 * @param authMethod the authMethod to set
104 public void setAuthMethod(int authMethod
)
106 this.authMethod
= authMethod
;
110 * @return the privMethod
112 public int getPrivMethod()
118 * @param privMethod the privMethod to set
120 public void setPrivMethod(int privMethod
)
122 this.privMethod
= privMethod
;
126 * @return the authPassword
128 public String
getAuthPassword()
134 * @param authPassword the authPassword to set
136 public void setAuthPassword(String authPassword
)
138 this.authPassword
= authPassword
;
142 * @return the privPassword
144 public String
getPrivPassword()
150 * @param privPassword the privPassword to set
152 public void setPrivPassword(String privPassword
)
154 this.privPassword
= privPassword
;
158 * @see java.lang.Object#hashCode()
161 public int hashCode()
163 final int prime
= 31;
165 result
= prime
* result
+ authMethod
;
166 result
= prime
* result
+ ((authPassword
== null
) ?
0 : authPassword
.hashCode());
167 result
= prime
* result
+ ((name
== null
) ?
0 : name
.hashCode());
168 result
= prime
* result
+ privMethod
;
169 result
= prime
* result
+ ((privPassword
== null
) ?
0 : privPassword
.hashCode());
174 * @see java.lang.Object#equals(java.lang.Object)
177 public boolean equals(Object obj
)
183 if (getClass() != obj
.getClass())
185 SnmpUsmCredential other
= (SnmpUsmCredential
)obj
;
186 if (authMethod
!= other
.authMethod
)
188 if (authPassword
== null
)
190 if (other
.authPassword
!= null
)
193 else if (!authPassword
.equals(other
.authPassword
))
197 if (other
.name
!= null
)
200 else if (!name
.equals(other
.name
))
202 if (privMethod
!= other
.privMethod
)
204 if (privPassword
== null
)
206 if (other
.privPassword
!= null
)
209 else if (!privPassword
.equals(other
.privPassword
))