[jboss-jira] [JBoss JIRA] (WFLY-1988) SaslException at startup in domain mode using JAAS for ManagementRealm

RH Bugzilla Integration (JIRA) jira-events at lists.jboss.org
Thu Sep 12 02:51:03 EDT 2013


    [ https://issues.jboss.org/browse/WFLY-1988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12803709#comment-12803709 ] 

RH Bugzilla Integration commented on WFLY-1988:
-----------------------------------------------

Hisanobu Okuda <hokuda at redhat.com> made a comment on [bug 1003464|https://bugzilla.redhat.com/show_bug.cgi?id=1003464]

The below works for me.

diff --git a/host-controller/src/main/java/org/jboss/as/host/controller/ServerInventoryImpl.java b/host-controller/src/main/java/org/jboss/as/host/controller/ServerInventoryImpl.java
index e10dc69..f1eaeb3 100644
--- a/host-controller/src/main/java/org/jboss/as/host/controller/ServerInventoryImpl.java
+++ b/host-controller/src/main/java/org/jboss/as/host/controller/ServerInventoryImpl.java
@@ -83,6 +83,8 @@ import org.jboss.sasl.util.UsernamePasswordHashUtil;
 public class ServerInventoryImpl implements ServerInventory {
 
     private static final Charset UTF_8 = Charset.forName("UTF-8");
+    private static final int SPC = 0x20;
+    private static final int TILDE = 0x7e;
 
     /** The managed servers. */
     private final ConcurrentMap<String, ManagedServer> servers = new ConcurrentHashMap<String, ManagedServer>();
@@ -177,7 +179,7 @@ public class ServerInventoryImpl implements ServerInventory {
         if(server == null) {
             // Create a new authKey
             final byte[] authKey = new byte[16];
-            new Random(new SecureRandom().nextLong()).nextBytes(authKey);
+            storeRandomAsciiChar(authKey);
             // Create the managed server
             final ManagedServer newServer = createManagedServer(serverName, domainModel, authKey);
             server = servers.putIfAbsent(serverName, newServer);
@@ -595,4 +597,10 @@ public class ServerInventoryImpl implements ServerInventory {
         };
     }
 
+    static void storeRandomAsciiChar(byte[] authKey) {
+        Random rand = new Random(new SecureRandom().nextLong());
+        for(int i =0; i < authKey.length; i++) {
+            authKey[i] = (byte)(SPC + rand.nextInt(TILDE-SPC+1));
+        }
+    }
 }
diff --git a/host-controller/src/test/java/org/jboss/as/host/controller/ServerInventoryImplTestCase.java b/host-controller/src/test/java/org/jboss/as/host/controller/ServerInventoryImplTestCase.java
new file mode 100644
index 0000000..feb3c1d
--- /dev/null
+++ b/host-controller/src/test/java/org/jboss/as/host/controller/ServerInventoryImplTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc., and individual contributors 
+ * as indicated by the @author tags. See the copyright.txt file 
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301  USA
+ */
+package org.jboss.as.host.controller;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import static org.hamcrest.CoreMatchers.is;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author <a href="mailto:ehugonne at redhat.com">Emmanuel Hugonnet</a> (c) 2013 Red Hat, inc.
+ */
+public class ServerInventoryImplTestCase {
+ private static final String HEX_DIGITS = "0123456789abcdef";
+    @Test
+    public void testStoreRandomeAsciiChar() throws Exception {
+        byte[] array = new byte[1000];
+	boolean isok = true;
+
+        ServerInventoryImpl.storeRandomAsciiChar(array);
+	for (byte b:array) {
+	    if( b<0x20 || b>0x7e ) {
+		isok = false;
+	    }
+	}
+        Assert.assertThat(isok, is(true));
+    }
+}
                
>  SaslException at startup in domain mode using JAAS for ManagementRealm
> -----------------------------------------------------------------------
>
>                 Key: WFLY-1988
>                 URL: https://issues.jboss.org/browse/WFLY-1988
>             Project: WildFly
>          Issue Type: Feature Request
>          Components: Domain Management
>    Affects Versions: 8.0.0.Alpha4
>            Reporter: Emmanuel Hugonnet
>            Assignee: Emmanuel Hugonnet
>             Fix For: 8.0.0.Beta1
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list