@Override protected Aaa featureValueOf(CiscoFamily actual) { return actual.getAaa(); } }
@Override public void exitAaa_new_model(Aaa_new_modelContext ctx) { _configuration.getCf().getAaa().setNewModel(!_no); }
@Override public void exitAaa_accounting_default_group(Aaa_accounting_default_groupContext ctx) { List<String> groups = ctx.groups.stream().map(RuleContext::getText).collect(Collectors.toList()); _configuration.getCf().getAaa().getAccounting().getDefault().setGroups(groups); }
private void processLines() { // nxos does not have 'login authentication' for lines, so just have it // use default list if one exists if (_vendor == ConfigurationFormat.CISCO_NX && _cf.getAaa() != null && _cf.getAaa().getAuthentication() != null && _cf.getAaa().getAuthentication().getLogin() != null && _cf.getAaa() .getAuthentication() .getLogin() .getLists() .get(AaaAuthenticationLogin.DEFAULT_LIST_NAME) != null) { for (Line line : _cf.getLines().values()) { line.setLoginAuthentication(AaaAuthenticationLogin.DEFAULT_LIST_NAME); } } }
@Override public void enterAaa_accounting_commands_line(Aaa_accounting_commands_lineContext ctx) { Map<String, AaaAccountingCommands> commands = _configuration.getCf().getAaa().getAccounting().getCommands(); Set<String> levels = new TreeSet<>(); if (ctx.levels != null) { List<SubRange> range = toRange(ctx.levels); for (SubRange subRange : range) { for (int i = subRange.getStart(); i <= subRange.getEnd(); i++) { String level = Integer.toString(i); levels.add(level); } } } else { levels.add(AaaAccounting.DEFAULT_COMMANDS); } List<AaaAccountingCommands> currentAaaAccountingCommands = new ArrayList<>(); for (String level : levels) { AaaAccountingCommands c = commands.computeIfAbsent(level, k -> new AaaAccountingCommands()); currentAaaAccountingCommands.add(c); } _currentAaaAccountingCommands = currentAaaAccountingCommands; }
@Override public void exitAaa_authentication_login_privilege_mode( Aaa_authentication_login_privilege_modeContext ctx) { _configuration.getCf().getAaa().getAuthentication().getLogin().setPrivilegeMode(true); }
@Override public void exitAaa_accounting_default_local(Aaa_accounting_default_localContext ctx) { _configuration.getCf().getAaa().getAccounting().getDefault().setLocal(true); }
@Override public void exitL_login_authentication(L_login_authenticationContext ctx) { String list; if (ctx.DEFAULT() != null) { list = ctx.DEFAULT().getText(); } else if (ctx.name != null) { list = ctx.name.getText(); } else { throw new BatfishException("Invalid list name"); } // get the authentication list or null if Aaa, AaaAuthentication, or AaaAuthenticationLogin is // null or the list is not defined AaaAuthenticationLoginList authList = Optional.ofNullable(_configuration.getCf().getAaa()) .map(Aaa::getAuthentication) .map(AaaAuthentication::getLogin) .map(AaaAuthenticationLogin::getLists) .map(lists -> lists.get(list)) .orElse(null); // if the authentication list has been defined, apply it to all lines in _currentLineNames for (String line : _currentLineNames) { if (authList != null) { _configuration.getCf().getLines().get(line).setAaaAuthenticationLoginList(authList); } // set the name of the login list even if the list hasn't been defined yet because it may be // defined later _configuration.getCf().getLines().get(line).setLoginAuthentication(list); } }
@Override public void enterAaa_accounting_default(Aaa_accounting_defaultContext ctx) { AaaAccounting accounting = _configuration.getCf().getAaa().getAccounting(); if (accounting.getDefault() == null) { accounting.setDefault(new AaaAccountingDefault()); } }
@Override public void enterS_aaa(S_aaaContext ctx) { _no = ctx.NO() != null; if (_configuration.getCf().getAaa() == null) { _configuration.getCf().setAaa(new Aaa()); } }
@Override public void enterAaa_authentication_asa(Aaa_authentication_asaContext ctx) { if (_configuration.getCf().getAaa().getAuthentication().getLogin() == null) { _configuration.getCf().getAaa().getAuthentication().setLogin(new AaaAuthenticationLogin()); } ArrayList<AuthenticationMethod> methods = new ArrayList<>(); if (ctx.aaa_authentication_asa_console().group != null) { methods.add(AuthenticationMethod.GROUP_USER_DEFINED); } if (ctx.aaa_authentication_asa_console().LOCAL_ASA() != null) { methods.add(AuthenticationMethod.LOCAL_CASE); } if (!methods.isEmpty()) { AaaAuthenticationLogin login = _configuration.getCf().getAaa().getAuthentication().getLogin(); String name = ctx.linetype.getText(); AaaAuthenticationLoginList authList = new AaaAuthenticationLoginList(methods); _configuration .getCf() .getLines() .computeIfAbsent(name, Line::new) .setAaaAuthenticationLoginList(authList); // not allowed to specify multiple login lists for a given linetype so use computeIfAbsent // rather than put so we only accept the first login list _currentAaaAuthenticationLoginList = login.getLists().computeIfAbsent(name, k -> authList); } }
@Override public void enterAaa_authentication_login_list(Aaa_authentication_login_listContext ctx) { AaaAuthenticationLogin login = _configuration.getCf().getAaa().getAuthentication().getLogin(); String name; if (ctx.DEFAULT() != null) {
Aaa aaa = _cf.getAaa(); if (aaa != null) { AaaAuthentication authentication = aaa.getAuthentication();