16727: Refresh block permission signatures on Sync and Read.
[arvados.git] / sdk / go / arvados / blob_signature.go
index 47b31a18e893d0a848f39d0b9a16e5e736c84c71..9a031face2e957d91eed93982817fa8e1dc67d7f 100644 (file)
@@ -16,6 +16,7 @@ import (
        "fmt"
        "regexp"
        "strconv"
+       "strings"
        "time"
 )
 
@@ -126,3 +127,21 @@ func parseHexTimestamp(timestampHex string) (ts time.Time, err error) {
        }
        return ts, err
 }
+
+var errNoSignature = errors.New("locator has no signature")
+
+func signatureExpiryTime(signedLocator string) (time.Time, error) {
+       matches := SignedLocatorRe.FindStringSubmatch(signedLocator)
+       if matches == nil {
+               return time.Time{}, errNoSignature
+       }
+       expiryHex := matches[7]
+       return parseHexTimestamp(expiryHex)
+}
+
+func stripAllHints(locator string) string {
+       if i := strings.IndexRune(locator, '+'); i > 0 {
+               return locator[:i]
+       }
+       return locator
+}