diff --git a/src/main/java/edu/hawaii/its/api/controller/ForTestingController.java b/src/main/java/edu/hawaii/its/api/controller/ForTestingController.java index e5f52a211..2f0f49214 100644 --- a/src/main/java/edu/hawaii/its/api/controller/ForTestingController.java +++ b/src/main/java/edu/hawaii/its/api/controller/ForTestingController.java @@ -2,7 +2,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -21,11 +20,14 @@ public class ForTestingController { @Value("${url.api.2.1.base}/testing") private String API_2_1_BASE; - @Autowired - private HttpRequestService httpRequestService; + private final HttpRequestService httpRequestService; - @Autowired - private UserContextService userContextService; + private final UserContextService userContextService; + + public ForTestingController(HttpRequestService httpRequestService, UserContextService userContextService) { + this.httpRequestService = httpRequestService; + this.userContextService = userContextService; + } @GetMapping(value = "/exception") public ResponseEntity throwException() { diff --git a/src/main/java/edu/hawaii/its/api/controller/GeneralRestController.java b/src/main/java/edu/hawaii/its/api/controller/GeneralRestController.java index 649504caf..1f1ffa99e 100644 --- a/src/main/java/edu/hawaii/its/api/controller/GeneralRestController.java +++ b/src/main/java/edu/hawaii/its/api/controller/GeneralRestController.java @@ -2,7 +2,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -20,11 +19,14 @@ public class GeneralRestController { @Value("${url.api.2.1.base}") private String API_2_1_BASE; - @Autowired - private HttpRequestService httpRequestService; + private final HttpRequestService httpRequestService; - @Autowired - private UserContextService userContextService; + private final UserContextService userContextService; + + public GeneralRestController(HttpRequestService httpRequestService, UserContextService userContextService) { + this.httpRequestService = httpRequestService; + this.userContextService = userContextService; + } /** * Get the list of active announcements to display. diff --git a/src/main/java/edu/hawaii/its/api/controller/GroupingsRestController.java b/src/main/java/edu/hawaii/its/api/controller/GroupingsRestController.java index 46fe5572f..8b76678a1 100644 --- a/src/main/java/edu/hawaii/its/api/controller/GroupingsRestController.java +++ b/src/main/java/edu/hawaii/its/api/controller/GroupingsRestController.java @@ -12,7 +12,6 @@ import org.apache.commons.logging.LogFactory; import org.owasp.html.PolicyFactory; import org.owasp.html.Sanitizers; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; @@ -39,7 +38,7 @@ public class GroupingsRestController { private static final Log logger = LogFactory.getLog(GroupingsRestController.class); - private final PolicyFactory policy; + private final PolicyFactory policy = Sanitizers.FORMATTING;; @Value("${app.groupings.controller.uuid}") private String uuid; @@ -56,8 +55,7 @@ public class GroupingsRestController { @Value("${app.api.handshake.enabled:true}") private Boolean API_HANDSHAKE_ENABLED = true; - @Autowired - private UserContextService userContextService; + private final UserContextService userContextService; /* * Checks to make sure that the API is running and that there are no issues with the overrides file. @@ -66,15 +64,15 @@ public class GroupingsRestController { @Value("${groupings.api.check}") private String CREDENTIAL_CHECK_USER; - @Autowired private HttpRequestService httpRequestService; - @Autowired private Realm realm; // Constructor. - public GroupingsRestController() { - policy = Sanitizers.FORMATTING; + public GroupingsRestController(UserContextService userContextService, HttpRequestService httpRequestService, Realm realm) { + this.userContextService = userContextService; + this.httpRequestService = httpRequestService; + this.realm = realm; } /* diff --git a/src/main/java/edu/hawaii/its/api/controller/OotbRestController.java b/src/main/java/edu/hawaii/its/api/controller/OotbRestController.java index d2eebdb49..26190314a 100644 --- a/src/main/java/edu/hawaii/its/api/controller/OotbRestController.java +++ b/src/main/java/edu/hawaii/its/api/controller/OotbRestController.java @@ -8,7 +8,6 @@ import org.apache.commons.logging.LogFactory; import org.owasp.html.PolicyFactory; import org.owasp.html.Sanitizers; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -30,26 +29,28 @@ @RequestMapping("/api/groupings/ootb") public class OotbRestController { private static final Log logger = LogFactory.getLog(OotbRestController.class); - private final PolicyFactory policy; + private final PolicyFactory policy = Sanitizers.FORMATTING;; @Value("${url.api.2.1.base}") private String API_2_1_BASE; - @Autowired - private UserContextService userContextService; + private final UserContextService userContextService; - @Autowired - private OotbStaticUserAuthenticationFilter ootbAuthenticationFilter; + private final OotbStaticUserAuthenticationFilter ootbAuthenticationFilter; - @Autowired - private OotbActiveUserProfileService ootbActiveUserProfileService; + private final OotbActiveUserProfileService ootbActiveUserProfileService; - @Autowired - private HttpRequestService httpRequestService; + private final HttpRequestService httpRequestService; // Constructor. - public OotbRestController() { - policy = Sanitizers.FORMATTING; + public OotbRestController(UserContextService userContextService, + OotbStaticUserAuthenticationFilter ootbAuthenticationFilter, + OotbActiveUserProfileService ootbActiveUserProfileService, + HttpRequestService httpRequestService) { + this.userContextService = userContextService; + this.ootbAuthenticationFilter = ootbAuthenticationFilter; + this.ootbActiveUserProfileService = ootbActiveUserProfileService; + this.httpRequestService = httpRequestService; } /* diff --git a/src/main/java/edu/hawaii/its/groupings/access/AuthorizationService.java b/src/main/java/edu/hawaii/its/groupings/access/AuthorizationService.java index 52ac4190c..312c01b0b 100755 --- a/src/main/java/edu/hawaii/its/groupings/access/AuthorizationService.java +++ b/src/main/java/edu/hawaii/its/groupings/access/AuthorizationService.java @@ -7,7 +7,6 @@ import org.apereo.cas.client.authentication.SimplePrincipal; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -17,12 +16,15 @@ @Service public class AuthorizationService { - @Autowired - GroupingsRestController groupingsRestController; - - @Autowired - UhUuidCheckerService uhUuidCheckerService; private static final Log logger = LogFactory.getLog(AuthorizationService.class); + private final GroupingsRestController groupingsRestController; + + private final UhUuidCheckerService uhUuidCheckerService; + + public AuthorizationService(GroupingsRestController groupingsRestController, UhUuidCheckerService uhUuidCheckerService) { + this.groupingsRestController = groupingsRestController; + this.uhUuidCheckerService = uhUuidCheckerService; + } /** * Assign roles to user diff --git a/src/main/java/edu/hawaii/its/groupings/access/UserBuilder.java b/src/main/java/edu/hawaii/its/groupings/access/UserBuilder.java index 5dab28f39..6735042a9 100755 --- a/src/main/java/edu/hawaii/its/groupings/access/UserBuilder.java +++ b/src/main/java/edu/hawaii/its/groupings/access/UserBuilder.java @@ -4,7 +4,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; @@ -15,8 +14,11 @@ public final class UserBuilder { private static final Log logger = LogFactory.getLog(UserBuilder.class); - @Autowired - private AuthorizationService authorizationService; + private final AuthorizationService authorizationService; + + public UserBuilder(AuthorizationService authorizationService) { + this.authorizationService = authorizationService; + } public User make(Map map) { return make(new UhAttributes(map)); diff --git a/src/main/java/edu/hawaii/its/groupings/configuration/GrouperPropertyConfigurer.java b/src/main/java/edu/hawaii/its/groupings/configuration/GrouperPropertyConfigurer.java index f4e91751e..8f29509ee 100755 --- a/src/main/java/edu/hawaii/its/groupings/configuration/GrouperPropertyConfigurer.java +++ b/src/main/java/edu/hawaii/its/groupings/configuration/GrouperPropertyConfigurer.java @@ -2,7 +2,6 @@ import jakarta.annotation.PostConstruct; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; @@ -11,8 +10,11 @@ @Configuration public class GrouperPropertyConfigurer { - @Autowired - private Environment env; + private final Environment env; + + public GrouperPropertyConfigurer(Environment env) { + this.env = env; + } @PostConstruct public void init() { diff --git a/src/main/java/edu/hawaii/its/groupings/configuration/Realm.java b/src/main/java/edu/hawaii/its/groupings/configuration/Realm.java index 53154726c..8e63cb96c 100644 --- a/src/main/java/edu/hawaii/its/groupings/configuration/Realm.java +++ b/src/main/java/edu/hawaii/its/groupings/configuration/Realm.java @@ -7,7 +7,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; import org.springframework.util.Assert; @@ -17,8 +16,11 @@ public class Realm { private static final Log logger = LogFactory.getLog(Realm.class); - @Autowired - private Environment environment; + private final Environment environment; + + public Realm(Environment environment) { + this.environment = environment; + } private Map profileMap = new ConcurrentHashMap<>(); diff --git a/src/main/java/edu/hawaii/its/groupings/configuration/SecurityConfig.java b/src/main/java/edu/hawaii/its/groupings/configuration/SecurityConfig.java index 99711f2b2..f60e6f721 100755 --- a/src/main/java/edu/hawaii/its/groupings/configuration/SecurityConfig.java +++ b/src/main/java/edu/hawaii/its/groupings/configuration/SecurityConfig.java @@ -10,7 +10,6 @@ import org.apereo.cas.client.proxy.ProxyGrantingTicketStorageImpl; import org.apereo.cas.client.session.SingleSignOutFilter; import org.apereo.cas.client.validation.Saml11TicketValidator; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; @@ -65,8 +64,11 @@ public class SecurityConfig { @Value("${cas.send.renew:false}") private boolean casSendRenew; - @Autowired - private UserBuilder userBuilder; + private final UserBuilder userBuilder; + + public SecurityConfig(UserBuilder userBuilder) { + this.userBuilder = userBuilder; + } @PostConstruct public void init() { diff --git a/src/main/java/edu/hawaii/its/groupings/controller/ErrorControllerAdvice.java b/src/main/java/edu/hawaii/its/groupings/controller/ErrorControllerAdvice.java index b76840789..614b88555 100755 --- a/src/main/java/edu/hawaii/its/groupings/controller/ErrorControllerAdvice.java +++ b/src/main/java/edu/hawaii/its/groupings/controller/ErrorControllerAdvice.java @@ -7,7 +7,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.TypeMismatchException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -26,11 +25,14 @@ public class ErrorControllerAdvice { private static final Log logger = LogFactory.getLog(ErrorControllerAdvice.class); - @Autowired - private UserContextService userContextService; + private final UserContextService userContextService; - @Autowired - private EmailService emailService; + private final EmailService emailService; + + public ErrorControllerAdvice(UserContextService userContextService, EmailService emailService) { + this.userContextService = userContextService; + this.emailService = emailService; + } @ExceptionHandler(GroupingsServiceResultException.class) public ResponseEntity handleGroupingsServiceResultException(GroupingsServiceResultException gsre) { diff --git a/src/main/java/edu/hawaii/its/groupings/controller/HomeController.java b/src/main/java/edu/hawaii/its/groupings/controller/HomeController.java index 52dde2805..a17e42702 100755 --- a/src/main/java/edu/hawaii/its/groupings/controller/HomeController.java +++ b/src/main/java/edu/hawaii/its/groupings/controller/HomeController.java @@ -8,7 +8,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; @@ -35,11 +34,14 @@ public class HomeController { @Value("${cas.logout.url}") private String casLogoutUrl; - @Autowired - private EmailService emailService; + private final EmailService emailService; - @Autowired - private UserContextService userContextService; + private final UserContextService userContextService; + + public HomeController(EmailService emailService, UserContextService userContextService) { + this.emailService = emailService; + this.userContextService = userContextService; + } // Mapping to home. @GetMapping(value = { "/", "/home" }) diff --git a/src/main/java/edu/hawaii/its/groupings/service/EmailService.java b/src/main/java/edu/hawaii/its/groupings/service/EmailService.java index 4e18774a4..a25b71b12 100755 --- a/src/main/java/edu/hawaii/its/groupings/service/EmailService.java +++ b/src/main/java/edu/hawaii/its/groupings/service/EmailService.java @@ -7,7 +7,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.MailException; import org.springframework.mail.SimpleMailMessage; @@ -33,9 +32,8 @@ public class EmailService { private static final Log logger = LogFactory.getLog(EmailService.class); - private JavaMailSender javaMailSender; + private final JavaMailSender javaMailSender; - @Autowired public EmailService(JavaMailSender javaMailSender) { this.javaMailSender = javaMailSender; }