Last active
August 29, 2015 13:56
-
-
Save quickshiftin/8950283 to your computer and use it in GitHub Desktop.
A thin wrapper around a jetty utility to hash passwords for xml files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ----------------------------------------------------------------------------------- | |
# jetty-hash-pass.sh | |
# (c) Nathan Nobbe 2014 | |
# [email protected] | |
# http://quickshiftin.com | |
# | |
# See the Password Issues section of the below link | |
# http://docs.codehaus.org/display/JETTY/How+to+configure+SSL#HowtoconfigureSSL-step3 | |
# | |
# A thin wrapper around a jetty utility to hash passwords for xml files | |
# XXX narrowly supports one version (at least, 6.1.24) of Jetty | |
# ----------------------------------------------------------------------------------- | |
# ----------------------------------- | |
# Configuration (alter to your needs) | |
# ----------------------------------- | |
JETTY_CLASSPATH='/usr/share/java/jetty-6.1.24.jar:/usr/share/java/jetty-util-6.1.24.jar' | |
JETTY_PWD_FQCN=org.mortbay.jetty.security.Password | |
## | |
# Password utility wrapper function | |
# @note This is hardly portable between environments, needs work for that | |
# Tested against 6.1.24 on Ubuntu (version?) | |
## | |
function jetty_hash_pass | |
{ | |
user=$1 | |
pass=$2 | |
$(java -cp $JETTY_CLASSPATH $JETTY_PWD_FQCN $user $pass) | |
} | |
# read optional user argument | |
user='' | |
if [ -n "$1" ]; then | |
user=$1 | |
echo "user: $user" | |
fi | |
# since our version of the password tool seems to not handle the ? option correctly | |
# and prompt for a password, we can just handle that part ourselves | |
echo Enter password | |
read passwd | |
# hash the username/password | |
if [ -n "$user" ]; then | |
jetty_hash_pass $user $passwd | |
else | |
jetty_hash_pass $passwd | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment