Skip to content

Commit

Permalink
[AS7-2587] Add a add-user script / utility for adding a new user to t…
Browse files Browse the repository at this point in the history
…he properties file used by default for AS domain management authentication.
  • Loading branch information
darranl committed Nov 22, 2011
1 parent 8bc6408 commit 3d9199f
Show file tree
Hide file tree
Showing 9 changed files with 456 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
public class Authentication {

public static final String USERNAME = "test_user";
public static final String USERNAME = "testUser";
public static final String PASSWORD = "test_user_password";

public static CallbackHandler getCallbackHandler() {
Expand Down
2 changes: 2 additions & 0 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@
<maven-resource group="org.jboss.as" artifact="jboss-as-deployment-scanner"/>
</module-def>

<module-def name="org.jboss.as.domain-add-user" />

<module-def name="org.jboss.as.domain-http-error-context">
<maven-resource group="org.jboss.as" artifact="jboss-as-domain-http-error-context"/>
</module-def>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
@echo off
rem -------------------------------------------------------------------------
rem JBoss SASL Password Digest script for Windows
rem Ass User script for Windows
rem -------------------------------------------------------------------------
rem
rem A simple utility for adding new users to the properties file used
rem for domain management authentication out of the box.

rem $Id$

Expand All @@ -14,7 +17,7 @@ if "%OS%" == "Windows_NT" (
set DIRNAME=.\
)

pushd %DIRNAME%..\..
pushd %DIRNAME%..
if "x%JBOSS_HOME%" == "x" (
set "JBOSS_HOME=%CD%"
)
Expand All @@ -25,12 +28,10 @@ set DIRNAME=
if "%OS%" == "Windows_NT" (
set "PROGNAME=%~nx0%"
) else (
set "PROGNAME=digest-password.bat"
set "PROGNAME=jdr.bat"
)

rem Setup JBoss specific properties
set JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%

if "x%JAVA_HOME%" == "x" (
set JAVA=java
echo JAVA_HOME is not set. Unexpected results may occur.
Expand All @@ -39,7 +40,7 @@ if "x%JAVA_HOME%" == "x" (
set "JAVA=%JAVA_HOME%\bin\java"
)

rem Find run.jar, or we can't continue
rem Find jboss-modules.jar, or we can't continue
if exist "%JBOSS_HOME%\jboss-modules.jar" (
set "RUNJAR=%JBOSS_HOME%\jboss-modules.jar"
) else (
Expand All @@ -48,12 +49,21 @@ if exist "%JBOSS_HOME%\jboss-modules.jar" (
goto END
)

"%JAVA%" %JAVA_OPTS% ^
rem Setup JBoss specific properties

rem Setup the java endorsed dirs
set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed

rem Set default module root paths
if "x%MODULEPATH%" == "x" (
set "MODULEPATH=%JBOSS_HOME%\modules"
)

"%JAVA%" ^
-jar "%JBOSS_HOME%\jboss-modules.jar" ^
-logmodule "org.jboss.logmanager" ^
-mp "%JBOSS_HOME%\modules" ^
org.jboss.sasl ^
-mp "%MODULEPATH%" ^
org.jboss.as.domain-add-user ^
-Djboss.home.dir="%JBOSS_HOME%" ^
%*

:END

if "x%NOPAUSE%" == "x" pause
Original file line number Diff line number Diff line change
@@ -1,44 +1,18 @@
#!/bin/sh

DIRNAME=`dirname "$0"`
PROGNAME=`basename "$0"`
GREP="grep"

# Use the maximum available, or set MAX_FD != -1 to use that
MAX_FD="maximum"

# Add User Utility
#
# Helper to complain.
# A simple utility for adding new users to the properties file used
# for domain management authentication out of the box.
#
warn() {
echo "${PROGNAME}: $*"
}

#
# Helper to puke.
#
die() {
warn $*
exit 1
}
DIRNAME=`dirname "$0"`

# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
linux=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;

Darwin*)
darwin=true
;;

Linux)
linux=true
;;
esac
if [ `uname|grep -i CYGWIN` ]; then
cygwin = true;
fi

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
Expand All @@ -51,7 +25,10 @@ if $cygwin ; then
fi

# Setup JBOSS_HOME
JBOSS_HOME=`cd "$DIRNAME/../.."; pwd`
if [ "x$JBOSS_HOME" = "x" ]; then
# get the full path (without any relative bits)
JBOSS_HOME=`cd "$DIRNAME/.."; pwd`
fi
export JBOSS_HOME

# Setup the JVM
Expand All @@ -67,28 +44,19 @@ if [ "x$MODULEPATH" = "x" ]; then
MODULEPATH="$JBOSS_HOME/modules"
fi

###
# Setup the JBoss SASL classpath
###

# Shared libs
JBOSS_SASL_CLASSPATH="$MODULEPATH/org/jboss/sasl/main/*"

export JBOSS_SASL_CLASSPATH

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
JBOSS_HOME=`cygpath --path --windows "$JBOSS_HOME"`
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
JBOSS_CLASSPATH=`cygpath --path --windows "$JBOSS_CLASSPATH"`
JBOSS_ENDORSED_DIRS=`cygpath --path --windows "$JBOSS_ENDORSED_DIRS"`
MODULEPATH=`cygpath --path --windows "$MODULEPATH"`
JBOSS_SASL_CLASSPATH=`cygpath --path --windows "$JBOSS_SASL_CLASSPATH"`
fi

# Sample JPDA settings for remote socket debugging
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

"$JAVA" $JAVA_OPTS -classpath "$JBOSS_SASL_CLASSPATH" \
org.jboss.sasl.util.UsernamePasswordHashUtil $@

eval \"$JAVA\" $JAVA_OPTS \
-jar \"$JBOSS_HOME/jboss-modules.jar\" \
-mp \"${MODULEPATH}\" \
-logmodule "org.jboss.logmanager" \
org.jboss.as.domain-add-user \
-Djboss.home.dir=\"$JBOSS_HOME\" \
"$@"
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
# By default the properties realm expects the entries to be in the format: -
# username=HEX( MD5( username ':' realm ':' password))
#
# A utility script is provided which can be executed from the bin folder to generate the entries: -
# A utility script is provided which can be executed from the bin folder to add the users: -
# - Linux
# bin\digest-password.sh username realm password
# bin\add-user.sh
#
# - Windows
# bin/digest-password username realm password
# bin/add-user
#
# On start-up the server will also automatically add a user $local - this user is specifically
# for local tools running against this AS installation.
#
# The following illustrates how an admin user could be defined, this
# is for illustration only an does not correspond to a useable password.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2011, 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 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 software 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 software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<module xmlns="urn:jboss:module:1.1" name="org.jboss.as.domain-add-user">

<main-class name="org.jboss.as.domain.management.security.AddPropertiesUser"/>

<resources>
<!-- Insert resources here -->
</resources>

<dependencies>
<module name="org.jboss.as.domain-management"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

<module xmlns="urn:jboss:module:1.1" name="org.jboss.sasl">

<main-class name="org.jboss.sasl.util.UsernamePasswordHashUtil"/>

<resources>
<!-- Insert resources here -->
</resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
# By default the properties realm expects the entries to be in the format: -
# username=HEX( MD5( username ':' realm ':' password))
#
# A utility script is provided which can be executed from the bin folder to generate the entries: -
# A utility script is provided which can be executed from the bin folder to add the users: -
# - Linux
# bin\digest-password.sh username realm password
# bin\add-user.sh
#
# - Windows
# bin/digest-password username realm password
# bin/add-user
#
# On start-up the server will also automatically add a user $local - this user is specifically
# for local tools running against this AS installation.
#
# The following illustrates how an admin user could be defined, this
# is for illustration only an does not correspond to a useable password.
Expand Down
Loading

0 comments on commit 3d9199f

Please sign in to comment.