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;
|
2021-02-13 12:22:28 +01:00
|
|
|
import java.util.Date;
|
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
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
public interface KeyRingBuilderInterface<B extends KeyRingBuilderInterface<B>> {
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
B setPrimaryKey(@Nonnull KeySpec keySpec);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
default B setPrimaryKey(@Nonnull KeySpecBuilder builder) {
|
|
|
|
return setPrimaryKey(builder.build());
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
B addSubkey(@Nonnull KeySpec keySpec);
|
2020-10-16 12:46:58 +02:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
default B addSubkey(@Nonnull KeySpecBuilder builder) {
|
|
|
|
return addSubkey(builder.build());
|
|
|
|
}
|
2020-11-13 15:59:28 +01:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
default B addUserId(UserId userId) {
|
|
|
|
return addUserId(userId.toString());
|
|
|
|
}
|
2021-02-13 12:22:28 +01:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
B addUserId(@Nonnull String userId);
|
2020-10-16 12:46:58 +02:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
B addUserId(@Nonnull byte[] userId);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
B setExpirationDate(@Nonnull Date expirationDate);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
B setPassphrase(@Nonnull Passphrase passphrase);
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2021-09-20 12:30:03 +02:00
|
|
|
PGPSecretKeyRing build() throws NoSuchAlgorithmException, PGPException,
|
2018-06-04 14:50:09 +02:00
|
|
|
InvalidAlgorithmParameterException;
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|