cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf-fediz git commit: Injecting MessageContext instead following feedback from Sergey
Date Wed, 19 Apr 2017 11:20:12 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/1.3.x-fixes 8aeeed22a -> 035c43406


Injecting MessageContext instead following feedback from Sergey


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/035c4340
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/035c4340
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/035c4340

Branch: refs/heads/1.3.x-fixes
Commit: 035c434068233a5773dc5853be1489a6ca1f09cf
Parents: 8aeeed2
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Apr 19 11:46:02 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Apr 19 12:20:07 2017 +0100

----------------------------------------------------------------------
 .../oidc/clients/ClientRegistrationService.java      | 15 +++++++--------
 .../service/oidc/console/UserConsoleService.java     | 10 ++++++----
 2 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/035c4340/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
index 50b38ad..90b2aff 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
@@ -58,8 +58,7 @@ import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.Base64UrlUtility;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.fediz.service.oidc.CSRFUtils;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.rs.security.oauth2.common.Client;
 import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken;
 import org.apache.cxf.rs.security.oauth2.common.UserSubject;
@@ -71,7 +70,6 @@ import org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken;
 import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
 import org.apache.cxf.rs.security.oidc.idp.OidcUserSubject;
 import org.apache.cxf.rt.security.crypto.CryptoUtils;
-import org.apache.cxf.transport.http.AbstractHTTPDestination;
 
 @Path("/")
 public class ClientRegistrationService {
@@ -86,11 +84,11 @@ public class ClientRegistrationService {
     private boolean protectIdTokenWithClientSecret;
     private Map<String, String> clientScopes;
 
-    private SecurityContext sc;
+    private MessageContext mc;
 
     @Context
-    public void setSecurityContext(SecurityContext securityContext) {
-        this.sc = securityContext;
+    public void setMessageContext(MessageContext messageContext) {
+        this.mc = messageContext;
     }
 
     @GET
@@ -283,6 +281,7 @@ public class ClientRegistrationService {
         Client newClient = new Client(clientId, clientSecret, isConfidential, appName);
 
         // User who registered this client
+        SecurityContext sc = mc.getSecurityContext();
         String userName = sc.getUserPrincipal().getName();
         UserSubject userSubject = new OidcUserSubject(userName);
         newClient.setResourceOwnerSubject(userSubject);
@@ -374,8 +373,7 @@ public class ClientRegistrationService {
 
     private boolean checkCSRFToken(String csrfToken) {
         // CSRF
-        Message message = PhaseInterceptorChain.getCurrentMessage();
-        HttpServletRequest httpRequest = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST);
+        HttpServletRequest httpRequest = mc.getHttpServletRequest();
         String savedToken = CSRFUtils.getCSRFToken(httpRequest, false);
         return !(StringUtils.isEmpty(csrfToken) || StringUtils.isEmpty(savedToken)
             || !savedToken.equals(csrfToken));
@@ -467,6 +465,7 @@ public class ClientRegistrationService {
     }
 
     private String getUserName() {
+        SecurityContext sc = mc.getSecurityContext();
         if (sc == null || sc.getUserPrincipal() == null) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/035c4340/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/console/UserConsoleService.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/console/UserConsoleService.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/console/UserConsoleService.java
index ef29295..18c7fdd 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/console/UserConsoleService.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/console/UserConsoleService.java
@@ -27,18 +27,19 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.SecurityContext;
 
 import org.apache.cxf.fediz.service.oidc.clients.ClientRegistrationService;
+import org.apache.cxf.jaxrs.ext.MessageContext;
 
 @Path("/")
 public class UserConsoleService {
 
-    private SecurityContext sc;
+    private MessageContext mc;
 
     private ClientRegistrationService clientRegService;
     
     @Context
-    public void setSecurityContext(SecurityContext securityContext) {
-        this.sc = securityContext;
-        clientRegService.setSecurityContext(securityContext);
+    public void setMessageContext(MessageContext messageContext) {
+        this.mc = messageContext;
+        clientRegService.setMessageContext(messageContext);
     }
      
     
@@ -48,6 +49,7 @@ public class UserConsoleService {
         return new UserConsole(getUserName()); 
     }
     private String getUserName() {
+        SecurityContext sc = mc.getSecurityContext();
         return sc.getUserPrincipal().getName();
     }
     @Path("clients")


Mime
View raw message