@Override public void exitSyt_source_address(Syt_source_addressContext ctx) { Ip sourceAddress = Ip.parse(ctx.address.getText()); _currentTacplusServer.setSourceAddress(sourceAddress); }
@Override public void exitSyt_secret(Syt_secretContext ctx) { _currentTacplusServer.setSecret(applySecret(ctx.secret())); }
@Override public void enterSyp_disable(Syp_disableContext ctx) { // line is disabled so remove it from list of lines _currentLogicalSystem.getJf().getLines().remove(_currentLine.getName()); }
@Override public void enterSy_services_linetype(Sy_services_linetypeContext ctx) { String name = ctx.linetype.getText(); _currentLogicalSystem.getJf().getLines().computeIfAbsent(name, Line::new); _currentLine = _currentLogicalSystem.getJf().getLines().get(name); // if system authentication order defined, set the current line's authentication login list to // the system authentication order if (_currentLogicalSystem.getJf().getSystemAuthenticationOrder() != null && _currentLine.getAaaAuthenticationLoginList() == null) { _currentLine.setAaaAuthenticationLoginList( new AaaAuthenticationLoginList( _currentLogicalSystem.getJf().getSystemAuthenticationOrder().getMethods(), true)); } }
_ipsecProposals = new TreeMap<>(); _ipsecVpns = new TreeMap<>(); _jf = new JuniperFamily(); _ntpServers = new TreeSet<>(); _prefixLists = new TreeMap<>();
@Override public void enterSy_authentication_order(Sy_authentication_orderContext ctx) { if (_currentLine != null) { // in system services/ports hierarchy _currentAuthenticationOrder = _currentLine.getAaaAuthenticationLoginList(); if (_currentAuthenticationOrder == null || _currentAuthenticationOrder.isDefault()) { // if the line already has a default authentication order, give it a new non-default one _currentAuthenticationOrder = new AaaAuthenticationLoginList(new ArrayList<>(), false); _currentLine.setAaaAuthenticationLoginList(_currentAuthenticationOrder); } } else { // in system hierarchy _currentAuthenticationOrder = _currentLogicalSystem.getJf().getSystemAuthenticationOrder(); if (_currentAuthenticationOrder == null || _currentAuthenticationOrder.isDefault()) { // if system already has a default authentication order, give it a new non-default one _currentAuthenticationOrder = new AaaAuthenticationLoginList(new ArrayList<>(), false); _currentLogicalSystem.getJf().setSystemAuthenticationOrder(_currentAuthenticationOrder); } } // _currentAuthenticationOrder = authenticationOrder.getMethods(); }
@Override public void enterSy_tacplus_server(Sy_tacplus_serverContext ctx) { String hostname = ctx.hostname.getText(); _currentLogicalSystem.getTacplusServers().add(hostname); _currentTacplusServer = _currentLogicalSystem .getJf() .getTacplusServers() .computeIfAbsent(hostname, TacplusServer::new); }
@Override public void exitSyr_encrypted_password(Syr_encrypted_passwordContext ctx) { String hash = ctx.password.getText(); String rehashedPassword = CommonUtil.sha256Digest(hash + CommonUtil.salt()); _currentLogicalSystem.getJf().setRootAuthenticationEncryptedPassword(rehashedPassword); }
@Override public void enterSy_ports(Sy_portsContext ctx) { String name = ctx.porttype.getText(); // aux and console ports should already exist unless they've been disabled, if disabled don't // add it to juniperFamily's lines _currentLine = firstNonNull(_currentLogicalSystem.getJf().getLines().get(name), new Line(name)); }
@Test public void toStringMulitipleFamilies() { VendorFamily family = new VendorFamily(); family.setCisco(new CiscoFamily()); family.setJuniper(new JuniperFamily()); assertThat( family.toString(), equalTo(String.join(" ", Arrays.asList(Type.CISCO.toString(), Type.JUNIPER.toString())))); }
@Override public void exitSy_authentication_order(Sy_authentication_orderContext ctx) { if (_currentLine == null) { // in system hierarchy for (Line line : _currentLogicalSystem.getJf().getLines().values()) { if (line.getAaaAuthenticationLoginList() == null || line.getAaaAuthenticationLoginList().isDefault()) { // line has no login list or has default login list, give it the system's login list line.setAaaAuthenticationLoginList( new AaaAuthenticationLoginList(_currentAuthenticationOrder.getMethods(), true)); } } } _currentAuthenticationOrder = null; }
@Override public TableAnswerElement answer() { AaaAuthenticationLoginQuestion question = (AaaAuthenticationLoginQuestion) _question; TableAnswerElement answerElement = create(question); Set<String> specifiedNodes = question.getNodes().getMatchingNodes(_batfish); SortedMap<String, Configuration> configs = _batfish.loadConfigurations(); configs.forEach( (configName, config) -> { if (specifiedNodes.contains(configName)) { Row row = null; if (config.getVendorFamily().getCisco() != null) { row = getRow(configName, config.getVendorFamily().getCisco().getLines().values()); } else if (config.getVendorFamily().getJuniper() != null) { row = getRow(configName, config.getVendorFamily().getJuniper().getLines().values()); } if (row != null) { answerElement.addRow(row); } } }); answerElement.setSummary(answerElement.computeSummary(question.getAssertion())); return answerElement; }