cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1567045 [2/2] - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/ rt/fron...
Date Tue, 11 Feb 2014 11:07:01 GMT
Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansElementProvider.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansElementProvider.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansElementProvider.java
Tue Feb 11 11:07:00 2014
@@ -29,7 +29,6 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 
 import javax.ws.rs.Consumes;
-import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -39,6 +38,7 @@ import javax.ws.rs.ext.Provider;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.xmlbeans.XmlObject;
 
 /**
@@ -113,11 +113,11 @@ public class XMLBeansElementProvider ext
             }
 
         } catch (NoSuchMethodException nsme) {
-            throw new InternalServerErrorException(nsme);
+            throw ExceptionUtils.toInternalServerErrorException(nsme, null);
         } catch (InvocationTargetException ite) {
-            throw new InternalServerErrorException(ite);
+            throw ExceptionUtils.toInternalServerErrorException(ite, null);
         } catch (IllegalAccessException iae) {
-            throw new InternalServerErrorException(iae);
+            throw ExceptionUtils.toInternalServerErrorException(iae, null);
         }
 
         return result;

Modified: cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansJSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansJSONProvider.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansJSONProvider.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeansJSONProvider.java
Tue Feb 11 11:07:00 2014
@@ -28,9 +28,7 @@ import java.lang.reflect.Type;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
-import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -40,6 +38,7 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.xmlbeans.XmlObject;
 import org.codehaus.jettison.mapped.MappedXMLInputFactory;
 import org.codehaus.jettison.mapped.MappedXMLOutputFactory;
@@ -72,7 +71,7 @@ public class XMLBeansJSONProvider extend
             xsr.close();
 
         } catch (XMLStreamException e) {
-            throw new BadRequestException(e);
+            throw ExceptionUtils.toBadRequestException(e, null);
         }
 
         return result;
@@ -101,9 +100,9 @@ public class XMLBeansJSONProvider extend
             xsw.close();
 
         } catch (XMLStreamException e) {
-            throw new InternalServerErrorException(e);
+            throw ExceptionUtils.toInternalServerErrorException(e, null);
         } catch (IOException ioe) {
-            throw new InternalServerErrorException(ioe);
+            throw ExceptionUtils.toInternalServerErrorException(ioe, null);
         }
     }
 }

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/services/AuthorizationRequestHandler.java
Tue Feb 11 11:07:00 2014
@@ -36,7 +36,6 @@ import java.util.logging.Logger;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
-import javax.ws.rs.BadRequestException;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 
@@ -47,6 +46,7 @@ import net.oauth.OAuthProblemException;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.rs.security.oauth.data.AuthorizationInput;
 import org.apache.cxf.rs.security.oauth.data.OAuthAuthorizationData;
 import org.apache.cxf.rs.security.oauth.data.OAuthPermission;
@@ -88,7 +88,7 @@ public class AuthorizationRequestHandler
                 if (decision != null) {
                     // this is a user decision request, the session has expired or been possibly
hijacked
                     LOG.warning("Session authenticity token is missing or invalid");
-                    throw new BadRequestException();
+                    throw ExceptionUtils.toBadRequestException(null, null);
                 }
                 // assume it is an initial authorization request
                 addAuthenticityTokenToSession(secData, request);

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/auth/saml/Saml2BearerAuthHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/auth/saml/Saml2BearerAuthHandler.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/auth/saml/Saml2BearerAuthHandler.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/auth/saml/Saml2BearerAuthHandler.java
Tue Feb 11 11:07:00 2014
@@ -22,7 +22,6 @@ package org.apache.cxf.rs.security.oauth
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
-import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.core.Response;
 
 import org.w3c.dom.Element;
@@ -31,6 +30,7 @@ import org.apache.cxf.common.util.Base64
 import org.apache.cxf.jaxrs.ext.form.Form;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.provider.FormEncodingProvider;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.jaxrs.utils.FormUtils;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.message.Message;
@@ -60,7 +60,7 @@ public class Saml2BearerAuthHandler exte
         String assertionType = form.getData().getFirst(Constants.CLIENT_AUTH_ASSERTION_TYPE);
         String decodedAssertionType = assertionType != null ? HttpUtils.urlDecode(assertionType)
: null;
         if (decodedAssertionType == null || !Constants.CLIENT_AUTH_SAML2_BEARER.equals(decodedAssertionType))
{
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
         String assertion = form.getData().getFirst(Constants.CLIENT_AUTH_ASSERTION_PARAM);
         
@@ -77,7 +77,7 @@ public class Saml2BearerAuthHandler exte
         try {
             FormUtils.restoreForm(provider, form, message);
         } catch (Exception ex) {
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
         return null;
     }
@@ -86,20 +86,20 @@ public class Saml2BearerAuthHandler exte
         try {
             return FormUtils.readForm(provider, message);
         } catch (Exception ex) {
-            throw new NotAuthorizedException(errorResponse());    
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());    
         }
     }
     
     protected Element readToken(Message message, String assertion) {
         if (assertion == null) {
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
         try {
             byte[] deflatedToken = Base64UrlUtility.decode(assertion);
             InputStream is = new ByteArrayInputStream(deflatedToken); 
             return readToken(message, is); 
         } catch (Base64Exception ex) {
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }         
     }
     
@@ -114,12 +114,12 @@ public class Saml2BearerAuthHandler exte
         // Introduce SAMLOAuth2Validator to be reused between auth and grant handlers
         Subject subject = SAMLUtils.getSubject(message, wrapper);
         if (subject.getName() == null) {
-            throw new NotAuthorizedException(errorResponse());  
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());  
         }
         
         if (clientId != null && !clientId.equals(subject.getName())) {
             //TODO:  Attempt to map client_id to subject.getName()
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
         samlOAuthValidator.validate(message, wrapper);
         message.put(OAuthConstants.CLIENT_ID, subject.getName());

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/saml/SamlOAuthValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/saml/SamlOAuthValidator.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/saml/SamlOAuthValidator.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/saml/SamlOAuthValidator.java
Tue Feb 11 11:07:00 2014
@@ -21,11 +21,11 @@ package org.apache.cxf.rs.security.oauth
 
 import java.util.List;
 
-import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
 import org.apache.ws.security.saml.ext.AssertionWrapper;
@@ -72,11 +72,11 @@ public class SamlOAuthValidator {
             String expectedIssuer = OAuthConstants.CLIENT_ID.equals(issuer) 
                 ? wrapper.getSaml2().getSubject().getNameID().getValue() : issuer;
             if (actualIssuer == null || !actualIssuer.equals(expectedIssuer)) {
-                throw new NotAuthorizedException(errorResponse());
+                throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
             }
         }
         if (!validateAuthenticationSubject(message, cs, wrapper.getSaml2().getSubject()))
{
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
     }
     
@@ -97,7 +97,7 @@ public class SamlOAuthValidator {
                 }
             }
         }
-        throw new NotAuthorizedException(errorResponse());
+        throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
     }
     
     private String getAbsoluteTargetAddress(Message m) {
@@ -142,19 +142,19 @@ public class SamlOAuthValidator {
                 && cs.getNotOnOrAfter() != null && !cs.getNotOnOrAfter().isBeforeNow())
{
                 return;
             }
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
           
         // Recipient must match assertion consumer URL
         String recipient = subjectConfData.getRecipient();
         if (recipient == null || !recipient.equals(getAbsoluteTargetAddress(m))) {
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
           
         // We must have a NotOnOrAfter timestamp
         if (subjectConfData.getNotOnOrAfter() == null
             || subjectConfData.getNotOnOrAfter().isBeforeNow()) {
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
           
         //TODO: replay cache, same as with SAML SSO case
@@ -162,7 +162,7 @@ public class SamlOAuthValidator {
         // Check address
         if (subjectConfData.getAddress() != null
             && (clientAddress == null || !subjectConfData.getAddress().equals(clientAddress)))
{
-            throw new NotAuthorizedException(errorResponse());
+            throw ExceptionUtils.toNotAuthorizedException(null, errorResponse());
         }
           
           

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractAccessTokenValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractAccessTokenValidator.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractAccessTokenValidator.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractAccessTokenValidator.java
Tue Feb 11 11:07:00 2014
@@ -24,11 +24,11 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
-import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.Context;
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.MessageContextImpl;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.rs.security.oauth2.common.AccessTokenValidation;
 import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
@@ -95,7 +95,7 @@ public abstract class AbstractAccessToke
     protected AccessTokenValidation getAccessTokenValidation() {
         AccessTokenValidation accessTokenV = null;
         if (dataProvider == null && tokenHandlers.isEmpty()) {
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         
         // Get the scheme and its data, Bearer only is supported by default

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AbstractOAuthService.java
Tue Feb 11 11:07:00 2014
@@ -20,7 +20,6 @@ package org.apache.cxf.rs.security.oauth
 
 import java.util.logging.Logger;
 
-import javax.ws.rs.BadRequestException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -29,6 +28,7 @@ import javax.ws.rs.core.Response.Respons
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.OAuthError;
 import org.apache.cxf.rs.security.oauth2.provider.OAuthDataProvider;
@@ -102,7 +102,7 @@ public abstract class AbstractOAuthServi
         if (!mc.getSecurityContext().isSecure()) {
             LOG.warning("Unsecure HTTP, Transport Layer Security is recommended");
             if (blockUnsecureRequests) {
-                throw new BadRequestException();    
+                throw ExceptionUtils.toBadRequestException(null, null);    
             }
         }
     }
@@ -126,7 +126,7 @@ public abstract class AbstractOAuthServi
         if (mt != null) {
             rb.type(mt);
         }
-        throw new BadRequestException(rb.entity(entity).build());
+        throw ExceptionUtils.toBadRequestException(null, rb.entity(entity).build());
     }
 
     /**

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AccessTokenService.java
Tue Feb 11 11:07:00 2014
@@ -26,7 +26,6 @@ import java.util.LinkedList;
 import java.util.List;
 
 import javax.ws.rs.Consumes;
-import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
@@ -37,6 +36,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.SecurityContext;
 
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.ClientAccessToken;
 import org.apache.cxf.rs.security.oauth2.common.OAuthError;
@@ -188,7 +188,7 @@ public class AccessTokenService extends 
         }
         
         if (client == null) {
-            throw new NotAuthorizedException(Response.status(401).build());
+            throw ExceptionUtils.toNotAuthorizedException(null, Response.status(401).build());
         }
         return client;
     }
@@ -205,7 +205,7 @@ public class AccessTokenService extends 
         if (clientSecret == null || client.getClientSecret() == null 
             || !client.getClientId().equals(clientId) 
             || !client.getClientSecret().equals(clientSecret)) {
-            throw new NotAuthorizedException(Response.status(401).build());
+            throw ExceptionUtils.toNotAuthorizedException(null, Response.status(401).build());
         }
         return client;
     }
@@ -300,7 +300,8 @@ public class AccessTokenService extends 
     
     protected void reportInvalidClient(OAuthError error) {
         ResponseBuilder rb = Response.status(401);
-        throw new NotAuthorizedException(rb.type(MediaType.APPLICATION_JSON_TYPE).entity(error).build());
+        throw ExceptionUtils.toNotAuthorizedException(null, 
+            rb.type(MediaType.APPLICATION_JSON_TYPE).entity(error).build());
     }
     
     public void setCanSupportPublicClients(boolean support) {

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/RedirectionBasedGrantService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/RedirectionBasedGrantService.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/RedirectionBasedGrantService.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/RedirectionBasedGrantService.java
Tue Feb 11 11:07:00 2014
@@ -25,10 +25,8 @@ import java.util.List;
 import java.util.UUID;
 
 import javax.servlet.http.HttpSession;
-import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
-import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
@@ -36,6 +34,7 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.OAuthAuthorizationData;
 import org.apache.cxf.rs.security.oauth2.common.OAuthPermission;
@@ -219,7 +218,7 @@ public abstract class RedirectionBasedGr
         
         // Make sure the session is valid
         if (!compareRequestAndSessionTokens(params.getFirst(OAuthConstants.SESSION_AUTHENTICITY_TOKEN)))
{
-            throw new BadRequestException();     
+            throw ExceptionUtils.toBadRequestException(null, null);     
         }
         //TODO: additionally we can check that the Principal that got authenticated
         // in startAuthorization is the same that got authenticated in completeAuthorization
@@ -304,7 +303,7 @@ public abstract class RedirectionBasedGr
         SecurityContext securityContext =  
             (SecurityContext)getMessageContext().get(SecurityContext.class.getName());
         if (securityContext == null || securityContext.getUserPrincipal() == null) {
-            throw new NotAuthorizedException(Response.status(401).build());
+            throw ExceptionUtils.toNotAuthorizedException(null, Response.status(401).build());
         }
         checkTransportSecurity();
         return securityContext;

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/AuthorizationUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/AuthorizationUtils.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/AuthorizationUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/AuthorizationUtils.java
Tue Feb 11 11:07:00 2014
@@ -23,13 +23,13 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
-import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 
 /**
  * Authorization helpers
@@ -43,13 +43,13 @@ public final class AuthorizationUtils {
         try {
             authDecoded = new String(Base64Utility.decode(data));
         } catch (Exception ex) {
-            throw new NotAuthorizedException(ex);
+            throw ExceptionUtils.toNotAuthorizedException(ex, null);
         }
         String authInfo[] = authDecoded.split(":");
         if (authInfo.length == 2) {
             return authInfo;
         }
-        throw new NotAuthorizedException(Response.status(401).build());
+        throw ExceptionUtils.toNotAuthorizedException(null, Response.status(401).build());
     }
     
     public static String[] getAuthorizationParts(MessageContext mc) {
@@ -93,7 +93,7 @@ public final class AuthorizationUtils {
             rb.header(HttpHeaders.WWW_AUTHENTICATE, sb.toString());
         }
         Response r = rb.build();
-        throw new NotAuthorizedException(r);
+        throw ExceptionUtils.toNotAuthorizedException(null, r);
     }
 
 }

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/OAuthContextUtils.java
Tue Feb 11 11:07:00 2014
@@ -20,12 +20,12 @@ package org.apache.cxf.rs.security.oauth
 
 import java.util.List;
 
-import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.rs.security.oauth2.common.OAuthContext;
 import org.apache.cxf.rs.security.oauth2.common.OAuthPermission;
 
@@ -136,7 +136,7 @@ public final class OAuthContextUtils {
     public static OAuthContext getContext(final MessageContext mc) {
         final OAuthContext oauth = mc.getContent(OAuthContext.class);
         if ((oauth == null) || (oauth.getSubject() == null) || (oauth.getSubject().getLogin()
== null)) {
-            throw new NotAuthorizedException(Response.status(401).build());
+            throw ExceptionUtils.toNotAuthorizedException(null, Response.status(401).build());
         }
         return oauth;
     }

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/AbstractServiceProviderFilter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/AbstractServiceProviderFilter.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/AbstractServiceProviderFilter.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/AbstractServiceProviderFilter.java
Tue Feb 11 11:07:00 2014
@@ -30,7 +30,6 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.annotation.PreDestroy;
-import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.Cookie;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.UriBuilder;
@@ -45,6 +44,7 @@ import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
 import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.rs.security.saml.SAMLUtils;
 import org.apache.cxf.rs.security.saml.assertion.Subject;
@@ -281,7 +281,7 @@ public abstract class AbstractServicePro
             //TODO: Review the possibility of using this filter
             //for validating SAMLResponse too
             reportError("MISSING_ASSERTION_SERVICE_URL");
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         if (!assertionConsumerServiceAddress.startsWith("http")) {
             String httpBasePath = (String)m.get("http.base.path");

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/RequestAssertionConsumerService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/RequestAssertionConsumerService.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/RequestAssertionConsumerService.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/RequestAssertionConsumerService.java
Tue Feb 11 11:07:00 2014
@@ -32,7 +32,6 @@ import java.util.logging.Logger;
 import java.util.zip.DataFormatException;
 
 import javax.annotation.PreDestroy;
-import javax.ws.rs.BadRequestException;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -53,6 +52,7 @@ import org.apache.cxf.common.util.Base64
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.rs.security.saml.DeflateEncoderDecoder;
 import org.apache.cxf.rs.security.saml.sso.state.RequestState;
 import org.apache.cxf.rs.security.saml.sso.state.ResponseState;
@@ -198,20 +198,20 @@ public class RequestAssertionConsumerSer
     private RequestState processRelayState(String relayState) {
         if (relayState == null) {
             reportError("MISSING_RELAY_STATE");
-            throw new BadRequestException();
+            throw ExceptionUtils.toBadRequestException(null, null);
         }
         if (relayState.getBytes().length < 0 || relayState.getBytes().length > 80)
{
             reportError("INVALID_RELAY_STATE");
-            throw new BadRequestException();
+            throw ExceptionUtils.toBadRequestException(null, null);
         }
         RequestState requestState = getStateProvider().removeRequestState(relayState);
         if (requestState == null) {
             reportError("MISSING_REQUEST_STATE");
-            throw new WebApplicationException(400);
+            throw ExceptionUtils.toBadRequestException(null, null);
         }
         if (isStateExpired(requestState.getCreatedAt(), 0)) {
             reportError("EXPIRED_REQUEST_STATE");
-            throw new BadRequestException();
+            throw ExceptionUtils.toBadRequestException(null, null);
         }
         return requestState;
     }
@@ -222,7 +222,7 @@ public class RequestAssertionConsumerSer
     ) {
         if (StringUtils.isEmpty(samlResponse)) {
             reportError("MISSING_SAML_RESPONSE");
-            throw new BadRequestException();
+            throw ExceptionUtils.toBadRequestException(null, null);
         }
         
         String samlResponseDecoded = samlResponse;
@@ -232,7 +232,7 @@ public class RequestAssertionConsumerSer
             try {
                 samlResponseDecoded = URLDecoder.decode(samlResponse, "UTF-8");
             } catch (UnsupportedEncodingException e) {
-                throw new BadRequestException();
+                throw ExceptionUtils.toBadRequestException(null, null);
             }
         }
         */
@@ -244,15 +244,15 @@ public class RequestAssertionConsumerSer
                     ? new DeflateEncoderDecoder().inflateToken(deflatedToken)
                     : new ByteArrayInputStream(deflatedToken); 
             } catch (Base64Exception ex) {
-                throw new BadRequestException(ex);
+                throw ExceptionUtils.toBadRequestException(ex, null);
             } catch (DataFormatException ex) {
-                throw new BadRequestException(ex);
+                throw ExceptionUtils.toBadRequestException(ex, null);
             }
         } else {
             try {
                 tokenStream = new ByteArrayInputStream(samlResponseDecoded.getBytes("UTF-8"));
             } catch (UnsupportedEncodingException ex) {
-                throw new BadRequestException(ex);
+                throw ExceptionUtils.toBadRequestException(ex, null);
             }
         }
         
@@ -269,10 +269,10 @@ public class RequestAssertionConsumerSer
         try {
             responseObject = OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());
         } catch (WSSecurityException ex) {
-            throw new BadRequestException(ex);
+            throw ExceptionUtils.toBadRequestException(ex, null);
         }
         if (!(responseObject instanceof org.opensaml.saml2.core.Response)) {
-            throw new BadRequestException();
+            throw ExceptionUtils.toBadRequestException(null, null);
         }
         return (org.opensaml.saml2.core.Response)responseObject;
     }
@@ -289,7 +289,7 @@ public class RequestAssertionConsumerSer
         } catch (WSSecurityException ex) {
             LOG.log(Level.FINE, ex.getMessage(), ex);
             reportError("INVALID_SAML_RESPONSE");
-            throw new BadRequestException();
+            throw ExceptionUtils.toBadRequestException(null, null);
         }
     }
     
@@ -319,7 +319,7 @@ public class RequestAssertionConsumerSer
             return ssoResponseValidator.validateSamlResponse(samlResponse, postBinding);
         } catch (WSSecurityException ex) {
             reportError("INVALID_SAML_RESPONSE");
-            throw new BadRequestException(ex);
+            throw ExceptionUtils.toBadRequestException(ex, null);
         }
     }
     
@@ -333,7 +333,7 @@ public class RequestAssertionConsumerSer
         } else {
             reportError("MISSING_TARGET_URI");
         }
-        throw new BadRequestException();
+        throw ExceptionUtils.toBadRequestException(null, null);
     }
     
     private void reportError(String code) {

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlPostBindingFilter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlPostBindingFilter.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlPostBindingFilter.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlPostBindingFilter.java
Tue Feb 11 11:07:00 2014
@@ -23,7 +23,6 @@ import java.security.PrivateKey;
 import java.security.cert.X509Certificate;
 
 import javax.security.auth.callback.CallbackHandler;
-import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
 
@@ -32,6 +31,7 @@ import org.w3c.dom.Element;
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.jaxrs.ext.MessageContextImpl;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.rs.security.saml.DeflateEncoderDecoder;
 import org.apache.ws.security.WSPasswordCallback;
@@ -83,7 +83,7 @@ public class SamlPostBindingFilter exten
                                .build();
                 
             } catch (Exception ex) {
-                throw new InternalServerErrorException(ex);
+                throw ExceptionUtils.toInternalServerErrorException(ex, null);
             }
         }
     }
@@ -107,17 +107,17 @@ public class SamlPostBindingFilter exten
         Crypto crypto = getSignatureCrypto();
         if (crypto == null) {
             LOG.fine("No crypto instance of properties file configured for signature");
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         String signatureUser = getSignatureUsername();
         if (signatureUser == null) {
             LOG.fine("No user configured for signature");
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         CallbackHandler callbackHandler = getCallbackHandler();
         if (callbackHandler == null) {
             LOG.fine("No CallbackHandler configured to supply a password for signature");
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlRedirectBindingFilter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlRedirectBindingFilter.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlRedirectBindingFilter.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlRedirectBindingFilter.java
Tue Feb 11 11:07:00 2014
@@ -25,7 +25,6 @@ import java.security.Signature;
 import java.security.cert.X509Certificate;
 
 import javax.security.auth.callback.CallbackHandler;
-import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
@@ -34,6 +33,7 @@ import org.w3c.dom.Element;
 
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.rs.security.saml.DeflateEncoderDecoder;
 import org.apache.ws.security.WSPasswordCallback;
@@ -75,7 +75,7 @@ public class SamlRedirectBindingFilter e
                                .build();
             } catch (Exception ex) {
                 ex.printStackTrace();
-                throw new InternalServerErrorException(ex);
+                throw ExceptionUtils.toInternalServerErrorException(ex, null);
             }
         }
     }
@@ -104,17 +104,17 @@ public class SamlRedirectBindingFilter e
         Crypto crypto = getSignatureCrypto();
         if (crypto == null) {
             LOG.fine("No crypto instance of properties file configured for signature");
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         String signatureUser = getSignatureUsername();
         if (signatureUser == null) {
             LOG.fine("No user configured for signature");
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         CallbackHandler callbackHandler = getCallbackHandler();
         if (callbackHandler == null) {
             LOG.fine("No CallbackHandler configured to supply a password for signature");
-            throw new InternalServerErrorException();
+            throw ExceptionUtils.toInternalServerErrorException(null, null);
         }
         
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/AbstractSamlInHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/AbstractSamlInHandler.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/AbstractSamlInHandler.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/saml/AbstractSamlInHandler.java
Tue Feb 11 11:07:00 2014
@@ -28,7 +28,6 @@ import java.security.cert.X509Certificat
 import java.util.List;
 import java.util.logging.Logger;
 
-import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.core.Response;
 
 import org.w3c.dom.Document;
@@ -37,6 +36,7 @@ import org.w3c.dom.Node;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.rs.security.common.CryptoLoader;
@@ -178,7 +178,7 @@ public abstract class AbstractSamlInHand
         // to rt/rs/security
         LOG.warning(error);
         Response response = Response.status(401).entity(error).build();
-        throw ex != null ? new NotAuthorizedException(response, ex) : new NotAuthorizedException(response);
+        throw ExceptionUtils.toNotAuthorizedException(null, response);
     }
     
     /**

Modified: cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/AbstractXmlSecInHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/AbstractXmlSecInHandler.java?rev=1567045&r1=1567044&r2=1567045&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/AbstractXmlSecInHandler.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/xml/AbstractXmlSecInHandler.java
Tue Feb 11 11:07:00 2014
@@ -23,7 +23,6 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.logging.Logger;
 
-import javax.ws.rs.BadRequestException;
 import javax.ws.rs.core.Response;
 import javax.xml.stream.XMLStreamReader;
 
@@ -32,6 +31,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.staxutils.W3CDOMStreamReader;
@@ -81,7 +81,7 @@ public abstract class AbstractXmlSecInHa
     protected void throwFault(String error, Exception ex) {
         LOG.warning(error);
         Response response = Response.status(400).entity(error).build();
-        throw ex != null ? new BadRequestException(response, ex) : new BadRequestException(response);
+        throw ExceptionUtils.toBadRequestException(null, response);
     }
 
     protected Element getNode(Element parent, String ns, String name, int index) {



Mime
View raw message