+# update the cache for userid, and prompt to add file to
+# authorized_user_ids file if the userid is found in gpg
+# and not already in file.
+update_userid() {
+ local userID
+ local cacheDir
+ local keyCache
+
+ userID="$1"
+ cacheDir="$2"
+
+ log "processing userid: '$userID'"
+
+ # return 1 if there is no output of the user ID processing
+ # ie. no key was found
+ keyCachePath=$(process_user_id "$userID" "$cacheDir")
+ if [ -z "$keyCachePath" ] ; then
+ return 1
+ fi
+
+ # check if user ID is in the authorized_user_ids file
+ if ! grep -q "^${userID}\$" "$AUTHORIZED_USER_IDS" ; then
+ read -p "user ID not currently authorized. authorize? [Y|n]: " OK; OK=${OK:=Y}
+ if [ ${OK/y/Y} = 'Y' ] ; then
+ # add if specified
+ log -n "adding user ID to authorized_user_ids file... "
+ echo "$userID" >> "$AUTHORIZED_USER_IDS"
+ echo "done."
+ else
+ # else do nothing
+ log "authorized_user_ids file untouched."
+ fi
+ fi
+}
+
+# remove a userid from the authorized_user_ids file
+remove_userid() {
+ local userID
+
+ userID="$1"
+
+ log "processing userid: '$userID'"
+
+ if ! grep -q "^${userID}\$" "$AUTHORIZED_USER_IDS" ; then
+ log "user ID not currently authorized."
+ return 1
+ fi
+
+ log -n "removing user ID '$userID'... "
+ grep -v "$userID" "$AUTHORIZED_USER_IDS" | sponge "$AUTHORIZED_USER_IDS"
+ echo "done."
+}
+