From 743a3023dc85d0682b81036c03a5a324e8a15328 Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Fri, 12 Apr 2013 16:04:40 -0400 Subject: [PATCH] removed old error handlers --- .../exception/ClientNotFoundException.java | 58 -------------- .../JwtBearerAuthenticationProvider.java | 4 +- .../exception/ExpiredTokenException.java | 34 --------- .../exception/InvalidJwtIssuerException.java | 34 --------- .../InvalidJwtSignatureException.java | 34 --------- .../UnknownUserInfoSchemaException.java | 34 --------- .../exception/UserNotFoundException.java | 27 ------- .../connect/view/ExceptionAsJSONView.java | 75 ------------------- .../openid/connect/web/UserInfoEndpoint.java | 8 +- .../webapp/WEB-INF/application-context.xml | 13 ---- .../WEB-INF/views/exception/usernotfound.jsp | 13 ---- 11 files changed, 3 insertions(+), 331 deletions(-) delete mode 100644 openid-connect-server/src/main/java/org/mitre/oauth2/exception/ClientNotFoundException.java delete mode 100644 openid-connect-server/src/main/java/org/mitre/openid/connect/exception/ExpiredTokenException.java delete mode 100644 openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtIssuerException.java delete mode 100644 openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtSignatureException.java delete mode 100644 openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UnknownUserInfoSchemaException.java delete mode 100644 openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UserNotFoundException.java delete mode 100644 openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java delete mode 100644 openid-connect-server/src/main/webapp/WEB-INF/views/exception/usernotfound.jsp diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/exception/ClientNotFoundException.java b/openid-connect-server/src/main/java/org/mitre/oauth2/exception/ClientNotFoundException.java deleted file mode 100644 index a4aaf8e0e..000000000 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/exception/ClientNotFoundException.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright 2012 The MITRE Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.mitre.oauth2.exception; - -/** - * @author aanganes - * - */ -public class ClientNotFoundException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - /** - * - */ - public ClientNotFoundException() { - // TODO Auto-generated constructor stub - } - - /** - * @param message - */ - public ClientNotFoundException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - /** - * @param cause - */ - public ClientNotFoundException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - - /** - * @param message - * @param cause - */ - public ClientNotFoundException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - -} diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/assertion/JwtBearerAuthenticationProvider.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/assertion/JwtBearerAuthenticationProvider.java index fa9adc2a1..b681aa8c4 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/assertion/JwtBearerAuthenticationProvider.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/assertion/JwtBearerAuthenticationProvider.java @@ -8,7 +8,6 @@ import java.util.Date; import org.mitre.jwt.signer.service.JwtSigningAndValidationService; import org.mitre.jwt.signer.service.impl.JWKSetSigningAndValidationServiceCacheService; -import org.mitre.oauth2.exception.ClientNotFoundException; import org.mitre.oauth2.model.ClientDetailsEntity; import org.mitre.oauth2.service.ClientDetailsEntityService; import org.mitre.openid.connect.config.ConfigurationPropertiesBean; @@ -20,6 +19,7 @@ import org.springframework.security.authentication.AuthenticationServiceExceptio import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.oauth2.common.exceptions.InvalidClientException; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.ReadOnlyJWTClaimsSet; @@ -117,7 +117,7 @@ public class JwtBearerAuthenticationProvider implements AuthenticationProvider { // IFF we managed to get all the way down here, the token is valid return new JwtBearerAssertionAuthenticationToken(client.getClientId(), jwt, client.getAuthorities()); - } catch (ClientNotFoundException e) { + } catch (InvalidClientException e) { throw new UsernameNotFoundException("Could not find client: " + jwtAuth.getClientId()); } catch (ParseException e) { // TODO Auto-generated catch block diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/ExpiredTokenException.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/ExpiredTokenException.java deleted file mode 100644 index 2aa9118a6..000000000 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/ExpiredTokenException.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright 2012 The MITRE Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.mitre.openid.connect.exception; - -/** - * @author aanganes, nemonik - * - */ -public class ExpiredTokenException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public ExpiredTokenException() { - super(); - } - - public ExpiredTokenException(String message) { - super(message); - } - -} diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtIssuerException.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtIssuerException.java deleted file mode 100644 index c760393ff..000000000 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtIssuerException.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright 2012 The MITRE Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.mitre.openid.connect.exception; - -/** - * @author aanganes, nemonik - * - */ -public class InvalidJwtIssuerException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public InvalidJwtIssuerException() { - super(); - } - - public InvalidJwtIssuerException(String message) { - super(message); - } - -} diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtSignatureException.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtSignatureException.java deleted file mode 100644 index c4dbd79f7..000000000 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/InvalidJwtSignatureException.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright 2012 The MITRE Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.mitre.openid.connect.exception; - -/** - * @author aanganes, nemonik - * - */ -public class InvalidJwtSignatureException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public InvalidJwtSignatureException() { - super(); - } - - public InvalidJwtSignatureException(String message) { - super(message); - } - -} diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UnknownUserInfoSchemaException.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UnknownUserInfoSchemaException.java deleted file mode 100644 index 766357122..000000000 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UnknownUserInfoSchemaException.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright 2012 The MITRE Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.mitre.openid.connect.exception; - -/** - * @author aanganes, nemonik - * - */ -public class UnknownUserInfoSchemaException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public UnknownUserInfoSchemaException() { - super(); - } - - public UnknownUserInfoSchemaException(String message) { - super(message); - } - -} diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UserNotFoundException.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UserNotFoundException.java deleted file mode 100644 index 06e12d609..000000000 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/exception/UserNotFoundException.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.mitre.openid.connect.exception; - -public class UserNotFoundException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public UserNotFoundException() { - super(); - // TODO Auto-generated constructor stub - } - - public UserNotFoundException(String message, Throwable cause) { - super(message, cause); - // TODO Auto-generated constructor stub - } - - public UserNotFoundException(String message) { - super(message); - // TODO Auto-generated constructor stub - } - - public UserNotFoundException(Throwable cause) { - super(cause); - // TODO Auto-generated constructor stub - } - -} diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java deleted file mode 100644 index c3f057175..000000000 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ExceptionAsJSONView.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright 2012 The MITRE Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.mitre.openid.connect.view; - -import java.io.IOException; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.view.AbstractView; - -import com.google.gson.JsonObject; - -/** - * @author nemonik - * - */ -@Component("exceptionAsJSONView") -public class ExceptionAsJSONView extends AbstractView { - - private static Logger logger = LoggerFactory.getLogger(ExceptionAsJSONView.class); - - /* - * (non-Javadoc) - * - * @see - * org.springframework.web.servlet.view.AbstractView#renderMergedOutputModel - * (java.util.Map, javax.servlet.http.HttpServletRequest, - * javax.servlet.http.HttpServletResponse) - */ - @Override - protected void renderMergedOutputModel(Map model, HttpServletRequest requesr, HttpServletResponse response) { - - response.setContentType("application/json"); - - response.setStatus(HttpStatus.BAD_REQUEST.value()); - - final JsonObject jsonObject = new JsonObject(); - - Object ex = model.get("exception"); - - jsonObject.addProperty("error", ex.getClass().getName()); - jsonObject.addProperty("error_description", - ((Exception) ex).getMessage()); - - try { - - response.getWriter().write(jsonObject.toString()); - - } catch (IOException e) { - - logger.error("IOException in ExceptionAsJSONView.java: ", e); - - } - } - -} diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java index c78fd31bc..8d4c3b024 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoEndpoint.java @@ -17,8 +17,6 @@ package org.mitre.openid.connect.web; import java.security.Principal; -import org.mitre.openid.connect.exception.UnknownUserInfoSchemaException; -import org.mitre.openid.connect.exception.UserNotFoundException; import org.mitre.openid.connect.model.UserInfo; import org.mitre.openid.connect.service.UserInfoService; import org.slf4j.Logger; @@ -48,11 +46,7 @@ public class UserInfoEndpoint { private static Logger logger = LoggerFactory.getLogger(UserInfoEndpoint.class); /** - * Get information about the user as specified in the accessToken->idToken included in this request - * - * @throws UserNotFoundException if the user does not exist or cannot be found - * @throws UnknownUserInfoSchemaException if an unknown schema is used - * @throws InvalidScopeException if the oauth2 token doesn't have the "openid" scope + * Get information about the user as specified in the accessToken included in this request */ @PreAuthorize("hasRole('ROLE_USER') and #oauth2.hasScope('openid')") @RequestMapping(value="/userinfo", method= {RequestMethod.GET, RequestMethod.POST}, produces = "application/json") diff --git a/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml b/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml index 621ae6ec9..da7e32564 100644 --- a/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml +++ b/openid-connect-server/src/main/webapp/WEB-INF/application-context.xml @@ -216,19 +216,6 @@ - - - - - exceptionAsJSONView - exceptionAsJSONView - exceptionAsJSONView - exceptionAsJSONView - exception/usernotfound - - - - diff --git a/openid-connect-server/src/main/webapp/WEB-INF/views/exception/usernotfound.jsp b/openid-connect-server/src/main/webapp/WEB-INF/views/exception/usernotfound.jsp deleted file mode 100644 index 3f40d453d..000000000 --- a/openid-connect-server/src/main/webapp/WEB-INF/views/exception/usernotfound.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1"%> - - - - -User Not Found - - -<% response.setStatus(404); %> -

Error: requested user was not found

- - \ No newline at end of file