Readium LCP Components:
* lcpencrypt: A command line utility for content encryption.
* lcpserver: license server that generate a license or returns an up-to-date license, generate a protected publication (i.e. an encrypted publication in which a license is embedded),
update the rights associated with a license, get a license or a set of licenses.
* lsdserver: license Status server that 
Public functionalities (accessible from the web) are:
Return a license status document
Process a device registration request
Process a lending return request
Process a lending renewal request

Private functionalities (authentication required) are:
Be notified of the generation of a new license
Filter licenses by count of registered devices
List all registered devices for a given licence
Revoke or cancel a license
-------------------------------------------------------------------------------------------------------------------------------------------------------------



https://go.dev/dl/
C:\Program Files\Go\


https://nodejs.org/en/download/
C:\Program Files\nodejs\

Download Git
https://git-scm.com/download/win



go install github.com/readium/readium-lcp-server/@latest


* Run "go env GOPATH" to see the current GOPATH.
To Change 
- CMD: go env -w GOPATH=c:\go-work
- UI check : https://github.com/golang/go/wiki/SettingGOPATH
 
 
 
 C:\Users\deployadmin\go\src\github.com\readium\readium-lcp-server\frontend\manage
 npm install
 
npm start
 
 Ask For Config file for each server 
 
 
 
 go get -v github.com/readium/readium-lcp-server/lcpserver
 go get -v github.com/readium/readium-lcp-server/lsdserver
 go get -v github.com/readium/readium-lcp-server/frontend
 
 10.10.10.148:8991
 
 
There are then two different methods to deliver the License Document and Protected Publication to the User:

License Document included inside Protected Publication: The Provider adds the License Document to the Protected Publication’s Container and delivers this to the User.

License Document delivered separately: The Provider includes a link from the License Document to the Protected Publication, and then delivers just the License Document to the User. The Reading System processing the License Document will retrieve the Protected Publication and add the License Document to the Container of this Protected Publication.

Whichever method is used, the Reading System will be presented with an EPUB Container that includes the Protected Publication and the License Document.
 
 ================================================================================================================================================
 
 
License Server API EndPoints:

* PUT <LCPbaseURL>/contents/<content_id>
- This method is used primarly by lcpencrypt to store data about generated encrypted publication.

Request:
{
  "content-id" : "string", // (Unique Identifier for publication "GUID"), the content_id in the URL must be equal to the content-id in the json.
  "content-encryption-key" : "string", // encryption key used to encrypt the publication
  "protected-content-location" : "string", // absolution URL or file path of the encrypted content
  "protected-content-length" : "string", // size of the encrypted content
  "protected-content-sha256" : "string", // hash of the encrypted content
  "protected-content-disposition" : "string" //original file name
} 

Response:
200: content found (OK: file updated and db updated )
201: the content was added (created)
400: bad request (File not saved)
401: unauthorized 
404: not found (File not found) 
500: internal server error (File was copied, but database was not updated) 
-------------------------------------------------------------------------------------------------------------------------------------------------------------
* GET <LCPbaseURL>/contents/<content_id>:
- Fetch encrypted publication (not licensed publication).

Response:
200: Content found
404: File not found
500: Internal server error
-------------------------------------------------------------------------------------------------------------------------------------------------------------
* POST <LCPbaseURL>/contents/<content_id>/license
- Create user License for specific content
- Hash online tool link: https://passwordsgenerator.net/sha256-hash-generator/

Request:
{
  "provider": "http://www.imaginaryebookretailer.com", // URL for provider
  "user": {
    "id": "d9f298a7-7f34-49e7-8aae-4378ecb1d597", // Mandatory
    "email": "user@mymail.com", // Optional
    "encrypted": ["email"] // Optional
  },
  "encryption": {
   "user_key": {
    "text_hint": "The title of the first book you ever read", // Hint for User passphrase
    "hex_value": "4981AA0A50D563040519E9032B5D74367B1D129E239A1BA82667A57333866494", // Value of hashed user passphrase with below algorithm as hex-encoded string
    "algorithm": "http://www.w3.org/2001/04/xmlenc#sha256"  // the URI of the hashing algorithm, if this property is removed the value will be sha256 (Default)
	}
  },
  "rights": {
    "print": 10, // maximum number of pages that can be printed over the lifetime of the license, if zero copy will not be allowed, to be unlimited don't send it 
    "copy": 2048, // maximum number of characters that can be copied over the lifetime of the license, if zero copy will not be allowed, to be unlimited don't send it 
    "start": "2019-11-04T01:08:15+01:00", // Start Date of licence
    "end": "2019-11-25T01:08:15+01:00" // End Date of licence
  }
}

Response:
201 + the license Created as .lcpl file
404 Content not found

-------------------------------------------------------------------------------------------------------------------------------------------------------------
* POST <LCPbaseURL>/contents/<content_id>/publication
- Generates and embeds the license in the encrypted publication
- Generating a licensed publication is CPU and memory intensive

Request:
{
  "provider": "http://www.imaginaryebookretailer.com", // URL for provider
  "user": {
    "id": "d9f298a7-7f34-49e7-8aae-4378ecb1d597", // Mandatory
    "email": "user@mymail.com", // Optional
    "encrypted": ["email"] // Optional
  },
  "encryption": {
   "user_key": {
    "text_hint": "The title of the first book you ever read", // Hint for User passphrase
    "hex_value": "4981AA0A50D563040519E9032B5D74367B1D129E239A1BA82667A57333866494", // Value of hashed user passphrase with below algorithm as hex-encoded string
    "algorithm": "http://www.w3.org/2001/04/xmlenc#sha256"  // the URI of the hashing algorithm, if this property is removed the value will be sha256 (Default)
	}
  },
  "rights": {
    "print": 10, // maximum number of pages that can be printed over the lifetime of the license, if zero copy will not be allowed, to be unlimited don't send it 
    "copy": 2048, // maximum number of characters that can be copied over the lifetime of the license, if zero copy will not be allowed, to be unlimited don't send it 
    "start": "2019-11-04T01:08:15+01:00", // Start Date of licence
    "end": "2019-11-25T01:08:15+01:00" // End Date of licence
  }
}

Response:
201 + the licensed publication, the license Created
400 Bad request
404 Content not found
-------------------------------------------------------------------------------------------------------------------------------------------------------------
* POST <LCPbaseURL>/licenses/<license_id>
- Fetch an existing license
- Generating a licensed publication is CPU and memory intensive

Request:
{
  "user": { // Any user data that the provider wants to be embedded in the licence (Optional)
    "email": "user@mymail.com",
    "encrypted": ["email"]
  },
  "encryption": {
   "user_key": {
    "text_hint": "The title of the first book you ever read", // Hint for User passphrase
    "hex_value": "4981AA0A50D563040519E9032B5D74367B1D129E239A1BA82667A57333866494", // Value of hashed user passphrase as hex-encoded string
    }
  }
}

Response:
200 + the requested license
404 License not found
-------------------------------------------------------------------------------------------------------------------------------------------------------------
* POST <LCPbaseURL>/licenses/<license_id>/publication
- Fetch a licensed publication
- Generating a licensed publication is CPU and memory intensive

Request:
{
  "user": { // Any user data that the provider wants to be embedded in the licence (Optional)
    "email": "user@mymail.com",
    "encrypted": ["email"]
  },
  "encryption": {
   "user_key": {
    "text_hint": "The title of the first book you ever read", // Hint for User passphrase
    "hex_value": "4981AA0A50D563040519E9032B5D74367B1D129E239A1BA82667A57333866494", // Value of hashed user passphrase as hex-encoded string
    }
  }
}

Response:
200 + the licensed publication as stream
404 License not found
-------------------------------------------------------------------------------------------------------------------------------------------------------------
* GET <LCPbaseURL>/licenses{page?, per_page?}
- List licences ordered by creation Date (issue date)
- page numbering is 1-based (starts with 1 not 0), and the default pagesize is 30
- ex: Example: http://lcpserver.my.org/licenses?page=2&per_page=50

Response:
200 + the requested array of licenses: ok
400 Wrong pagination parameters 
Sample licence from response is :
{
  "id": "e698a7-7f34-49e7-8aae-4378ecb1d5ff",
  "issued": "2016-11-04T01:08:15+01:00",
  "updated": "2016-11-04T01:09:15+01:00",
  "provider": "http://www.imaginaryebookretailer.com",
  "user": {
    "id": "d9f298a7-7f34-49e7-8aae-4378ecb1d597",
  },
  "rights": {
    "print": 10,
    "copy": 2048,
    "start": "2016-11-04T01:08:15+01:00",
    "end": "2016-11-25T01:08:15+01:00"
  }
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
* GET <LCPbaseURL>/contents/<content_id>/licenses{page?, per_page?}
- List licences associated with specific content ordered by creation Date (issue date)
- page numbering is 1-based (starts with 1 not 0), and the default pagesize is 30

Response:
200 + the requested array of licenses
400 (bad request) The pagination parameters are wrong 
404 Content not found

Sample licence from response is :
{
  "id": "e698a7-7f34-49e7-8aae-4378ecb1d5ff",
  "issued": "2016-11-04T01:08:15+01:00",
  "updated": "2016-11-04T01:09:15+01:00",
  "provider": "http://www.imaginaryebookretailer.com",
  "user": {
    "id": "d9f298a7-7f34-49e7-8aae-4378ecb1d597",
  },
  "rights": {
    "print": 10,
    "copy": 2048,
    "start": "2016-11-04T01:08:15+01:00",
    "end": "2016-11-25T01:08:15+01:00"
  }
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
* PATCH <LCPbaseURL>/licenses/<license_id>
- Update a licence

Request:
Request:
{
  "provider": "http://www.imaginaryebookretailer.com", // URL for provider
  "user": {
    "id": "d9f298a7-7f34-49e7-8aae-4378ecb1d597", // Mandatory
    "email": "user@mymail.com", // Optional
    "encrypted": ["email"] // Optional
  },
  "rights": {
    "print": 10, // maximum number of pages that can be printed over the lifetime of the license, if zero copy will not be allowed, to be unlimited don't send it 
    "copy": 2048, // maximum number of characters that can be copied over the lifetime of the license, if zero copy will not be allowed, to be unlimited don't send it 
    "start": "2019-11-04T01:08:15+01:00", // Start Date of licence
    "end": "2019-11-25T01:08:15+01:00" // End Date of licence
  }
}

Response:
200: ok
400 (bad request) 
404 (not found) The license does not exist


