Merge Remove Redudant Throws

Fixes gh-7301
This commit is contained in:
Rob Winch
2019-09-19 09:48:20 -05:00
424 changed files with 1147 additions and 1343 deletions

View File

@@ -231,7 +231,7 @@ class DummyRequest extends HttpServletRequestWrapper {
}
final class UnsupportedOperationExceptionInvocationHandler implements InvocationHandler {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
public Object invoke(Object proxy, Method method, Object[] args) {
throw new UnsupportedOperationException(method + " is not supported");
}
}

View File

@@ -21,7 +21,6 @@ import org.springframework.util.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -58,7 +57,7 @@ public abstract class AbstractRetryEntryPoint implements ChannelEntryPoint {
// ========================================================================================================
public void commence(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
throws IOException {
String queryString = request.getQueryString();
String redirectUrl = request.getRequestURI()
+ ((queryString == null) ? "" : ("?" + queryString));

View File

@@ -60,7 +60,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager,
// ~ Methods
// ========================================================================================================
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.notEmpty(channelProcessors, "A list of ChannelProcessors is required");
}

View File

@@ -18,7 +18,6 @@ package org.springframework.security.web.access.channel;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -48,5 +47,5 @@ public interface ChannelEntryPoint {
*
*/
void commence(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException;
throws IOException;
}

View File

@@ -50,7 +50,7 @@ public class InsecureChannelProcessor implements InitializingBean, ChannelProces
// ~ Methods
// ========================================================================================================
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.hasLength(insecureKeyword, "insecureKeyword required");
Assert.notNull(entryPoint, "entryPoint required");
}

View File

@@ -50,7 +50,7 @@ public class SecureChannelProcessor implements InitializingBean, ChannelProcesso
// ~ Methods
// ========================================================================================================
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.hasLength(secureKeyword, "secureKeyword required");
Assert.notNull(entryPoint, "entryPoint required");
}

View File

@@ -63,9 +63,8 @@ public class FilterSecurityInterceptor extends AbstractSecurityInterceptor imple
*
* @param arg0 ignored
*
* @throws ServletException never thrown
*/
public void init(FilterConfig arg0) throws ServletException {
public void init(FilterConfig arg0) {
}
/**

View File

@@ -280,8 +280,7 @@ public abstract class AbstractAuthenticationProcessingFilter extends GenericFilt
* @throws AuthenticationException if authentication fails.
*/
public abstract Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException, IOException,
ServletException;
HttpServletResponse response) throws AuthenticationException, IOException;
/**
* Default behaviour for successful authentication.

View File

@@ -17,7 +17,6 @@ package org.springframework.security.web.authentication;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -79,7 +78,7 @@ public abstract class AbstractAuthenticationTargetUrlRequestHandler {
* The redirect will not be performed if the response has already been committed.
*/
protected void handle(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
Authentication authentication) throws IOException {
String targetUrl = determineTargetUrl(request, response, authentication);
if (response.isCommitted()) {

View File

@@ -172,7 +172,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
}
private Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
throws AuthenticationException, IOException, ServletException {
throws AuthenticationException, ServletException {
Authentication authentication = this.authenticationConverter.convert(request);
if (authentication == null) {
return null;

View File

@@ -102,7 +102,7 @@ public class DelegatingAuthenticationEntryPoint implements AuthenticationEntryPo
this.defaultEntryPoint = defaultEntryPoint;
}
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.notEmpty(entryPoints, "entryPoints must be specified");
Assert.notNull(defaultEntryPoint, "defaultEntryPoint must be specified");
}

View File

@@ -17,7 +17,6 @@ package org.springframework.security.web.authentication;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -52,10 +51,10 @@ public class Http403ForbiddenEntryPoint implements AuthenticationEntryPoint {
* Always returns a 403 error code to the client.
*/
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException arg2) throws IOException, ServletException {
AuthenticationException arg2) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Pre-authenticated entry point called. Rejecting access");
}
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Access Denied");
}
}
}

View File

@@ -15,9 +15,6 @@
*/
package org.springframework.security.web.authentication;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -48,7 +45,7 @@ public final class HttpStatusEntryPoint implements AuthenticationEntryPoint {
}
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
AuthenticationException authException) {
response.setStatus(httpStatus.value());
}
}

View File

@@ -99,7 +99,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
// ~ Methods
// ========================================================================================================
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.isTrue(
StringUtils.hasText(loginFormUrl)
&& UrlUtils.isValidRedirectUrl(loginFormUrl),
@@ -211,8 +211,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
* Builds a URL to redirect the supplied request to HTTPS. Used to redirect the
* current request to HTTPS, before doing a forward to the login page.
*/
protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request)
throws IOException, ServletException {
protected String buildHttpsRedirectUrlForRequest(HttpServletRequest request) {
int serverPort = portResolver.getServerPort(request);
Integer httpsPort = portMapper.lookupHttpsPort(serverPort);

View File

@@ -18,7 +18,6 @@ package org.springframework.security.web.authentication.logout;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -63,7 +62,7 @@ public class HttpStatusReturningLogoutSuccessHandler implements LogoutSuccessHan
* . Sets the status on the {@link HttpServletResponse}.
*/
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
Authentication authentication) throws IOException {
response.setStatus(this.httpStatusToReturn.value());
response.getWriter().flush();
}

View File

@@ -50,7 +50,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource
/**
* Check that all required properties have been set.
*/
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.notNull(j2eeMappableRoles, "No mappable roles available");
Assert.notNull(j2eeUserRoles2GrantedAuthoritiesMapper,
"Roles to granted authorities mapper not set");

View File

@@ -130,8 +130,7 @@ public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware,
* We do not need to resolve external entities, so just return an empty String.
*/
private static final class MyEntityResolver implements EntityResolver {
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
public InputSource resolveEntity(String publicId, String systemId) {
return new InputSource(new StringReader(""));
}
}

View File

@@ -94,7 +94,7 @@ public abstract class AbstractRememberMeServices implements RememberMeServices,
}
@Override
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.hasLength(key, "key cannot be empty or null");
Assert.notNull(userDetailsService, "A UserDetailsService is required");
}

View File

@@ -18,7 +18,6 @@ package org.springframework.security.web.authentication.www;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -56,7 +55,7 @@ public class BasicAuthenticationEntryPoint implements AuthenticationEntryPoint,
}
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
AuthenticationException authException) throws IOException {
response.addHeader("WWW-Authenticate", "Basic realm=\"" + realmName + "\"");
response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase());
}

View File

@@ -244,12 +244,11 @@ public class BasicAuthenticationFilter extends OncePerRequestFilter {
}
protected void onSuccessfulAuthentication(HttpServletRequest request,
HttpServletResponse response, Authentication authResult) throws IOException {
HttpServletResponse response, Authentication authResult) {
}
protected void onUnsuccessfulAuthentication(HttpServletRequest request,
HttpServletResponse response, AuthenticationException failed)
throws IOException {
HttpServletResponse response, AuthenticationException failed) {
}
protected AuthenticationEntryPoint getAuthenticationEntryPoint() {

View File

@@ -19,7 +19,6 @@ package org.springframework.security.web.authentication.www;
import java.io.IOException;
import java.util.Base64;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -72,7 +71,7 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint,
this.order = order;
}
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
if ((realmName == null) || "".equals(realmName)) {
throw new IllegalArgumentException("realmName must be specified");
}
@@ -83,7 +82,7 @@ public class DigestAuthenticationEntryPoint implements AuthenticationEntryPoint,
}
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
AuthenticationException authException) throws IOException {
HttpServletResponse httpResponse = response;
// compute a nonce (do not use remote IP address due to proxy farms)

View File

@@ -107,7 +107,7 @@ public final class AuthenticationPrincipalArgumentResolver
*/
public Object resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) throws Exception {
WebDataBinderFactory binderFactory) {
Authentication authentication = SecurityContextHolder.getContext()
.getAuthentication();
if (authentication == null) {
@@ -153,4 +153,4 @@ public final class AuthenticationPrincipalArgumentResolver
}
return null;
}
}
}

View File

@@ -106,7 +106,7 @@ public final class CurrentSecurityContextArgumentResolver
*/
public Object resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) throws Exception {
WebDataBinderFactory binderFactory) {
SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext == null) {
return null;

View File

@@ -23,7 +23,6 @@ import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterRegistration.Dynamic;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.SessionTrackingMode;
import org.springframework.context.ApplicationContext;
@@ -109,7 +108,7 @@ public abstract class AbstractSecurityWebApplicationInitializer
* @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.
* ServletContext)
*/
public final void onStartup(ServletContext servletContext) throws ServletException {
public final void onStartup(ServletContext servletContext) {
beforeSpringSecurityFilterChain(servletContext);
if (this.configurationClasses != null) {
AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();

View File

@@ -65,22 +65,20 @@ public final class SecurityContextCallableProcessingInterceptor extends
}
@Override
public <T> void beforeConcurrentHandling(NativeWebRequest request, Callable<T> task)
throws Exception {
public <T> void beforeConcurrentHandling(NativeWebRequest request, Callable<T> task) {
if (securityContext == null) {
setSecurityContext(SecurityContextHolder.getContext());
}
}
@Override
public <T> void preProcess(NativeWebRequest request, Callable<T> task)
throws Exception {
public <T> void preProcess(NativeWebRequest request, Callable<T> task) {
SecurityContextHolder.setContext(securityContext);
}
@Override
public <T> void postProcess(NativeWebRequest request, Callable<T> task,
Object concurrentResult) throws Exception {
Object concurrentResult) {
SecurityContextHolder.clearContext();
}

View File

@@ -143,7 +143,7 @@ public final class DebugFilter implements Filter {
return null;
}
public void init(FilterConfig filterConfig) throws ServletException {
public void init(FilterConfig filterConfig) {
}
public void destroy() {

View File

@@ -112,7 +112,7 @@ public final class AuthenticationPrincipalArgumentResolver
*/
public Object resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) throws Exception {
WebDataBinderFactory binderFactory) {
Authentication authentication = SecurityContextHolder.getContext()
.getAuthentication();
if (authentication == null) {
@@ -180,4 +180,4 @@ public final class AuthenticationPrincipalArgumentResolver
}
return null;
}
}
}

View File

@@ -68,9 +68,9 @@ public final class CsrfTokenArgumentResolver implements HandlerMethodArgumentRes
*/
public Object resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
WebDataBinderFactory binderFactory) throws Exception {
WebDataBinderFactory binderFactory) {
CsrfToken token = (CsrfToken) webRequest.getAttribute(CsrfToken.class.getName(),
NativeWebRequest.SCOPE_REQUEST);
return token;
}
}
}

View File

@@ -204,7 +204,7 @@ public class ConcurrentSessionFilter extends GenericFilterBean {
implements SessionInformationExpiredStrategy {
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event)
throws IOException, ServletException {
throws IOException {
HttpServletResponse response = event.getResponse();
response.getWriter().print(
"This session has been expired (possibly due to multiple concurrent "

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.security.web.session;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -29,6 +28,6 @@ import java.io.IOException;
public interface InvalidSessionStrategy {
void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException;
throws IOException;
}

View File

@@ -17,8 +17,6 @@ package org.springframework.security.web.session;
import java.io.IOException;
import javax.servlet.ServletException;
/**
* Determines the behaviour of the {@code ConcurrentSessionFilter} when an expired session
* is detected in the {@code ConcurrentSessionFilter}.
@@ -30,5 +28,5 @@ import javax.servlet.ServletException;
public interface SessionInformationExpiredStrategy {
void onExpiredSessionDetected(SessionInformationExpiredEvent event)
throws IOException, ServletException;
throws IOException;
}