From 0e16acf4d8579fd82349d6cd24e236275735a818 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 14 Feb 2017 19:45:48 -0500 Subject: Initial OpenECOMP policy/drools-pdp commit Change-Id: I0072ccab6f40ed32da39667f9f8523b6d6dad2e2 Signed-off-by: Pamela Dragosh --- .../main/server-gen/bin/add-secured-participant.sh | 122 +++++++++++++ .../src/main/server-gen/bin/create-api-key.sh | 76 ++++++++ .../main/server-gen/bin/create-secured-topic.sh | 130 ++++++++++++++ policy-management/src/main/server-gen/bin/options | 125 +++++++++++++ .../src/main/server-gen/bin/pdpd-configuration.sh | 200 +++++++++++++++++++++ .../server-gen/bin/policy-management-controller | 191 ++++++++++++++++++++ .../src/main/server-gen/bin/rest-add-controller.sh | 37 ++++ .../main/server-gen/bin/rest-delete-controller.sh | 43 +++++ 8 files changed, 924 insertions(+) create mode 100644 policy-management/src/main/server-gen/bin/add-secured-participant.sh create mode 100644 policy-management/src/main/server-gen/bin/create-api-key.sh create mode 100644 policy-management/src/main/server-gen/bin/create-secured-topic.sh create mode 100644 policy-management/src/main/server-gen/bin/options create mode 100644 policy-management/src/main/server-gen/bin/pdpd-configuration.sh create mode 100644 policy-management/src/main/server-gen/bin/policy-management-controller create mode 100644 policy-management/src/main/server-gen/bin/rest-add-controller.sh create mode 100644 policy-management/src/main/server-gen/bin/rest-delete-controller.sh (limited to 'policy-management/src/main/server-gen/bin') diff --git a/policy-management/src/main/server-gen/bin/add-secured-participant.sh b/policy-management/src/main/server-gen/bin/add-secured-participant.sh new file mode 100644 index 00000000..d6843fee --- /dev/null +++ b/policy-management/src/main/server-gen/bin/add-secured-participant.sh @@ -0,0 +1,122 @@ +#! /bin/bash + +### +# ============LICENSE_START======================================================= +# policy-management +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +function usage() { + echo -n "Usage: $(basename $0) " + echo -n "[(-d|--debug)] " + echo -n "(-h|--host) " + echo -n "[(-p|--port) ] " + echo -n "(-k|--key) " + echo -n "(-s|--secret) " + echo -n "(-P|--producer-key) " + echo -n "(-C|--consumer-key) " + echo "(-t|--topic) " +} + +BUS_PORT=3904 + +# command line options parsing +until [[ -z "$1" ]]; do + case $1 in + -d|--debug) set -x + ;; + -h|--host) shift + BUS_HOST=$1 + ;; + -p|--port) shift + BUS_PORT=$1 + ;; + -k|--key) shift + API_KEY=$1 + ;; + -s|--secret) shift + API_SECRET=$1 + ;; + -t|--topic) shift + TOPIC=$1 + ;; + -P|--producer-key) shift + URL_CONTEXT="producers" + PRODUCER_KEY=$1 + KEY=$1 + ;; + -C|--consumer-key) shift + URL_CONTEXT="consumers" + CONSUMER_KEY=$1 + KEY=$1 + ;; + *) usage + exit 1 + ;; + esac + shift +done + +if [[ -z ${BUS_HOST} ]]; then + echo "An UEB/DMAAP server must be provided." + echo + usage + exit 1 +fi + +if [[ -z ${API_KEY} ]]; then + echo "The API Key must be provided." + usage + exit 2 +fi + +if [[ -z ${API_SECRET} ]]; then + echo "The API Secret must be provided." + usage + exit 3 +fi + +if [[ -z ${TOPIC} ]]; then + echo "The Topic Name must be provided." + usage + exit 3 +fi + +if [[ -z ${PRODUCER_KEY} && -z ${CONSUMER_KEY} ]]; then + echo "Either the Producer or Consumer options must be provided." + usage + exit 4 +fi + +if [[ -n ${PRODUCER_KEY} && -n ${CONSUMER_KEY} ]]; then + echo "Only and only one of the Producer or Consumer options must be provided." + usage + exit 5 +fi + + +DATE=$(date) +DATE_HASH=$(echo -n "${DATE}" | openssl sha1 -hmac "${API_SECRET}" -binary | openssl base64) + +unset http_proxy +curl --silent -X PUT \ + --header "Accept:" \ + --header "X-CambriaDate: ${DATE}" \ + --header "X-CambriaAuth: ${API_KEY}:${DATE_HASH}" \ + --header "Content-Type: application/json" \ + --data "{}" \ + http://${BUS_HOST}:${BUS_PORT}/topics/${TOPIC}/${URL_CONTEXT}/${KEY} diff --git a/policy-management/src/main/server-gen/bin/create-api-key.sh b/policy-management/src/main/server-gen/bin/create-api-key.sh new file mode 100644 index 00000000..ea0ec7ad --- /dev/null +++ b/policy-management/src/main/server-gen/bin/create-api-key.sh @@ -0,0 +1,76 @@ +#! /bin/bash + +### +# ============LICENSE_START======================================================= +# policy-management +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +function usage() { + echo -n "Usage: $(basename $0) " + echo -n "[(-d|--debug)] " + echo -n "(-h|--host) " + echo -n "[(-p|--port) ] " + echo "(-e|--email) " +} + +BUS_PORT=3904 + +# command line options parsing +until [[ -z "$1" ]]; do + case $1 in + -d|--debug) set -x + ;; + -h|--host) shift + BUS_HOST=$1 + ;; + -p|--port) shift + BUS_PORT=$1 + ;; + -e|--email) shift + EMAIL=$1 + ;; + *) usage + exit 1 + ;; + esac + shift +done + +if [[ -z ${BUS_HOST} ]]; then + echo "An UEB/DMAAP server must be provided." + echo + usage + exit 1 +fi + +if [[ -z ${EMAIL} ]]; then + echo "An email address must be provided." + usage + exit 2 +fi + +REQUEST_API_KEY_BODY=$(< <(cat < " + echo -n "[(-p|--port) ] " + echo -n "(-k|--key) " + echo -n "(-s|--secret) " + echo -n "[(-P|--partition) ] " + echo -n "[(-R|--replication) ] " + echo "(-t|--topic) " + echo "" +} + +BUS_PORT=3904 +PARTITION_COUNT=1 +REPLICATION_COUNT=1 + +# command line options parsing +until [[ -z "$1" ]]; do + case $1 in + -d|--debug) set -x + ;; + -h|--host) shift + BUS_HOST=$1 + ;; + -p|--port) shift + BUS_PORT=$1 + ;; + -k|--key) shift + API_KEY=$1 + ;; + -s|--secret) shift + API_SECRET=$1 + ;; + -t|--topic) shift + TOPIC=$1 + ;; + -P|--partition-count) shift + PARTITION_COUNT=$1 + ;; + -R|--replication-count) shift + REPLICATION_COUNT=$1 + ;; + *) usage + exit 1 + ;; + esac + shift +done + +if [[ -z ${BUS_HOST} ]]; then + echo "An UEB/DMAAP server must be provided." + echo + usage + exit 1 +fi + +if [[ -z ${API_KEY} ]]; then + echo "The API Key must be provided." + usage + exit 2 +fi + +if [[ -z ${API_SECRET} ]]; then + echo "The API Secret must be provided." + usage + exit 3 +fi + +if [[ -z ${TOPIC} ]]; then + echo "The Topic Name must be provided." + usage + exit 3 +fi + +if [[ -z ${PARTITION_COUNT} ]]; then + echo "The Partition Count must be provided." + usage + exit 4 +fi + +if [[ -z ${REPLICATION_COUNT} ]]; then + echo "The Replication Count must be provided." + usage + exit 5 +fi + +REQUEST_API_KEY_BODY=$(< <(cat < nameLength )) ; then + nameLength="${#name}" + fi + if (( "${#version}" > versionLength )) ; then + versionLength="${#version}" + fi +done + +# dump out status information +function status +{ + local tmp name version status + local format="%-${nameLength}s %-${versionLength}s %s\n" + + printf "${format}" "name" "version" "status" + printf "${format}" "----" "-------" "------" + for jar in $(ls) ; do + # get file name without 'jar' suffix + tmp="${jar%\.jar}" + + # get feature name by removing the version portion + name="${tmp%%-[0-9]*}" + + # extract version portion of name + version="${tmp#${name}-}" + + # determine status + status=disabled + if [[ -e "${lib}/${jar}" ]] ; then + status=enabled + fi + printf "${format}" "${name}" "${version}" "${status}" + done +} + +case "$1" in + status) + { + # dump out status information + status + };; + + enable) + { + # enable the specified options + shift + match= + for name in "$@" ; do + # look for matches - 'file' has the full path name + file=$(ls ${opt}/"${name}"-[0-9]* 2>/dev/null) + if [[ "$?" != 0 ]] ; then + # no matching file + echo "${name}: no such option" + else + # found a match (handle multiple matches, just in case) + match=true + ln -s -f ${file} "${lib}/" + fi + done + if [[ "${match}" ]] ; then + echo + status + fi + };; + + disable) + { + # disable the specified options + shift + match= + for name in "$@" ; do + # look for matches -- 'file' has the last segment of the path name + file=$(ls "${name}"-[0-9]* 2>/dev/null) + if [[ "$?" != 0 ]] ; then + echo "${name}: no such option" + else + # found a match (handle multiple matches, just in case) + match=true + (cd ${lib} ; rm -f ${file}) + fi + done + if [[ "${match}" ]] ; then + echo + status + fi + };; + + *) + { + # print out usage information + cat >&2 <<-'EOF' + Usage: options status + Get enabled/disabled status on all options + options enable