org.eclipse.tractusx.ssi.examples.ResolveDIDDoc Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cx-ssi-lib Show documentation
Show all versions of cx-ssi-lib Show documentation
A library for processing verifiable credentials
/*
* ******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
* *******************************************************************************
*/
package org.eclipse.tractusx.ssi.examples;
import java.net.http.HttpClient;
import org.eclipse.tractusx.ssi.lib.did.web.DidWebFactory;
import org.eclipse.tractusx.ssi.lib.did.web.DidWebResolver;
import org.eclipse.tractusx.ssi.lib.did.web.util.DidWebParser;
import org.eclipse.tractusx.ssi.lib.exception.did.DidParseException;
import org.eclipse.tractusx.ssi.lib.exception.did.DidResolverException;
import org.eclipse.tractusx.ssi.lib.model.did.Did;
import org.eclipse.tractusx.ssi.lib.model.did.DidDocument;
/** This is an example class to demonstrate did document resolve from given did web url */
public class ResolveDIDDoc {
private ResolveDIDDoc() {
throw new IllegalStateException("Utility class");
}
/**
* Resolve did document.
*
* @param didUrl the did url
* @return the did document
* @throws DidResolverException the did resolve exception
* @throws DidParseException the did parse exception
*/
public static DidDocument resolveDidDocument(String didUrl)
throws DidParseException, DidResolverException {
DidWebParser didParser = new DidWebParser();
var httpClient = HttpClient.newHttpClient();
var enforceHttps = false;
// DID
Did did = DidWebFactory.fromHostname(didUrl);
var didResolver = new DidWebResolver(httpClient, didParser, enforceHttps);
return didResolver.resolve(did);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy