2018-06-13 17:26:48 +02:00
|
|
|
/*
|
2020-10-20 22:58:45 +02:00
|
|
|
* Copyright 2018-2020 Paul Schaub.
|
2018-06-13 17:26:48 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2018-07-18 18:23:06 +02:00
|
|
|
package org.pgpainless.key.generation;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-06-04 14:50:09 +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;
|
2018-07-18 18:23:06 +02:00
|
|
|
import org.pgpainless.util.Passphrase;
|
2018-06-02 21:21:35 +02:00
|
|
|
|
|
|
|
public interface KeyRingBuilderInterface {
|
|
|
|
|
2018-07-31 20:09:16 +02:00
|
|
|
KeyRingBuilderInterface withSubKey(@Nonnull KeySpec keySpec);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2021-02-11 17:18:59 +01: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());
|
|
|
|
}
|
|
|
|
|
2020-10-16 12:46:58 +02:00
|
|
|
WithAdditionalUserIdOrPassphrase withPrimaryUserId(@Nonnull String userId);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2020-10-16 12:46:58 +02:00
|
|
|
WithAdditionalUserIdOrPassphrase withPrimaryUserId(@Nonnull byte[] userId);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-16 12:46:58 +02:00
|
|
|
interface WithAdditionalUserIdOrPassphrase {
|
|
|
|
|
2020-11-13 15:59:28 +01:00
|
|
|
default WithAdditionalUserIdOrPassphrase withAdditionalUserId(@Nonnull UserId userId) {
|
|
|
|
return withAdditionalUserId(userId.toString());
|
|
|
|
}
|
|
|
|
|
2020-10-16 12:46:58 +02:00
|
|
|
WithAdditionalUserIdOrPassphrase withAdditionalUserId(@Nonnull String userId);
|
|
|
|
|
|
|
|
WithAdditionalUserIdOrPassphrase withAdditionalUserId(@Nonnull byte[] userId);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-07-31 20:09:16 +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,
|
2018-06-04 14:50:09 +02:00
|
|
|
InvalidAlgorithmParameterException;
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
}
|