#!/usr/bin/env bash # To get the required settings, please go to your BWSPortal OnPrem and BioID BWSPortal and click # on the user settings in the top right corner. Copy API keys for onpremapikey and for apikey. # The onpremsubject/subject is the email of the logged in user.. # The value for onpremclientId can be found in the BioID BWSPortal. Select your client and go to update # on-prem client. The first entry - Client Id - is the value for onpremclientId. # Set here your apikey for your BWSPortal On-Premises onpremapikey='' onpremsubject='' onpremhost='' days='8' # Set here your apikey for BioID BWSPortal apikey='=' subject='' host='bwsportal.bioid.com' onpremclientId='' # Check if curl is installed if ! command -v "curl" &> /dev/null; then echo "Error: curl not found. Please make sure it is installed." exit 1 fi # Attempt to use jwt binary directly or use an environment variable if command -v "jwt" &> /dev/null; then JWT_BINARY="jwt" else # If jwt binary is not in path, use the environment variable JWT_BINARY if set, else exit with an error if ! command -v "${JWT_BINARY:="jwt"}" &> /dev/null; then echo "Error: $JWT_BINARY not found. Please make sure it is installed or set the correct path in the environment variable JWT_BINARY." exit 1 fi fi # Get Bearer token for On-Premises echo "Create On-Premises jwt - JSON Web Token..." onpremtoken=$("$JWT_BINARY" --sub "$onpremsubject" --key "$onpremapikey") # Get signed usage report from On-Premises echo "Get signed usage report..." usagereport=$(curl --silent --ssl-no-revoke --header "Accept: application/json" --header "Authorization: Bearer $onpremtoken" --url "https://$onpremhost/api/usagereport/$days") echo "Signed usage report: $usagereport" # Get Bearer token for BWS Portal echo "Create Portal jwt - JSON Web Token..." token=$("$JWT_BINARY" --sub "$subject" --key "$apikey") # Put signed usage report to BWSPortal echo "Put signed usage report to Portal..." curl --silent -X "PUT" --ssl-no-revoke --header "Accept: application/json" --header "Authorization: Bearer $token" --header "Content-Type: text/json" --data "$usagereport" --url "https://$host/api/usagereport" # Get latest protection key from BWSPortal echo "Get latest protection key..." protectionkey=$(curl --silent --ssl-no-revoke --header "Accept: text/plain" --header "Authorization: Bearer $token" --url "https://$host/api/protectionkey/$onpremclientId") # Put latest protection key to On-Premises version echo "Put latest protection key to On-Premises version..." license=$(curl --silent -X "PUT" --ssl-no-revoke --header "Accept: application/json" --header "Authorization: Bearer $onpremtoken" --header "Content-Type: text/json" --data "$protectionkey" --url "https://$onpremhost/api/protectionkey") echo "LicenseInfo: $license" exit 0