AbstractWebDidMethod
abstract class AbstractWebDidMethod(method: String, kms: KeyManagementService, httpClient: OkHttpClient, ownsHttpClient: Boolean = false) : AbstractDidMethod, AutoCloseable
Abstract base class for HTTP-based DID method implementations (e.g., did:web).
Provides common functionality for DID methods that host documents over HTTP/HTTPS:
HTTP client for document retrieval and publishing
Document hosting abstraction
HTTPS validation
Common HTTP error handling
Subclasses should implement:
createDid: Create a new DID and publish its document
resolveDid: Resolve DID from HTTP endpoint
getDocumentUrl: Get the HTTP URL for a DID document
publishDocument: Publish a document to the HTTP endpoint
Pattern: HTTP client abstraction for web-based DID methods.
Example Usage:
class WebDidMethod(
kms: KeyManagementService,
private val httpClient: OkHttpClient,
private val documentHost: DocumentHost
) : AbstractWebDidMethod("web", kms, httpClient) {
override fun getDocumentUrl(did: String): String {
val (_, domain, path) = parseWebDid(did)
return if (path != null) {
"https://$domain/.well-known/did.json"
} else {
"https://$domain/.well-known/did.json"
}
}
override suspend fun publishDocument(url: String, document: DidDocument): Boolean {
return documentHost.publish(url, document)
}
}Content copied to clipboard
Constructors
Link copied to clipboard
constructor(method: String, kms: KeyManagementService, httpClient: OkHttpClient, ownsHttpClient: Boolean = false)