001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether.generator.gnupg;
020
021import org.eclipse.aether.ConfigurationProperties;
022import org.eclipse.aether.RepositorySystemSession;
023
024/**
025 * Configuration for GPG Signer.
026 *
027 * @since 2.0.0
028 */
029public final class GnupgConfigurationKeys {
030    private GnupgConfigurationKeys() {}
031
032    static final String NAME = "gpg";
033
034    static final String CONFIG_PROPS_PREFIX = ConfigurationProperties.PREFIX_GENERATOR + NAME + ".";
035
036    /**
037     * Whether GnuPG signer is enabled.
038     *
039     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
040     * @configurationType {@link Boolean}
041     * @configurationDefaultValue {@link #DEFAULT_ENABLED}
042     */
043    public static final String CONFIG_PROP_ENABLED = CONFIG_PROPS_PREFIX + "enabled";
044
045    public static final boolean DEFAULT_ENABLED = false;
046
047    /**
048     * The PGP Key fingerprint as hex string (40 characters long), optional. If not set, first secret key found will
049     * be used.
050     *
051     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
052     * @configurationType {@link String}
053     */
054    public static final String CONFIG_PROP_KEY_FINGERPRINT = CONFIG_PROPS_PREFIX + "keyFingerprint";
055
056    /**
057     * The path to the OpenPGP transferable secret key file. If relative, is resolved from local repository root.
058     *
059     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
060     * @configurationType {@link String}
061     * @configurationDefaultValue {@link #DEFAULT_KEY_FILE_PATH}
062     */
063    public static final String CONFIG_PROP_KEY_FILE_PATH = CONFIG_PROPS_PREFIX + "keyFilePath";
064
065    public static final String DEFAULT_KEY_FILE_PATH = "maven-signing-key.key";
066
067    /**
068     * Whether GnuPG agent should be used.
069     *
070     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
071     * @configurationType {@link java.lang.Boolean}
072     * @configurationDefaultValue {@link #DEFAULT_USE_AGENT}
073     */
074    public static final String CONFIG_PROP_USE_AGENT = CONFIG_PROPS_PREFIX + "useAgent";
075
076    public static final boolean DEFAULT_USE_AGENT = true;
077
078    /**
079     * The GnuPG agent socket(s) to try. Comma separated list of socket paths. If relative, will be resolved from
080     * user home directory.
081     *
082     * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
083     * @configurationType {@link String}
084     * @configurationDefaultValue {@link #DEFAULT_AGENT_SOCKET_LOCATIONS}
085     */
086    public static final String CONFIG_PROP_AGENT_SOCKET_LOCATIONS = CONFIG_PROPS_PREFIX + "agentSocketLocations";
087
088    public static final String DEFAULT_AGENT_SOCKET_LOCATIONS = ".gnupg/S.gpg-agent";
089
090    /**
091     * Env variable name to pass in key pass.
092     */
093    public static final String RESOLVER_GPG_KEY_PASS = "RESOLVER_GPG_KEY_PASS";
094
095    /**
096     * Env variable name to pass in key material.
097     */
098    public static final String RESOLVER_GPG_KEY = "RESOLVER_GPG_KEY";
099
100    /**
101     * Env variable name to pass in key fingerprint (hex encoded, 40 characters long).
102     */
103    public static final String RESOLVER_GPG_KEY_FINGERPRINT = "RESOLVER_GPG_KEY_FINGERPRINT";
104}