...
Code Block | ||
---|---|---|
| ||
func parseEncryptions() -> [String: Encryption] { guard let document = document else { return [:] } var encryptions: [String: Encryption] = [:] // Loop through <EncryptedData> elements.. for encryptedDataElement in document.xpath("./enc:EncryptedData") { guard let algorithm = encryptedDataElement.firstChild(xpath: "enc:EncryptionMethod")?.attr("Algorithm var resourceURI = encryptedDataElement.firstChild(xpath:"enc:CipherData/enc:CipherReference")?.attr("URI")?.removingPercentEncoding else { continue } resourceURI = normalize(base: "/", href: resourceURI) var encryption = Encryption(algorithm: algorithm) // LCP. Tag LCP protected resources. let keyInfoURI = encryptedDataElement.firstChild(xpath: "ds:KeyInfo/ds:RetrievalMethod")?.attr("URI") if keyInfoURI == "license.lcpl#/encryption/content_key", drm?.brand == DRM.Brand.lcp { encryption.scheme = drm?.scheme.rawValue } // LCP END. if drm?.brand == .adobe { encryption.scheme = drm?.scheme.rawValue } . . . |
func parseEncryptions() -> [String: Encryption] {
guard let document = document else {
return [:]
}
var encryptions: [String: Encryption] = [:]
// Loop through <EncryptedData> elements..
for encryptedDataElement in document.xpath("./enc:EncryptedData") {
guard let algorithm = encryptedDataElement.firstChild(xpath: "enc:EncryptionMethod")?.attr("Algorithm"),
var resourceURI = encryptedDataElement.firstChild(xpath:"enc:CipherData/enc:CipherReference")?.attr("URI")?.removingPercentEncoding else
{
continue
...
} |
resourceURI = normalize(base: "/", href: resourceURI)
var encryption = Encryption(algorithm: algorithm)
// LCP. Tag LCP protected resources.
let keyInfoURI = encryptedDataElement.firstChild(xpath: "ds:KeyInfo/ds:RetrievalMethod")?.attr("URI")
if keyInfoURI == "license.lcpl#/encryption/content_key",
drm?.brand == DRM.Brand.lcp
{
encryption.scheme = drm?.scheme.rawValue
}
// LCP END.
if drm?.brand == .adobe {
encryption.scheme = drm?.scheme.rawValue
}
. . .
Commit:
https://github.com/NYPL-Simplified/r2-streamer-swift/commit/08c6d6a204cebff5137f868794a412b453437a5b
In `Parser/EPUB/EPUBEncryptionParser.swift` changed how Adobe encryption scheme is assigned:
Code Block | ||
---|---|---|
| ||
scheme = drm?.scheme.rawValue |
In `Parser/EPUB/EPUBParser.swift` added `links` to the initialized publication
Code Block | ||
---|---|---|
| ||
publication.links = links |
publication.links = links
...