Skip to content

Commit

Permalink
#207 Update dependencies [version does not work]
Browse files Browse the repository at this point in the history
  • Loading branch information
sklein94 committed Mar 29, 2023
1 parent d063bfd commit 8f60d2f
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 61 deletions.
14 changes: 11 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.14</version>
<version>3.0.5</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -196,6 +196,14 @@
<version>5.2.1</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>


</dependencies>


Expand Down Expand Up @@ -395,7 +403,7 @@
<cas-client.version>3.4.1</cas-client.version>
<java.version>11</java.version>
<jaxb.version>2.3.0</jaxb.version>
<tomcat.version>9.0.69</tomcat.version>
<groovy.version>2.5.14</groovy.version>
<!-- <tomcat.version>9.0.69</tomcat.version>-->
<!-- <groovy.version>2.5.14</groovy.version>-->
</properties>
</project>
4 changes: 2 additions & 2 deletions src/main/java/com/cloudogu/smeagol/AccountService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -16,8 +18,6 @@
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Base64;
import java.util.Map;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cloudogu/smeagol/CustomErrorController.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.cloudogu.smeagol;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;

@Controller
public class CustomErrorController implements ErrorController {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cloudogu/smeagol/DevelopmentDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.io.ByteStreams;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/cloudogu/smeagol/Dispatcher.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.cloudogu.smeagol;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/cloudogu/smeagol/ProductionDispatcher.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.cloudogu.smeagol;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Pattern;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cloudogu/smeagol/ScmHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected static RestTemplate createRestTemplate(RestTemplateBuilder restTemplat
.disableCookieManagement();

if (stage == Stage.DEVELOPMENT) {
throw new RuntimeException("IMPLEMENT ME: TODO");
// TODO
// httpClientBuilder = disableSSLVerification(httpClientBuilder);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/cloudogu/smeagol/Smeagol.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.triology.cb.decorator.LoggingCommandBus;
import de.triology.cb.spring.Registry;
import de.triology.cb.spring.SpringCommandBus;
import jakarta.servlet.DispatcherType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -14,18 +15,17 @@
import org.springframework.context.annotation.Bean;
import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.util.UrlPathHelper;

import javax.servlet.DispatcherType;
import java.util.Collections;

/**
* Main entry point for the whole application.
*/
@SpringBootApplication
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
public class Smeagol extends WebMvcConfigurerAdapter {
public class Smeagol implements WebMvcConfigurer {

private static final Logger LOG = LoggerFactory.getLogger(Smeagol.class);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/cloudogu/smeagol/UiFilter.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.cloudogu.smeagol;

import com.google.common.base.Strings;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.cloudogu.smeagol.authc.infrastructure;

import com.google.common.annotations.VisibleForTesting;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jasig.cas.client.authentication.AuthenticationRedirectStrategy;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
Expand All @@ -21,13 +21,19 @@ public class AjaxAwareAuthenticationRedirectStrategy implements AuthenticationRe
@VisibleForTesting
static final String AJAX_HEADER_VALUE = "XMLHttpRequest";

// @Override
// public void redirect(HttpServletRequest request, HttpServletResponse response, String potentialRedirectUrl) throws IOException {
// if (isAjaxRequest(request)) {
// sendAjaxResponse(response, potentialRedirectUrl);
// } else {
// sendNormalResponse(response, potentialRedirectUrl);
// }
// }


@Override
public void redirect(HttpServletRequest request, HttpServletResponse response, String potentialRedirectUrl) throws IOException {
if (isAjaxRequest(request)) {
sendAjaxResponse(response, potentialRedirectUrl);
} else {
sendNormalResponse(response, potentialRedirectUrl);
}
public void redirect(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, String s) throws IOException {
// TODO
}

private boolean isAjaxRequest(HttpServletRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Provides configuration details for cas authentication.
*/
@Component
//@Component
public class CasConfiguration {

private final String contextPath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.cloudogu.smeagol.authc.infrastructure;

import com.cloudogu.smeagol.Stage;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;
import org.jasig.cas.client.authentication.AuthenticationFilter;
import org.jasig.cas.client.session.SingleSignOutFilter;
import org.jasig.cas.client.session.SingleSignOutHttpSessionListener;
Expand All @@ -14,23 +17,22 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;
import javax.servlet.http.HttpSessionListener;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;

/**
* CasInfrastructureRegistration will take the configuration parameters from the application configuration and will
* construct the required infrastructure for cas authentication.
*/
@Configuration
//@Configuration
public class CasInfrastructureRegistration {

private static final Logger LOG = LoggerFactory.getLogger(CasInfrastructureRegistration.class);

private Map<String,String> casSettings;

@Autowired
// @Autowired
public CasInfrastructureRegistration(CasConfiguration configuration, Stage stage) {
this.casSettings = configuration.createCasSettings();
if (stage == Stage.DEVELOPMENT) {
Expand All @@ -47,39 +49,78 @@ public CasInfrastructureRegistration(CasConfiguration configuration, Stage stage
*/
@Bean
public ServletListenerRegistrationBean<HttpSessionListener> singleSignOutListener() {
ServletListenerRegistrationBean<HttpSessionListener> listener = new ServletListenerRegistrationBean<>();
listener.setListener(new SingleSignOutHttpSessionListener());
return listener;
throw new RuntimeException("asdasdasd");
// ServletListenerRegistrationBean<HttpSessionListener> listener = new ServletListenerRegistrationBean<>();
// // TODO
//// listener.setListener(new SingleSignOutHttpSessionListener());
// listener.setListener(new HttpSessionListener() {
// @Override
// public void sessionCreated(HttpSessionEvent se) {
// HttpSessionListener.super.sessionCreated(se);
// }
//
// @Override
// public void sessionDestroyed(HttpSessionEvent se) {
// HttpSessionListener.super.sessionDestroyed(se);
// }
// });
// return listener;
}

/**
* Registers a servlet filter who is responsible for handling single sign out.
*
* @return filter registration
*/
@Bean
// @Bean
public FilterRegistrationBean singleSignOutFilter() {
return casFilterRegistration(new SingleSignOutFilter(), 0);
throw new RuntimeException("asdasdasd");
// // TODO
//// return casFilterRegistration(new SingleSignOutFilter(), 0);
// return casFilterRegistration(new Filter() {
// @Override
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//
// }
// }, 0);
}

/**
* Registers a servlet filter who is responsible for validating received cas tickets.
*
* @return filter registration
*/
@Bean
// @Bean
public FilterRegistrationBean proxyReceivingTicketValidationFilter() {
return casFilterRegistration(new Cas30ProxyReceivingTicketValidationFilter(), 1);
throw new RuntimeException("asdasdasd");

// TODO
//// return casFilterRegistration(new Cas30ProxyReceivingTicketValidationFilter(), 1);
// return casFilterRegistration(new Filter() {
// @Override
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//
// }
// }, 1);
}

/**
* Registers a servlet filter who is responsible for the cas authentication flow.
*
* @return filter registration
*/
@Bean
// @Bean
public FilterRegistrationBean authenticationFilter() {
return casFilterRegistration(new AuthenticationFilter(), 2);
throw new RuntimeException("asdasdasd");
//
// // TODO
//// return casFilterRegistration(new AuthenticationFilter(), 2);
// return casFilterRegistration(new Filter() {
// @Override
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//
// }
// }, 2);
}

/**
Expand All @@ -88,9 +129,18 @@ public FilterRegistrationBean authenticationFilter() {
*
* @return filter registration
*/
@Bean
// @Bean
public FilterRegistrationBean requestWrapperFilter() {
return casFilterRegistration(new HttpServletRequestWrapperFilter(), 3);
throw new RuntimeException("asdasdasd");
//
// // TODO
//// return casFilterRegistration(new HttpServletRequestWrapperFilter(), 3);
// return casFilterRegistration(new Filter() {
// @Override
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//
// }
// }, 3);
}

private FilterRegistrationBean casFilterRegistration(Filter filter, int order){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.cloudogu.smeagol.authc.infrastructure;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
* Destroy the user session and redirects to the cas server.
*/
@RestController
@RequestMapping("/api/v1/logout")
//@RestController
//@RequestMapping("/api/v1/logout")
public class SignOutController {

private CasConfiguration casConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* - cas redirects back to /api/v1/authc ({@link UICasAuthenticationController})
* - {@link UICasAuthenticationController} extracts the location parameter and redirects back to ui
*/
@RestController
@RequestMapping("/api/v1/authc")
//@RestController
//@RequestMapping("/api/v1/authc")
public class UICasAuthenticationController {

@RequestMapping
Expand Down
Loading

0 comments on commit 8f60d2f

Please sign in to comment.