KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > snmp > UsmOwnKeyChange


1 /*_############################################################################
2   _##
3   _## SNMP4J-Agent - UsmOwnKeyChange.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21
22 package org.snmp4j.agent.mo.snmp;
23
24 import org.snmp4j.agent.MOAccess;
25 import org.snmp4j.agent.request.SubRequest;
26 import org.snmp4j.agent.mo.MOTableRow;
27 import org.snmp4j.PDU;
28 import org.snmp4j.smi.OctetString;
29 import org.snmp4j.smi.Variable;
30 import org.snmp4j.security.SecurityModel;
31
32 public class UsmOwnKeyChange extends UsmKeyChange {
33
34   public UsmOwnKeyChange(int columnID, MOAccess access, int type) {
35     super(columnID, access, type);
36   }
37
38   public void prepare(SubRequest subRequest, MOTableRow row,
39                       MOTableRow changeSet, int column) {
40     Variable[] indexValues =
41         ((UsmMIB.UsmTableRow)row).getIndexDef().getIndexValues(row.getIndex());
42     OctetString userName = (OctetString) indexValues[1];
43     if ((!subRequest.getRequest().getSecurityName().equals(userName)) ||
44         subRequest.getRequest().getSecurityModel() !=
45         SecurityModel.SECURITY_MODEL_USM) {
46       subRequest.getStatus().setErrorStatus(PDU.noAccess);
47     }
48     else {
49       super.prepare(subRequest, row, changeSet, column);
50     }
51   }
52
53
54 }
55
Popular Tags