/** * Updates the USM user entry with the same engine ID and user name as the * supplied instance and fires an appropriate <code>UsmUserEvent</code>. * If the corresponding user entry does not yet exist then it will be added. * @param entry * an <code>UsmUserEntry</code> instance not necessarily the same as an * already existing entry. * @since 1.2 */ public void updateUser(UsmUserEntry entry) { UsmUserEntry oldEntry = userTable.addUser(entry); fireUsmUserChange(new UsmUserEvent(this, entry, (oldEntry == null) ? UsmUserEvent.USER_ADDED: UsmUserEvent.USER_CHANGED)); }
/** * Checks if the specified user is known by this USM. * @param engineID * the engineID of the user (may be <code>null</code> if any target should * match). * @param securityName * the security name of the user to earch for. * @return * <code>true</code> if the user is either known for the specified engine ID * or without a specific engine ID (discovery only). * @since */ public boolean hasUser(OctetString engineID, OctetString securityName) { UsmUserEntry entry = userTable.getUser(engineID, securityName); if (entry == null) { entry = userTable.getUser(securityName); if ((entry == null) && (securityName.length() > 0)) { return false; } } return true; }
/** * Creates a USM with the support for the supplied security protocols. * * @param securityProtocols * the security protocols to support. * @param localEngineID * the local engine ID. * @param engineBoots * the number of engine boots. * @since 1.2 */ public USM(SecurityProtocols securityProtocols, OctetString localEngineID, int engineBoots) { this.localEngineID = localEngineID; timeTable = new UsmTimeTable(localEngineID, engineBoots); userTable = new UsmUserTable(); this.securityProtocols = securityProtocols; counterSupport = CounterSupport.getInstance(); }
/** * Sets the users of this USM. All previously added users and all localized * user information will be discarded and replaced by the supplied users. * * @param users * a possibly empty {@code UsmUser} array of users. * @since 1.1 */ public void setUsers(UsmUser[] users) { if ((users == null) || (users.length == 0)) { userTable.clear(); } else { Vector<UsmUserEntry> v = new Vector<UsmUserEntry>(users.length); for (UsmUser user : users) { UsmUserEntry entry = new UsmUserEntry(user.getSecurityName(), (UsmUser) user.clone()); v.add(entry); } userTable.setUsers(v); } }
privProtocol, privKey)); usmUserEntry.setStorageType(SnmpConstants.StorageTypeEnum.permanent); usm.getUserTable().addUser(usmUserEntry); if (usm.getUserTable().getUser(dhKickstartParameters.getSecurityName()) == null || dhKickstartParameters.isResetRequested()) { usm.addUsmUserEntry(usmUserEntry); usm.getUserTable().addUser(new UsmUserEntry(dhKickstart, new UsmUser(dhKickstart, SnmpConstants.usmNoAuthProtocol, null,
/** * Removes all users from the USM. */ public void removeAllUsers() { userTable.clear(); fireUsmUserChange(new UsmUserEvent(this, null, UsmUserEvent.USER_REMOVED)); }
/** * Removes an USM user from the internal user name table. * * @param engineID * the authoritative engine ID associated with the user, or * {@code null} * @param userName * a user name. * * @return the removed {@code UsmUser} instance associate with the given * {@code userName} or {@code null} if such a user could not * be found. * @deprecated If the engineID {@code null} is provided this method does only * delete the generic user. All already localized users will not be deleted. * To delete those users too, use {@link #removeAllUsers(OctetString, OctetString)} instead. */ @Deprecated public UsmUser removeUser(OctetString engineID, OctetString userName) { UsmUserEntry entry = userTable.removeUser(engineID, userName); if (entry != null) { fireUsmUserChange(new UsmUserEvent(this, entry, UsmUserEvent.USER_REMOVED)); return entry.getUsmUser(); } return null; }
/** * Removes all USM user from the internal user name table with the specified user * name and (optional) engine ID. If the engine ID is not provided (null) * then any user (including localized) are removed that have the specified user name. * * @param userName * a user name. * @param engineID * the authoritative engine ID associated with the user by localization, or * {@code null} if all users with {@code userName} should be * deleted. * @return * the removed {@code UsmUser} instances as a List. If the user could * be found, an empty list is returned. * @since * 2.2 */ public List<UsmUser> removeAllUsers(OctetString userName, OctetString engineID) { List<UsmUserEntry> entries = userTable.removeAllUsers(userName, engineID); if (!entries.isEmpty()) { List<UsmUser> users = new ArrayList<UsmUser>(); for (UsmUserEntry entry : entries) { users.add(entry.getUsmUser()); fireUsmUserChange(new UsmUserEvent(this, entry, UsmUserEvent.USER_REMOVED)); } return users; } return Collections.emptyList(); }
/** * Sets the users of this USM. All previously added users and all localized * user information will be discarded and replaced by the supplied users. * * @param users * a possibly empty <code>UsmUser</code> array of users. * @since 1.1 */ public void setUsers(UsmUser[] users) { if ((users == null) || (users.length == 0)) { userTable.clear(); } else { Vector v = new Vector(users.length); for (int i=0; i<users.length; i++) { UsmUserEntry entry = new UsmUserEntry(users[i].getSecurityName(), (UsmUser)users[i].clone()); v.add(entry); } userTable.setUsers(v); } }
/** * Removes all users from the USM. */ public void removeAllUsers() { userTable.clear(); fireUsmUserChange(new UsmUserEvent(this, null, UsmUserEvent.USER_REMOVED)); }
/** * Removes an USM user from the internal user name table. * @param engineID * the authoritative engine ID associated with the user, or * <code>null</code> * @param userName * a user name. * @return * the removed <code>UsmUser</code> instance associate with the given * <code>userName</code> or <code>null</code> if such a user could not * be found. */ public UsmUser removeUser(OctetString engineID, OctetString userName) { UsmUserEntry entry = userTable.removeUser(engineID, userName); if (entry != null) { fireUsmUserChange(new UsmUserEvent(this, entry, UsmUserEvent.USER_REMOVED)); return entry.getUsmUser(); } return null; }
/** * Removes all USM user from the internal user name table with the specified user * name and (optional) engine ID. If the engine ID is not provided (null) * then any user (including localized) are removed that have the specified user name. * * @param userName * a user name. * @param engineID * the authoritative engine ID associated with the user by localization, or * {@code null} if all users with {@code userName} should be * deleted. * * @return the removed {@code UsmUser} instances as a List. If the user could * be found, an empty list is returned. * @since 2.2 */ public List<UsmUser> removeAllUsers(OctetString userName, OctetString engineID) { List<UsmUserEntry> entries = userTable.removeAllUsers(userName, engineID); if (!entries.isEmpty()) { List<UsmUser> users = new ArrayList<UsmUser>(); for (UsmUserEntry entry : entries) { users.add(entry.getUsmUser()); fireUsmUserChange(new UsmUserEvent(this, entry, UsmUserEvent.USER_REMOVED)); } return users; } return Collections.emptyList(); }
/** * Adds an USM user to the internal user name table. * The user's security name is used as userName. * The storage type member of the supplied by {@link UsmUserEntry#getStorageType()} defines the storage type * of the new USM user table entry. * * Caution: This is a low level call and the provided UsmUserEntry must contain already correctly localized * authentication and privacy keys as well as a correct user engine ID. * * @param usmUserEntry * the {@link UsmUserEntry} to add. * @since 2.5.7 */ public void addUsmUserEntry(UsmUserEntry usmUserEntry) { userTable.addUser(usmUserEntry); fireUsmUserChange(new UsmUserEvent(this, usmUserEntry, UsmUserEvent.USER_ADDED)); }
/** * Checks if the specified user is known by this USM. * @param engineID * the engineID of the user (may be {@code null} if any target should * match). * @param securityName * the security name of the user to earch for. * @return * {@code true} if the user is either known for the specified engine ID * or without a specific engine ID (discovery only). */ public boolean hasUser(OctetString engineID, OctetString securityName) { UsmUserEntry entry = userTable.getUser(engineID, securityName); if (entry == null) { entry = userTable.getUser(securityName); if ((entry == null) && (securityName.length() > 0)) { return false; } } return true; }
/** * Sets the users of this USM. All previously added users and all localized * user information will be discarded and replaced by the supplied users. * * @param users * a possibly empty {@code UsmUser} array of users. * * @since 1.1 */ public void setUsers(UsmUser[] users) { if ((users == null) || (users.length == 0)) { userTable.clear(); } else { ArrayList<UsmUserEntry> v = new ArrayList<>(users.length); for (UsmUser user : users) { UsmUserEntry entry = new UsmUserEntry(user.getSecurityName(), (UsmUser) user.clone()); v.add(entry); } userTable.setUsers(v); } }
/** * Removes all users from the USM. */ public void removeAllUsers() { userTable.clear(); fireUsmUserChange(new UsmUserEvent(this, null, UsmUserEvent.USER_REMOVED)); }
/** * Creates a USM with the support for the supplied security protocols. * * @param securityProtocols * the security protocols to support. * @param localEngineID * the local engine ID. * @param engineBoots * the number of engine boots. * @since 1.2 */ public USM(SecurityProtocols securityProtocols, OctetString localEngineID, int engineBoots) { this.localEngineID = localEngineID; timeTable = new UsmTimeTable(localEngineID, engineBoots); userTable = new UsmUserTable(); this.securityProtocols = securityProtocols; counterSupport = CounterSupport.getInstance(); }
/** * Removes an USM user from the internal user name table. * @param engineID * the authoritative engine ID associated with the user, or * {@code null} * @param userName * a user name. * @return * the removed {@code UsmUser} instance associate with the given * {@code userName} or {@code null} if such a user could not * be found. * @deprecated * If the engineID {@code null} is provided this method does only * delete the generic user. All already localized users will not be deleted. * To delete those users too, use {@link #removeAllUsers()} instead. */ public UsmUser removeUser(OctetString engineID, OctetString userName) { UsmUserEntry entry = userTable.removeUser(engineID, userName); if (entry != null) { fireUsmUserChange(new UsmUserEvent(this, entry, UsmUserEvent.USER_REMOVED)); return entry.getUsmUser(); } return null; }
/** * Adds an USM user to the internal user name table. * The user's security name is used as userName. * The storage type member of the supplied by {@link UsmUserEntry#getStorageType()} defines the storage type * of the new USM user table entry. * <p> * Caution: This is a low level call and the provided UsmUserEntry must contain already correctly localized * authentication and privacy keys as well as a correct user engine ID. * * @param usmUserEntry * the {@link UsmUserEntry} to add. * * @since 2.5.7 */ public void addUsmUserEntry(UsmUserEntry usmUserEntry) { userTable.addUser(usmUserEntry); fireUsmUserChange(new UsmUserEvent(this, usmUserEntry, UsmUserEvent.USER_ADDED)); }
/** * Checks if the specified user is known by this USM. * * @param engineID * the engineID of the user (may be {@code null} if any target should * match). * @param securityName * the security name of the user to earch for. * * @return {@code true} if the user is either known for the specified engine ID * or without a specific engine ID (discovery only). */ public boolean hasUser(OctetString engineID, OctetString securityName) { UsmUserEntry entry = userTable.getUser(engineID, securityName); if (entry == null) { entry = userTable.getUser(securityName); if ((entry == null) && (securityName.length() > 0)) { return false; } } return true; }