Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleExample for Getting and Storing Settings
linenumberstrue
# common options for connection to JS7 REST API
request_options=(--url=http://localhost:4446 --user=root --password=root)

# get settings
settings=$(./operate-joc.sh get-settings "${request_options[@]}")

# update settings
settings=$(echo "$settings" | jq '.dailyplan.days_ahead_submit.value = "4"')
settings=$(echo "$settings" | jq '.dailyplan.days_ahead_plan.value = "6"')

# store settings
./operate-joc.sh store-settings "${request_options[@]}" --settings="$settings"

...

Using encrypted Passwords

Code Block
languagebash
titleExample for Encrypting and Decrypting
linenumberstrue
# create Private Key
openssl ecparam -name secp384r1 -genkey -noout -out encrypt.key

# create Certificate Signing Request, adjust the subject to your needs
openssl req -new -sha512 -nodes -key encrypt.key -out encrypt.csr -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=Encrypt"

# create Certificate, adjust the validity period to your needs
openssl x509 -req -sha512 -days 1825 -signkey encrypt.key -in encrypt.csr -out encrypt.crt -extfile <(printf "keyUsage=critical,keyEncipherment,keyAgreement\n")


# encrypt athe secret such as a password password "root" using the Certificate, the encryption result will be returned and will look like: enc:BEXbHYa...
MY_JS7_PASSWORD=$(./operate-joc.sh encrypt --in="root" --cert=encrypt.crt)

# store the environment variable to your profile ($HOME/.bash_profile or similar) to make the encrypted password available to the shell
# export MY_JS7_PASSWORD=enc:BEXbHYa...


# options for connection to the JS7 REST API can specify the encryption result as password and the Private Key for decryption
request_options=(--url=http://localhost:4446 --user=root --password="enc:BEXbHYa...$MY_JS7_PASSWORD" --key=encrypt.key --controller-id=controller)

# for example, when gettingreading version information, the Private Key is used to decrypt the password on-the-fly for access to the REST API on-the-fly
./operate-joc.sh version "${request_options[@]}"

# decrypt an encrypted secret using the Private Key
./operate-joc.sh decrypt --in="enc:BEXbHYa..." --key=encrypt.key

Resources

...