diff --git a/src/main/java/edu/kit/kastel/sdq/newslist/config/SecurityConfiguration.java b/src/main/java/edu/kit/kastel/sdq/newslist/config/SecurityConfiguration.java index 8bf2fe1..51f8986 100644 --- a/src/main/java/edu/kit/kastel/sdq/newslist/config/SecurityConfiguration.java +++ b/src/main/java/edu/kit/kastel/sdq/newslist/config/SecurityConfiguration.java @@ -25,35 +25,28 @@ @Configuration public class SecurityConfiguration { - public SecurityConfiguration(){ - Security.addProvider(new BouncyCastleProvider()); - } - - @Bean - SecurityFilterChain app(HttpSecurity http) throws Exception { - // @formatter:off - http - .authorizeHttpRequests((authorize) -> authorize - .anyRequest().authenticated() - ) - .saml2Login(Customizer.withDefaults()); - // @formatter:on - - return http.build(); - } - - @Bean - RelyingPartyRegistrationResolver relyingPartyRegistrationResolver( - RelyingPartyRegistrationRepository registrations) { - return new DefaultRelyingPartyRegistrationResolver(registrations); - } - - @Bean - FilterRegistrationBean metadata(RelyingPartyRegistrationResolver registrations) { - Saml2MetadataFilter metadata = new Saml2MetadataFilter(registrations, new OpenSamlMetadataResolver()); - FilterRegistrationBean filter = new FilterRegistrationBean<>(metadata); - filter.setOrder(-101); - return filter; - } + public SecurityConfiguration() { + Security.addProvider(new BouncyCastleProvider()); + } + + @Bean + SecurityFilterChain app(HttpSecurity http) throws Exception { + http.authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated()).saml2Login(Customizer.withDefaults()); + return http.build(); + } + + @Bean + RelyingPartyRegistrationResolver relyingPartyRegistrationResolver( + RelyingPartyRegistrationRepository registrations) { + return new DefaultRelyingPartyRegistrationResolver(registrations); + } + + @Bean + FilterRegistrationBean metadata(RelyingPartyRegistrationResolver registrations) { + Saml2MetadataFilter metadata = new Saml2MetadataFilter(registrations, new OpenSamlMetadataResolver()); + FilterRegistrationBean filter = new FilterRegistrationBean<>(metadata); + filter.setOrder(-101); + return filter; + } } diff --git a/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsItem.java b/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsItem.java index 7275f50..44596d2 100644 --- a/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsItem.java +++ b/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsItem.java @@ -4,8 +4,8 @@ * @author Lucas Alber */ public class NewsItem { - private String title; - private String content; + private final String title; + private final String content; /** * diff --git a/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsService.java b/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsService.java index e8902d6..85e6253 100644 --- a/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsService.java +++ b/src/main/java/edu/kit/kastel/sdq/newslist/service/NewsService.java @@ -52,7 +52,7 @@ public void parseCSVs() { .map(Path::toFile) .filter(e -> e.getName().endsWith(".csv")) .sorted() - .collect(Collectors.toList()); + .toList(); } catch (IOException e) { logger.warn("CSVs could not be parsed.", e); @@ -62,20 +62,20 @@ public void parseCSVs() { for (File file : files) { logger.debug("Parsing " + file.getAbsolutePath()); try { - for (CSVRecord record : format.parse(new FileReader(file))) { - if (record.size() != 2) { - logger.warn("Expected exactly two columns, but record " + record + " had " + record.size() + ". Skipping!"); + for (CSVRecord csvRecord : format.parse(new FileReader(file))) { + if (csvRecord.size() != 2) { + logger.warn("Expected exactly two columns, but record " + csvRecord + " had " + csvRecord.size() + ". Skipping!"); continue; } - final String key = record.get(0); + final String key = csvRecord.get(0); if (!news.containsKey(key)) { news.put(key, new LinkedList<>()); } String title = file.getName().substring(0, file.getName().length() - 4).replaceAll("[_]", ""); - String content = record.get(1); + String content = csvRecord.get(1); news.get(key).add(new NewsItem(title, content)); } diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 250f363..cdb227f 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -1,28 +1,27 @@ - + News List - - - + + -
-

SDQ-NewsList

-

You are successfully identified as . Looking for News via ''.

-

Your News

- + + +