You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ra...@apache.org on 2019/01/09 17:26:32 UTC

[tomee] 44/48: TOMEE-2365 - MessageInfo to pass AuthenticationParameters for SecurityContext.

This is an automated email from the ASF dual-hosted git repository.

radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 3281fa45dee7bc80fe4d59e646b6569df4114cbb
Author: Roberto Cortez <ra...@yahoo.com>
AuthorDate: Tue Jan 8 18:53:40 2019 +0000

    TOMEE-2365 - MessageInfo to pass AuthenticationParameters for SecurityContext.
---
 .../security/http/TomEEHttpMessageContext.java     |  5 ++-
 .../tomee/security/message/TomEEMessageInfo.java   | 41 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/TomEEHttpMessageContext.java b/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/TomEEHttpMessageContext.java
index d67d74d..f6c25d4 100644
--- a/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/TomEEHttpMessageContext.java
+++ b/tomee/tomee-security/src/main/java/org/apache/tomee/security/http/TomEEHttpMessageContext.java
@@ -17,6 +17,7 @@
 package org.apache.tomee.security.http;
 
 import org.apache.catalina.authenticator.jaspic.MessageInfoImpl;
+import org.apache.tomee.security.message.TomEEMessageInfo;
 
 import javax.security.auth.Subject;
 import javax.security.auth.callback.Callback;
@@ -99,7 +100,9 @@ public class TomEEHttpMessageContext implements HttpMessageContext {
 
     @Override
     public AuthenticationParameters getAuthParameters() {
-        return new AuthenticationParameters();
+        return (AuthenticationParameters) messageInfo.getMap()
+                                                     .getOrDefault(TomEEMessageInfo.AUTH_PARAMS,
+                                                                   new AuthenticationParameters());
     }
 
     @Override
diff --git a/tomee/tomee-security/src/main/java/org/apache/tomee/security/message/TomEEMessageInfo.java b/tomee/tomee-security/src/main/java/org/apache/tomee/security/message/TomEEMessageInfo.java
new file mode 100644
index 0000000..1c4c989
--- /dev/null
+++ b/tomee/tomee-security/src/main/java/org/apache/tomee/security/message/TomEEMessageInfo.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.tomee.security.message;
+
+import org.apache.catalina.authenticator.jaspic.MessageInfoImpl;
+
+import javax.security.enterprise.authentication.mechanism.http.AuthenticationParameters;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TomEEMessageInfo extends MessageInfoImpl {
+    public static final String AUTH_PARAMS = "org.apache.tomee.security.context.authParams";
+
+    public TomEEMessageInfo(final HttpServletRequest request,
+                            final HttpServletResponse response,
+                            final boolean authMandatory) {
+        super(request, response, authMandatory);
+    }
+
+    public TomEEMessageInfo(final HttpServletRequest request,
+                            final HttpServletResponse response,
+                            final boolean authMandatory,
+                            final AuthenticationParameters authParameters) {
+        super(request, response, authMandatory);
+        getMap().put(AUTH_PARAMS, authParameters);
+    }
+}