Class MCRSecureTokenV2

java.lang.Object
org.mycore.frontend.support.MCRSecureTokenV2

public class MCRSecureTokenV2 extends Object
An implementation of SecureToken V2 used by "Wowza Streaming Engine".

A description of the algorithm:

  1. A string is constructed by combining contentPath,'?' and all alphabetically sorted parameters consisting of ipAddress, sharedSecret and any queryParameters
  2. Generate an SHA-256 hash of that string builded in step 1 and StandardCharsets.UTF_8.
  3. Generate a Base64 encoded string of the digest of step 2.
  4. replace '+' by '-' and '/' by '_' to make it a safe parameter value.
Author:
Thomas Scheffler (yagee)
See Also:
  • Constructor Details

    • MCRSecureTokenV2

      public MCRSecureTokenV2(String contentPath, String ipAddress, String sharedSecret, String... queryParameters)
  • Method Details

    • getHash

      public String getHash()
    • toURI

      public URI toURI(String baseURL, String hashParameterName) throws URISyntaxException
      Same as calling toURI(String, String, String) with suffix="".
      Throws:
      URISyntaxException
    • toURI

      public URI toURI(String baseURL, String suffix, String hashParameterName) throws URISyntaxException
      Constructs an URL by using all information from the constructor except ipAddress and sharedSecret and the supplied parameters.
      Parameters:
      baseURL - a valid and absolute base URL
      suffix - is appended to the contentPath
      hashParameterName - the name of the query parameter that holds the hash value
      Returns:
      an absolute URL consisting of all elements as stated above and queryParameters in the given order appended by the hash parameter and the hash value from getHash().
      Throws:
      URISyntaxException - if baseURL is not a valid URI
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object