tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject git commit: TOMEE-1434 wire users/roles in tomee embedded arquillian adapter
Date Wed, 29 Oct 2014 14:00:15 GMT
Repository: tomee
Updated Branches:
  refs/heads/develop c75cd6f52 -> c83da159d


TOMEE-1434 wire users/roles in tomee embedded arquillian adapter


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c83da159
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c83da159
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c83da159

Branch: refs/heads/develop
Commit: c83da159d4e7bebbf9a6a6add54916e9ae48ac62
Parents: c75cd6f
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Wed Oct 29 14:59:46 2014 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Wed Oct 29 15:00:02 2014 +0100

----------------------------------------------------------------------
 .../embedded/EmbeddedTomEEConfiguration.java    | 39 +++++++++++++++++++-
 .../embedded/EmbeddedTomEEContainer.java        |  8 ++++
 2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/c83da159/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
index af2177c..1e3deb4 100644
--- a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
+++ b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEConfiguration.java
@@ -20,6 +20,7 @@ import org.apache.openejb.OpenEJBRuntimeException;
 import org.apache.openejb.arquillian.common.IO;
 import org.apache.openejb.arquillian.common.Prefixes;
 import org.apache.openejb.arquillian.common.TomEEConfiguration;
+import org.jboss.arquillian.config.descriptor.api.Multiline;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -40,6 +41,8 @@ public class EmbeddedTomEEConfiguration extends TomEEConfiguration {
     private String clientAuth;
     private String keyAlias;
     private String sslProtocol;
+    private String users;
+    private String roles;
 
     public int getHttpsPort() {
         return httpsPort;
@@ -105,6 +108,32 @@ public class EmbeddedTomEEConfiguration extends TomEEConfiguration {
         this.sslProtocol = sslProtocol;
     }
 
+    public String getUsers() {
+        return users;
+    }
+
+    public Properties getUsersAsProperties() {
+        return toProperties(users);
+    }
+
+    @Multiline
+    public void setUsers(final String users) {
+        this.users = users;
+    }
+
+    public String getRoles() {
+        return roles;
+    }
+
+    public Properties getRolesAsProperties() {
+        return toProperties(roles);
+    }
+
+    @Multiline
+    public void setRoles(final String roles) {
+        this.roles = roles;
+    }
+
     @Override
     public int[] portsAlreadySet() {
         final List<Integer> value = new ArrayList<Integer>();
@@ -125,8 +154,16 @@ public class EmbeddedTomEEConfiguration extends TomEEConfiguration {
             return new Properties();
         }
 
+        return toProperties(properties);
+    }
+
+    private static Properties toProperties(final String value) {
+        if (value == null || value.isEmpty()) {
+            return null;
+        }
+
         final Properties properties = new Properties();
-        final ByteArrayInputStream bais = new ByteArrayInputStream(getProperties().getBytes());
+        final ByteArrayInputStream bais = new ByteArrayInputStream(value.getBytes());
         try {
             properties.load(bais);
         } catch (final IOException e) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/c83da159/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
index e3e600e..ef5324a 100644
--- a/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
+++ b/arquillian/arquillian-tomee-embedded/src/main/java/org/apache/openejb/arquillian/embedded/EmbeddedTomEEContainer.java
@@ -44,6 +44,7 @@ import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
 import javax.servlet.http.HttpSession;
 import java.io.File;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -96,6 +97,13 @@ public class EmbeddedTomEEContainer extends TomEEContainer<EmbeddedTomEEConfigur
         configuration.setKeyAlias(tomeeConfiguration.getKeyAlias());
         configuration.setSslProtocol(tomeeConfiguration.getSslProtocol());
 
+        if (tomeeConfiguration.getRoles() != null) {
+            configuration.setRoles(new HashMap<String, String>(Map.class.cast(tomeeConfiguration.getRolesAsProperties())));
+        }
+        if (tomeeConfiguration.getUsers() != null) {
+            configuration.setUsers(new HashMap<String, String>(Map.class.cast(tomeeConfiguration.getUsersAsProperties())));
+        }
+
         return configuration;
     }
 


Mime
View raw message