1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-14 07:34:52 +02:00
pgpainless/pgpainless-core/src/main/java/org/pgpainless/key/generation/KeyRingBuilderInterface.java

78 lines
2.4 KiB
Java
Raw Normal View History

/*
2020-10-20 22:58:45 +02:00
* Copyright 2018-2020 Paul Schaub.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://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.
*/
package org.pgpainless.key.generation;
2018-06-02 21:21:35 +02:00
import java.security.InvalidAlgorithmParameterException;
2018-06-02 21:21:35 +02:00
import java.security.NoSuchAlgorithmException;
2020-12-08 19:14:52 +01:00
import javax.annotation.Nonnull;
2018-06-02 21:21:35 +02:00
import org.bouncycastle.openpgp.PGPException;
2020-12-08 19:14:52 +01:00
import org.bouncycastle.openpgp.PGPSecretKeyRing;
2020-11-13 15:59:28 +01:00
import org.pgpainless.key.util.UserId;
import org.pgpainless.util.Passphrase;
2018-06-02 21:21:35 +02:00
public interface KeyRingBuilderInterface {
KeyRingBuilderInterface withSubKey(@Nonnull KeySpec keySpec);
2018-06-02 21:21:35 +02:00
/**
* Define the primary key spec.
*
* @deprecated use {@link #withPrimaryKey(KeySpec)} instead.
* @param keySpec key spec
* @return builder step
*/
@Deprecated
default WithPrimaryUserId withMasterKey(@Nonnull KeySpec keySpec) {
return withPrimaryKey(keySpec);
}
WithPrimaryUserId withPrimaryKey(@Nonnull KeySpec keySpec);
2018-06-02 21:21:35 +02:00
interface WithPrimaryUserId {
2020-11-13 15:59:28 +01:00
default WithAdditionalUserIdOrPassphrase withPrimaryUserId(@Nonnull UserId userId) {
return withPrimaryUserId(userId.toString());
}
WithAdditionalUserIdOrPassphrase withPrimaryUserId(@Nonnull String userId);
2018-06-02 21:21:35 +02:00
WithAdditionalUserIdOrPassphrase withPrimaryUserId(@Nonnull byte[] userId);
2018-06-02 21:21:35 +02:00
}
interface WithAdditionalUserIdOrPassphrase {
2020-11-13 15:59:28 +01:00
default WithAdditionalUserIdOrPassphrase withAdditionalUserId(@Nonnull UserId userId) {
return withAdditionalUserId(userId.toString());
}
WithAdditionalUserIdOrPassphrase withAdditionalUserId(@Nonnull String userId);
WithAdditionalUserIdOrPassphrase withAdditionalUserId(@Nonnull byte[] userId);
2018-06-02 21:21:35 +02:00
Build withPassphrase(@Nonnull Passphrase passphrase);
2018-06-02 21:21:35 +02:00
Build withoutPassphrase();
}
interface Build {
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing build() throws NoSuchAlgorithmException, PGPException,
InvalidAlgorithmParameterException;
2018-06-02 21:21:35 +02:00
}
}