All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.shredzone.acme4j.provider.google.GoogleAcmeProvider Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
/*
 * acme4j - Java ACME client
 *
 * Copyright (C) 2024 Richard "Shred" Körber
 *   http://acme4j.shredzone.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
package org.shredzone.acme4j.provider.google;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.Optional;

import org.jose4j.jws.AlgorithmIdentifiers;
import org.shredzone.acme4j.exception.AcmeProtocolException;
import org.shredzone.acme4j.provider.AbstractAcmeProvider;
import org.shredzone.acme4j.provider.AcmeProvider;

/**
 * An {@link AcmeProvider} for the Google Trust Services.
 * 

* The {@code serverUri} is {@code "acme://pki.goog"} for the production server, * and {@code "acme://pki.goog/staging"} for the staging server. * * @see https://pki.goog/ * @since 3.5.0 */ public class GoogleAcmeProvider extends AbstractAcmeProvider { private static final String PRODUCTION_DIRECTORY_URL = "https://dv.acme-v02.api.pki.goog/directory"; private static final String STAGING_DIRECTORY_URL = "https://dv.acme-v02.test-api.pki.goog/directory"; @Override public boolean accepts(URI serverUri) { return "acme".equals(serverUri.getScheme()) && "pki.goog".equals(serverUri.getHost()); } @Override public URL resolve(URI serverUri) { var path = serverUri.getPath(); String directoryUrl; if (path == null || path.isEmpty() || "/".equals(path)) { directoryUrl = PRODUCTION_DIRECTORY_URL; } else if ("/staging".equals(path)) { directoryUrl = STAGING_DIRECTORY_URL; } else { throw new IllegalArgumentException("Unknown URI " + serverUri); } try { return new URL(directoryUrl); } catch (MalformedURLException ex) { throw new AcmeProtocolException(directoryUrl, ex); } } @Override public Optional getProposedEabMacAlgorithm() { return Optional.of(AlgorithmIdentifiers.HMAC_SHA256); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy