Adding GUI login/logout capability using form-based login.

Adding REST API login capability using basic authentication.

HTTP to HTTPS redirect is suppressed for now.

Change-Id: I1a98bdc5576c515e1aa5a1b8d66402af0c0bf8c8
diff --git a/tools/package/bin/onos-secure-ssh b/tools/package/bin/onos-secure-ssh
index 6c46904..ac94de5 100755
--- a/tools/package/bin/onos-secure-ssh
+++ b/tools/package/bin/onos-secure-ssh
@@ -7,6 +7,17 @@
 
 set -e
 
+# Scan argument for user/password or other options...
+while getopts u:p: o; do
+    case "$o" in
+        u) user=$OPTARG;;
+        p) password=$OPTARG;;
+    esac
+done
+password=${password:-user} # password defaults to the user name if not specified
+let OPC=$OPTIND-1
+shift $OPC
+
 cd $(dirname $0)/../apache-karaf-*/etc
 USERS=users.properties
 KEYS=keys.properties
@@ -18,5 +29,10 @@
 # Remove any previous known keys for the local host.
 ssh-keygen -f "$HOME/.ssh/known_hosts" -R [localhost]:8101
 
-# Swap the onos client to use the SSH variant
+# Swap the onos client to use the SSH variant.
 ln -s $(dirname $0)/onos-ssh $(dirname $0)/onos
+
+# If user and password options were given, setup the user/password.
+if [ -n "$user" -a -n "$password" ]; then
+    echo "$user = $password,_g_:admingroup" >> $USERS
+fi
\ No newline at end of file
diff --git a/tools/package/etc/org.ops4j.pax.web.cfg b/tools/package/etc/org.ops4j.pax.web.cfg
new file mode 100644
index 0000000..c8fb3b3
--- /dev/null
+++ b/tools/package/etc/org.ops4j.pax.web.cfg
@@ -0,0 +1,12 @@
+org.osgi.service.http.port=8181
+org.osgi.service.http.port.secure=8443
+
+org.osgi.service.http.enabled=true
+org.osgi.service.http.secure.enabled=false
+
+org.ops4j.pax.web.ssl.keystore=etc/keystore
+org.ops4j.pax.web.ssl.password=OBF:1xtn1w1u1uob1xtv1y7z1xtn1unn1w1o1xtv
+org.ops4j.pax.web.ssl.keypassword=OBF:1xtn1w1u1uob1xtv1y7z1xtn1unn1w1o1xtv
+
+org.ops4j.pax.web.session.url=none
+org.ops4j.pax.web.config.file=./etc/jetty.xml
diff --git a/tools/test/bin/onos-secure-ssh b/tools/test/bin/onos-secure-ssh
index 1ec0bff..3c15fa3 100755
--- a/tools/test/bin/onos-secure-ssh
+++ b/tools/test/bin/onos-secure-ssh
@@ -19,7 +19,7 @@
     ssh $ONOS_USER@$node "
         [ ! -f ~/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' -q
         $ONOS_INSTALL_DIR/bin/onos-user-key \$(id -un) \$(cut -d\\  -f2 ~/.ssh/id_rsa.pub)
-        $ONOS_INSTALL_DIR/bin/onos-secure-ssh
+        $ONOS_INSTALL_DIR/bin/onos-secure-ssh "$@"
 
         # Implicitly accept the new server key in dev/test environments
         while ! ssh -p 8101 -o StrictHostKeyChecking=no localhost list 2>/dev/null; do
diff --git a/tools/test/scenarios/setup.xml b/tools/test/scenarios/setup.xml
index 740260f..bcc65d9 100644
--- a/tools/test/scenarios/setup.xml
+++ b/tools/test/scenarios/setup.xml
@@ -16,7 +16,7 @@
 <scenario name="setup" description="ONOS cluster setup">
     <group name="Setup">
         <step name="Push-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/>
-        <step name="Secure-SSH" exec="onos-secure-ssh" if="${ONOS_USE_SSH}"/>
+        <step name="Secure-SSH" exec="onos-secure-ssh -u onos -p rocks" if="${ONOS_USE_SSH}"/>
 
         <parallel var="${OC#}">
             <step name="Push-Bits-${#}" exec="onos-push-bits ${OC#}"