-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xds: security code refactoring/renaming (#9555)
* xds: security code refactoring/renaming 1) move certprovider package under security 2) refactor inner Factory into CertProviderClientSslContextProviderFactory and CertProviderServerSslContextProviderFactory 3) Make CertProviderClientSslContextProvider and CertProviderServerSslContextProvider non-public 4) use only public (non package private) types like SslContextProvider (instead of CertProviderClientSslContextProvider etc)
- Loading branch information
1 parent
0cda133
commit 6f8e44a
Showing
25 changed files
with
261 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
.../grpc/xds/internal/security/certprovider/CertProviderClientSslContextProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2022 The gRPC Authors | ||
* | ||
* 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 io.grpc.xds.internal.security.certprovider; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import io.envoyproxy.envoy.config.core.v3.Node; | ||
import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext; | ||
import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext; | ||
import io.grpc.Internal; | ||
import io.grpc.xds.Bootstrapper.CertificateProviderInfo; | ||
import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext; | ||
import io.grpc.xds.internal.security.SslContextProvider; | ||
import java.util.Map; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Creates CertProviderClientSslContextProvider. | ||
*/ | ||
@Internal | ||
public final class CertProviderClientSslContextProviderFactory { | ||
|
||
private static final CertProviderClientSslContextProviderFactory DEFAULT_INSTANCE = | ||
new CertProviderClientSslContextProviderFactory(CertificateProviderStore.getInstance()); | ||
private final CertificateProviderStore certificateProviderStore; | ||
|
||
@VisibleForTesting | ||
public CertProviderClientSslContextProviderFactory( | ||
CertificateProviderStore certificateProviderStore) { | ||
this.certificateProviderStore = certificateProviderStore; | ||
} | ||
|
||
public static CertProviderClientSslContextProviderFactory getInstance() { | ||
return DEFAULT_INSTANCE; | ||
} | ||
|
||
/** | ||
* Creates a {@link CertProviderClientSslContextProvider}. | ||
*/ | ||
public SslContextProvider getProvider( | ||
UpstreamTlsContext upstreamTlsContext, | ||
Node node, | ||
@Nullable Map<String, CertificateProviderInfo> certProviders) { | ||
checkNotNull(upstreamTlsContext, "upstreamTlsContext"); | ||
CommonTlsContext commonTlsContext = upstreamTlsContext.getCommonTlsContext(); | ||
CertificateValidationContext staticCertValidationContext | ||
= CertProviderSslContextProvider.getStaticValidationContext(commonTlsContext); | ||
CommonTlsContext.CertificateProviderInstance rootCertInstance | ||
= CertProviderSslContextProvider.getRootCertProviderInstance(commonTlsContext); | ||
CommonTlsContext.CertificateProviderInstance certInstance | ||
= CertProviderSslContextProvider.getCertProviderInstance(commonTlsContext); | ||
return new CertProviderClientSslContextProvider( | ||
node, | ||
certProviders, | ||
certInstance, | ||
rootCertInstance, | ||
staticCertValidationContext, | ||
upstreamTlsContext, | ||
certificateProviderStore); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.