2 * Copyright 2000-2018 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package jetbrains.buildServer.buildTriggers.vcs.git;
19 import jetbrains.buildServer.util.StringUtil;
20 import jetbrains.buildServer.util.ssl.TrustStoreIO;
21 import org.jetbrains.annotations.NotNull;
22 import org.jetbrains.annotations.Nullable;
24 import java.security.KeyStore;
27 * Implementation of {@link GitTrustStoreProvider} for static folder.
29 * @author Mikhail Khorkov
32 public class GitTrustStoreProviderStatic implements GitTrustStoreProvider {
35 private String myTrustedCertificatesDir;
37 public GitTrustStoreProviderStatic(@Nullable final String trustedCertificatesDir) {
38 myTrustedCertificatesDir = trustedCertificatesDir;
43 public KeyStore getTrustStore() {
44 if (myTrustedCertificatesDir == null) {
47 return TrustStoreIO.readTrustStoreFromDirectory(myTrustedCertificatesDir);
53 public String serialize() {
54 return myTrustedCertificatesDir != null ? myTrustedCertificatesDir : "";
59 public GitTrustStoreProvider deserialize(@NotNull final String serialized) {
60 if (StringUtil.isEmptyOrSpaces(serialized)) {
61 myTrustedCertificatesDir = null;
63 myTrustedCertificatesDir = serialized;