From 66fcea4c0176e73e303d7eef61f353af77193a79 Mon Sep 17 00:00:00 2001 From: tharindu1st Date: Tue, 9 Jan 2024 18:48:19 +0530 Subject: [PATCH] xrefactor tokenissuer --- .../discovery/service/apkmgt/eventds.proto | 18 - .../discovery/subscription/application.proto | 35 - .../application_key_mapping.proto | 37 - .../subscription/applicationmapping.proto | 34 - .../wso2/discovery/subscription/event.proto | 42 - .../subscription/jwtIssuer_list.proto | 33 - .../discovery/subscription/subscription.proto | 39 - .../discovery/subscription/url_mapping.proto | 18 - adapter/api/protogen.sh | 1 - adapter/internal/discovery/xds/server.go | 21 - .../controllers/dp/tokenissuer_controller.go | 295 --- adapter/internal/operator/operator.go | 3 - .../discovery/subscription/jwtIssuer.pb.go | 410 ---- .../subscription/jwtIssuer_list.pb.go | 179 -- .../discovery/subscription/url_mapping.pb.go | 184 -- .../discovery/protocol/cache/v3/resource.go | 5 - common-controller/go.mod | 4 +- .../internal/cache/subscriptionDataStore.go | 29 + .../internal/operator/constant/constant.go | 4 + .../dp/ratelimitpolicy_controller.go | 5 +- .../controllers/dp/tokenissuer_controller.go | 314 +++ .../internal/operator/operator.go | 3 + common-controller/internal/server/server.go | 18 + .../internal/server/token_issuer_types.go | 53 + .../internal/utils/event_utils.go | 65 + common-controller/internal/utils/utils.go | 79 + .../internal/xds/ratelimiter_cache.go | 2 - common-controller/internal/xds/server.go | 39 +- .../discovery/service/apkmgt/eventds.pb.go | 278 --- .../discovery/subscription/application.pb.go | 219 -- .../application_key_mapping.pb.go | 235 -- .../subscription/applicationmapping.pb.go | 203 -- .../wso2/discovery/subscription/event.pb.go | 268 --- .../discovery/subscription/subscription.pb.go | 277 --- .../wso2/discovery/subscription/event.pb.go | 53 +- .../discovery/subscription/token_issuer.pb.go | 411 ++++ .../discovery/JWTIssuerDiscoveryClient.java | 229 -- .../scheduler/XdsSchedulerManager.java | 7 - .../discovery/subscription/Certificate.java | 12 +- .../subscription/CertificateOrBuilder.java | 2 +- .../discovery/subscription/Event.java | 188 ++ .../subscription/EventOrBuilder.java | 15 + .../discovery/subscription/EventProto.java | 35 +- .../enforcer/discovery/subscription/JWKS.java | 12 +- .../discovery/subscription/JWKSOrBuilder.java | 2 +- .../discovery/subscription/TokenIssuer.java | 1921 +++++++++++++++++ .../subscription/TokenIssuerOrBuilder.java | 155 ++ .../subscription/TokenIssuerProto.java | 96 + .../subscription/EventingGrpcClient.java | 11 +- .../subscription/ResolvedCertificate.java | 27 + .../enforcer/subscription/ResolvedJWKS.java | 27 + .../SignatureValidationRestDto.java | 27 + .../subscription/SubscriptionDataStore.java | 6 + .../SubscriptionDataStoreImpl.java | 724 ++++--- .../SubscriptionDataStoreUtil.java | 46 +- ...tionValidationDataRetrievalRestClient.java | 5 + .../subscription/TokenIssuerListDto.java | 15 + .../subscription/TokenIssuerRestDto.java | 97 + protos/protogen.sh | 2 +- .../wso2/discovery/subscription/event.proto | 2 + .../discovery/subscription/token_issuer.proto | 36 +- 61 files changed, 4120 insertions(+), 3492 deletions(-) delete mode 100644 adapter/api/proto/wso2/discovery/service/apkmgt/eventds.proto delete mode 100644 adapter/api/proto/wso2/discovery/subscription/application.proto delete mode 100644 adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto delete mode 100644 adapter/api/proto/wso2/discovery/subscription/applicationmapping.proto delete mode 100644 adapter/api/proto/wso2/discovery/subscription/event.proto delete mode 100644 adapter/api/proto/wso2/discovery/subscription/jwtIssuer_list.proto delete mode 100644 adapter/api/proto/wso2/discovery/subscription/subscription.proto delete mode 100644 adapter/api/proto/wso2/discovery/subscription/url_mapping.proto delete mode 100644 adapter/internal/operator/controllers/dp/tokenissuer_controller.go delete mode 100644 adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer.pb.go delete mode 100644 adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer_list.pb.go delete mode 100644 adapter/pkg/discovery/api/wso2/discovery/subscription/url_mapping.pb.go create mode 100644 common-controller/internal/operator/controllers/dp/tokenissuer_controller.go create mode 100644 common-controller/internal/server/token_issuer_types.go delete mode 100644 common-controller/pkg/discovery/api/wso2/discovery/service/apkmgt/eventds.pb.go delete mode 100644 common-controller/pkg/discovery/api/wso2/discovery/subscription/application.pb.go delete mode 100644 common-controller/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go delete mode 100644 common-controller/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go delete mode 100644 common-controller/pkg/discovery/api/wso2/discovery/subscription/event.pb.go delete mode 100644 common-controller/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go create mode 100644 common-go-libs/pkg/discovery/api/wso2/discovery/subscription/token_issuer.pb.go delete mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/JWTIssuerDiscoveryClient.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuer.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerOrBuilder.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerProto.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedCertificate.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedJWKS.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SignatureValidationRestDto.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerListDto.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerRestDto.java rename adapter/api/proto/wso2/discovery/subscription/jwtIssuer.proto => protos/wso2/discovery/subscription/token_issuer.proto (59%) diff --git a/adapter/api/proto/wso2/discovery/service/apkmgt/eventds.proto b/adapter/api/proto/wso2/discovery/service/apkmgt/eventds.proto deleted file mode 100644 index 9a2eeefa0..000000000 --- a/adapter/api/proto/wso2/discovery/service/apkmgt/eventds.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package discovery.service.apkmgt; - -import "wso2/discovery/subscription/event.proto"; -option go_package = "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/service/apkmgt"; -option java_package = "org.wso2.apk.enforcer.discovery.service.apkmgt"; -option java_outer_classname = "EventServiceProto"; -option java_multiple_files = true; -option java_generic_services = true; - -// [#protodoc-title: EventStreamDS] -service EventStreamService { - rpc StreamEvents (Request) returns (stream wso2.discovery.subscription.Event) {} - } -message Request { - string event = 1; -} \ No newline at end of file diff --git a/adapter/api/proto/wso2/discovery/subscription/application.proto b/adapter/api/proto/wso2/discovery/subscription/application.proto deleted file mode 100644 index 6a3ea7e36..000000000 --- a/adapter/api/proto/wso2/discovery/subscription/application.proto +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * 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. - * - */ -syntax = "proto3"; - -package wso2.discovery.subscription; - -option go_package = "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription"; -option java_package = "org.wso2.apk.enforcer.discovery.subscription"; -option java_outer_classname = "ApplicationProto"; -option java_multiple_files = true; - -// [#protodoc-title: Application] - -// Application data model -message Application { - string uuid = 1; - string name = 2; - string owner = 3; - string organization = 4; - map attributes = 5; -} diff --git a/adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto b/adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto deleted file mode 100644 index 6f124e7cd..000000000 --- a/adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * 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. - * - */ -syntax = "proto3"; - -package wso2.discovery.subscription; - -option go_package = "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription"; -option java_package = "org.wso2.apk.enforcer.discovery.subscription"; -option java_outer_classname = "ApplicationKeyMappingProto"; -option java_multiple_files = true; - -// [#protodoc-title: ApplicationKeyMapping] - -// ApplicationKeyMapping data model -message ApplicationKeyMapping { - string applicationUUID = 1; - string securityScheme = 2; - string applicationIdentifier = 3; - string keyType = 4; - string envID = 5; - int64 timestamp = 6; - string organization = 7; -} diff --git a/adapter/api/proto/wso2/discovery/subscription/applicationmapping.proto b/adapter/api/proto/wso2/discovery/subscription/applicationmapping.proto deleted file mode 100644 index 5ae10010b..000000000 --- a/adapter/api/proto/wso2/discovery/subscription/applicationmapping.proto +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * 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. - * - */ -syntax = "proto3"; - -package wso2.discovery.subscription; - -option go_package = "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription"; -option java_package = "org.wso2.apk.enforcer.discovery.subscription"; -option java_outer_classname = "ApplicationMappingProto"; -option java_multiple_files = true; - -// [#protodoc-title: ApplicationMapping] - -// ApplicationMapping data model -message ApplicationMapping { - string uuid = 1; - string applicationRef = 2; - string subscriptionRef = 3; - string organization = 4; -} diff --git a/adapter/api/proto/wso2/discovery/subscription/event.proto b/adapter/api/proto/wso2/discovery/subscription/event.proto deleted file mode 100644 index 542ed8a49..000000000 --- a/adapter/api/proto/wso2/discovery/subscription/event.proto +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * 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. - * - */ - syntax = "proto3"; - - package wso2.discovery.subscription; - - import "wso2/discovery/subscription/application.proto"; - import "wso2/discovery/subscription/applicationmapping.proto"; - import "wso2/discovery/subscription/application_key_mapping.proto"; - import "wso2/discovery/subscription/subscription.proto"; - option go_package = "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription"; - option java_package = "org.wso2.apk.enforcer.discovery.subscription"; - option java_outer_classname = "EventProto"; - option java_multiple_files = true; - - // [#protodoc-title: Event] - - // Event data model - message Event { - string uuid = 1; - int64 timeStamp = 2; - string type = 3; - Application application = 4; - ApplicationMapping applicationMapping = 5; - ApplicationKeyMapping applicationKeyMapping = 6; - Subscription subscription = 7; - } - \ No newline at end of file diff --git a/adapter/api/proto/wso2/discovery/subscription/jwtIssuer_list.proto b/adapter/api/proto/wso2/discovery/subscription/jwtIssuer_list.proto deleted file mode 100644 index 41ebca675..000000000 --- a/adapter/api/proto/wso2/discovery/subscription/jwtIssuer_list.proto +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * 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. - * - */ -syntax = "proto3"; - -package wso2.discovery.subscription; - -import "wso2/discovery/subscription/jwtIssuer.proto"; - -option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/subscription;subscription"; -option java_package = "org.wso2.apk.enforcer.discovery.subscription"; -option java_outer_classname = "JWTIssuerListProto"; -option java_multiple_files = true; - -// [#protodoc-title: JWTIssuerList] - -// JWTIssuerList data model -message JWTIssuerList { - repeated JWTIssuer list = 2; -} diff --git a/adapter/api/proto/wso2/discovery/subscription/subscription.proto b/adapter/api/proto/wso2/discovery/subscription/subscription.proto deleted file mode 100644 index 2f61bdfb3..000000000 --- a/adapter/api/proto/wso2/discovery/subscription/subscription.proto +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * 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. - * - */ -syntax = "proto3"; - -package wso2.discovery.subscription; - -option go_package = "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription"; -option java_package = "org.wso2.apk.enforcer.discovery.subscription"; -option java_outer_classname = "SubscriptionProto"; -option java_multiple_files = true; - -// [#protodoc-title: Subscription] - -// Subscription data model -message Subscription { - string subStatus = 1; - string uuid = 2; - string organization = 3; - SubscribedAPI subscribedApi = 4; -} - -message SubscribedAPI { - string name = 1; - string version = 2; -} diff --git a/adapter/api/proto/wso2/discovery/subscription/url_mapping.proto b/adapter/api/proto/wso2/discovery/subscription/url_mapping.proto deleted file mode 100644 index ee7f06aa6..000000000 --- a/adapter/api/proto/wso2/discovery/subscription/url_mapping.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package wso2.discovery.subscription; - -option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/subscription;subscription"; -option java_package = "org.wso2.apk.enforcer.discovery.subscription"; -option java_outer_classname = "URLMappingProto"; -option java_multiple_files = true; - -// [#protodoc-title: URLMapping] - -// URLMapping data model -message URLMapping { - string authScheme = 1; - string httpMethod = 2; - string urlPattern = 3; - repeated string scopes = 4; -} diff --git a/adapter/api/protogen.sh b/adapter/api/protogen.sh index 94163e088..f68fa8d65 100755 --- a/adapter/api/protogen.sh +++ b/adapter/api/protogen.sh @@ -56,7 +56,6 @@ printf " - ${GREEN}${BOLD}done${NC}\n" printf "protoc go messages" docker run -v `pwd`:/defs namely/protoc-all:$PROTOC_VERSION -l go --go-source-relative -i proto -i target/include/ -o target/gen/go -d proto/wso2/discovery/api/ docker run -v `pwd`:/defs namely/protoc-all:$PROTOC_VERSION -l go --go-source-relative -i proto -i target/include/ -o target/gen/go -d proto/wso2/discovery/config/enforcer/ -docker run -v `pwd`:/defs namely/protoc-all:$PROTOC_VERSION -l go --go-source-relative -i proto -i target/include/ -o target/gen/go -d proto/wso2/discovery/subscription/ printf " - ${GREEN}${BOLD}done${NC}\n" # map of proto imports for which we need to update the genrated import path diff --git a/adapter/internal/discovery/xds/server.go b/adapter/internal/discovery/xds/server.go index e12fb0010..04a884e81 100644 --- a/adapter/internal/discovery/xds/server.go +++ b/adapter/internal/discovery/xds/server.go @@ -49,7 +49,6 @@ import ( "github.com/wso2/apk/adapter/internal/oasparser/envoyconf" "github.com/wso2/apk/adapter/internal/oasparser/model" operatorconsts "github.com/wso2/apk/adapter/internal/operator/constants" - "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription" wso2_cache "github.com/wso2/apk/adapter/pkg/discovery/protocol/cache/v3" wso2_resource "github.com/wso2/apk/adapter/pkg/discovery/protocol/resource/v3" eventhubTypes "github.com/wso2/apk/adapter/pkg/eventhub/types" @@ -566,26 +565,6 @@ func UpdateEnforcerApis(label string, apis []types.Resource, version string) { } -// UpdateEnforcerJWTIssuers sets new update to the enforcer's Applications -func UpdateEnforcerJWTIssuers(jwtIssuers *subscription.JWTIssuerList) { - logger.LoggerXds.Debug("Updating Enforcer JWT Issuer Cache") - label := commonEnforcerLabel - jwtIssuerList := append(enforcerLabelMap[label].jwtIssuers, jwtIssuers) - - version, _ := crand.Int(crand.Reader, maxRandomBigInt()) - snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ - wso2_resource.JWTIssuerListType: jwtIssuerList, - }) - snap.Consistent() - - errSetSnap := enforcerJwtIssuerCache.SetSnapshot(context.Background(), label, snap) - if errSetSnap != nil { - logger.LoggerXds.ErrorC(logging.PrintError(logging.Error1414, logging.MAJOR, "Error while setting the snapshot : %v", errSetSnap.Error())) - } - enforcerLabelMap[label].jwtIssuers = jwtIssuerList - logger.LoggerXds.Infof("New JWTIssuer cache update for the label: " + label + " version: " + fmt.Sprint(version)) -} - // UpdateXdsCacheWithLock uses mutex and lock to avoid different go routines updating XDS at the same time func UpdateXdsCacheWithLock(label string, endpoints []types.Resource, clusters []types.Resource, routes []types.Resource, listeners []types.Resource) bool { diff --git a/adapter/internal/operator/controllers/dp/tokenissuer_controller.go b/adapter/internal/operator/controllers/dp/tokenissuer_controller.go deleted file mode 100644 index a399da059..000000000 --- a/adapter/internal/operator/controllers/dp/tokenissuer_controller.go +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * 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 dp - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/wso2/apk/adapter/internal/discovery/xds" - "github.com/wso2/apk/adapter/internal/loggers" - "github.com/wso2/apk/adapter/internal/operator/constants" - "github.com/wso2/apk/adapter/internal/operator/utils" - "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription" - "github.com/wso2/apk/adapter/pkg/logging" - dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" - dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" - ctrl "sigs.k8s.io/controller-runtime" - k8client "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/predicate" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" -) - -const ( - tokenIssuerIndex = "tokenIssuerIndex" - secretTokenIssuerIndex = "secretTokenIssuerIndex" - configmapIssuerIndex = "configmapIssuerIndex" - defaultAllEnvironments = "*" -) - -// TokenssuerReconciler reconciles a TokenIssuer object -type TokenssuerReconciler struct { - client k8client.Client - Scheme *runtime.Scheme -} - -//+kubebuilder:rbac:groups=dp.wso2.com,resources=jwtissuers,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=dp.wso2.com,resources=jwtissuers/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=dp.wso2.com,resources=jwtissuers/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the JWTIssuer object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile -func (r *TokenssuerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - var err error - - loggers.LoggerAPKOperator.Debugf("Reconciling jwtIssuer: %v", req.NamespacedName.String()) - - jwtKey := req.NamespacedName - var jwtIssuerList = new(dpv1alpha1.TokenIssuerList) - if err := r.client.List(ctx, jwtIssuerList); err != nil { - return reconcile.Result{}, fmt.Errorf("failed to get jwtIssuer %s/%s", jwtKey.Namespace, jwtKey.Name) - } - jwtIssuerMapping, err := getJWTIssuers(ctx, r.client, jwtKey) - if err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2660, logging.CRITICAL, - "Unable to find associated JWTIssuers for %s : %s", req.NamespacedName.String(), err.Error())) - return ctrl.Result{}, err - } - UpdateEnforcerJWTIssuers(jwtIssuerMapping) - return ctrl.Result{}, nil -} - -// NewTokenIssuerReconciler creates a new Application controller instance. -func NewTokenIssuerReconciler(mgr manager.Manager) error { - r := &TokenssuerReconciler{ - client: mgr.GetClient(), - } - ctx := context.Background() - - if err := addTokenIssuerIndexes(ctx, mgr); err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2658, logging.CRITICAL, "Error adding indexes: %v", err)) - return err - } - c, err := controller.New(constants.TokenIssuerController, mgr, controller.Options{Reconciler: r}) - if err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2657, logging.BLOCKER, "Error creating TokenIssuer controller: %v", err.Error())) - return err - } - - if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha1.TokenIssuer{}), &handler.EnqueueRequestForObject{}, - predicate.NewPredicateFuncs(utils.FilterByNamespaces([]string{utils.GetOperatorPodNamespace()}))); err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2656, logging.BLOCKER, "Error watching TokenIssuer resources: %v", err.Error())) - return err - } - - loggers.LoggerAPKOperator.Debug("TokenIssuer Controller successfully started. Watching TokenIssuer Objects...") - return nil -} - -// addTokenIssuerIndexes adds indexers related to Gateways -func addTokenIssuerIndexes(ctx context.Context, mgr manager.Manager) error { - - // Secret to TokenIssuer indexer - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.TokenIssuer{}, secretTokenIssuerIndex, - func(rawObj k8client.Object) []string { - jwtIssuer := rawObj.(*dpv1alpha1.TokenIssuer) - var secrets []string - if jwtIssuer.Spec.SignatureValidation.Certificate != nil && jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef != nil && len(jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef.Name) > 0 { - secrets = append(secrets, - types.NamespacedName{ - Name: string(jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef.Name), - Namespace: jwtIssuer.Namespace, - }.String()) - } - if jwtIssuer.Spec.SignatureValidation.JWKS != nil && jwtIssuer.Spec.SignatureValidation.JWKS.TLS != nil && jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef != nil && len(jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef.Name) > 0 { - secrets = append(secrets, - types.NamespacedName{ - Name: string(jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef.Name), - Namespace: jwtIssuer.Namespace, - }.String()) - } - return secrets - }); err != nil { - return err - } - // Configmap to TokenIssuer indexer - err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.TokenIssuer{}, configmapIssuerIndex, - func(rawObj k8client.Object) []string { - tokenIssuer := rawObj.(*dpv1alpha1.TokenIssuer) - var configMaps []string - if tokenIssuer.Spec.SignatureValidation.Certificate != nil && tokenIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef != nil && len(tokenIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef.Name) > 0 { - configMaps = append(configMaps, - types.NamespacedName{ - Name: string(tokenIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef.Name), - Namespace: tokenIssuer.Namespace, - }.String()) - } - if tokenIssuer.Spec.SignatureValidation.JWKS != nil && tokenIssuer.Spec.SignatureValidation.JWKS.TLS != nil && tokenIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef != nil && len(tokenIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef.Name) > 0 { - configMaps = append(configMaps, - types.NamespacedName{ - Name: string(tokenIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef.Name), - Namespace: tokenIssuer.Namespace, - }.String()) - } - return configMaps - }) - return err -} - -// UpdateEnforcerJWTIssuers updates the JWT Issuers in the Enforcer -func UpdateEnforcerJWTIssuers(jwtIssuerMapping dpv1alpha1.JWTIssuerMapping) { - jwtIssuerList := marshalJWTIssuerList(jwtIssuerMapping) - xds.UpdateEnforcerJWTIssuers(jwtIssuerList) -} -func marshalJWTIssuerList(jwtIssuerMapping dpv1alpha1.JWTIssuerMapping) *subscription.JWTIssuerList { - jwtIssuers := []*subscription.JWTIssuer{} - for _, internalJWTIssuer := range jwtIssuerMapping { - certificate := &subscription.Certificate{} - jwtIssuer := &subscription.JWTIssuer{ - Name: internalJWTIssuer.Name, - Organization: internalJWTIssuer.Organization, - Issuer: internalJWTIssuer.Issuer, - ConsumerKeyClaim: internalJWTIssuer.ConsumerKeyClaim, - ScopesClaim: internalJWTIssuer.ScopesClaim, - } - if internalJWTIssuer.SignatureValidation.Certificate != nil && internalJWTIssuer.SignatureValidation.Certificate.ResolvedCertificate != "" { - certificate.Certificate = internalJWTIssuer.SignatureValidation.Certificate.ResolvedCertificate - } - if internalJWTIssuer.SignatureValidation.JWKS != nil { - jwks := &subscription.JWKS{} - jwks.Url = internalJWTIssuer.SignatureValidation.JWKS.URL - if internalJWTIssuer.SignatureValidation.JWKS.TLS != nil && internalJWTIssuer.SignatureValidation.JWKS.TLS.ResolvedCertificate != "" { - jwks.Tls = internalJWTIssuer.SignatureValidation.JWKS.TLS.ResolvedCertificate - } - certificate.Jwks = jwks - } - jwtIssuer.ClaimMapping = internalJWTIssuer.ClaimMappings - jwtIssuer.Certificate = certificate - jwtIssuer.Environments = internalJWTIssuer.Environments - jwtIssuers = append(jwtIssuers, jwtIssuer) - - } - jwtIssuersJSON, _ := json.Marshal(jwtIssuers) - loggers.LoggerAPKOperator.Debugf("JwtIssuer Data: %v", string(jwtIssuersJSON)) - return &subscription.JWTIssuerList{List: jwtIssuers} -} - -// getJWTIssuers returns the JWTIssuers for the given JWTIssuerMapping -func getJWTIssuers(ctx context.Context, client k8client.Client, namespace types.NamespacedName) (dpv1alpha1.JWTIssuerMapping, error) { - jwtIssuerMapping := make(dpv1alpha1.JWTIssuerMapping) - jwtIssuerList := &dpv1alpha2.TokenIssuerList{} - if err := client.List(ctx, jwtIssuerList); err != nil { - return nil, err - } - for _, jwtIssuer := range jwtIssuerList.Items { - resolvedJwtIssuer := dpv1alpha1.ResolvedJWTIssuer{} - resolvedJwtIssuer.Issuer = jwtIssuer.Spec.Issuer - resolvedJwtIssuer.ConsumerKeyClaim = jwtIssuer.Spec.ConsumerKeyClaim - resolvedJwtIssuer.ScopesClaim = jwtIssuer.Spec.ScopesClaim - resolvedJwtIssuer.Organization = jwtIssuer.Spec.Organization - resolvedJwtIssuer.Environments = getTokenIssuerEnvironments(jwtIssuer.Spec.Environments) - - signatureValidation := dpv1alpha1.ResolvedSignatureValidation{} - if jwtIssuer.Spec.SignatureValidation.JWKS != nil && len(jwtIssuer.Spec.SignatureValidation.JWKS.URL) > 0 { - jwks := &dpv1alpha1.ResolvedJWKS{} - jwks.URL = jwtIssuer.Spec.SignatureValidation.JWKS.URL - if jwtIssuer.Spec.SignatureValidation.JWKS.TLS != nil { - - var tlsConfigMapRef *dpv1alpha1.RefConfig - var tlsSecretRef *dpv1alpha1.RefConfig - if jwtIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef != nil { - tlsConfigMapRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef) - } - if jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef != nil { - tlsSecretRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef) - } - - tlsCertificate, err := utils.ResolveCertificate(ctx, client, jwtIssuer.ObjectMeta.Namespace, jwtIssuer.Spec.SignatureValidation.JWKS.TLS.CertificateInline, tlsConfigMapRef, tlsSecretRef) - if err != nil || tlsCertificate == "" { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2659, logging.MAJOR, "Error resolving certificate for JWKS %v", err.Error())) - continue - } - jwks.TLS = &dpv1alpha1.ResolvedTLSConfig{ResolvedCertificate: tlsCertificate} - } - signatureValidation.JWKS = jwks - } - if jwtIssuer.Spec.SignatureValidation.Certificate != nil { - - var tlsConfigMapRef *dpv1alpha1.RefConfig - var tlsSecretRef *dpv1alpha1.RefConfig - if jwtIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef != nil { - tlsConfigMapRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef) - } - if jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef != nil { - tlsSecretRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef) - } - - tlsCertificate, err := utils.ResolveCertificate(ctx, client, jwtIssuer.ObjectMeta.Namespace, jwtIssuer.Spec.SignatureValidation.Certificate.CertificateInline, tlsConfigMapRef, tlsSecretRef) - if err != nil || tlsCertificate == "" { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2659, logging.MAJOR, "Error resolving certificate for JWKS %v", err.Error())) - return nil, err - } - signatureValidation.Certificate = &dpv1alpha1.ResolvedTLSConfig{ResolvedCertificate: tlsCertificate} - } - resolvedJwtIssuer.SignatureValidation = signatureValidation - jwtIssuerMappingName := types.NamespacedName{ - Name: jwtIssuer.Name, - Namespace: jwtIssuer.Namespace, - } - if jwtIssuer.Spec.ClaimMappings != nil { - resolvedJwtIssuer.ClaimMappings = getResolvedClaimMapping(*jwtIssuer.Spec.ClaimMappings) - } else { - resolvedJwtIssuer.ClaimMappings = make(map[string]string) - } - jwtIssuerMapping[jwtIssuerMappingName] = &resolvedJwtIssuer - } - return jwtIssuerMapping, nil -} -func getResolvedClaimMapping(claimMappings []dpv1alpha2.ClaimMapping) map[string]string { - resolvedClaimMappings := make(map[string]string) - for _, claimMapping := range claimMappings { - resolvedClaimMappings[claimMapping.RemoteClaim] = claimMapping.LocalClaim - } - return resolvedClaimMappings -} - -func getTokenIssuerEnvironments(environments []string) []string { - - resolvedEnvironments := []string{} - if len(environments) == 0 { - resolvedEnvironments = append(resolvedEnvironments, defaultAllEnvironments) - } else { - resolvedEnvironments = environments - } - - return resolvedEnvironments -} diff --git a/adapter/internal/operator/operator.go b/adapter/internal/operator/operator.go index 4630190b4..a8efe7169 100644 --- a/adapter/internal/operator/operator.go +++ b/adapter/internal/operator/operator.go @@ -127,9 +127,6 @@ func InitOperator() { loggers.LoggerAPKOperator.Errorf("Error creating API controller: %v", err) } - if err := dpcontrollers.NewTokenIssuerReconciler(mgr); err != nil { - loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3114, logging.BLOCKER, "Error creating JWT Issuer controller: %v", err)) - } if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2602, logging.BLOCKER, "Unable to set up health check: %v", err)) } diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer.pb.go deleted file mode 100644 index 5b28d8c8d..000000000 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer.pb.go +++ /dev/null @@ -1,410 +0,0 @@ -// -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/jwtIssuer.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// JWTIssuer data model -type JWTIssuer struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - EventId string `protobuf:"bytes,1,opt,name=eventId,proto3" json:"eventId,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Organization string `protobuf:"bytes,3,opt,name=organization,proto3" json:"organization,omitempty"` - Issuer string `protobuf:"bytes,4,opt,name=issuer,proto3" json:"issuer,omitempty"` - Certificate *Certificate `protobuf:"bytes,5,opt,name=certificate,proto3" json:"certificate,omitempty"` - ConsumerKeyClaim string `protobuf:"bytes,6,opt,name=consumerKeyClaim,proto3" json:"consumerKeyClaim,omitempty"` - ScopesClaim string `protobuf:"bytes,7,opt,name=scopesClaim,proto3" json:"scopesClaim,omitempty"` - ClaimMapping map[string]string `protobuf:"bytes,8,rep,name=claimMapping,proto3" json:"claimMapping,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Environments []string `protobuf:"bytes,9,rep,name=environments,proto3" json:"environments,omitempty"` -} - -func (x *JWTIssuer) Reset() { - *x = JWTIssuer{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *JWTIssuer) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*JWTIssuer) ProtoMessage() {} - -func (x *JWTIssuer) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use JWTIssuer.ProtoReflect.Descriptor instead. -func (*JWTIssuer) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_jwtIssuer_proto_rawDescGZIP(), []int{0} -} - -func (x *JWTIssuer) GetEventId() string { - if x != nil { - return x.EventId - } - return "" -} - -func (x *JWTIssuer) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *JWTIssuer) GetOrganization() string { - if x != nil { - return x.Organization - } - return "" -} - -func (x *JWTIssuer) GetIssuer() string { - if x != nil { - return x.Issuer - } - return "" -} - -func (x *JWTIssuer) GetCertificate() *Certificate { - if x != nil { - return x.Certificate - } - return nil -} - -func (x *JWTIssuer) GetConsumerKeyClaim() string { - if x != nil { - return x.ConsumerKeyClaim - } - return "" -} - -func (x *JWTIssuer) GetScopesClaim() string { - if x != nil { - return x.ScopesClaim - } - return "" -} - -func (x *JWTIssuer) GetClaimMapping() map[string]string { - if x != nil { - return x.ClaimMapping - } - return nil -} - -func (x *JWTIssuer) GetEnvironments() []string { - if x != nil { - return x.Environments - } - return nil -} - -type Certificate struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Certificate string `protobuf:"bytes,1,opt,name=certificate,proto3" json:"certificate,omitempty"` - Jwks *JWKS `protobuf:"bytes,2,opt,name=jwks,proto3" json:"jwks,omitempty"` -} - -func (x *Certificate) Reset() { - *x = Certificate{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Certificate) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Certificate) ProtoMessage() {} - -func (x *Certificate) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Certificate.ProtoReflect.Descriptor instead. -func (*Certificate) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_jwtIssuer_proto_rawDescGZIP(), []int{1} -} - -func (x *Certificate) GetCertificate() string { - if x != nil { - return x.Certificate - } - return "" -} - -func (x *Certificate) GetJwks() *JWKS { - if x != nil { - return x.Jwks - } - return nil -} - -type JWKS struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` - Tls string `protobuf:"bytes,2,opt,name=tls,proto3" json:"tls,omitempty"` -} - -func (x *JWKS) Reset() { - *x = JWKS{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *JWKS) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*JWKS) ProtoMessage() {} - -func (x *JWKS) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use JWKS.ProtoReflect.Descriptor instead. -func (*JWKS) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_jwtIssuer_proto_rawDescGZIP(), []int{2} -} - -func (x *JWKS) GetUrl() string { - if x != nil { - return x.Url - } - return "" -} - -func (x *JWKS) GetTls() string { - if x != nil { - return x.Tls - } - return "" -} - -var File_wso2_discovery_subscription_jwtIssuer_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_jwtIssuer_proto_rawDesc = []byte{ - 0x0a, 0x2b, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x77, - 0x74, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x77, - 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xd2, 0x03, 0x0a, 0x09, 0x4a, - 0x57, 0x54, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, - 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, - 0x73, 0x75, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, - 0x65, 0x72, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x65, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2a, - 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x43, 0x6c, 0x61, - 0x69, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, - 0x65, 0x72, 0x4b, 0x65, 0x79, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x63, - 0x6f, 0x70, 0x65, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x5c, 0x0a, 0x0c, - 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x4a, 0x57, 0x54, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, - 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x63, 0x6c, - 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x6e, - 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x0c, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x1a, 0x3f, - 0x0a, 0x11, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x66, 0x0a, 0x0b, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x20, - 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, - 0x12, 0x35, 0x0a, 0x04, 0x6a, 0x77, 0x6b, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, - 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, - 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4a, 0x57, 0x4b, - 0x53, 0x52, 0x04, 0x6a, 0x77, 0x6b, 0x73, 0x22, 0x2a, 0x0a, 0x04, 0x4a, 0x57, 0x4b, 0x53, 0x12, - 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, - 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x74, 0x6c, 0x73, 0x42, 0x91, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, - 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0e, 0x4a, 0x57, 0x54, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, - 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, - 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x73, 0x75, 0x62, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_jwtIssuer_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_jwtIssuer_proto_rawDescData = file_wso2_discovery_subscription_jwtIssuer_proto_rawDesc -) - -func file_wso2_discovery_subscription_jwtIssuer_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_jwtIssuer_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_jwtIssuer_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_jwtIssuer_proto_rawDescData) - }) - return file_wso2_discovery_subscription_jwtIssuer_proto_rawDescData -} - -var file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_wso2_discovery_subscription_jwtIssuer_proto_goTypes = []interface{}{ - (*JWTIssuer)(nil), // 0: wso2.discovery.subscription.JWTIssuer - (*Certificate)(nil), // 1: wso2.discovery.subscription.Certificate - (*JWKS)(nil), // 2: wso2.discovery.subscription.JWKS - nil, // 3: wso2.discovery.subscription.JWTIssuer.ClaimMappingEntry -} -var file_wso2_discovery_subscription_jwtIssuer_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.subscription.JWTIssuer.certificate:type_name -> wso2.discovery.subscription.Certificate - 3, // 1: wso2.discovery.subscription.JWTIssuer.claimMapping:type_name -> wso2.discovery.subscription.JWTIssuer.ClaimMappingEntry - 2, // 2: wso2.discovery.subscription.Certificate.jwks:type_name -> wso2.discovery.subscription.JWKS - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_jwtIssuer_proto_init() } -func file_wso2_discovery_subscription_jwtIssuer_proto_init() { - if File_wso2_discovery_subscription_jwtIssuer_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JWTIssuer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Certificate); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JWKS); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_jwtIssuer_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_jwtIssuer_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_jwtIssuer_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_jwtIssuer_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_jwtIssuer_proto = out.File - file_wso2_discovery_subscription_jwtIssuer_proto_rawDesc = nil - file_wso2_discovery_subscription_jwtIssuer_proto_goTypes = nil - file_wso2_discovery_subscription_jwtIssuer_proto_depIdxs = nil -} diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer_list.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer_list.pb.go deleted file mode 100644 index 8a6381cfc..000000000 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/jwtIssuer_list.pb.go +++ /dev/null @@ -1,179 +0,0 @@ -// -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/jwtIssuer_list.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// JWTIssuerList data model -type JWTIssuerList struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - List []*JWTIssuer `protobuf:"bytes,2,rep,name=list,proto3" json:"list,omitempty"` -} - -func (x *JWTIssuerList) Reset() { - *x = JWTIssuerList{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_jwtIssuer_list_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *JWTIssuerList) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*JWTIssuerList) ProtoMessage() {} - -func (x *JWTIssuerList) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_jwtIssuer_list_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use JWTIssuerList.ProtoReflect.Descriptor instead. -func (*JWTIssuerList) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescGZIP(), []int{0} -} - -func (x *JWTIssuerList) GetList() []*JWTIssuer { - if x != nil { - return x.List - } - return nil -} - -var File_wso2_discovery_subscription_jwtIssuer_list_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDesc = []byte{ - 0x0a, 0x30, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x77, - 0x74, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x1b, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, - 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x1a, - 0x2b, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, - 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x77, 0x74, - 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4b, 0x0a, 0x0d, - 0x4a, 0x57, 0x54, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x3a, 0x0a, - 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x77, 0x73, - 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4a, 0x57, 0x54, 0x49, 0x73, 0x73, - 0x75, 0x65, 0x72, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x42, 0x95, 0x01, 0x0a, 0x2c, 0x6f, 0x72, - 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x12, 0x4a, 0x57, 0x54, 0x49, - 0x73, 0x73, 0x75, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, - 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescData = file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDesc -) - -func file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescData) - }) - return file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDescData -} - -var file_wso2_discovery_subscription_jwtIssuer_list_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_subscription_jwtIssuer_list_proto_goTypes = []interface{}{ - (*JWTIssuerList)(nil), // 0: wso2.discovery.subscription.JWTIssuerList - (*JWTIssuer)(nil), // 1: wso2.discovery.subscription.JWTIssuer -} -var file_wso2_discovery_subscription_jwtIssuer_list_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.subscription.JWTIssuerList.list:type_name -> wso2.discovery.subscription.JWTIssuer - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_jwtIssuer_list_proto_init() } -func file_wso2_discovery_subscription_jwtIssuer_list_proto_init() { - if File_wso2_discovery_subscription_jwtIssuer_list_proto != nil { - return - } - file_wso2_discovery_subscription_jwtIssuer_proto_init() - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_jwtIssuer_list_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JWTIssuerList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_jwtIssuer_list_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_jwtIssuer_list_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_jwtIssuer_list_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_jwtIssuer_list_proto = out.File - file_wso2_discovery_subscription_jwtIssuer_list_proto_rawDesc = nil - file_wso2_discovery_subscription_jwtIssuer_list_proto_goTypes = nil - file_wso2_discovery_subscription_jwtIssuer_list_proto_depIdxs = nil -} diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/url_mapping.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/url_mapping.pb.go deleted file mode 100644 index 8de98b068..000000000 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/url_mapping.pb.go +++ /dev/null @@ -1,184 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/url_mapping.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// URLMapping data model -type URLMapping struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - AuthScheme string `protobuf:"bytes,1,opt,name=authScheme,proto3" json:"authScheme,omitempty"` - HttpMethod string `protobuf:"bytes,2,opt,name=httpMethod,proto3" json:"httpMethod,omitempty"` - UrlPattern string `protobuf:"bytes,3,opt,name=urlPattern,proto3" json:"urlPattern,omitempty"` - Scopes []string `protobuf:"bytes,4,rep,name=scopes,proto3" json:"scopes,omitempty"` -} - -func (x *URLMapping) Reset() { - *x = URLMapping{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_url_mapping_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *URLMapping) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*URLMapping) ProtoMessage() {} - -func (x *URLMapping) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_url_mapping_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use URLMapping.ProtoReflect.Descriptor instead. -func (*URLMapping) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_url_mapping_proto_rawDescGZIP(), []int{0} -} - -func (x *URLMapping) GetAuthScheme() string { - if x != nil { - return x.AuthScheme - } - return "" -} - -func (x *URLMapping) GetHttpMethod() string { - if x != nil { - return x.HttpMethod - } - return "" -} - -func (x *URLMapping) GetUrlPattern() string { - if x != nil { - return x.UrlPattern - } - return "" -} - -func (x *URLMapping) GetScopes() []string { - if x != nil { - return x.Scopes - } - return nil -} - -var File_wso2_discovery_subscription_url_mapping_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_url_mapping_proto_rawDesc = []byte{ - 0x0a, 0x2d, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x75, 0x72, - 0x6c, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x1b, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, - 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x84, 0x01, 0x0a, - 0x0a, 0x55, 0x52, 0x4c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x61, - 0x75, 0x74, 0x68, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x61, 0x75, 0x74, 0x68, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x68, - 0x74, 0x74, 0x70, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x68, 0x74, 0x74, 0x70, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x75, - 0x72, 0x6c, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x75, 0x72, 0x6c, 0x50, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x6f, - 0x70, 0x65, 0x73, 0x42, 0x92, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, - 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0f, 0x55, 0x52, 0x4c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, - 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, - 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, - 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_url_mapping_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_url_mapping_proto_rawDescData = file_wso2_discovery_subscription_url_mapping_proto_rawDesc -) - -func file_wso2_discovery_subscription_url_mapping_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_url_mapping_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_url_mapping_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_url_mapping_proto_rawDescData) - }) - return file_wso2_discovery_subscription_url_mapping_proto_rawDescData -} - -var file_wso2_discovery_subscription_url_mapping_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_subscription_url_mapping_proto_goTypes = []interface{}{ - (*URLMapping)(nil), // 0: wso2.discovery.subscription.URLMapping -} -var file_wso2_discovery_subscription_url_mapping_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_url_mapping_proto_init() } -func file_wso2_discovery_subscription_url_mapping_proto_init() { - if File_wso2_discovery_subscription_url_mapping_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_url_mapping_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*URLMapping); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_url_mapping_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_url_mapping_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_url_mapping_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_url_mapping_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_url_mapping_proto = out.File - file_wso2_discovery_subscription_url_mapping_proto_rawDesc = nil - file_wso2_discovery_subscription_url_mapping_proto_goTypes = nil - file_wso2_discovery_subscription_url_mapping_proto_depIdxs = nil -} diff --git a/adapter/pkg/discovery/protocol/cache/v3/resource.go b/adapter/pkg/discovery/protocol/cache/v3/resource.go index e74624120..543b620b0 100644 --- a/adapter/pkg/discovery/protocol/cache/v3/resource.go +++ b/adapter/pkg/discovery/protocol/cache/v3/resource.go @@ -20,7 +20,6 @@ import ( envoy_types "github.com/envoyproxy/go-control-plane/pkg/cache/types" "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/api" "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/config/enforcer" - "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription" "github.com/wso2/apk/adapter/pkg/discovery/protocol/cache/types" "github.com/wso2/apk/adapter/pkg/discovery/protocol/resource/v3" ) @@ -76,10 +75,6 @@ func GetResourceName(res envoy_types.Resource) string { return fmt.Sprint(v.Vhost, v.BasePath, v.Version) case *enforcer.Config: return "Config" - case *subscription.JWTIssuerList: - return "JWTIssuer" - case *subscription.JWTIssuer: - return fmt.Sprint(v.Name) default: return "" } diff --git a/common-controller/go.mod b/common-controller/go.mod index 3841e339f..197e57f82 100644 --- a/common-controller/go.mod +++ b/common-controller/go.mod @@ -104,12 +104,12 @@ require ( google.golang.org/genproto v0.0.0-20230731193218-e0aa005b6bdf // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect - google.golang.org/protobuf v1.31.0 + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.27.2 // indirect + k8s.io/api v0.27.2 k8s.io/apiextensions-apiserver v0.27.2 // indirect k8s.io/component-base v0.27.2 // indirect k8s.io/klog/v2 v2.100.1 // indirect diff --git a/common-controller/internal/cache/subscriptionDataStore.go b/common-controller/internal/cache/subscriptionDataStore.go index 85d5cecd1..358a5a2bf 100644 --- a/common-controller/internal/cache/subscriptionDataStore.go +++ b/common-controller/internal/cache/subscriptionDataStore.go @@ -22,6 +22,7 @@ import ( logger "github.com/sirupsen/logrus" cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" + dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" "k8s.io/apimachinery/pkg/types" ) @@ -30,6 +31,7 @@ type SubscriptionDataStore struct { applicationStore map[types.NamespacedName]*cpv1alpha2.ApplicationSpec subscriptionStore map[types.NamespacedName]*cpv1alpha2.SubscriptionSpec applicationMappingStore map[types.NamespacedName]*cpv1alpha2.ApplicationMappingSpec + tokenIssuerStore map[types.NamespacedName]*dpv1alpha2.TokenIssuerSpec mu sync.Mutex } @@ -39,6 +41,7 @@ func CreateNewSubscriptionDataStore() *SubscriptionDataStore { applicationStore: map[types.NamespacedName]*cpv1alpha2.ApplicationSpec{}, subscriptionStore: map[types.NamespacedName]*cpv1alpha2.SubscriptionSpec{}, applicationMappingStore: map[types.NamespacedName]*cpv1alpha2.ApplicationMappingSpec{}, + tokenIssuerStore: map[types.NamespacedName]*dpv1alpha2.TokenIssuerSpec{}, } } @@ -50,6 +53,14 @@ func (ods *SubscriptionDataStore) AddorUpdateApplicationToStore(name types.Names ods.applicationStore[name] = &application } +// AddorUpdateTokenIssuerToStore adds a new tokenIssuer to the DataStore. +func (ods *SubscriptionDataStore) AddorUpdateTokenIssuerToStore(name types.NamespacedName, tokenIssuer dpv1alpha2.TokenIssuerSpec) { + ods.mu.Lock() + defer ods.mu.Unlock() + logger.Debug("Adding/Updating tokenIssuer to cache") + ods.tokenIssuerStore[name] = &tokenIssuer +} + // AddorUpdateSubscriptionToStore adds a new subscription to the DataStore. func (ods *SubscriptionDataStore) AddorUpdateSubscriptionToStore(name types.NamespacedName, subscription cpv1alpha2.SubscriptionSpec) { ods.mu.Lock() @@ -76,6 +87,16 @@ func (ods *SubscriptionDataStore) GetApplicationFromStore(name types.NamespacedN return application, false } +// GetTokenIssuerFromStore get cached tokenIssuer +func (ods *SubscriptionDataStore) GetTokenIssuerFromStore(name types.NamespacedName) (dpv1alpha2.TokenIssuerSpec, bool) { + var tokenIssuerSpec dpv1alpha2.TokenIssuerSpec + if cachedTokenIssuer, found := ods.tokenIssuerStore[name]; found { + logger.Debug("Found cached TokenIssuer") + return *cachedTokenIssuer, true + } + return tokenIssuerSpec, false +} + // GetSubscriptionFromStore get cached subscription func (ods *SubscriptionDataStore) GetSubscriptionFromStore(name types.NamespacedName) (cpv1alpha2.SubscriptionSpec, bool) { var subscription cpv1alpha2.SubscriptionSpec @@ -104,6 +125,14 @@ func (ods *SubscriptionDataStore) DeleteApplicationFromStore(name types.Namespac delete(ods.applicationStore, name) } +// DeleteTokenIssuerFromStore delete from tokenIssuer cache +func (ods *SubscriptionDataStore) DeleteTokenIssuerFromStore(name types.NamespacedName) { + ods.mu.Lock() + defer ods.mu.Unlock() + logger.Info("Deleting tokenIssuer from cache") + delete(ods.tokenIssuerStore, name) +} + // DeleteSubscriptionFromStore delete from subscription cache func (ods *SubscriptionDataStore) DeleteSubscriptionFromStore(name types.NamespacedName) { ods.mu.Lock() diff --git a/common-controller/internal/operator/constant/constant.go b/common-controller/internal/operator/constant/constant.go index db35de637..27c3c1445 100644 --- a/common-controller/internal/operator/constant/constant.go +++ b/common-controller/internal/operator/constant/constant.go @@ -23,6 +23,7 @@ const ( ApplicationController string = "ApplicationController" SubscriptionController string = "SubscriptionController" ApplicationMappingController string = "ApplicationMappingController" + TokenIssuerReconSiler string = "TokenIssuerReconSiler" ) // API events related constants @@ -46,6 +47,9 @@ const ( ApplicationKeyMappingCreated string = "APPLICATION_KEY_MAPPING_CREATED" ApplicationKeyMappingUpdated string = "APPLICATION_KEY_MAPPING_UPDATED" ApplicationKeyMappingDeleted string = "APPLICATION_KEY_MAPPING_DELETED" + TokenIssuerCreated string = "TOKEN_ISSUER_CREATED" + TokenIssuerDeleted string = "TOKEN_ISSUER_DELETED" + TokenIssuerUpdated string = "TOKEN_ISSUER_UPDATED" AllEvnts string = "ALL_EVENTS" ) diff --git a/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go index c2b97b682..d0f2a650e 100644 --- a/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go +++ b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go @@ -26,7 +26,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/log" @@ -51,7 +50,7 @@ import ( // RateLimitPolicyReconciler reconciles a RateLimitPolicy object type RateLimitPolicyReconciler struct { - client client.Client + client k8client.Client ods *cache.RatelimitDataStore Scheme *runtime.Scheme } @@ -414,7 +413,7 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { } // NamespacedName generates namespaced name for Kubernetes objects -func NamespacedName(obj client.Object) types.NamespacedName { +func NamespacedName(obj k8client.Object) types.NamespacedName { return types.NamespacedName{ Namespace: obj.GetNamespace(), Name: obj.GetName(), diff --git a/common-controller/internal/operator/controllers/dp/tokenissuer_controller.go b/common-controller/internal/operator/controllers/dp/tokenissuer_controller.go new file mode 100644 index 000000000..da200a32e --- /dev/null +++ b/common-controller/internal/operator/controllers/dp/tokenissuer_controller.go @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * 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" , + * 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 dp + +import ( + "context" + + "github.com/wso2/apk/adapter/pkg/logging" + cache "github.com/wso2/apk/common-controller/internal/cache" + "github.com/wso2/apk/common-controller/internal/config" + loggers "github.com/wso2/apk/common-controller/internal/loggers" + constants "github.com/wso2/apk/common-controller/internal/operator/constant" + "github.com/wso2/apk/common-controller/internal/server" + "github.com/wso2/apk/common-controller/internal/utils" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" + k8error "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + ctrl "sigs.k8s.io/controller-runtime" + k8client "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/source" +) + +const ( + tokenIssuerIndex = "tokenIssuerIndex" + secretTokenIssuerIndex = "secretTokenIssuerIndex" + configmapIssuerIndex = "configmapIssuerIndex" + defaultAllEnvironments = "*" +) + +// TokenssuerReconciler reconciles a TokenIssuer object +type TokenssuerReconciler struct { + client k8client.Client + Scheme *runtime.Scheme + ods *cache.SubscriptionDataStore +} + +//+kubebuilder:rbac:groups=dp.wso2.com,resources=jwtissuers,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=dp.wso2.com,resources=jwtissuers/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=dp.wso2.com,resources=jwtissuers/finalizers,verbs=update + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// TODO(user): Modify the Reconcile function to compare the state specified by +// the JWTIssuer object against the actual cluster state, and then +// perform operations to make the cluster state reflect the state specified by +// the user. +// +// For more details, check Reconcile and its Result here: +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile +func (r *TokenssuerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + + _ = log.FromContext(ctx) + tokenIssuerKey := req.NamespacedName + + loggers.LoggerAPKOperator.Debugf("Reconciling tokenIssuer: %v", tokenIssuerKey.String()) + var tokenIssuer dpv1alpha2.TokenIssuer + if err := r.client.Get(ctx, req.NamespacedName, &tokenIssuer); err != nil { + if k8error.IsNotFound(err) { + tokenIssuerSpec, found := r.ods.GetTokenIssuerFromStore(tokenIssuerKey) + loggers.LoggerAPKOperator.Debugf("TokenIssuer cr not available in k8s") + loggers.LoggerAPKOperator.Debugf("cached TokenIssuer spec: %v,%v", tokenIssuerSpec, found) + if found { + resolvedTokenIssuer, err := getResolvedTokenIssuer(ctx, r.client, tokenIssuerKey.Namespace, tokenIssuerSpec) + if err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2661, logging.CRITICAL, "Error resolving tokenIssuer: %v", err.Error())) + return ctrl.Result{}, err + } + utils.SendDeleteTokenIssuerEvent(*resolvedTokenIssuer) + r.ods.DeleteTokenIssuerFromStore(tokenIssuerKey) + server.DeleteTokenIssuer(tokenIssuerKey.String()) + } else { + loggers.LoggerAPKOperator.Debugf("TokenIssuer %s/%s does not exist in k8s", tokenIssuerKey.Namespace, tokenIssuerKey.Name) + } + } + } else { + loggers.LoggerAPKOperator.Debugf("TokenIssuer cr available in k8s") + oldTokenIssuerSpec, found := r.ods.GetTokenIssuerFromStore(tokenIssuerKey) + resolvedTokenIssuer, err := getResolvedTokenIssuer(ctx, r.client, tokenIssuerKey.Namespace, tokenIssuer.Spec) + if err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2661, logging.BLOCKER, "Error resolving tokenIssuer: %v", err.Error())) + return ctrl.Result{}, nil + } + if found { + resolvedOldTokenIssuer, err := getResolvedTokenIssuer(ctx, r.client, tokenIssuerKey.Namespace, oldTokenIssuerSpec) + if err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2661, logging.BLOCKER, "Error resolving tokenIssuer: %v", err.Error())) + return ctrl.Result{}, nil + } + // update + loggers.LoggerAPKOperator.Debugf("TokenIssuer in ods") + utils.SendUpdateTokenIssuerEvent(*resolvedOldTokenIssuer, *resolvedTokenIssuer) + } else { + loggers.LoggerAPKOperator.Debugf("TokenIssuer in ods consider as update") + utils.SendAddTokenIssuerEvent(*resolvedTokenIssuer) + } + r.ods.AddorUpdateTokenIssuerToStore(tokenIssuerKey, tokenIssuer.Spec) + r.sendTokenIssuerUpdates(tokenIssuerKey, *resolvedTokenIssuer, found) + } + return ctrl.Result{}, nil + +} +func (r *TokenssuerReconciler) sendTokenIssuerUpdates(tokenIssuerKey types.NamespacedName, tokenIssuer dpv1alpha1.ResolvedJWTIssuer, update bool) { + resolvedTokenIssuer := marshalTokenIssuer(tokenIssuer) + if update { + server.DeleteTokenIssuer(tokenIssuerKey.String()) + } + server.AddTokenIssuer(tokenIssuerKey.String(), resolvedTokenIssuer) +} + +func marshalTokenIssuer(tokenIssuer dpv1alpha1.ResolvedJWTIssuer) server.TokenIssuer { + resolvedTokenIssuer := server.TokenIssuer{ + Name: tokenIssuer.Name, + Issuer: tokenIssuer.Issuer, + Organization: tokenIssuer.Organization, + ConsumerKeyClaim: tokenIssuer.ConsumerKeyClaim, + ScopesClaim: tokenIssuer.ScopesClaim, + ClaimMappings: tokenIssuer.ClaimMappings, + Environments: tokenIssuer.Environments, + } + signatureValidation := server.ResolvedSignatureValidation{} + if tokenIssuer.SignatureValidation.JWKS != nil { + signatureValidation.JWKS = &server.ResolvedJWKS{} + if len(tokenIssuer.SignatureValidation.JWKS.URL) > 0 { + signatureValidation.JWKS.URL = tokenIssuer.SignatureValidation.JWKS.URL + } + if tokenIssuer.SignatureValidation.JWKS.TLS != nil { + signatureValidation.JWKS.TLS = &server.ResolvedTLSConfig{ResolvedCertificate: tokenIssuer.SignatureValidation.JWKS.TLS.ResolvedCertificate} + } + } else if tokenIssuer.SignatureValidation.Certificate != nil { + signatureValidation.Certificate = &server.ResolvedTLSConfig{ResolvedCertificate: tokenIssuer.SignatureValidation.Certificate.ResolvedCertificate} + } + resolvedTokenIssuer.SignatureValidation = signatureValidation + return resolvedTokenIssuer +} + +// NewTokenIssuerReconciler creates a new Application controller instance. +func NewTokenIssuerReconciler(mgr manager.Manager, subscriptionStore *cache.SubscriptionDataStore) error { + r := &TokenssuerReconciler{ + client: mgr.GetClient(), + ods: subscriptionStore, + } + ctx := context.Background() + conf := config.ReadConfigs() + predicates := []predicate.Predicate{predicate.NewPredicateFuncs(utils.FilterByNamespaces(conf.CommonController.Operator.Namespaces))} + + if err := addTokenIssuerIndexes(ctx, mgr); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2658, logging.CRITICAL, "Error adding indexes: %v", err)) + return err + } + c, err := controller.New(constants.TokenIssuerReconSiler, mgr, controller.Options{Reconciler: r}) + if err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2657, logging.BLOCKER, "Error creating TokenIssuer controller: %v", err.Error())) + return err + } + + if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha1.TokenIssuer{}), &handler.EnqueueRequestForObject{}, predicates...); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2656, logging.BLOCKER, "Error watching TokenIssuer resources: %v", err.Error())) + return err + } + + loggers.LoggerAPKOperator.Debug("TokenIssuer Controller successfully started. Watching TokenIssuer Objects...") + return nil +} + +// addTokenIssuerIndexes adds indexers related to Gateways +func addTokenIssuerIndexes(ctx context.Context, mgr manager.Manager) error { + + // Secret to TokenIssuer indexer + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.TokenIssuer{}, secretTokenIssuerIndex, + func(rawObj k8client.Object) []string { + jwtIssuer := rawObj.(*dpv1alpha1.TokenIssuer) + var secrets []string + if jwtIssuer.Spec.SignatureValidation.Certificate != nil && jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef != nil && len(jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef.Name) > 0 { + secrets = append(secrets, + types.NamespacedName{ + Name: string(jwtIssuer.Spec.SignatureValidation.Certificate.SecretRef.Name), + Namespace: jwtIssuer.Namespace, + }.String()) + } + if jwtIssuer.Spec.SignatureValidation.JWKS != nil && jwtIssuer.Spec.SignatureValidation.JWKS.TLS != nil && jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef != nil && len(jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef.Name) > 0 { + secrets = append(secrets, + types.NamespacedName{ + Name: string(jwtIssuer.Spec.SignatureValidation.JWKS.TLS.SecretRef.Name), + Namespace: jwtIssuer.Namespace, + }.String()) + } + return secrets + }); err != nil { + return err + } + // Configmap to TokenIssuer indexer + err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.TokenIssuer{}, configmapIssuerIndex, + func(rawObj k8client.Object) []string { + tokenIssuer := rawObj.(*dpv1alpha1.TokenIssuer) + var configMaps []string + if tokenIssuer.Spec.SignatureValidation.Certificate != nil && tokenIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef != nil && len(tokenIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef.Name) > 0 { + configMaps = append(configMaps, + types.NamespacedName{ + Name: string(tokenIssuer.Spec.SignatureValidation.Certificate.ConfigMapRef.Name), + Namespace: tokenIssuer.Namespace, + }.String()) + } + if tokenIssuer.Spec.SignatureValidation.JWKS != nil && tokenIssuer.Spec.SignatureValidation.JWKS.TLS != nil && tokenIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef != nil && len(tokenIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef.Name) > 0 { + configMaps = append(configMaps, + types.NamespacedName{ + Name: string(tokenIssuer.Spec.SignatureValidation.JWKS.TLS.ConfigMapRef.Name), + Namespace: tokenIssuer.Namespace, + }.String()) + } + return configMaps + }) + return err +} + +// getResolvedTokenIssuer returns the resolved tokenIssuer +func getResolvedTokenIssuer(ctx context.Context, client k8client.Client, namespace string, jwtIssuer dpv1alpha2.TokenIssuerSpec) (*dpv1alpha1.ResolvedJWTIssuer, error) { + resolvedJwtIssuer := dpv1alpha1.ResolvedJWTIssuer{} + resolvedJwtIssuer.Issuer = jwtIssuer.Issuer + resolvedJwtIssuer.ConsumerKeyClaim = jwtIssuer.ConsumerKeyClaim + resolvedJwtIssuer.ScopesClaim = jwtIssuer.ScopesClaim + resolvedJwtIssuer.Organization = jwtIssuer.Organization + resolvedJwtIssuer.Environments = getTokenIssuerEnvironments(jwtIssuer.Environments) + + signatureValidation := dpv1alpha1.ResolvedSignatureValidation{} + if jwtIssuer.SignatureValidation.JWKS != nil && len(jwtIssuer.SignatureValidation.JWKS.URL) > 0 { + jwks := &dpv1alpha1.ResolvedJWKS{} + jwks.URL = jwtIssuer.SignatureValidation.JWKS.URL + if jwtIssuer.SignatureValidation.JWKS.TLS != nil { + + var tlsConfigMapRef *dpv1alpha1.RefConfig + var tlsSecretRef *dpv1alpha1.RefConfig + if jwtIssuer.SignatureValidation.JWKS.TLS.ConfigMapRef != nil { + tlsConfigMapRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.SignatureValidation.JWKS.TLS.ConfigMapRef) + } + if jwtIssuer.SignatureValidation.JWKS.TLS.SecretRef != nil { + tlsSecretRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.SignatureValidation.JWKS.TLS.SecretRef) + } + + tlsCertificate, err := utils.ResolveCertificate(ctx, client, namespace, jwtIssuer.SignatureValidation.JWKS.TLS.CertificateInline, tlsConfigMapRef, tlsSecretRef) + if err != nil || tlsCertificate == "" { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2659, logging.MAJOR, "Error resolving certificate for JWKS %v", err.Error())) + return nil, err + } + jwks.TLS = &dpv1alpha1.ResolvedTLSConfig{ResolvedCertificate: tlsCertificate} + } + signatureValidation.JWKS = jwks + } + if jwtIssuer.SignatureValidation.Certificate != nil { + + var tlsConfigMapRef *dpv1alpha1.RefConfig + var tlsSecretRef *dpv1alpha1.RefConfig + if jwtIssuer.SignatureValidation.Certificate.ConfigMapRef != nil { + tlsConfigMapRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.SignatureValidation.Certificate.ConfigMapRef) + } + if jwtIssuer.SignatureValidation.Certificate.SecretRef != nil { + tlsSecretRef = utils.ConvertRefConfigsV2ToV1(jwtIssuer.SignatureValidation.Certificate.SecretRef) + } + + tlsCertificate, err := utils.ResolveCertificate(ctx, client, namespace, jwtIssuer.SignatureValidation.Certificate.CertificateInline, tlsConfigMapRef, tlsSecretRef) + if err != nil || tlsCertificate == "" { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2659, logging.MAJOR, "Error resolving certificate for JWKS %v", err.Error())) + return nil, err + } + signatureValidation.Certificate = &dpv1alpha1.ResolvedTLSConfig{ResolvedCertificate: tlsCertificate} + } + resolvedJwtIssuer.SignatureValidation = signatureValidation + if jwtIssuer.ClaimMappings != nil { + resolvedJwtIssuer.ClaimMappings = getResolvedClaimMapping(*jwtIssuer.ClaimMappings) + } else { + resolvedJwtIssuer.ClaimMappings = make(map[string]string) + } + return &resolvedJwtIssuer, nil +} +func getResolvedClaimMapping(claimMappings []dpv1alpha2.ClaimMapping) map[string]string { + resolvedClaimMappings := make(map[string]string) + for _, claimMapping := range claimMappings { + resolvedClaimMappings[claimMapping.RemoteClaim] = claimMapping.LocalClaim + } + return resolvedClaimMappings +} + +func getTokenIssuerEnvironments(environments []string) []string { + + resolvedEnvironments := []string{} + if len(environments) == 0 { + resolvedEnvironments = append(resolvedEnvironments, defaultAllEnvironments) + } else { + resolvedEnvironments = environments + } + + return resolvedEnvironments +} diff --git a/common-controller/internal/operator/operator.go b/common-controller/internal/operator/operator.go index 73a252074..28e7d40f2 100644 --- a/common-controller/internal/operator/operator.go +++ b/common-controller/internal/operator/operator.go @@ -151,6 +151,9 @@ func InitOperator() { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3117, logging.MAJOR, "Error creating Application Mapping controller, error: %v", err)) } + if err := dpcontrollers.NewTokenIssuerReconciler(mgr, subscriptionStore); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3114, logging.BLOCKER, "Error creating JWT Issuer controller: %v", err)) + } //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { diff --git a/common-controller/internal/server/server.go b/common-controller/internal/server/server.go index 659e2ec6c..eab7e5d86 100644 --- a/common-controller/internal/server/server.go +++ b/common-controller/internal/server/server.go @@ -13,6 +13,7 @@ var applicationMap = make(map[string]Application) var subscriptionMap = make(map[string]Subscription) var applicationMappingMap = make(map[string]ApplicationMapping) var applicationKeyMappingMap = make(map[string]ApplicationKeyMapping) +var tokenIssuerMap = make(map[string]TokenIssuer) // StartInternalServer starts the internal server func StartInternalServer() { @@ -46,6 +47,13 @@ func StartInternalServer() { } c.JSON(http.StatusOK, ApplicationKeyMappingList{List: applicationKeyMappingList}) }) + r.GET("/tokenissuers", func(c *gin.Context) { + tokenIssuerList := []TokenIssuer{} + for _, tokenIssuer := range tokenIssuerMap { + tokenIssuerList = append(tokenIssuerList, tokenIssuer) + } + c.JSON(http.StatusOK, TokenIssuserList{List: tokenIssuerList}) + }) gin.SetMode(gin.ReleaseMode) conf := config.ReadConfigs() certPath := conf.CommonController.Keystore.CertPath @@ -85,6 +93,16 @@ func DeleteApplication(applicationUUID string) { } } +// DeleteTokenIssuer deletes a token issuer from the token issuer list +func DeleteTokenIssuer(tokenIssuerUUID string) { + delete(tokenIssuerMap, tokenIssuerUUID) +} + +// AddTokenIssuer adds a token issuer to the token issuer list +func AddTokenIssuer(tokenIssuerUUID string, tokenIssuer TokenIssuer) { + tokenIssuerMap[tokenIssuerUUID] = tokenIssuer +} + // DeleteSubscription deletes a subscription from the subscription list func DeleteSubscription(subscriptionUUID string) { delete(subscriptionMap, subscriptionUUID) diff --git a/common-controller/internal/server/token_issuer_types.go b/common-controller/internal/server/token_issuer_types.go new file mode 100644 index 000000000..5164a1575 --- /dev/null +++ b/common-controller/internal/server/token_issuer_types.go @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * 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 server + +// TokenIssuer holds the properties of TokenIssuer +type TokenIssuer struct { + Name string `json:"name"` + Organization string `json:"organization"` + Issuer string `json:"issuer"` + ConsumerKeyClaim string `json:"consumerKeyClaim"` + ScopesClaim string `json:"scopesClaim"` + SignatureValidation ResolvedSignatureValidation `json:"signatureValidation"` + ClaimMappings map[string]string `json:"claimMappings"` + Environments []string `json:"environments"` +} + +// ResolvedSignatureValidation holds the resolved properties of SignatureValidation +type ResolvedSignatureValidation struct { + JWKS *ResolvedJWKS `json:"jwks"` + Certificate *ResolvedTLSConfig `json:"certificate"` +} + +// ResolvedJWKS holds the resolved properties of JWKS +type ResolvedJWKS struct { + URL string `json:"url"` + TLS *ResolvedTLSConfig `json:"tls"` +} + +// ResolvedTLSConfig defines enpoint TLS configurations +type ResolvedTLSConfig struct { + ResolvedCertificate string `json:"resolvedCertificate"` + AllowedSANs []string `json:"allowedSANs"` +} + +// TokenIssuserList contains a list of TokenIssuser +type TokenIssuserList struct { + List []TokenIssuer `json:"list"` +} diff --git a/common-controller/internal/utils/event_utils.go b/common-controller/internal/utils/event_utils.go index de350566d..593e22bba 100644 --- a/common-controller/internal/utils/event_utils.go +++ b/common-controller/internal/utils/event_utils.go @@ -7,10 +7,75 @@ import ( "github.com/wso2/apk/common-controller/internal/loggers" constants "github.com/wso2/apk/common-controller/internal/operator/constant" cpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/cp/v1alpha2" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" apkmgt "github.com/wso2/apk/common-go-libs/pkg/discovery/api/wso2/discovery/service/apkmgt" "github.com/wso2/apk/common-go-libs/pkg/discovery/api/wso2/discovery/subscription" ) +// SendDeleteTokenIssuerEvent sends a token issuer event to the enforcer +func SendDeleteTokenIssuerEvent(resolvedTokenIssuer dpv1alpha1.ResolvedJWTIssuer) { + currentTime := time.Now() + milliseconds := currentTime.UnixNano() / int64(time.Millisecond) + event := subscription.Event{ + Uuid: uuid.New().String(), + Type: constants.TokenIssuerDeleted, + TimeStamp: milliseconds, + TokenIssuer: &subscription.TokenIssuer{ + Name: resolvedTokenIssuer.Name, + Organization: resolvedTokenIssuer.Organization, + Issuer: resolvedTokenIssuer.Issuer, + ConsumerKeyClaim: resolvedTokenIssuer.ConsumerKeyClaim, + ScopesClaim: resolvedTokenIssuer.ScopesClaim, + Environments: resolvedTokenIssuer.Environments, + ClaimMapping: resolvedTokenIssuer.ClaimMappings, + Certificate: convertToCertificate(resolvedTokenIssuer.SignatureValidation), + }, + } + sendEvent(&event) +} + +// convertToCertificate converts the certificate to a string +func convertToCertificate(certificate dpv1alpha1.ResolvedSignatureValidation) *subscription.Certificate { + if certificate.Certificate != nil { + return &subscription.Certificate{ + Certificate: certificate.Certificate.ResolvedCertificate, + } + } + jwks := subscription.JWKS{Url: certificate.JWKS.URL} + if certificate.JWKS.TLS != nil { + jwks.Tls = certificate.JWKS.TLS.ResolvedCertificate + } + return &subscription.Certificate{Jwks: &jwks} +} + +// SendAddTokenIssuerEvent sends a token issuer event to the enforcer +func SendAddTokenIssuerEvent(resolvedTokenIssuer dpv1alpha1.ResolvedJWTIssuer) { + currentTime := time.Now() + milliseconds := currentTime.UnixNano() / int64(time.Millisecond) + event := subscription.Event{ + Uuid: uuid.New().String(), + Type: constants.TokenIssuerCreated, + TimeStamp: milliseconds, + TokenIssuer: &subscription.TokenIssuer{ + Name: resolvedTokenIssuer.Name, + Organization: resolvedTokenIssuer.Organization, + Issuer: resolvedTokenIssuer.Issuer, + ConsumerKeyClaim: resolvedTokenIssuer.ConsumerKeyClaim, + ScopesClaim: resolvedTokenIssuer.ScopesClaim, + Environments: resolvedTokenIssuer.Environments, + ClaimMapping: resolvedTokenIssuer.ClaimMappings, + Certificate: convertToCertificate(resolvedTokenIssuer.SignatureValidation), + }, + } + sendEvent(&event) +} + +// SendUpdateTokenIssuerEvent sends a token issuer event to the enforcer +func SendUpdateTokenIssuerEvent(oldTokenIssuer dpv1alpha1.ResolvedJWTIssuer, resolvedTokenIssuer dpv1alpha1.ResolvedJWTIssuer) { + SendDeleteTokenIssuerEvent(oldTokenIssuer) + SendAddTokenIssuerEvent(resolvedTokenIssuer) +} + // SendAppDeletionEvent sends an application creation event to the enforcer func SendAppDeletionEvent(applicationUUID string, applicationSpec cpv1alpha2.ApplicationSpec) { currentTime := time.Now() diff --git a/common-controller/internal/utils/utils.go b/common-controller/internal/utils/utils.go index 6c99df509..63cb99aad 100644 --- a/common-controller/internal/utils/utils.go +++ b/common-controller/internal/utils/utils.go @@ -19,13 +19,21 @@ package utils import ( + "context" + "crypto/x509" + "encoding/pem" "sync" discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" + "github.com/wso2/apk/adapter/pkg/logging" "github.com/wso2/apk/adapter/pkg/utils/envutils" "github.com/wso2/apk/adapter/pkg/utils/stringutils" "github.com/wso2/apk/common-controller/internal/config" + "github.com/wso2/apk/common-controller/internal/loggers" constants "github.com/wso2/apk/common-controller/internal/operator/constant" + dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha2" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" k8client "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -134,3 +142,74 @@ func NamespacedName(obj k8client.Object) types.NamespacedName { Name: obj.GetName(), } } + +// ConvertRefConfigsV2ToV1 converts RefConfig v2 to v1 +func ConvertRefConfigsV2ToV1(refConfig *dpv1alpha2.RefConfig) *dpv1alpha1.RefConfig { + + return &dpv1alpha1.RefConfig{ + Name: refConfig.Name, + Key: refConfig.Key, + } +} + +// ResolveCertificate reads the certificate from TLSConfig, first checks the certificateInline field, +// if no value then load the certificate from secretRef using util function called getSecretValue +func ResolveCertificate(ctx context.Context, client k8client.Client, namespace string, certificateInline *string, configMapRef *dpv1alpha1.RefConfig, secretRef *dpv1alpha1.RefConfig) (string, error) { + var certificate string + var err error + if certificateInline != nil && len(*certificateInline) > 0 { + certificate = *certificateInline + } else if secretRef != nil { + if certificate, err = getSecretValue(ctx, client, + namespace, secretRef.Name, secretRef.Key); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2642, logging.CRITICAL, "Error while reading certificate from secretRef: %s", secretRef)) + } + } else if configMapRef != nil { + if certificate, err = getConfigMapValue(ctx, client, + namespace, configMapRef.Name, configMapRef.Key); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2643, logging.CRITICAL, "Error while reading certificate from configMapRef: %s", configMapRef)) + } + } + if err != nil { + return "", err + } + if len(certificate) > 0 { + block, _ := pem.Decode([]byte(certificate)) + if block == nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2627, logging.CRITICAL, "Failed to decode certificate PEM.")) + return "", nil + } + _, err = x509.ParseCertificate(block.Bytes) + if err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2641, logging.CRITICAL, "Error while parsing certificate: %s", err.Error())) + return "", err + } + } + return certificate, nil +} + +// getConfigMapValue call kubernetes client and get the configmap and key +func getConfigMapValue(ctx context.Context, client k8client.Client, + namespace, configMapName, key string) (string, error) { + configMap := &corev1.ConfigMap{} + err := client.Get(ctx, types.NamespacedName{ + Name: configMapName, + Namespace: namespace}, configMap) + if err != nil { + return "", err + } + return configMap.Data[key], nil +} + +// getSecretValue call kubernetes client and get the secret and key +func getSecretValue(ctx context.Context, client k8client.Client, + namespace, secretName, key string) (string, error) { + secret := &corev1.Secret{} + err := client.Get(ctx, types.NamespacedName{ + Name: secretName, + Namespace: namespace}, secret) + if err != nil { + return "", err + } + return string(secret.Data[key]), nil +} diff --git a/common-controller/internal/xds/ratelimiter_cache.go b/common-controller/internal/xds/ratelimiter_cache.go index cdef67837..69811a90a 100644 --- a/common-controller/internal/xds/ratelimiter_cache.go +++ b/common-controller/internal/xds/ratelimiter_cache.go @@ -55,8 +55,6 @@ const ( RateLimitPolicyAPILevel string = "API" ) -var void struct{} - var rlsPolicyCache *rateLimitPolicyCache type rateLimitPolicyCache struct { diff --git a/common-controller/internal/xds/server.go b/common-controller/internal/xds/server.go index b65e5719c..b81511875 100644 --- a/common-controller/internal/xds/server.go +++ b/common-controller/internal/xds/server.go @@ -31,7 +31,6 @@ import ( "github.com/envoyproxy/go-control-plane/pkg/cache/types" envoy_cachev3 "github.com/envoyproxy/go-control-plane/pkg/cache/v3" - wso2_cache "github.com/wso2/apk/adapter/pkg/discovery/protocol/cache/v3" eventhubTypes "github.com/wso2/apk/adapter/pkg/eventhub/types" dpv1alpha1 "github.com/wso2/apk/common-go-libs/apis/dp/v1alpha1" ) @@ -62,6 +61,7 @@ type EnforcerInternalAPI struct { applications []types.Resource applicationKeyMappings []types.Resource applicationMappings []types.Resource + jwtIssuers []types.Resource } var ( @@ -69,12 +69,7 @@ var ( mutexForXdsUpdate sync.Mutex mutexForInternalMapUpdate sync.Mutex - cache envoy_cachev3.SnapshotCache - enforcerCache wso2_cache.SnapshotCache - enforcerSubscriptionCache wso2_cache.SnapshotCache - enforcerApplicationCache wso2_cache.SnapshotCache - enforcerApplicationKeyMappingCache wso2_cache.SnapshotCache - enforcerApplicationMappingCache wso2_cache.SnapshotCache + cache envoy_cachev3.SnapshotCache orgAPIMap map[string]map[string]*EnvoyInternalAPI // organizationID -> Vhost:API_UUID -> EnvoyInternalAPI struct map @@ -122,11 +117,6 @@ var _ envoy_cachev3.NodeHash = IDHash{} func init() { cache = envoy_cachev3.NewSnapshotCache(false, IDHash{}, nil) - enforcerCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) - enforcerSubscriptionCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) - enforcerApplicationCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) - enforcerApplicationKeyMappingCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) - enforcerApplicationMappingCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) gatewayLabelConfigMap = make(map[string]*EnvoyGatewayConfig) listenerToRouteArrayMap = make(map[string][]*routev3.Route) orgAPIMap = make(map[string]map[string]*EnvoyInternalAPI) @@ -214,28 +204,3 @@ func SetEmptySnapshotupdate(lable string) bool { func GetXdsCache() envoy_cachev3.SnapshotCache { return cache } - -// GetEnforcerCache returns xds server cache. -func GetEnforcerCache() wso2_cache.SnapshotCache { - return enforcerCache -} - -// GetEnforcerSubscriptionCache returns xds server cache. -func GetEnforcerSubscriptionCache() wso2_cache.SnapshotCache { - return enforcerSubscriptionCache -} - -// GetEnforcerApplicationCache returns xds server cache. -func GetEnforcerApplicationCache() wso2_cache.SnapshotCache { - return enforcerApplicationCache -} - -// GetEnforcerApplicationKeyMappingCache returns xds server cache. -func GetEnforcerApplicationKeyMappingCache() wso2_cache.SnapshotCache { - return enforcerApplicationKeyMappingCache -} - -// GetEnforcerApplicationMappingCache returns xds server cache. -func GetEnforcerApplicationMappingCache() wso2_cache.SnapshotCache { - return enforcerApplicationMappingCache -} diff --git a/common-controller/pkg/discovery/api/wso2/discovery/service/apkmgt/eventds.pb.go b/common-controller/pkg/discovery/api/wso2/discovery/service/apkmgt/eventds.pb.go deleted file mode 100644 index 20b1b3ffc..000000000 --- a/common-controller/pkg/discovery/api/wso2/discovery/service/apkmgt/eventds.pb.go +++ /dev/null @@ -1,278 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/service/apkmgt/eventds.proto - -package apkmgt - -import ( - context "context" - subscription "github.com/wso2/apk/common-go-libs/pkg/discovery/api/wso2/discovery/subscription" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"` -} - -func (x *Request) Reset() { - *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_service_apkmgt_eventds_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_service_apkmgt_eventds_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_wso2_discovery_service_apkmgt_eventds_proto_rawDescGZIP(), []int{0} -} - -func (x *Request) GetEvent() string { - if x != nil { - return x.Event - } - return "" -} - -var File_wso2_discovery_service_apkmgt_eventds_proto protoreflect.FileDescriptor - -var file_wso2_discovery_service_apkmgt_eventds_proto_rawDesc = []byte{ - 0x0a, 0x2b, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x61, 0x70, 0x6b, 0x6d, 0x67, 0x74, 0x2f, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x64, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x2e, 0x61, 0x70, 0x6b, 0x6d, 0x67, 0x74, 0x1a, 0x27, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x1f, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x32, 0x6f, 0x0a, 0x12, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x59, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x21, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x61, 0x70, 0x6b, 0x6d, - 0x67, 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x77, 0x73, 0x6f, - 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x00, - 0x30, 0x01, 0x42, 0x9c, 0x01, 0x0a, 0x2e, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, - 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x61, - 0x70, 0x6b, 0x6d, 0x67, 0x74, 0x42, 0x11, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x52, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x61, 0x70, 0x6b, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x73, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x61, 0x70, 0x6b, 0x6d, 0x67, 0x74, 0x88, 0x01, - 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_service_apkmgt_eventds_proto_rawDescOnce sync.Once - file_wso2_discovery_service_apkmgt_eventds_proto_rawDescData = file_wso2_discovery_service_apkmgt_eventds_proto_rawDesc -) - -func file_wso2_discovery_service_apkmgt_eventds_proto_rawDescGZIP() []byte { - file_wso2_discovery_service_apkmgt_eventds_proto_rawDescOnce.Do(func() { - file_wso2_discovery_service_apkmgt_eventds_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_service_apkmgt_eventds_proto_rawDescData) - }) - return file_wso2_discovery_service_apkmgt_eventds_proto_rawDescData -} - -var file_wso2_discovery_service_apkmgt_eventds_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_service_apkmgt_eventds_proto_goTypes = []interface{}{ - (*Request)(nil), // 0: discovery.service.apkmgt.Request - (*subscription.Event)(nil), // 1: wso2.discovery.subscription.Event -} -var file_wso2_discovery_service_apkmgt_eventds_proto_depIdxs = []int32{ - 0, // 0: discovery.service.apkmgt.EventStreamService.StreamEvents:input_type -> discovery.service.apkmgt.Request - 1, // 1: discovery.service.apkmgt.EventStreamService.StreamEvents:output_type -> wso2.discovery.subscription.Event - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_service_apkmgt_eventds_proto_init() } -func file_wso2_discovery_service_apkmgt_eventds_proto_init() { - if File_wso2_discovery_service_apkmgt_eventds_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_service_apkmgt_eventds_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_service_apkmgt_eventds_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_wso2_discovery_service_apkmgt_eventds_proto_goTypes, - DependencyIndexes: file_wso2_discovery_service_apkmgt_eventds_proto_depIdxs, - MessageInfos: file_wso2_discovery_service_apkmgt_eventds_proto_msgTypes, - }.Build() - File_wso2_discovery_service_apkmgt_eventds_proto = out.File - file_wso2_discovery_service_apkmgt_eventds_proto_rawDesc = nil - file_wso2_discovery_service_apkmgt_eventds_proto_goTypes = nil - file_wso2_discovery_service_apkmgt_eventds_proto_depIdxs = nil -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// EventStreamServiceClient is the client API for EventStreamService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type EventStreamServiceClient interface { - StreamEvents(ctx context.Context, in *Request, opts ...grpc.CallOption) (EventStreamService_StreamEventsClient, error) -} - -type eventStreamServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewEventStreamServiceClient(cc grpc.ClientConnInterface) EventStreamServiceClient { - return &eventStreamServiceClient{cc} -} - -func (c *eventStreamServiceClient) StreamEvents(ctx context.Context, in *Request, opts ...grpc.CallOption) (EventStreamService_StreamEventsClient, error) { - stream, err := c.cc.NewStream(ctx, &_EventStreamService_serviceDesc.Streams[0], "/discovery.service.apkmgt.EventStreamService/StreamEvents", opts...) - if err != nil { - return nil, err - } - x := &eventStreamServiceStreamEventsClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type EventStreamService_StreamEventsClient interface { - Recv() (*subscription.Event, error) - grpc.ClientStream -} - -type eventStreamServiceStreamEventsClient struct { - grpc.ClientStream -} - -func (x *eventStreamServiceStreamEventsClient) Recv() (*subscription.Event, error) { - m := new(subscription.Event) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// EventStreamServiceServer is the server API for EventStreamService service. -type EventStreamServiceServer interface { - StreamEvents(*Request, EventStreamService_StreamEventsServer) error -} - -// UnimplementedEventStreamServiceServer can be embedded to have forward compatible implementations. -type UnimplementedEventStreamServiceServer struct { -} - -func (*UnimplementedEventStreamServiceServer) StreamEvents(*Request, EventStreamService_StreamEventsServer) error { - return status.Errorf(codes.Unimplemented, "method StreamEvents not implemented") -} - -func RegisterEventStreamServiceServer(s *grpc.Server, srv EventStreamServiceServer) { - s.RegisterService(&_EventStreamService_serviceDesc, srv) -} - -func _EventStreamService_StreamEvents_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Request) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(EventStreamServiceServer).StreamEvents(m, &eventStreamServiceStreamEventsServer{stream}) -} - -type EventStreamService_StreamEventsServer interface { - Send(*subscription.Event) error - grpc.ServerStream -} - -type eventStreamServiceStreamEventsServer struct { - grpc.ServerStream -} - -func (x *eventStreamServiceStreamEventsServer) Send(m *subscription.Event) error { - return x.ServerStream.SendMsg(m) -} - -var _EventStreamService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "discovery.service.apkmgt.EventStreamService", - HandlerType: (*EventStreamServiceServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "StreamEvents", - Handler: _EventStreamService_StreamEvents_Handler, - ServerStreams: true, - }, - }, - Metadata: "wso2/discovery/service/apkmgt/eventds.proto", -} diff --git a/common-controller/pkg/discovery/api/wso2/discovery/subscription/application.pb.go b/common-controller/pkg/discovery/api/wso2/discovery/subscription/application.pb.go deleted file mode 100644 index 678ce09cc..000000000 --- a/common-controller/pkg/discovery/api/wso2/discovery/subscription/application.pb.go +++ /dev/null @@ -1,219 +0,0 @@ -// -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/application.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Application data model -type Application struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` - Organization string `protobuf:"bytes,4,opt,name=organization,proto3" json:"organization,omitempty"` - Attributes map[string]string `protobuf:"bytes,5,rep,name=attributes,proto3" json:"attributes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *Application) Reset() { - *x = Application{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_application_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Application) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Application) ProtoMessage() {} - -func (x *Application) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_application_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Application.ProtoReflect.Descriptor instead. -func (*Application) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_application_proto_rawDescGZIP(), []int{0} -} - -func (x *Application) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *Application) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Application) GetOwner() string { - if x != nil { - return x.Owner - } - return "" -} - -func (x *Application) GetOrganization() string { - if x != nil { - return x.Organization - } - return "" -} - -func (x *Application) GetAttributes() map[string]string { - if x != nil { - return x.Attributes - } - return nil -} - -var File_wso2_discovery_subscription_application_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_application_proto_rawDesc = []byte{ - 0x0a, 0x2d, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x70, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x1b, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, - 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x88, 0x02, 0x0a, - 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, - 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, - 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x58, - 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x41, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x61, 0x74, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x94, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, 0x2e, - 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x10, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x61, 0x70, - 0x6b, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x73, - 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, - 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_application_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_application_proto_rawDescData = file_wso2_discovery_subscription_application_proto_rawDesc -) - -func file_wso2_discovery_subscription_application_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_application_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_application_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_application_proto_rawDescData) - }) - return file_wso2_discovery_subscription_application_proto_rawDescData -} - -var file_wso2_discovery_subscription_application_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_wso2_discovery_subscription_application_proto_goTypes = []interface{}{ - (*Application)(nil), // 0: wso2.discovery.subscription.Application - nil, // 1: wso2.discovery.subscription.Application.AttributesEntry -} -var file_wso2_discovery_subscription_application_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.subscription.Application.attributes:type_name -> wso2.discovery.subscription.Application.AttributesEntry - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_application_proto_init() } -func file_wso2_discovery_subscription_application_proto_init() { - if File_wso2_discovery_subscription_application_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_application_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Application); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_application_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_application_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_application_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_application_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_application_proto = out.File - file_wso2_discovery_subscription_application_proto_rawDesc = nil - file_wso2_discovery_subscription_application_proto_goTypes = nil - file_wso2_discovery_subscription_application_proto_depIdxs = nil -} diff --git a/common-controller/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go b/common-controller/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go deleted file mode 100644 index 89b5e9963..000000000 --- a/common-controller/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go +++ /dev/null @@ -1,235 +0,0 @@ -// -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/application_key_mapping.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// ApplicationKeyMapping data model -type ApplicationKeyMapping struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ApplicationUUID string `protobuf:"bytes,1,opt,name=applicationUUID,proto3" json:"applicationUUID,omitempty"` - SecurityScheme string `protobuf:"bytes,2,opt,name=securityScheme,proto3" json:"securityScheme,omitempty"` - ApplicationIdentifier string `protobuf:"bytes,3,opt,name=applicationIdentifier,proto3" json:"applicationIdentifier,omitempty"` - KeyType string `protobuf:"bytes,4,opt,name=keyType,proto3" json:"keyType,omitempty"` - EnvID string `protobuf:"bytes,5,opt,name=envID,proto3" json:"envID,omitempty"` - Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Organization string `protobuf:"bytes,7,opt,name=organization,proto3" json:"organization,omitempty"` -} - -func (x *ApplicationKeyMapping) Reset() { - *x = ApplicationKeyMapping{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_application_key_mapping_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplicationKeyMapping) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplicationKeyMapping) ProtoMessage() {} - -func (x *ApplicationKeyMapping) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_application_key_mapping_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplicationKeyMapping.ProtoReflect.Descriptor instead. -func (*ApplicationKeyMapping) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_application_key_mapping_proto_rawDescGZIP(), []int{0} -} - -func (x *ApplicationKeyMapping) GetApplicationUUID() string { - if x != nil { - return x.ApplicationUUID - } - return "" -} - -func (x *ApplicationKeyMapping) GetSecurityScheme() string { - if x != nil { - return x.SecurityScheme - } - return "" -} - -func (x *ApplicationKeyMapping) GetApplicationIdentifier() string { - if x != nil { - return x.ApplicationIdentifier - } - return "" -} - -func (x *ApplicationKeyMapping) GetKeyType() string { - if x != nil { - return x.KeyType - } - return "" -} - -func (x *ApplicationKeyMapping) GetEnvID() string { - if x != nil { - return x.EnvID - } - return "" -} - -func (x *ApplicationKeyMapping) GetTimestamp() int64 { - if x != nil { - return x.Timestamp - } - return 0 -} - -func (x *ApplicationKeyMapping) GetOrganization() string { - if x != nil { - return x.Organization - } - return "" -} - -var File_wso2_discovery_subscription_application_key_mapping_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_application_key_mapping_proto_rawDesc = []byte{ - 0x0a, 0x39, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x70, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6d, 0x61, - 0x70, 0x70, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x77, 0x73, 0x6f, - 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x91, 0x02, 0x0a, 0x15, 0x41, 0x70, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x61, 0x70, 0x70, 0x69, - 0x6e, 0x67, 0x12, 0x28, 0x0a, 0x0f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x55, 0x55, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x70, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x55, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, - 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, - 0x68, 0x65, 0x6d, 0x65, 0x12, 0x34, 0x0a, 0x15, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x15, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, - 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x76, 0x49, 0x44, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, 0x76, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x9e, 0x01, 0x0a, - 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x1a, 0x41, - 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x61, 0x70, 0x6b, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x73, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_application_key_mapping_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_application_key_mapping_proto_rawDescData = file_wso2_discovery_subscription_application_key_mapping_proto_rawDesc -) - -func file_wso2_discovery_subscription_application_key_mapping_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_application_key_mapping_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_application_key_mapping_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_application_key_mapping_proto_rawDescData) - }) - return file_wso2_discovery_subscription_application_key_mapping_proto_rawDescData -} - -var file_wso2_discovery_subscription_application_key_mapping_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_subscription_application_key_mapping_proto_goTypes = []interface{}{ - (*ApplicationKeyMapping)(nil), // 0: wso2.discovery.subscription.ApplicationKeyMapping -} -var file_wso2_discovery_subscription_application_key_mapping_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_application_key_mapping_proto_init() } -func file_wso2_discovery_subscription_application_key_mapping_proto_init() { - if File_wso2_discovery_subscription_application_key_mapping_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_application_key_mapping_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplicationKeyMapping); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_application_key_mapping_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_application_key_mapping_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_application_key_mapping_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_application_key_mapping_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_application_key_mapping_proto = out.File - file_wso2_discovery_subscription_application_key_mapping_proto_rawDesc = nil - file_wso2_discovery_subscription_application_key_mapping_proto_goTypes = nil - file_wso2_discovery_subscription_application_key_mapping_proto_depIdxs = nil -} diff --git a/common-controller/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go b/common-controller/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go deleted file mode 100644 index 2c5740ebd..000000000 --- a/common-controller/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go +++ /dev/null @@ -1,203 +0,0 @@ -// -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/applicationmapping.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// ApplicationMapping data model -type ApplicationMapping struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` - ApplicationRef string `protobuf:"bytes,2,opt,name=applicationRef,proto3" json:"applicationRef,omitempty"` - SubscriptionRef string `protobuf:"bytes,3,opt,name=subscriptionRef,proto3" json:"subscriptionRef,omitempty"` - Organization string `protobuf:"bytes,4,opt,name=organization,proto3" json:"organization,omitempty"` -} - -func (x *ApplicationMapping) Reset() { - *x = ApplicationMapping{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_applicationmapping_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplicationMapping) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplicationMapping) ProtoMessage() {} - -func (x *ApplicationMapping) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_applicationmapping_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplicationMapping.ProtoReflect.Descriptor instead. -func (*ApplicationMapping) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_applicationmapping_proto_rawDescGZIP(), []int{0} -} - -func (x *ApplicationMapping) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *ApplicationMapping) GetApplicationRef() string { - if x != nil { - return x.ApplicationRef - } - return "" -} - -func (x *ApplicationMapping) GetSubscriptionRef() string { - if x != nil { - return x.SubscriptionRef - } - return "" -} - -func (x *ApplicationMapping) GetOrganization() string { - if x != nil { - return x.Organization - } - return "" -} - -var File_wso2_discovery_subscription_applicationmapping_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_applicationmapping_proto_rawDesc = []byte{ - 0x0a, 0x34, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x70, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0x9e, 0x01, 0x0a, 0x12, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x26, - 0x0a, 0x0e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, - 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x9b, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, - 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x17, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, - 0x32, 0x2f, 0x61, 0x70, 0x6b, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, - 0x6c, 0x69, 0x62, 0x73, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, - 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_applicationmapping_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_applicationmapping_proto_rawDescData = file_wso2_discovery_subscription_applicationmapping_proto_rawDesc -) - -func file_wso2_discovery_subscription_applicationmapping_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_applicationmapping_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_applicationmapping_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_applicationmapping_proto_rawDescData) - }) - return file_wso2_discovery_subscription_applicationmapping_proto_rawDescData -} - -var file_wso2_discovery_subscription_applicationmapping_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_subscription_applicationmapping_proto_goTypes = []interface{}{ - (*ApplicationMapping)(nil), // 0: wso2.discovery.subscription.ApplicationMapping -} -var file_wso2_discovery_subscription_applicationmapping_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_applicationmapping_proto_init() } -func file_wso2_discovery_subscription_applicationmapping_proto_init() { - if File_wso2_discovery_subscription_applicationmapping_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_applicationmapping_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplicationMapping); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_applicationmapping_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_applicationmapping_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_applicationmapping_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_applicationmapping_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_applicationmapping_proto = out.File - file_wso2_discovery_subscription_applicationmapping_proto_rawDesc = nil - file_wso2_discovery_subscription_applicationmapping_proto_goTypes = nil - file_wso2_discovery_subscription_applicationmapping_proto_depIdxs = nil -} diff --git a/common-controller/pkg/discovery/api/wso2/discovery/subscription/event.pb.go b/common-controller/pkg/discovery/api/wso2/discovery/subscription/event.pb.go deleted file mode 100644 index 74863d415..000000000 --- a/common-controller/pkg/discovery/api/wso2/discovery/subscription/event.pb.go +++ /dev/null @@ -1,268 +0,0 @@ -// -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/event.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Event data model -type Event struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` - TimeStamp int64 `protobuf:"varint,2,opt,name=timeStamp,proto3" json:"timeStamp,omitempty"` - Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` - Application *Application `protobuf:"bytes,4,opt,name=application,proto3" json:"application,omitempty"` - ApplicationMapping *ApplicationMapping `protobuf:"bytes,5,opt,name=applicationMapping,proto3" json:"applicationMapping,omitempty"` - ApplicationKeyMapping *ApplicationKeyMapping `protobuf:"bytes,6,opt,name=applicationKeyMapping,proto3" json:"applicationKeyMapping,omitempty"` - Subscription *Subscription `protobuf:"bytes,7,opt,name=subscription,proto3" json:"subscription,omitempty"` -} - -func (x *Event) Reset() { - *x = Event{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_event_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Event) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Event) ProtoMessage() {} - -func (x *Event) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_event_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Event.ProtoReflect.Descriptor instead. -func (*Event) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_event_proto_rawDescGZIP(), []int{0} -} - -func (x *Event) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *Event) GetTimeStamp() int64 { - if x != nil { - return x.TimeStamp - } - return 0 -} - -func (x *Event) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Event) GetApplication() *Application { - if x != nil { - return x.Application - } - return nil -} - -func (x *Event) GetApplicationMapping() *ApplicationMapping { - if x != nil { - return x.ApplicationMapping - } - return nil -} - -func (x *Event) GetApplicationKeyMapping() *ApplicationKeyMapping { - if x != nil { - return x.ApplicationKeyMapping - } - return nil -} - -func (x *Event) GetSubscription() *Subscription { - if x != nil { - return x.Subscription - } - return nil -} - -var File_wso2_discovery_subscription_event_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_event_proto_rawDesc = []byte{ - 0x0a, 0x27, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x77, 0x73, 0x6f, 0x32, 0x2e, - 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x2d, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x34, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x61, - 0x70, 0x70, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x39, 0x77, 0x73, 0x6f, - 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x03, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x75, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, - 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, - 0x6d, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x77, 0x73, - 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x5f, 0x0a, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, - 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, - 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x41, 0x70, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, - 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, - 0x69, 0x6e, 0x67, 0x12, 0x68, 0x0a, 0x15, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x4d, - 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x15, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x4d, 0x0a, - 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, - 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, - 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x8e, 0x01, 0x0a, - 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x61, 0x70, 0x6b, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x73, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_event_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_event_proto_rawDescData = file_wso2_discovery_subscription_event_proto_rawDesc -) - -func file_wso2_discovery_subscription_event_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_event_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_event_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_event_proto_rawDescData) - }) - return file_wso2_discovery_subscription_event_proto_rawDescData -} - -var file_wso2_discovery_subscription_event_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_subscription_event_proto_goTypes = []interface{}{ - (*Event)(nil), // 0: wso2.discovery.subscription.Event - (*Application)(nil), // 1: wso2.discovery.subscription.Application - (*ApplicationMapping)(nil), // 2: wso2.discovery.subscription.ApplicationMapping - (*ApplicationKeyMapping)(nil), // 3: wso2.discovery.subscription.ApplicationKeyMapping - (*Subscription)(nil), // 4: wso2.discovery.subscription.Subscription -} -var file_wso2_discovery_subscription_event_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.subscription.Event.application:type_name -> wso2.discovery.subscription.Application - 2, // 1: wso2.discovery.subscription.Event.applicationMapping:type_name -> wso2.discovery.subscription.ApplicationMapping - 3, // 2: wso2.discovery.subscription.Event.applicationKeyMapping:type_name -> wso2.discovery.subscription.ApplicationKeyMapping - 4, // 3: wso2.discovery.subscription.Event.subscription:type_name -> wso2.discovery.subscription.Subscription - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_event_proto_init() } -func file_wso2_discovery_subscription_event_proto_init() { - if File_wso2_discovery_subscription_event_proto != nil { - return - } - file_wso2_discovery_subscription_application_proto_init() - file_wso2_discovery_subscription_applicationmapping_proto_init() - file_wso2_discovery_subscription_application_key_mapping_proto_init() - file_wso2_discovery_subscription_subscription_proto_init() - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_event_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Event); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_event_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_event_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_event_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_event_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_event_proto = out.File - file_wso2_discovery_subscription_event_proto_rawDesc = nil - file_wso2_discovery_subscription_event_proto_goTypes = nil - file_wso2_discovery_subscription_event_proto_depIdxs = nil -} diff --git a/common-controller/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go b/common-controller/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go deleted file mode 100644 index 078dbf67b..000000000 --- a/common-controller/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// 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. -// - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.13.0 -// source: wso2/discovery/subscription/subscription.proto - -package subscription - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Subscription data model -type Subscription struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SubStatus string `protobuf:"bytes,1,opt,name=subStatus,proto3" json:"subStatus,omitempty"` - Uuid string `protobuf:"bytes,2,opt,name=uuid,proto3" json:"uuid,omitempty"` - Organization string `protobuf:"bytes,3,opt,name=organization,proto3" json:"organization,omitempty"` - SubscribedApi *SubscribedAPI `protobuf:"bytes,4,opt,name=subscribedApi,proto3" json:"subscribedApi,omitempty"` -} - -func (x *Subscription) Reset() { - *x = Subscription{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_subscription_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Subscription) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Subscription) ProtoMessage() {} - -func (x *Subscription) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_subscription_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Subscription.ProtoReflect.Descriptor instead. -func (*Subscription) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_subscription_proto_rawDescGZIP(), []int{0} -} - -func (x *Subscription) GetSubStatus() string { - if x != nil { - return x.SubStatus - } - return "" -} - -func (x *Subscription) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *Subscription) GetOrganization() string { - if x != nil { - return x.Organization - } - return "" -} - -func (x *Subscription) GetSubscribedApi() *SubscribedAPI { - if x != nil { - return x.SubscribedApi - } - return nil -} - -type SubscribedAPI struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` -} - -func (x *SubscribedAPI) Reset() { - *x = SubscribedAPI{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_subscription_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SubscribedAPI) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SubscribedAPI) ProtoMessage() {} - -func (x *SubscribedAPI) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_subscription_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SubscribedAPI.ProtoReflect.Descriptor instead. -func (*SubscribedAPI) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_subscription_proto_rawDescGZIP(), []int{1} -} - -func (x *SubscribedAPI) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *SubscribedAPI) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -var File_wso2_discovery_subscription_subscription_proto protoreflect.FileDescriptor - -var file_wso2_discovery_subscription_subscription_proto_rawDesc = []byte{ - 0x0a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x75, - 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x1b, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xb6, 0x01, - 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, - 0x0a, 0x09, 0x73, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, - 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, - 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x50, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, - 0x65, 0x64, 0x41, 0x70, 0x69, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, - 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x62, 0x65, 0x64, 0x41, 0x50, 0x49, 0x52, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x62, 0x65, 0x64, 0x41, 0x70, 0x69, 0x22, 0x3d, 0x0a, 0x0d, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x62, 0x65, 0x64, 0x41, 0x50, 0x49, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x95, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, - 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, - 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x61, 0x70, 0x6b, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x73, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_subscription_subscription_proto_rawDescOnce sync.Once - file_wso2_discovery_subscription_subscription_proto_rawDescData = file_wso2_discovery_subscription_subscription_proto_rawDesc -) - -func file_wso2_discovery_subscription_subscription_proto_rawDescGZIP() []byte { - file_wso2_discovery_subscription_subscription_proto_rawDescOnce.Do(func() { - file_wso2_discovery_subscription_subscription_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_subscription_proto_rawDescData) - }) - return file_wso2_discovery_subscription_subscription_proto_rawDescData -} - -var file_wso2_discovery_subscription_subscription_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_wso2_discovery_subscription_subscription_proto_goTypes = []interface{}{ - (*Subscription)(nil), // 0: wso2.discovery.subscription.Subscription - (*SubscribedAPI)(nil), // 1: wso2.discovery.subscription.SubscribedAPI -} -var file_wso2_discovery_subscription_subscription_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.subscription.Subscription.subscribedApi:type_name -> wso2.discovery.subscription.SubscribedAPI - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_subscription_subscription_proto_init() } -func file_wso2_discovery_subscription_subscription_proto_init() { - if File_wso2_discovery_subscription_subscription_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_subscription_subscription_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Subscription); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_wso2_discovery_subscription_subscription_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SubscribedAPI); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_subscription_subscription_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_subscription_subscription_proto_goTypes, - DependencyIndexes: file_wso2_discovery_subscription_subscription_proto_depIdxs, - MessageInfos: file_wso2_discovery_subscription_subscription_proto_msgTypes, - }.Build() - File_wso2_discovery_subscription_subscription_proto = out.File - file_wso2_discovery_subscription_subscription_proto_rawDesc = nil - file_wso2_discovery_subscription_subscription_proto_goTypes = nil - file_wso2_discovery_subscription_subscription_proto_depIdxs = nil -} diff --git a/common-go-libs/pkg/discovery/api/wso2/discovery/subscription/event.pb.go b/common-go-libs/pkg/discovery/api/wso2/discovery/subscription/event.pb.go index 74863d415..604771547 100644 --- a/common-go-libs/pkg/discovery/api/wso2/discovery/subscription/event.pb.go +++ b/common-go-libs/pkg/discovery/api/wso2/discovery/subscription/event.pb.go @@ -49,6 +49,7 @@ type Event struct { ApplicationMapping *ApplicationMapping `protobuf:"bytes,5,opt,name=applicationMapping,proto3" json:"applicationMapping,omitempty"` ApplicationKeyMapping *ApplicationKeyMapping `protobuf:"bytes,6,opt,name=applicationKeyMapping,proto3" json:"applicationKeyMapping,omitempty"` Subscription *Subscription `protobuf:"bytes,7,opt,name=subscription,proto3" json:"subscription,omitempty"` + TokenIssuer *TokenIssuer `protobuf:"bytes,8,opt,name=tokenIssuer,proto3" json:"tokenIssuer,omitempty"` } func (x *Event) Reset() { @@ -132,6 +133,13 @@ func (x *Event) GetSubscription() *Subscription { return nil } +func (x *Event) GetTokenIssuer() *TokenIssuer { + if x != nil { + return x.TokenIssuer + } + return nil +} + var File_wso2_discovery_subscription_event_proto protoreflect.FileDescriptor var file_wso2_discovery_subscription_event_proto_rawDesc = []byte{ @@ -151,8 +159,11 @@ var file_wso2_discovery_subscription_event_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, + 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x03, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xff, 0x03, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, @@ -179,17 +190,22 @@ var file_wso2_discovery_subscription_event_proto_rawDesc = []byte{ 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, - 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x8e, 0x01, 0x0a, - 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x61, 0x70, 0x6b, - 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x73, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4a, 0x0a, 0x0b, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x28, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x52, 0x0b, 0x74, 0x6f, 0x6b, + 0x65, 0x6e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x42, 0x8e, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, + 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, + 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x61, 0x70, 0x6b, 0x2f, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x73, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x77, 0x73, + 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -211,17 +227,19 @@ var file_wso2_discovery_subscription_event_proto_goTypes = []interface{}{ (*ApplicationMapping)(nil), // 2: wso2.discovery.subscription.ApplicationMapping (*ApplicationKeyMapping)(nil), // 3: wso2.discovery.subscription.ApplicationKeyMapping (*Subscription)(nil), // 4: wso2.discovery.subscription.Subscription + (*TokenIssuer)(nil), // 5: wso2.discovery.subscription.TokenIssuer } var file_wso2_discovery_subscription_event_proto_depIdxs = []int32{ 1, // 0: wso2.discovery.subscription.Event.application:type_name -> wso2.discovery.subscription.Application 2, // 1: wso2.discovery.subscription.Event.applicationMapping:type_name -> wso2.discovery.subscription.ApplicationMapping 3, // 2: wso2.discovery.subscription.Event.applicationKeyMapping:type_name -> wso2.discovery.subscription.ApplicationKeyMapping 4, // 3: wso2.discovery.subscription.Event.subscription:type_name -> wso2.discovery.subscription.Subscription - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 5, // 4: wso2.discovery.subscription.Event.tokenIssuer:type_name -> wso2.discovery.subscription.TokenIssuer + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_wso2_discovery_subscription_event_proto_init() } @@ -232,6 +250,7 @@ func file_wso2_discovery_subscription_event_proto_init() { file_wso2_discovery_subscription_application_proto_init() file_wso2_discovery_subscription_applicationmapping_proto_init() file_wso2_discovery_subscription_application_key_mapping_proto_init() + file_wso2_discovery_subscription_token_issuer_proto_init() file_wso2_discovery_subscription_subscription_proto_init() if !protoimpl.UnsafeEnabled { file_wso2_discovery_subscription_event_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { diff --git a/common-go-libs/pkg/discovery/api/wso2/discovery/subscription/token_issuer.pb.go b/common-go-libs/pkg/discovery/api/wso2/discovery/subscription/token_issuer.pb.go new file mode 100644 index 000000000..638bb8087 --- /dev/null +++ b/common-go-libs/pkg/discovery/api/wso2/discovery/subscription/token_issuer.pb.go @@ -0,0 +1,411 @@ +// +// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. +// +// 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. +// + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc v3.13.0 +// source: wso2/discovery/subscription/token_issuer.proto + +package subscription + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// TokenIssuer data model +type TokenIssuer struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EventId string `protobuf:"bytes,1,opt,name=eventId,proto3" json:"eventId,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Organization string `protobuf:"bytes,3,opt,name=organization,proto3" json:"organization,omitempty"` + Issuer string `protobuf:"bytes,4,opt,name=issuer,proto3" json:"issuer,omitempty"` + Certificate *Certificate `protobuf:"bytes,5,opt,name=certificate,proto3" json:"certificate,omitempty"` + ConsumerKeyClaim string `protobuf:"bytes,6,opt,name=consumerKeyClaim,proto3" json:"consumerKeyClaim,omitempty"` + ScopesClaim string `protobuf:"bytes,7,opt,name=scopesClaim,proto3" json:"scopesClaim,omitempty"` + ClaimMapping map[string]string `protobuf:"bytes,8,rep,name=claimMapping,proto3" json:"claimMapping,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Environments []string `protobuf:"bytes,9,rep,name=environments,proto3" json:"environments,omitempty"` +} + +func (x *TokenIssuer) Reset() { + *x = TokenIssuer{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_subscription_token_issuer_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TokenIssuer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TokenIssuer) ProtoMessage() {} + +func (x *TokenIssuer) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_subscription_token_issuer_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TokenIssuer.ProtoReflect.Descriptor instead. +func (*TokenIssuer) Descriptor() ([]byte, []int) { + return file_wso2_discovery_subscription_token_issuer_proto_rawDescGZIP(), []int{0} +} + +func (x *TokenIssuer) GetEventId() string { + if x != nil { + return x.EventId + } + return "" +} + +func (x *TokenIssuer) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *TokenIssuer) GetOrganization() string { + if x != nil { + return x.Organization + } + return "" +} + +func (x *TokenIssuer) GetIssuer() string { + if x != nil { + return x.Issuer + } + return "" +} + +func (x *TokenIssuer) GetCertificate() *Certificate { + if x != nil { + return x.Certificate + } + return nil +} + +func (x *TokenIssuer) GetConsumerKeyClaim() string { + if x != nil { + return x.ConsumerKeyClaim + } + return "" +} + +func (x *TokenIssuer) GetScopesClaim() string { + if x != nil { + return x.ScopesClaim + } + return "" +} + +func (x *TokenIssuer) GetClaimMapping() map[string]string { + if x != nil { + return x.ClaimMapping + } + return nil +} + +func (x *TokenIssuer) GetEnvironments() []string { + if x != nil { + return x.Environments + } + return nil +} + +type Certificate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Certificate string `protobuf:"bytes,1,opt,name=certificate,proto3" json:"certificate,omitempty"` + Jwks *JWKS `protobuf:"bytes,2,opt,name=jwks,proto3" json:"jwks,omitempty"` +} + +func (x *Certificate) Reset() { + *x = Certificate{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_subscription_token_issuer_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Certificate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Certificate) ProtoMessage() {} + +func (x *Certificate) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_subscription_token_issuer_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Certificate.ProtoReflect.Descriptor instead. +func (*Certificate) Descriptor() ([]byte, []int) { + return file_wso2_discovery_subscription_token_issuer_proto_rawDescGZIP(), []int{1} +} + +func (x *Certificate) GetCertificate() string { + if x != nil { + return x.Certificate + } + return "" +} + +func (x *Certificate) GetJwks() *JWKS { + if x != nil { + return x.Jwks + } + return nil +} + +type JWKS struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + Tls string `protobuf:"bytes,2,opt,name=tls,proto3" json:"tls,omitempty"` +} + +func (x *JWKS) Reset() { + *x = JWKS{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_subscription_token_issuer_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *JWKS) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*JWKS) ProtoMessage() {} + +func (x *JWKS) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_subscription_token_issuer_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use JWKS.ProtoReflect.Descriptor instead. +func (*JWKS) Descriptor() ([]byte, []int) { + return file_wso2_discovery_subscription_token_issuer_proto_rawDescGZIP(), []int{2} +} + +func (x *JWKS) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *JWKS) GetTls() string { + if x != nil { + return x.Tls + } + return "" +} + +var File_wso2_discovery_subscription_token_issuer_proto protoreflect.FileDescriptor + +var file_wso2_discovery_subscription_token_issuer_proto_rawDesc = []byte{ + 0x0a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x1b, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xd6, 0x03, + 0x0a, 0x0b, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x12, 0x18, 0x0a, + 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x6f, + 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x77, + 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, + 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x65, 0x72, 0x74, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x4b, + 0x65, 0x79, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x63, + 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, + 0x20, 0x0a, 0x0b, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x43, 0x6c, 0x61, 0x69, + 0x6d, 0x12, 0x5e, 0x0a, 0x0c, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x73, 0x73, 0x75, 0x65, + 0x72, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, + 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x1a, 0x3f, 0x0a, 0x11, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x4d, 0x61, + 0x70, 0x70, 0x69, 0x6e, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x66, 0x0a, 0x0b, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, + 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x35, 0x0a, 0x04, 0x6a, 0x77, 0x6b, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, + 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x4a, 0x57, 0x4b, 0x53, 0x52, 0x04, 0x6a, 0x77, 0x6b, 0x73, 0x22, 0x2a, + 0x0a, 0x04, 0x4a, 0x57, 0x4b, 0x53, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x6c, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x6c, 0x73, 0x42, 0x94, 0x01, 0x0a, 0x2c, 0x6f, + 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x10, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x73, 0x6f, 0x32, + 0x2f, 0x61, 0x70, 0x6b, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x6c, + 0x69, 0x62, 0x73, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_wso2_discovery_subscription_token_issuer_proto_rawDescOnce sync.Once + file_wso2_discovery_subscription_token_issuer_proto_rawDescData = file_wso2_discovery_subscription_token_issuer_proto_rawDesc +) + +func file_wso2_discovery_subscription_token_issuer_proto_rawDescGZIP() []byte { + file_wso2_discovery_subscription_token_issuer_proto_rawDescOnce.Do(func() { + file_wso2_discovery_subscription_token_issuer_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_token_issuer_proto_rawDescData) + }) + return file_wso2_discovery_subscription_token_issuer_proto_rawDescData +} + +var file_wso2_discovery_subscription_token_issuer_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_wso2_discovery_subscription_token_issuer_proto_goTypes = []interface{}{ + (*TokenIssuer)(nil), // 0: wso2.discovery.subscription.TokenIssuer + (*Certificate)(nil), // 1: wso2.discovery.subscription.Certificate + (*JWKS)(nil), // 2: wso2.discovery.subscription.JWKS + nil, // 3: wso2.discovery.subscription.TokenIssuer.ClaimMappingEntry +} +var file_wso2_discovery_subscription_token_issuer_proto_depIdxs = []int32{ + 1, // 0: wso2.discovery.subscription.TokenIssuer.certificate:type_name -> wso2.discovery.subscription.Certificate + 3, // 1: wso2.discovery.subscription.TokenIssuer.claimMapping:type_name -> wso2.discovery.subscription.TokenIssuer.ClaimMappingEntry + 2, // 2: wso2.discovery.subscription.Certificate.jwks:type_name -> wso2.discovery.subscription.JWKS + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_wso2_discovery_subscription_token_issuer_proto_init() } +func file_wso2_discovery_subscription_token_issuer_proto_init() { + if File_wso2_discovery_subscription_token_issuer_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_wso2_discovery_subscription_token_issuer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TokenIssuer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_wso2_discovery_subscription_token_issuer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Certificate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_wso2_discovery_subscription_token_issuer_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*JWKS); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_wso2_discovery_subscription_token_issuer_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_wso2_discovery_subscription_token_issuer_proto_goTypes, + DependencyIndexes: file_wso2_discovery_subscription_token_issuer_proto_depIdxs, + MessageInfos: file_wso2_discovery_subscription_token_issuer_proto_msgTypes, + }.Build() + File_wso2_discovery_subscription_token_issuer_proto = out.File + file_wso2_discovery_subscription_token_issuer_proto_rawDesc = nil + file_wso2_discovery_subscription_token_issuer_proto_goTypes = nil + file_wso2_discovery_subscription_token_issuer_proto_depIdxs = nil +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/JWTIssuerDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/JWTIssuerDiscoveryClient.java deleted file mode 100644 index 9d751a267..000000000 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/JWTIssuerDiscoveryClient.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 LLC. licenses this file to you 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.wso2.apk.enforcer.discovery; - -import com.google.protobuf.Any; -import com.google.rpc.Status; -import io.envoyproxy.envoy.config.core.v3.Node; -import io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest; -import io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse; -import io.grpc.ConnectivityState; -import io.grpc.ManagedChannel; -import io.grpc.stub.StreamObserver; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.wso2.apk.enforcer.config.ConfigHolder; -import org.wso2.apk.enforcer.constants.AdapterConstants; -import org.wso2.apk.enforcer.constants.Constants; -import org.wso2.apk.enforcer.discovery.common.XDSCommonUtils; -import org.wso2.apk.enforcer.discovery.scheduler.XdsSchedulerManager; -import org.wso2.apk.enforcer.discovery.service.subscription.JWTIssuerDiscoveryServiceGrpc; -import org.wso2.apk.enforcer.discovery.subscription.JWTIssuer; -import org.wso2.apk.enforcer.discovery.subscription.JWTIssuerList; -import org.wso2.apk.enforcer.subscription.SubscriptionDataHolder; -import org.wso2.apk.enforcer.subscription.SubscriptionDataStore; -import org.wso2.apk.enforcer.util.GRPCUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * Client to communicate with JWTIssuer discovery service at the adapter. - */ -public class JWTIssuerDiscoveryClient implements Runnable { - - private static final Logger logger = LogManager.getLogger(JWTIssuerDiscoveryClient.class); - private static JWTIssuerDiscoveryClient instance; - private ManagedChannel channel; - private JWTIssuerDiscoveryServiceGrpc.JWTIssuerDiscoveryServiceStub stub; - private StreamObserver reqObserver; - private final String host; - private final String hostname; - private final int port; - - /** - * This is a reference to the latest received response from the ADS. - *

- * Usage: When ack/nack a DiscoveryResponse this value is used to identify the latest received DiscoveryResponse - * which may not have been acked/nacked so far. - *

- */ - - private DiscoveryResponse latestReceived; - /** - * This is a reference to the latest acked response from the ADS. - *

- * Usage: When nack a DiscoveryResponse this value is used to find the latest successfully processed - * DiscoveryResponse. Information sent in the nack request will contain information about this response value. - *

- */ - private DiscoveryResponse latestACKed; - - /** - * Node struct for the discovery client - */ - private final Node node; - - private JWTIssuerDiscoveryClient(String host, String hostname, int port) { - - this.host = host; - this.hostname = hostname; - this.port = port; - initConnection(); - this.node = XDSCommonUtils.generateXDSNode(AdapterConstants.COMMON_ENFORCER_LABEL); - this.latestACKed = DiscoveryResponse.getDefaultInstance(); - } - - private void initConnection() { - - if (GRPCUtils.isReInitRequired(channel)) { - if (channel != null && !channel.isShutdown()) { - channel.shutdownNow(); - do { - try { - channel.awaitTermination(100, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.error("JWTISsuer discovery channel shutdown wait was interrupted", e); - } - } while (!channel.isShutdown()); - } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); - this.stub = JWTIssuerDiscoveryServiceGrpc.newStub(channel); - } else if (channel.getState(true) == ConnectivityState.READY) { - XdsSchedulerManager.getInstance().stopJWTIssuerDiscoveryScheduling(); - } - } - - public static JWTIssuerDiscoveryClient getInstance() { - - if (instance == null) { - String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHost(); - String sdsHostname = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHostname(); - int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getAdapterXdsPort()); - instance = new JWTIssuerDiscoveryClient(sdsHost, sdsHostname, sdsPort); - } - return instance; - } - - public void run() { - - initConnection(); - watchJWTIssuers(); - } - - public void watchJWTIssuers() { - - reqObserver = stub.streamJWTIssuers(new StreamObserver<>() { - @Override - public void onNext(DiscoveryResponse response) { - - logger.info("JWTIssuer creation event received with version : " + response.getVersionInfo()); - logger.debug("Received JWTIssuer discovery response " + response); - XdsSchedulerManager.getInstance().stopJWTIssuerDiscoveryScheduling(); - latestReceived = response; - try { - List jwtIssuers = new ArrayList<>(); - for (Any res : response.getResourcesList()) { - jwtIssuers.addAll(res.unpack(JWTIssuerList.class).getListList()); - } - Map> orgWizeIssuerMap = new HashMap<>(); - for (JWTIssuer jwtIssuer : jwtIssuers) { - List jwtIssuerList = orgWizeIssuerMap.computeIfAbsent(jwtIssuer.getOrganization(), - k -> new ArrayList<>()); - jwtIssuerList.add(jwtIssuer); - } - orgWizeIssuerMap.forEach((k, v) -> { - SubscriptionDataStore subscriptionDataStore = - SubscriptionDataHolder.getInstance().getSubscriptionDataStore(k); - if (subscriptionDataStore == null) { - subscriptionDataStore = - SubscriptionDataHolder.getInstance().initializeSubscriptionDataStore(k); - } - subscriptionDataStore.addJWTIssuers(v); - }); - logger.info("Number of jwt issuers received : " + jwtIssuers.size()); - ack(); - } catch (Exception e) { - // catching generic error here to wrap any grpc communication errors in the runtime - onError(e); - } - } - - @Override - public void onError(Throwable throwable) { - - logger.error("Error occurred during JWTIssuer discovery", throwable); - XdsSchedulerManager.getInstance().startJWTIssuerDiscoveryScheduling(); - nack(throwable); - } - - @Override - public void onCompleted() { - - logger.info("Completed receiving JWT Issuer data"); - } - }); - - try { - DiscoveryRequest req = DiscoveryRequest.newBuilder() - .setNode(node) - .setVersionInfo(latestACKed.getVersionInfo()) - .setTypeUrl(Constants.JWT_ISSUER_LIST_TYPE_URL).build(); - reqObserver.onNext(req); - logger.debug("Sent Discovery request for type url: " + Constants.JWT_ISSUER_LIST_TYPE_URL); - - } catch (Exception e) { - logger.error("Unexpected error occurred in JWTIssuer discovery service", e); - reqObserver.onError(e); - } - } - - /** - * Send acknowledgement of successfully processed DiscoveryResponse from the xDS server. This is part of the xDS - * communication protocol. - */ - private void ack() { - - DiscoveryRequest req = DiscoveryRequest.newBuilder() - .setNode(node) - .setVersionInfo(latestReceived.getVersionInfo()) - .setResponseNonce(latestReceived.getNonce()) - .setTypeUrl(Constants.JWT_ISSUER_LIST_TYPE_URL).build(); - reqObserver.onNext(req); - latestACKed = latestReceived; - } - - private void nack(Throwable e) { - - if (latestReceived == null) { - return; - } - DiscoveryRequest req = DiscoveryRequest.newBuilder() - .setNode(node) - .setVersionInfo(latestACKed.getVersionInfo()) - .setResponseNonce(latestReceived.getNonce()) - .setTypeUrl(Constants.JWT_ISSUER_LIST_TYPE_URL) - .setErrorDetail(Status.newBuilder().setMessage(e.getMessage())) - .build(); - reqObserver.onNext(req); - } -} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/scheduler/XdsSchedulerManager.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/scheduler/XdsSchedulerManager.java index 3ed73dcce..a87fa14fb 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/scheduler/XdsSchedulerManager.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/scheduler/XdsSchedulerManager.java @@ -21,7 +21,6 @@ import org.wso2.apk.enforcer.config.EnvVarConfig; import org.wso2.apk.enforcer.discovery.ApiDiscoveryClient; import org.wso2.apk.enforcer.discovery.ConfigDiscoveryClient; -import org.wso2.apk.enforcer.discovery.JWTIssuerDiscoveryClient; import org.wso2.apk.enforcer.subscription.EventingGrpcClient; import java.util.concurrent.Executors; @@ -74,13 +73,7 @@ public synchronized void stopAPIDiscoveryScheduling() { } } - public synchronized void startJWTIssuerDiscoveryScheduling() { - if (jwtIssuerDiscoveryScheduledFuture == null || jwtIssuerDiscoveryScheduledFuture.isDone()) { - jwtIssuerDiscoveryScheduledFuture = discoveryClientScheduler - .scheduleWithFixedDelay(JWTIssuerDiscoveryClient.getInstance(), 1, retryPeriod, TimeUnit.SECONDS); - } - } public synchronized void startEventScheduling() { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Certificate.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Certificate.java index b2e343943..59e2d8edf 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Certificate.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Certificate.java @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: wso2/discovery/subscription/jwtIssuer.proto +// source: wso2/discovery/subscription/token_issuer.proto package org.wso2.apk.enforcer.discovery.subscription; @@ -89,13 +89,13 @@ private Certificate( } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_Certificate_descriptor; + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_Certificate_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_Certificate_fieldAccessorTable + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_Certificate_fieldAccessorTable .ensureFieldAccessorsInitialized( org.wso2.apk.enforcer.discovery.subscription.Certificate.class, org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder.class); } @@ -343,13 +343,13 @@ public static final class Builder extends org.wso2.apk.enforcer.discovery.subscription.CertificateOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_Certificate_descriptor; + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_Certificate_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_Certificate_fieldAccessorTable + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_Certificate_fieldAccessorTable .ensureFieldAccessorsInitialized( org.wso2.apk.enforcer.discovery.subscription.Certificate.class, org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder.class); } @@ -386,7 +386,7 @@ public Builder clear() { @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_Certificate_descriptor; + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_Certificate_descriptor; } @java.lang.Override diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/CertificateOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/CertificateOrBuilder.java index 95be48bd3..80c3cd902 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/CertificateOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/CertificateOrBuilder.java @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: wso2/discovery/subscription/jwtIssuer.proto +// source: wso2/discovery/subscription/token_issuer.proto package org.wso2.apk.enforcer.discovery.subscription; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Event.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Event.java index 5cca96f54..f9620174f 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Event.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Event.java @@ -123,6 +123,19 @@ private Event( break; } + case 66: { + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder subBuilder = null; + if (tokenIssuer_ != null) { + subBuilder = tokenIssuer_.toBuilder(); + } + tokenIssuer_ = input.readMessage(org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(tokenIssuer_); + tokenIssuer_ = subBuilder.buildPartial(); + } + + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -346,6 +359,32 @@ public org.wso2.apk.enforcer.discovery.subscription.SubscriptionOrBuilder getSub return getSubscription(); } + public static final int TOKENISSUER_FIELD_NUMBER = 8; + private org.wso2.apk.enforcer.discovery.subscription.TokenIssuer tokenIssuer_; + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + * @return Whether the tokenIssuer field is set. + */ + @java.lang.Override + public boolean hasTokenIssuer() { + return tokenIssuer_ != null; + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + * @return The tokenIssuer. + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuer getTokenIssuer() { + return tokenIssuer_ == null ? org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.getDefaultInstance() : tokenIssuer_; + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuerOrBuilder getTokenIssuerOrBuilder() { + return getTokenIssuer(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -381,6 +420,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (subscription_ != null) { output.writeMessage(7, getSubscription()); } + if (tokenIssuer_ != null) { + output.writeMessage(8, getTokenIssuer()); + } unknownFields.writeTo(output); } @@ -416,6 +458,10 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(7, getSubscription()); } + if (tokenIssuer_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, getTokenIssuer()); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -457,6 +503,11 @@ public boolean equals(final java.lang.Object obj) { if (!getSubscription() .equals(other.getSubscription())) return false; } + if (hasTokenIssuer() != other.hasTokenIssuer()) return false; + if (hasTokenIssuer()) { + if (!getTokenIssuer() + .equals(other.getTokenIssuer())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -491,6 +542,10 @@ public int hashCode() { hash = (37 * hash) + SUBSCRIPTION_FIELD_NUMBER; hash = (53 * hash) + getSubscription().hashCode(); } + if (hasTokenIssuer()) { + hash = (37 * hash) + TOKENISSUER_FIELD_NUMBER; + hash = (53 * hash) + getTokenIssuer().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -658,6 +713,12 @@ public Builder clear() { subscription_ = null; subscriptionBuilder_ = null; } + if (tokenIssuerBuilder_ == null) { + tokenIssuer_ = null; + } else { + tokenIssuer_ = null; + tokenIssuerBuilder_ = null; + } return this; } @@ -707,6 +768,11 @@ public org.wso2.apk.enforcer.discovery.subscription.Event buildPartial() { } else { result.subscription_ = subscriptionBuilder_.build(); } + if (tokenIssuerBuilder_ == null) { + result.tokenIssuer_ = tokenIssuer_; + } else { + result.tokenIssuer_ = tokenIssuerBuilder_.build(); + } onBuilt(); return result; } @@ -778,6 +844,9 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.Event othe if (other.hasSubscription()) { mergeSubscription(other.getSubscription()); } + if (other.hasTokenIssuer()) { + mergeTokenIssuer(other.getTokenIssuer()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1465,6 +1534,125 @@ public org.wso2.apk.enforcer.discovery.subscription.SubscriptionOrBuilder getSub } return subscriptionBuilder_; } + + private org.wso2.apk.enforcer.discovery.subscription.TokenIssuer tokenIssuer_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer, org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder, org.wso2.apk.enforcer.discovery.subscription.TokenIssuerOrBuilder> tokenIssuerBuilder_; + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + * @return Whether the tokenIssuer field is set. + */ + public boolean hasTokenIssuer() { + return tokenIssuerBuilder_ != null || tokenIssuer_ != null; + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + * @return The tokenIssuer. + */ + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuer getTokenIssuer() { + if (tokenIssuerBuilder_ == null) { + return tokenIssuer_ == null ? org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.getDefaultInstance() : tokenIssuer_; + } else { + return tokenIssuerBuilder_.getMessage(); + } + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + public Builder setTokenIssuer(org.wso2.apk.enforcer.discovery.subscription.TokenIssuer value) { + if (tokenIssuerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + tokenIssuer_ = value; + onChanged(); + } else { + tokenIssuerBuilder_.setMessage(value); + } + + return this; + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + public Builder setTokenIssuer( + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder builderForValue) { + if (tokenIssuerBuilder_ == null) { + tokenIssuer_ = builderForValue.build(); + onChanged(); + } else { + tokenIssuerBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + public Builder mergeTokenIssuer(org.wso2.apk.enforcer.discovery.subscription.TokenIssuer value) { + if (tokenIssuerBuilder_ == null) { + if (tokenIssuer_ != null) { + tokenIssuer_ = + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.newBuilder(tokenIssuer_).mergeFrom(value).buildPartial(); + } else { + tokenIssuer_ = value; + } + onChanged(); + } else { + tokenIssuerBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + public Builder clearTokenIssuer() { + if (tokenIssuerBuilder_ == null) { + tokenIssuer_ = null; + onChanged(); + } else { + tokenIssuer_ = null; + tokenIssuerBuilder_ = null; + } + + return this; + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder getTokenIssuerBuilder() { + + onChanged(); + return getTokenIssuerFieldBuilder().getBuilder(); + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuerOrBuilder getTokenIssuerOrBuilder() { + if (tokenIssuerBuilder_ != null) { + return tokenIssuerBuilder_.getMessageOrBuilder(); + } else { + return tokenIssuer_ == null ? + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.getDefaultInstance() : tokenIssuer_; + } + } + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer, org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder, org.wso2.apk.enforcer.discovery.subscription.TokenIssuerOrBuilder> + getTokenIssuerFieldBuilder() { + if (tokenIssuerBuilder_ == null) { + tokenIssuerBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer, org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder, org.wso2.apk.enforcer.discovery.subscription.TokenIssuerOrBuilder>( + getTokenIssuer(), + getParentForChildren(), + isClean()); + tokenIssuer_ = null; + } + return tokenIssuerBuilder_; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventOrBuilder.java index 8f693067f..35a50977d 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventOrBuilder.java @@ -96,4 +96,19 @@ public interface EventOrBuilder extends * .wso2.discovery.subscription.Subscription subscription = 7; */ org.wso2.apk.enforcer.discovery.subscription.SubscriptionOrBuilder getSubscriptionOrBuilder(); + + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + * @return Whether the tokenIssuer field is set. + */ + boolean hasTokenIssuer(); + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + * @return The tokenIssuer. + */ + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer getTokenIssuer(); + /** + * .wso2.discovery.subscription.TokenIssuer tokenIssuer = 8; + */ + org.wso2.apk.enforcer.discovery.subscription.TokenIssuerOrBuilder getTokenIssuerOrBuilder(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventProto.java index ddf36b01e..80084a239 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EventProto.java @@ -34,20 +34,23 @@ public static void registerAllExtensions( "so2/discovery/subscription/applicationma" + "pping.proto\0329wso2/discovery/subscription" + "/application_key_mapping.proto\032.wso2/dis" + - "covery/subscription/subscription.proto\"\326" + - "\002\n\005Event\022\014\n\004uuid\030\001 \001(\t\022\021\n\ttimeStamp\030\002 \001(" + - "\003\022\014\n\004type\030\003 \001(\t\022=\n\013application\030\004 \001(\0132(.w" + - "so2.discovery.subscription.Application\022K" + - "\n\022applicationMapping\030\005 \001(\0132/.wso2.discov" + - "ery.subscription.ApplicationMapping\022Q\n\025a" + - "pplicationKeyMapping\030\006 \001(\01322.wso2.discov" + - "ery.subscription.ApplicationKeyMapping\022?" + - "\n\014subscription\030\007 \001(\0132).wso2.discovery.su" + - "bscription.SubscriptionB\216\001\n,org.wso2.apk" + - ".enforcer.discovery.subscriptionB\nEventP" + - "rotoP\001ZPgithub.com/wso2/apk/common-go-li" + - "bs/pkg/discovery/api/wso2/discovery/subs" + - "criptionb\006proto3" + "covery/subscription/token_issuer.proto\032." + + "wso2/discovery/subscription/subscription" + + ".proto\"\225\003\n\005Event\022\014\n\004uuid\030\001 \001(\t\022\021\n\ttimeSt" + + "amp\030\002 \001(\003\022\014\n\004type\030\003 \001(\t\022=\n\013application\030\004" + + " \001(\0132(.wso2.discovery.subscription.Appli" + + "cation\022K\n\022applicationMapping\030\005 \001(\0132/.wso" + + "2.discovery.subscription.ApplicationMapp" + + "ing\022Q\n\025applicationKeyMapping\030\006 \001(\01322.wso" + + "2.discovery.subscription.ApplicationKeyM" + + "apping\022?\n\014subscription\030\007 \001(\0132).wso2.disc" + + "overy.subscription.Subscription\022=\n\013token" + + "Issuer\030\010 \001(\0132(.wso2.discovery.subscripti" + + "on.TokenIssuerB\216\001\n,org.wso2.apk.enforcer" + + ".discovery.subscriptionB\nEventProtoP\001ZPg" + + "ithub.com/wso2/apk/common-go-libs/pkg/di" + + "scovery/api/wso2/discovery/subscriptionb" + + "\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -55,6 +58,7 @@ public static void registerAllExtensions( org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.getDescriptor(), org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.getDescriptor(), org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMappingProto.getDescriptor(), + org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.getDescriptor(), org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.getDescriptor(), }); internal_static_wso2_discovery_subscription_Event_descriptor = @@ -62,10 +66,11 @@ public static void registerAllExtensions( internal_static_wso2_discovery_subscription_Event_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_subscription_Event_descriptor, - new java.lang.String[] { "Uuid", "TimeStamp", "Type", "Application", "ApplicationMapping", "ApplicationKeyMapping", "Subscription", }); + new java.lang.String[] { "Uuid", "TimeStamp", "Type", "Application", "ApplicationMapping", "ApplicationKeyMapping", "Subscription", "TokenIssuer", }); org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.getDescriptor(); org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.getDescriptor(); org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMappingProto.getDescriptor(); + org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.getDescriptor(); org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.getDescriptor(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKS.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKS.java index a427eb717..853ae2791 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKS.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKS.java @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: wso2/discovery/subscription/jwtIssuer.proto +// source: wso2/discovery/subscription/token_issuer.proto package org.wso2.apk.enforcer.discovery.subscription; @@ -83,13 +83,13 @@ private JWKS( } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_JWKS_descriptor; + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_JWKS_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_JWKS_fieldAccessorTable + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_JWKS_fieldAccessorTable .ensureFieldAccessorsInitialized( org.wso2.apk.enforcer.discovery.subscription.JWKS.class, org.wso2.apk.enforcer.discovery.subscription.JWKS.Builder.class); } @@ -343,13 +343,13 @@ public static final class Builder extends org.wso2.apk.enforcer.discovery.subscription.JWKSOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_JWKS_descriptor; + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_JWKS_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_JWKS_fieldAccessorTable + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_JWKS_fieldAccessorTable .ensureFieldAccessorsInitialized( org.wso2.apk.enforcer.discovery.subscription.JWKS.class, org.wso2.apk.enforcer.discovery.subscription.JWKS.Builder.class); } @@ -382,7 +382,7 @@ public Builder clear() { @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return org.wso2.apk.enforcer.discovery.subscription.JWTIssuerProto.internal_static_wso2_discovery_subscription_JWKS_descriptor; + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_JWKS_descriptor; } @java.lang.Override diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKSOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKSOrBuilder.java index 8008c96d4..4a7a3dbec 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKSOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/JWKSOrBuilder.java @@ -1,5 +1,5 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: wso2/discovery/subscription/jwtIssuer.proto +// source: wso2/discovery/subscription/token_issuer.proto package org.wso2.apk.enforcer.discovery.subscription; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuer.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuer.java new file mode 100644 index 000000000..4e6a9578d --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuer.java @@ -0,0 +1,1921 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/token_issuer.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +/** + *
+ * TokenIssuer data model
+ * 
+ * + * Protobuf type {@code wso2.discovery.subscription.TokenIssuer} + */ +public final class TokenIssuer extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.TokenIssuer) + TokenIssuerOrBuilder { +private static final long serialVersionUID = 0L; + // Use TokenIssuer.newBuilder() to construct. + private TokenIssuer(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TokenIssuer() { + eventId_ = ""; + name_ = ""; + organization_ = ""; + issuer_ = ""; + consumerKeyClaim_ = ""; + scopesClaim_ = ""; + environments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new TokenIssuer(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TokenIssuer( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + eventId_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + organization_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + issuer_ = s; + break; + } + case 42: { + org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder subBuilder = null; + if (certificate_ != null) { + subBuilder = certificate_.toBuilder(); + } + certificate_ = input.readMessage(org.wso2.apk.enforcer.discovery.subscription.Certificate.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(certificate_); + certificate_ = subBuilder.buildPartial(); + } + + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + consumerKeyClaim_ = s; + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + + scopesClaim_ = s; + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + claimMapping_ = com.google.protobuf.MapField.newMapField( + ClaimMappingDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000001; + } + com.google.protobuf.MapEntry + claimMapping__ = input.readMessage( + ClaimMappingDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + claimMapping_.getMutableMap().put( + claimMapping__.getKey(), claimMapping__.getValue()); + break; + } + case 74: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + environments_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + environments_.add(s); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) != 0)) { + environments_ = environments_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_TokenIssuer_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 8: + return internalGetClaimMapping(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_TokenIssuer_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.class, org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder.class); + } + + public static final int EVENTID_FIELD_NUMBER = 1; + private volatile java.lang.Object eventId_; + /** + * string eventId = 1; + * @return The eventId. + */ + @java.lang.Override + public java.lang.String getEventId() { + java.lang.Object ref = eventId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventId_ = s; + return s; + } + } + /** + * string eventId = 1; + * @return The bytes for eventId. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getEventIdBytes() { + java.lang.Object ref = eventId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object name_; + /** + * string name = 2; + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 2; + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ORGANIZATION_FIELD_NUMBER = 3; + private volatile java.lang.Object organization_; + /** + * string organization = 3; + * @return The organization. + */ + @java.lang.Override + public java.lang.String getOrganization() { + java.lang.Object ref = organization_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + organization_ = s; + return s; + } + } + /** + * string organization = 3; + * @return The bytes for organization. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getOrganizationBytes() { + java.lang.Object ref = organization_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + organization_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ISSUER_FIELD_NUMBER = 4; + private volatile java.lang.Object issuer_; + /** + * string issuer = 4; + * @return The issuer. + */ + @java.lang.Override + public java.lang.String getIssuer() { + java.lang.Object ref = issuer_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + issuer_ = s; + return s; + } + } + /** + * string issuer = 4; + * @return The bytes for issuer. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getIssuerBytes() { + java.lang.Object ref = issuer_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + issuer_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CERTIFICATE_FIELD_NUMBER = 5; + private org.wso2.apk.enforcer.discovery.subscription.Certificate certificate_; + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + * @return Whether the certificate field is set. + */ + @java.lang.Override + public boolean hasCertificate() { + return certificate_ != null; + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + * @return The certificate. + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.Certificate getCertificate() { + return certificate_ == null ? org.wso2.apk.enforcer.discovery.subscription.Certificate.getDefaultInstance() : certificate_; + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.CertificateOrBuilder getCertificateOrBuilder() { + return getCertificate(); + } + + public static final int CONSUMERKEYCLAIM_FIELD_NUMBER = 6; + private volatile java.lang.Object consumerKeyClaim_; + /** + * string consumerKeyClaim = 6; + * @return The consumerKeyClaim. + */ + @java.lang.Override + public java.lang.String getConsumerKeyClaim() { + java.lang.Object ref = consumerKeyClaim_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + consumerKeyClaim_ = s; + return s; + } + } + /** + * string consumerKeyClaim = 6; + * @return The bytes for consumerKeyClaim. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getConsumerKeyClaimBytes() { + java.lang.Object ref = consumerKeyClaim_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + consumerKeyClaim_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SCOPESCLAIM_FIELD_NUMBER = 7; + private volatile java.lang.Object scopesClaim_; + /** + * string scopesClaim = 7; + * @return The scopesClaim. + */ + @java.lang.Override + public java.lang.String getScopesClaim() { + java.lang.Object ref = scopesClaim_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + scopesClaim_ = s; + return s; + } + } + /** + * string scopesClaim = 7; + * @return The bytes for scopesClaim. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getScopesClaimBytes() { + java.lang.Object ref = scopesClaim_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + scopesClaim_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CLAIMMAPPING_FIELD_NUMBER = 8; + private static final class ClaimMappingDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_TokenIssuer_ClaimMappingEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> claimMapping_; + private com.google.protobuf.MapField + internalGetClaimMapping() { + if (claimMapping_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ClaimMappingDefaultEntryHolder.defaultEntry); + } + return claimMapping_; + } + + public int getClaimMappingCount() { + return internalGetClaimMapping().getMap().size(); + } + /** + * map<string, string> claimMapping = 8; + */ + + @java.lang.Override + public boolean containsClaimMapping( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetClaimMapping().getMap().containsKey(key); + } + /** + * Use {@link #getClaimMappingMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getClaimMapping() { + return getClaimMappingMap(); + } + /** + * map<string, string> claimMapping = 8; + */ + @java.lang.Override + + public java.util.Map getClaimMappingMap() { + return internalGetClaimMapping().getMap(); + } + /** + * map<string, string> claimMapping = 8; + */ + @java.lang.Override + + public java.lang.String getClaimMappingOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetClaimMapping().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> claimMapping = 8; + */ + @java.lang.Override + + public java.lang.String getClaimMappingOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetClaimMapping().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int ENVIRONMENTS_FIELD_NUMBER = 9; + private com.google.protobuf.LazyStringList environments_; + /** + * repeated string environments = 9; + * @return A list containing the environments. + */ + public com.google.protobuf.ProtocolStringList + getEnvironmentsList() { + return environments_; + } + /** + * repeated string environments = 9; + * @return The count of environments. + */ + public int getEnvironmentsCount() { + return environments_.size(); + } + /** + * repeated string environments = 9; + * @param index The index of the element to return. + * @return The environments at the given index. + */ + public java.lang.String getEnvironments(int index) { + return environments_.get(index); + } + /** + * repeated string environments = 9; + * @param index The index of the value to return. + * @return The bytes of the environments at the given index. + */ + public com.google.protobuf.ByteString + getEnvironmentsBytes(int index) { + return environments_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getEventIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, eventId_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); + } + if (!getOrganizationBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, organization_); + } + if (!getIssuerBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, issuer_); + } + if (certificate_ != null) { + output.writeMessage(5, getCertificate()); + } + if (!getConsumerKeyClaimBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, consumerKeyClaim_); + } + if (!getScopesClaimBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, scopesClaim_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetClaimMapping(), + ClaimMappingDefaultEntryHolder.defaultEntry, + 8); + for (int i = 0; i < environments_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, environments_.getRaw(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getEventIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, eventId_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); + } + if (!getOrganizationBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, organization_); + } + if (!getIssuerBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, issuer_); + } + if (certificate_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getCertificate()); + } + if (!getConsumerKeyClaimBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, consumerKeyClaim_); + } + if (!getScopesClaimBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, scopesClaim_); + } + for (java.util.Map.Entry entry + : internalGetClaimMapping().getMap().entrySet()) { + com.google.protobuf.MapEntry + claimMapping__ = ClaimMappingDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, claimMapping__); + } + { + int dataSize = 0; + for (int i = 0; i < environments_.size(); i++) { + dataSize += computeStringSizeNoTag(environments_.getRaw(i)); + } + size += dataSize; + size += 1 * getEnvironmentsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.wso2.apk.enforcer.discovery.subscription.TokenIssuer)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer other = (org.wso2.apk.enforcer.discovery.subscription.TokenIssuer) obj; + + if (!getEventId() + .equals(other.getEventId())) return false; + if (!getName() + .equals(other.getName())) return false; + if (!getOrganization() + .equals(other.getOrganization())) return false; + if (!getIssuer() + .equals(other.getIssuer())) return false; + if (hasCertificate() != other.hasCertificate()) return false; + if (hasCertificate()) { + if (!getCertificate() + .equals(other.getCertificate())) return false; + } + if (!getConsumerKeyClaim() + .equals(other.getConsumerKeyClaim())) return false; + if (!getScopesClaim() + .equals(other.getScopesClaim())) return false; + if (!internalGetClaimMapping().equals( + other.internalGetClaimMapping())) return false; + if (!getEnvironmentsList() + .equals(other.getEnvironmentsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + EVENTID_FIELD_NUMBER; + hash = (53 * hash) + getEventId().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + ORGANIZATION_FIELD_NUMBER; + hash = (53 * hash) + getOrganization().hashCode(); + hash = (37 * hash) + ISSUER_FIELD_NUMBER; + hash = (53 * hash) + getIssuer().hashCode(); + if (hasCertificate()) { + hash = (37 * hash) + CERTIFICATE_FIELD_NUMBER; + hash = (53 * hash) + getCertificate().hashCode(); + } + hash = (37 * hash) + CONSUMERKEYCLAIM_FIELD_NUMBER; + hash = (53 * hash) + getConsumerKeyClaim().hashCode(); + hash = (37 * hash) + SCOPESCLAIM_FIELD_NUMBER; + hash = (53 * hash) + getScopesClaim().hashCode(); + if (!internalGetClaimMapping().getMap().isEmpty()) { + hash = (37 * hash) + CLAIMMAPPING_FIELD_NUMBER; + hash = (53 * hash) + internalGetClaimMapping().hashCode(); + } + if (getEnvironmentsCount() > 0) { + hash = (37 * hash) + ENVIRONMENTS_FIELD_NUMBER; + hash = (53 * hash) + getEnvironmentsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.wso2.apk.enforcer.discovery.subscription.TokenIssuer prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * TokenIssuer data model
+   * 
+ * + * Protobuf type {@code wso2.discovery.subscription.TokenIssuer} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.TokenIssuer) + org.wso2.apk.enforcer.discovery.subscription.TokenIssuerOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_TokenIssuer_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 8: + return internalGetClaimMapping(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 8: + return internalGetMutableClaimMapping(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_TokenIssuer_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.class, org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + eventId_ = ""; + + name_ = ""; + + organization_ = ""; + + issuer_ = ""; + + if (certificateBuilder_ == null) { + certificate_ = null; + } else { + certificate_ = null; + certificateBuilder_ = null; + } + consumerKeyClaim_ = ""; + + scopesClaim_ = ""; + + internalGetMutableClaimMapping().clear(); + environments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuerProto.internal_static_wso2_discovery_subscription_TokenIssuer_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuer getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuer build() { + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuer buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer result = new org.wso2.apk.enforcer.discovery.subscription.TokenIssuer(this); + int from_bitField0_ = bitField0_; + result.eventId_ = eventId_; + result.name_ = name_; + result.organization_ = organization_; + result.issuer_ = issuer_; + if (certificateBuilder_ == null) { + result.certificate_ = certificate_; + } else { + result.certificate_ = certificateBuilder_.build(); + } + result.consumerKeyClaim_ = consumerKeyClaim_; + result.scopesClaim_ = scopesClaim_; + result.claimMapping_ = internalGetClaimMapping(); + result.claimMapping_.makeImmutable(); + if (((bitField0_ & 0x00000002) != 0)) { + environments_ = environments_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.environments_ = environments_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.wso2.apk.enforcer.discovery.subscription.TokenIssuer) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.TokenIssuer)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.TokenIssuer other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.TokenIssuer.getDefaultInstance()) return this; + if (!other.getEventId().isEmpty()) { + eventId_ = other.eventId_; + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getOrganization().isEmpty()) { + organization_ = other.organization_; + onChanged(); + } + if (!other.getIssuer().isEmpty()) { + issuer_ = other.issuer_; + onChanged(); + } + if (other.hasCertificate()) { + mergeCertificate(other.getCertificate()); + } + if (!other.getConsumerKeyClaim().isEmpty()) { + consumerKeyClaim_ = other.consumerKeyClaim_; + onChanged(); + } + if (!other.getScopesClaim().isEmpty()) { + scopesClaim_ = other.scopesClaim_; + onChanged(); + } + internalGetMutableClaimMapping().mergeFrom( + other.internalGetClaimMapping()); + if (!other.environments_.isEmpty()) { + if (environments_.isEmpty()) { + environments_ = other.environments_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureEnvironmentsIsMutable(); + environments_.addAll(other.environments_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.wso2.apk.enforcer.discovery.subscription.TokenIssuer parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.TokenIssuer) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object eventId_ = ""; + /** + * string eventId = 1; + * @return The eventId. + */ + public java.lang.String getEventId() { + java.lang.Object ref = eventId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string eventId = 1; + * @return The bytes for eventId. + */ + public com.google.protobuf.ByteString + getEventIdBytes() { + java.lang.Object ref = eventId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string eventId = 1; + * @param value The eventId to set. + * @return This builder for chaining. + */ + public Builder setEventId( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + eventId_ = value; + onChanged(); + return this; + } + /** + * string eventId = 1; + * @return This builder for chaining. + */ + public Builder clearEventId() { + + eventId_ = getDefaultInstance().getEventId(); + onChanged(); + return this; + } + /** + * string eventId = 1; + * @param value The bytes for eventId to set. + * @return This builder for chaining. + */ + public Builder setEventIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + eventId_ = value; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 2; + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 2; + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 2; + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 2; + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 2; + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object organization_ = ""; + /** + * string organization = 3; + * @return The organization. + */ + public java.lang.String getOrganization() { + java.lang.Object ref = organization_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + organization_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string organization = 3; + * @return The bytes for organization. + */ + public com.google.protobuf.ByteString + getOrganizationBytes() { + java.lang.Object ref = organization_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + organization_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string organization = 3; + * @param value The organization to set. + * @return This builder for chaining. + */ + public Builder setOrganization( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + organization_ = value; + onChanged(); + return this; + } + /** + * string organization = 3; + * @return This builder for chaining. + */ + public Builder clearOrganization() { + + organization_ = getDefaultInstance().getOrganization(); + onChanged(); + return this; + } + /** + * string organization = 3; + * @param value The bytes for organization to set. + * @return This builder for chaining. + */ + public Builder setOrganizationBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + organization_ = value; + onChanged(); + return this; + } + + private java.lang.Object issuer_ = ""; + /** + * string issuer = 4; + * @return The issuer. + */ + public java.lang.String getIssuer() { + java.lang.Object ref = issuer_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + issuer_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string issuer = 4; + * @return The bytes for issuer. + */ + public com.google.protobuf.ByteString + getIssuerBytes() { + java.lang.Object ref = issuer_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + issuer_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string issuer = 4; + * @param value The issuer to set. + * @return This builder for chaining. + */ + public Builder setIssuer( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + issuer_ = value; + onChanged(); + return this; + } + /** + * string issuer = 4; + * @return This builder for chaining. + */ + public Builder clearIssuer() { + + issuer_ = getDefaultInstance().getIssuer(); + onChanged(); + return this; + } + /** + * string issuer = 4; + * @param value The bytes for issuer to set. + * @return This builder for chaining. + */ + public Builder setIssuerBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + issuer_ = value; + onChanged(); + return this; + } + + private org.wso2.apk.enforcer.discovery.subscription.Certificate certificate_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.Certificate, org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder, org.wso2.apk.enforcer.discovery.subscription.CertificateOrBuilder> certificateBuilder_; + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + * @return Whether the certificate field is set. + */ + public boolean hasCertificate() { + return certificateBuilder_ != null || certificate_ != null; + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + * @return The certificate. + */ + public org.wso2.apk.enforcer.discovery.subscription.Certificate getCertificate() { + if (certificateBuilder_ == null) { + return certificate_ == null ? org.wso2.apk.enforcer.discovery.subscription.Certificate.getDefaultInstance() : certificate_; + } else { + return certificateBuilder_.getMessage(); + } + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + public Builder setCertificate(org.wso2.apk.enforcer.discovery.subscription.Certificate value) { + if (certificateBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + certificate_ = value; + onChanged(); + } else { + certificateBuilder_.setMessage(value); + } + + return this; + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + public Builder setCertificate( + org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder builderForValue) { + if (certificateBuilder_ == null) { + certificate_ = builderForValue.build(); + onChanged(); + } else { + certificateBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + public Builder mergeCertificate(org.wso2.apk.enforcer.discovery.subscription.Certificate value) { + if (certificateBuilder_ == null) { + if (certificate_ != null) { + certificate_ = + org.wso2.apk.enforcer.discovery.subscription.Certificate.newBuilder(certificate_).mergeFrom(value).buildPartial(); + } else { + certificate_ = value; + } + onChanged(); + } else { + certificateBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + public Builder clearCertificate() { + if (certificateBuilder_ == null) { + certificate_ = null; + onChanged(); + } else { + certificate_ = null; + certificateBuilder_ = null; + } + + return this; + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + public org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder getCertificateBuilder() { + + onChanged(); + return getCertificateFieldBuilder().getBuilder(); + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + public org.wso2.apk.enforcer.discovery.subscription.CertificateOrBuilder getCertificateOrBuilder() { + if (certificateBuilder_ != null) { + return certificateBuilder_.getMessageOrBuilder(); + } else { + return certificate_ == null ? + org.wso2.apk.enforcer.discovery.subscription.Certificate.getDefaultInstance() : certificate_; + } + } + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.Certificate, org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder, org.wso2.apk.enforcer.discovery.subscription.CertificateOrBuilder> + getCertificateFieldBuilder() { + if (certificateBuilder_ == null) { + certificateBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.Certificate, org.wso2.apk.enforcer.discovery.subscription.Certificate.Builder, org.wso2.apk.enforcer.discovery.subscription.CertificateOrBuilder>( + getCertificate(), + getParentForChildren(), + isClean()); + certificate_ = null; + } + return certificateBuilder_; + } + + private java.lang.Object consumerKeyClaim_ = ""; + /** + * string consumerKeyClaim = 6; + * @return The consumerKeyClaim. + */ + public java.lang.String getConsumerKeyClaim() { + java.lang.Object ref = consumerKeyClaim_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + consumerKeyClaim_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string consumerKeyClaim = 6; + * @return The bytes for consumerKeyClaim. + */ + public com.google.protobuf.ByteString + getConsumerKeyClaimBytes() { + java.lang.Object ref = consumerKeyClaim_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + consumerKeyClaim_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string consumerKeyClaim = 6; + * @param value The consumerKeyClaim to set. + * @return This builder for chaining. + */ + public Builder setConsumerKeyClaim( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + consumerKeyClaim_ = value; + onChanged(); + return this; + } + /** + * string consumerKeyClaim = 6; + * @return This builder for chaining. + */ + public Builder clearConsumerKeyClaim() { + + consumerKeyClaim_ = getDefaultInstance().getConsumerKeyClaim(); + onChanged(); + return this; + } + /** + * string consumerKeyClaim = 6; + * @param value The bytes for consumerKeyClaim to set. + * @return This builder for chaining. + */ + public Builder setConsumerKeyClaimBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + consumerKeyClaim_ = value; + onChanged(); + return this; + } + + private java.lang.Object scopesClaim_ = ""; + /** + * string scopesClaim = 7; + * @return The scopesClaim. + */ + public java.lang.String getScopesClaim() { + java.lang.Object ref = scopesClaim_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + scopesClaim_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string scopesClaim = 7; + * @return The bytes for scopesClaim. + */ + public com.google.protobuf.ByteString + getScopesClaimBytes() { + java.lang.Object ref = scopesClaim_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + scopesClaim_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string scopesClaim = 7; + * @param value The scopesClaim to set. + * @return This builder for chaining. + */ + public Builder setScopesClaim( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + scopesClaim_ = value; + onChanged(); + return this; + } + /** + * string scopesClaim = 7; + * @return This builder for chaining. + */ + public Builder clearScopesClaim() { + + scopesClaim_ = getDefaultInstance().getScopesClaim(); + onChanged(); + return this; + } + /** + * string scopesClaim = 7; + * @param value The bytes for scopesClaim to set. + * @return This builder for chaining. + */ + public Builder setScopesClaimBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + scopesClaim_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> claimMapping_; + private com.google.protobuf.MapField + internalGetClaimMapping() { + if (claimMapping_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ClaimMappingDefaultEntryHolder.defaultEntry); + } + return claimMapping_; + } + private com.google.protobuf.MapField + internalGetMutableClaimMapping() { + onChanged();; + if (claimMapping_ == null) { + claimMapping_ = com.google.protobuf.MapField.newMapField( + ClaimMappingDefaultEntryHolder.defaultEntry); + } + if (!claimMapping_.isMutable()) { + claimMapping_ = claimMapping_.copy(); + } + return claimMapping_; + } + + public int getClaimMappingCount() { + return internalGetClaimMapping().getMap().size(); + } + /** + * map<string, string> claimMapping = 8; + */ + + @java.lang.Override + public boolean containsClaimMapping( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetClaimMapping().getMap().containsKey(key); + } + /** + * Use {@link #getClaimMappingMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getClaimMapping() { + return getClaimMappingMap(); + } + /** + * map<string, string> claimMapping = 8; + */ + @java.lang.Override + + public java.util.Map getClaimMappingMap() { + return internalGetClaimMapping().getMap(); + } + /** + * map<string, string> claimMapping = 8; + */ + @java.lang.Override + + public java.lang.String getClaimMappingOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetClaimMapping().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> claimMapping = 8; + */ + @java.lang.Override + + public java.lang.String getClaimMappingOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetClaimMapping().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearClaimMapping() { + internalGetMutableClaimMapping().getMutableMap() + .clear(); + return this; + } + /** + * map<string, string> claimMapping = 8; + */ + + public Builder removeClaimMapping( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableClaimMapping().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableClaimMapping() { + return internalGetMutableClaimMapping().getMutableMap(); + } + /** + * map<string, string> claimMapping = 8; + */ + public Builder putClaimMapping( + java.lang.String key, + java.lang.String value) { + if (key == null) { throw new java.lang.NullPointerException(); } + if (value == null) { throw new java.lang.NullPointerException(); } + internalGetMutableClaimMapping().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, string> claimMapping = 8; + */ + + public Builder putAllClaimMapping( + java.util.Map values) { + internalGetMutableClaimMapping().getMutableMap() + .putAll(values); + return this; + } + + private com.google.protobuf.LazyStringList environments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureEnvironmentsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + environments_ = new com.google.protobuf.LazyStringArrayList(environments_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated string environments = 9; + * @return A list containing the environments. + */ + public com.google.protobuf.ProtocolStringList + getEnvironmentsList() { + return environments_.getUnmodifiableView(); + } + /** + * repeated string environments = 9; + * @return The count of environments. + */ + public int getEnvironmentsCount() { + return environments_.size(); + } + /** + * repeated string environments = 9; + * @param index The index of the element to return. + * @return The environments at the given index. + */ + public java.lang.String getEnvironments(int index) { + return environments_.get(index); + } + /** + * repeated string environments = 9; + * @param index The index of the value to return. + * @return The bytes of the environments at the given index. + */ + public com.google.protobuf.ByteString + getEnvironmentsBytes(int index) { + return environments_.getByteString(index); + } + /** + * repeated string environments = 9; + * @param index The index to set the value at. + * @param value The environments to set. + * @return This builder for chaining. + */ + public Builder setEnvironments( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvironmentsIsMutable(); + environments_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string environments = 9; + * @param value The environments to add. + * @return This builder for chaining. + */ + public Builder addEnvironments( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvironmentsIsMutable(); + environments_.add(value); + onChanged(); + return this; + } + /** + * repeated string environments = 9; + * @param values The environments to add. + * @return This builder for chaining. + */ + public Builder addAllEnvironments( + java.lang.Iterable values) { + ensureEnvironmentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, environments_); + onChanged(); + return this; + } + /** + * repeated string environments = 9; + * @return This builder for chaining. + */ + public Builder clearEnvironments() { + environments_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * repeated string environments = 9; + * @param value The bytes of the environments to add. + * @return This builder for chaining. + */ + public Builder addEnvironmentsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureEnvironmentsIsMutable(); + environments_.add(value); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:wso2.discovery.subscription.TokenIssuer) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.TokenIssuer) + private static final org.wso2.apk.enforcer.discovery.subscription.TokenIssuer DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.TokenIssuer(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.TokenIssuer getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TokenIssuer parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TokenIssuer(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.TokenIssuer getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerOrBuilder.java new file mode 100644 index 000000000..1d2178635 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerOrBuilder.java @@ -0,0 +1,155 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/token_issuer.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface TokenIssuerOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.TokenIssuer) + com.google.protobuf.MessageOrBuilder { + + /** + * string eventId = 1; + * @return The eventId. + */ + java.lang.String getEventId(); + /** + * string eventId = 1; + * @return The bytes for eventId. + */ + com.google.protobuf.ByteString + getEventIdBytes(); + + /** + * string name = 2; + * @return The name. + */ + java.lang.String getName(); + /** + * string name = 2; + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * string organization = 3; + * @return The organization. + */ + java.lang.String getOrganization(); + /** + * string organization = 3; + * @return The bytes for organization. + */ + com.google.protobuf.ByteString + getOrganizationBytes(); + + /** + * string issuer = 4; + * @return The issuer. + */ + java.lang.String getIssuer(); + /** + * string issuer = 4; + * @return The bytes for issuer. + */ + com.google.protobuf.ByteString + getIssuerBytes(); + + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + * @return Whether the certificate field is set. + */ + boolean hasCertificate(); + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + * @return The certificate. + */ + org.wso2.apk.enforcer.discovery.subscription.Certificate getCertificate(); + /** + * .wso2.discovery.subscription.Certificate certificate = 5; + */ + org.wso2.apk.enforcer.discovery.subscription.CertificateOrBuilder getCertificateOrBuilder(); + + /** + * string consumerKeyClaim = 6; + * @return The consumerKeyClaim. + */ + java.lang.String getConsumerKeyClaim(); + /** + * string consumerKeyClaim = 6; + * @return The bytes for consumerKeyClaim. + */ + com.google.protobuf.ByteString + getConsumerKeyClaimBytes(); + + /** + * string scopesClaim = 7; + * @return The scopesClaim. + */ + java.lang.String getScopesClaim(); + /** + * string scopesClaim = 7; + * @return The bytes for scopesClaim. + */ + com.google.protobuf.ByteString + getScopesClaimBytes(); + + /** + * map<string, string> claimMapping = 8; + */ + int getClaimMappingCount(); + /** + * map<string, string> claimMapping = 8; + */ + boolean containsClaimMapping( + java.lang.String key); + /** + * Use {@link #getClaimMappingMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getClaimMapping(); + /** + * map<string, string> claimMapping = 8; + */ + java.util.Map + getClaimMappingMap(); + /** + * map<string, string> claimMapping = 8; + */ + + java.lang.String getClaimMappingOrDefault( + java.lang.String key, + java.lang.String defaultValue); + /** + * map<string, string> claimMapping = 8; + */ + + java.lang.String getClaimMappingOrThrow( + java.lang.String key); + + /** + * repeated string environments = 9; + * @return A list containing the environments. + */ + java.util.List + getEnvironmentsList(); + /** + * repeated string environments = 9; + * @return The count of environments. + */ + int getEnvironmentsCount(); + /** + * repeated string environments = 9; + * @param index The index of the element to return. + * @return The environments at the given index. + */ + java.lang.String getEnvironments(int index); + /** + * repeated string environments = 9; + * @param index The index of the value to return. + * @return The bytes of the environments at the given index. + */ + com.google.protobuf.ByteString + getEnvironmentsBytes(int index); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerProto.java new file mode 100644 index 000000000..3722fc8e9 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/TokenIssuerProto.java @@ -0,0 +1,96 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/token_issuer.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public final class TokenIssuerProto { + private TokenIssuerProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_subscription_TokenIssuer_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_TokenIssuer_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_subscription_TokenIssuer_ClaimMappingEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_TokenIssuer_ClaimMappingEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_subscription_Certificate_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_Certificate_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_subscription_JWKS_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_JWKS_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n.wso2/discovery/subscription/token_issu" + + "er.proto\022\033wso2.discovery.subscription\"\335\002" + + "\n\013TokenIssuer\022\017\n\007eventId\030\001 \001(\t\022\014\n\004name\030\002" + + " \001(\t\022\024\n\014organization\030\003 \001(\t\022\016\n\006issuer\030\004 \001" + + "(\t\022=\n\013certificate\030\005 \001(\0132(.wso2.discovery" + + ".subscription.Certificate\022\030\n\020consumerKey" + + "Claim\030\006 \001(\t\022\023\n\013scopesClaim\030\007 \001(\t\022P\n\014clai" + + "mMapping\030\010 \003(\0132:.wso2.discovery.subscrip" + + "tion.TokenIssuer.ClaimMappingEntry\022\024\n\014en" + + "vironments\030\t \003(\t\0323\n\021ClaimMappingEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"S\n\013Certifi" + + "cate\022\023\n\013certificate\030\001 \001(\t\022/\n\004jwks\030\002 \001(\0132" + + "!.wso2.discovery.subscription.JWKS\" \n\004JW" + + "KS\022\013\n\003url\030\001 \001(\t\022\013\n\003tls\030\002 \001(\tB\224\001\n,org.wso" + + "2.apk.enforcer.discovery.subscriptionB\020T" + + "okenIssuerProtoP\001ZPgithub.com/wso2/apk/c" + + "ommon-go-libs/pkg/discovery/api/wso2/dis" + + "covery/subscriptionb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_wso2_discovery_subscription_TokenIssuer_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_wso2_discovery_subscription_TokenIssuer_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_TokenIssuer_descriptor, + new java.lang.String[] { "EventId", "Name", "Organization", "Issuer", "Certificate", "ConsumerKeyClaim", "ScopesClaim", "ClaimMapping", "Environments", }); + internal_static_wso2_discovery_subscription_TokenIssuer_ClaimMappingEntry_descriptor = + internal_static_wso2_discovery_subscription_TokenIssuer_descriptor.getNestedTypes().get(0); + internal_static_wso2_discovery_subscription_TokenIssuer_ClaimMappingEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_TokenIssuer_ClaimMappingEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_wso2_discovery_subscription_Certificate_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_wso2_discovery_subscription_Certificate_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_Certificate_descriptor, + new java.lang.String[] { "Certificate", "Jwks", }); + internal_static_wso2_discovery_subscription_JWKS_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_wso2_discovery_subscription_JWKS_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_JWKS_descriptor, + new java.lang.String[] { "Url", "Tls", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/EventingGrpcClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/EventingGrpcClient.java index 2083cc141..ccd275090 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/EventingGrpcClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/EventingGrpcClient.java @@ -21,7 +21,6 @@ import io.grpc.ConnectivityState; import io.grpc.ManagedChannel; import io.grpc.Metadata; -import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder; import io.grpc.stub.MetadataUtils; import io.grpc.stub.StreamObserver; import org.apache.logging.log4j.LogManager; @@ -168,6 +167,16 @@ private void handleNotificationEvent(Event event) { case "APPLICATION_DELETED": SubscriptionDataStoreUtil.removeApplication(event.getApplication()); break; + case "TOKEN_ISSUER_CREATED": + SubscriptionDataStoreUtil.addTokenIssuer(event.getTokenIssuer()); + break; + case "TOKEN_ISSUER_UPDATED": + SubscriptionDataStoreUtil.deleteTokenIssuer(event.getTokenIssuer()); + SubscriptionDataStoreUtil.addTokenIssuer(event.getTokenIssuer()); + break; + case "TOKEN_ISSUER_DELETED": + SubscriptionDataStoreUtil.deleteTokenIssuer(event.getTokenIssuer()); + break; default: logger.error("Unknown event type received from the server"); break; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedCertificate.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedCertificate.java new file mode 100644 index 000000000..5266adcf3 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedCertificate.java @@ -0,0 +1,27 @@ +package org.wso2.apk.enforcer.subscription; + +public class ResolvedCertificate { + + private String resolvedCertificate; + private String[] allowedSANs; + + public String getResolvedCertificate() { + + return resolvedCertificate; + } + + public void setResolvedCertificate(String resolvedCertificate) { + + this.resolvedCertificate = resolvedCertificate; + } + + public String[] getAllowedSANs() { + + return allowedSANs; + } + + public void setAllowedSANs(String[] allowedSANs) { + + this.allowedSANs = allowedSANs; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedJWKS.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedJWKS.java new file mode 100644 index 000000000..b4795ee8b --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/ResolvedJWKS.java @@ -0,0 +1,27 @@ +package org.wso2.apk.enforcer.subscription; + +public class ResolvedJWKS { + + private String url; + private ResolvedCertificate tls; + + public String getUrl() { + + return url; + } + + public void setUrl(String url) { + + this.url = url; + } + + public ResolvedCertificate getTls() { + + return tls; + } + + public void setTls(ResolvedCertificate tls) { + + this.tls = tls; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SignatureValidationRestDto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SignatureValidationRestDto.java new file mode 100644 index 000000000..9d5ff162b --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SignatureValidationRestDto.java @@ -0,0 +1,27 @@ +package org.wso2.apk.enforcer.subscription; + +public class SignatureValidationRestDto { + + private ResolvedJWKS jwks; + private ResolvedCertificate certificate; + + public ResolvedJWKS getJwks() { + + return jwks; + } + + public void setJwks(ResolvedJWKS jwks) { + + this.jwks = jwks; + } + + public ResolvedCertificate getCertificate() { + + return certificate; + } + + public void setCertificate(ResolvedCertificate certificate) { + + this.certificate = certificate; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStore.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStore.java index 33be66ea2..478d450f2 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStore.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStore.java @@ -19,6 +19,7 @@ package org.wso2.apk.enforcer.subscription; import org.wso2.apk.enforcer.discovery.subscription.JWTIssuer; +import org.wso2.apk.enforcer.discovery.subscription.TokenIssuer; import org.wso2.apk.enforcer.models.*; import org.wso2.apk.enforcer.security.jwt.validator.JWTValidator; @@ -120,4 +121,9 @@ ApplicationKeyMapping getMatchingApplicationKeyMapping(String applicationIdentif public void addApplicationMappings(List applicationMappingList); + void addJWTIssuer(TokenIssuer tokenIssuer); + + void removeTokenIssuer(TokenIssuer tokenIssuer); + + void addTokenIssuers(List tokenIssuers); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreImpl.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreImpl.java index a326faaf3..a40b779a1 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreImpl.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreImpl.java @@ -1,229 +1,180 @@ -/* - * Copyright (c) 2020, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 LLC. licenses this file to you 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.wso2.apk.enforcer.subscription; - -import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.wso2.apk.enforcer.commons.dto.ClaimMappingDto; -import org.wso2.apk.enforcer.commons.dto.JWKSConfigurationDTO; -import org.wso2.apk.enforcer.commons.exception.EnforcerException; -import org.wso2.apk.enforcer.config.dto.ExtendedTokenIssuerDto; -import org.wso2.apk.enforcer.constants.Constants; -import org.wso2.apk.enforcer.discovery.subscription.Certificate; -import org.wso2.apk.enforcer.discovery.subscription.JWTIssuer; -import org.wso2.apk.enforcer.models.Application; -import org.wso2.apk.enforcer.models.ApplicationKeyMapping; -import org.wso2.apk.enforcer.models.ApplicationMapping; -import org.wso2.apk.enforcer.models.SubscribedAPI; -import org.wso2.apk.enforcer.models.Subscription; -import org.wso2.apk.enforcer.security.jwt.validator.JWTValidator; -import org.wso2.apk.enforcer.util.TLSUtils; - -import java.io.IOException; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Implementation of the subscription data store. - */ -public class SubscriptionDataStoreImpl implements SubscriptionDataStore { - - private static final Logger log = LogManager.getLogger(SubscriptionDataStoreImpl.class); - private static final SubscriptionDataStoreImpl instance = new SubscriptionDataStoreImpl(); - - public static final String DELEM_PERIOD = ":"; - - // Maps for keeping Subscription related details. - private Map applicationKeyMappingMap = new ConcurrentHashMap<>(); - private Map applicationMappingMap = new ConcurrentHashMap<>(); - private Map applicationMap = new ConcurrentHashMap<>(); - private Map subscriptionMap = new ConcurrentHashMap<>(); - - private Map jwtValidatorMap = new ConcurrentHashMap<>(); - - SubscriptionDataStoreImpl() { + /* + * Copyright (c) 2020, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you 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.wso2.apk.enforcer.subscription; + + import org.apache.commons.lang3.StringUtils; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + import org.wso2.apk.enforcer.commons.dto.ClaimMappingDto; + import org.wso2.apk.enforcer.commons.dto.JWKSConfigurationDTO; + import org.wso2.apk.enforcer.commons.exception.EnforcerException; + import org.wso2.apk.enforcer.config.dto.ExtendedTokenIssuerDto; + import org.wso2.apk.enforcer.constants.Constants; + import org.wso2.apk.enforcer.discovery.subscription.Certificate; + import org.wso2.apk.enforcer.discovery.subscription.JWTIssuer; + import org.wso2.apk.enforcer.discovery.subscription.TokenIssuer; + import org.wso2.apk.enforcer.models.Application; + import org.wso2.apk.enforcer.models.ApplicationKeyMapping; + import org.wso2.apk.enforcer.models.ApplicationMapping; + import org.wso2.apk.enforcer.models.SubscribedAPI; + import org.wso2.apk.enforcer.models.Subscription; + import org.wso2.apk.enforcer.security.jwt.validator.JWTValidator; + import org.wso2.apk.enforcer.util.TLSUtils; + + import java.io.IOException; + import java.security.cert.CertificateException; + import java.util.ArrayList; + import java.util.Arrays; + import java.util.HashMap; + import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Set; + import java.util.concurrent.ConcurrentHashMap; + + /** + * Implementation of the subscription data store. + */ + public class SubscriptionDataStoreImpl implements SubscriptionDataStore { + + private static final Logger log = LogManager.getLogger(SubscriptionDataStoreImpl.class); + private static final SubscriptionDataStoreImpl instance = new SubscriptionDataStoreImpl(); + + public static final String DELEM_PERIOD = ":"; + + // Maps for keeping Subscription related details. + private Map applicationKeyMappingMap = new ConcurrentHashMap<>(); + private Map applicationMappingMap = new ConcurrentHashMap<>(); + private Map applicationMap = new ConcurrentHashMap<>(); + private Map subscriptionMap = new ConcurrentHashMap<>(); + + private Map jwtValidatorMap = new ConcurrentHashMap<>(); + + SubscriptionDataStoreImpl() { - } - - public static SubscriptionDataStoreImpl getInstance() { - - return instance; - } - - @Override - public Application getApplicationById(String appUUID) { - - return applicationMap.get(appUUID); - } - - @Override - public Subscription getSubscriptionById(String appId, String apiId) { - - return subscriptionMap.get(SubscriptionDataStoreUtil.getSubscriptionCacheKey(appId, apiId)); - } - - public void addSubscriptions(List subscriptionList) { - - Map newSubscriptionMap = new ConcurrentHashMap<>(); - - for (SubscriptionDto subscription : subscriptionList) { - SubscribedAPI subscribedAPI = new SubscribedAPI(); - subscribedAPI.setName(subscription.getSubscribedApi().getName()); - subscribedAPI.setVersion(subscription.getSubscribedApi().getVersion()); - - Subscription newSubscription = new Subscription(); - newSubscription.setSubscriptionId(subscription.getUuid()); - newSubscription.setSubscriptionStatus(subscription.getSubStatus()); - newSubscription.setOrganization(subscription.getOrganization()); - newSubscription.setSubscribedApi(subscribedAPI); - newSubscriptionMap.put(newSubscription.getCacheKey(), newSubscription); } - if (log.isDebugEnabled()) { - log.debug("Total Subscriptions in new cache: {}", newSubscriptionMap.size()); + public static SubscriptionDataStoreImpl getInstance() { + + return instance; } - this.subscriptionMap = newSubscriptionMap; - } - public void addApplications(List applicationList) { + @Override + public Application getApplicationById(String appUUID) { - Map newApplicationMap = new ConcurrentHashMap<>(); + return applicationMap.get(appUUID); + } - for (ApplicationDto application : applicationList) { - Application newApplication = new Application(); - newApplication.setUUID(application.getUuid()); - newApplication.setName(application.getName()); - newApplication.setOwner(application.getOwner()); - application.getAttributes().forEach(newApplication::addAttribute); + @Override + public Subscription getSubscriptionById(String appId, String apiId) { - newApplicationMap.put(newApplication.getCacheKey(), newApplication); + return subscriptionMap.get(SubscriptionDataStoreUtil.getSubscriptionCacheKey(appId, apiId)); } - if (log.isDebugEnabled()) { - log.debug("Total Applications in new cache: {}", newApplicationMap.size()); - } - this.applicationMap = newApplicationMap; - } - public void addApplicationKeyMappings(List applicationKeyMappingList) { + public void addSubscriptions(List subscriptionList) { - Map newApplicationKeyMappingMap = new ConcurrentHashMap<>(); + Map newSubscriptionMap = new ConcurrentHashMap<>(); - for (ApplicationKeyMappingDTO applicationKeyMapping : applicationKeyMappingList) { - ApplicationKeyMapping mapping = new ApplicationKeyMapping(); - mapping.setApplicationUUID(applicationKeyMapping.getApplicationUUID()); - mapping.setSecurityScheme(applicationKeyMapping.getSecurityScheme()); - mapping.setApplicationIdentifier(applicationKeyMapping.getApplicationIdentifier()); - mapping.setKeyType(applicationKeyMapping.getKeyType()); - mapping.setEnvId(applicationKeyMapping.getEnvID()); - newApplicationKeyMappingMap.put(mapping.getCacheKey(), mapping); - } - if (log.isDebugEnabled()) { - log.debug("Total Application Key Mappings in new cache: {}", newApplicationKeyMappingMap.size()); - } - this.applicationKeyMappingMap = newApplicationKeyMappingMap; - } + for (SubscriptionDto subscription : subscriptionList) { + SubscribedAPI subscribedAPI = new SubscribedAPI(); + subscribedAPI.setName(subscription.getSubscribedApi().getName()); + subscribedAPI.setVersion(subscription.getSubscribedApi().getVersion()); - public void addApplicationMappings(List applicationMappingList) { + Subscription newSubscription = new Subscription(); + newSubscription.setSubscriptionId(subscription.getUuid()); + newSubscription.setSubscriptionStatus(subscription.getSubStatus()); + newSubscription.setOrganization(subscription.getOrganization()); + newSubscription.setSubscribedApi(subscribedAPI); + newSubscriptionMap.put(newSubscription.getCacheKey(), newSubscription); + } - Map newApplicationMappingMap = new ConcurrentHashMap<>(); - for (ApplicationMappingDto applicationMapping : applicationMappingList) { - ApplicationMapping appMapping = new ApplicationMapping(); - appMapping.setUuid(applicationMapping.getUuid()); - appMapping.setApplicationUUID(applicationMapping.getApplicationRef()); - appMapping.setSubscriptionUUID(applicationMapping.getSubscriptionRef()); - appMapping.setOrganization(applicationMapping.getOrganizationId()); - newApplicationMappingMap.put(appMapping.getCacheKey(), appMapping); - } - if (log.isDebugEnabled()) { - log.debug("Total Application Mappings in new cache: {}", newApplicationMappingMap.size()); + if (log.isDebugEnabled()) { + log.debug("Total Subscriptions in new cache: {}", newSubscriptionMap.size()); + } + this.subscriptionMap = newSubscriptionMap; } - this.applicationMappingMap = newApplicationMappingMap; - } - @Override - public ApplicationKeyMapping getMatchingApplicationKeyMapping(String applicationIdentifier, String keyType, - String securityScheme, String envType) { + public void addApplications(List applicationList) { - String cacheKey = SubscriptionDataStoreUtil.getApplicationKeyMappingCacheKey(applicationIdentifier, keyType, - securityScheme, envType); - return applicationKeyMappingMap.get(cacheKey); - } + Map newApplicationMap = new ConcurrentHashMap<>(); - @Override - public Set getMatchingApplicationMappings(String uuid) { + for (ApplicationDto application : applicationList) { + Application newApplication = new Application(); + newApplication.setUUID(application.getUuid()); + newApplication.setName(application.getName()); + newApplication.setOwner(application.getOwner()); + application.getAttributes().forEach(newApplication::addAttribute); - Set applicationMappings = new HashSet<>(); - if (StringUtils.isNotEmpty(uuid)) { - for (ApplicationMapping applicationMapping : applicationMappingMap.values()) { - if (applicationMapping.getApplicationUUID().equals(uuid)) { - applicationMappings.add(applicationMapping); - } + newApplicationMap.put(newApplication.getCacheKey(), newApplication); } + if (log.isDebugEnabled()) { + log.debug("Total Applications in new cache: {}", newApplicationMap.size()); + } + this.applicationMap = newApplicationMap; } - return applicationMappings; - } - @Override - public Application getMatchingApplication(String uuid) { + public void addApplicationKeyMappings(List applicationKeyMappingList) { - for (Application application : applicationMap.values()) { - if (StringUtils.isNotEmpty(uuid)) { - if (application.getUUID().equals(uuid)) { - return application; - } + Map newApplicationKeyMappingMap = new ConcurrentHashMap<>(); + + for (ApplicationKeyMappingDTO applicationKeyMapping : applicationKeyMappingList) { + ApplicationKeyMapping mapping = new ApplicationKeyMapping(); + mapping.setApplicationUUID(applicationKeyMapping.getApplicationUUID()); + mapping.setSecurityScheme(applicationKeyMapping.getSecurityScheme()); + mapping.setApplicationIdentifier(applicationKeyMapping.getApplicationIdentifier()); + mapping.setKeyType(applicationKeyMapping.getKeyType()); + mapping.setEnvId(applicationKeyMapping.getEnvID()); + newApplicationKeyMappingMap.put(mapping.getCacheKey(), mapping); } + if (log.isDebugEnabled()) { + log.debug("Total Application Key Mappings in new cache: {}", newApplicationKeyMappingMap.size()); + } + this.applicationKeyMappingMap = newApplicationKeyMappingMap; } - return null; - } - @Override - public Subscription getMatchingSubscription(String uuid) { + public void addApplicationMappings(List applicationMappingList) { - for (Subscription subscription : subscriptionMap.values()) { - if (StringUtils.isNotEmpty(uuid)) { - if (subscription.getSubscriptionId().equals(uuid)) { - return subscription; - } + Map newApplicationMappingMap = new ConcurrentHashMap<>(); + for (ApplicationMappingDto applicationMapping : applicationMappingList) { + ApplicationMapping appMapping = new ApplicationMapping(); + appMapping.setUuid(applicationMapping.getUuid()); + appMapping.setApplicationUUID(applicationMapping.getApplicationRef()); + appMapping.setSubscriptionUUID(applicationMapping.getSubscriptionRef()); + appMapping.setOrganization(applicationMapping.getOrganizationId()); + newApplicationMappingMap.put(appMapping.getCacheKey(), appMapping); + } + if (log.isDebugEnabled()) { + log.debug("Total Application Mappings in new cache: {}", newApplicationMappingMap.size()); } + this.applicationMappingMap = newApplicationMappingMap; } - return null; - } - @Override - public void addJWTIssuers(List jwtIssuers) { + @Override + public void addJWTIssuer(TokenIssuer tokenIssuer) { - Map jwtValidatorMap = new ConcurrentHashMap<>(); - for (JWTIssuer jwtIssuer : jwtIssuers) { try { - ExtendedTokenIssuerDto tokenIssuerDto = new ExtendedTokenIssuerDto(jwtIssuer.getIssuer()); - tokenIssuerDto.setName(jwtIssuer.getName()); - tokenIssuerDto.setConsumerKeyClaim(jwtIssuer.getConsumerKeyClaim()); - tokenIssuerDto.setScopesClaim(jwtIssuer.getScopesClaim()); - Certificate certificate = jwtIssuer.getCertificate(); + ExtendedTokenIssuerDto tokenIssuerDto = new ExtendedTokenIssuerDto(tokenIssuer.getIssuer()); + tokenIssuerDto.setName(tokenIssuer.getName()); + tokenIssuerDto.setConsumerKeyClaim(tokenIssuer.getConsumerKeyClaim()); + tokenIssuerDto.setScopesClaim(tokenIssuer.getScopesClaim()); + Certificate certificate = tokenIssuer.getCertificate(); if (StringUtils.isNotEmpty(certificate.getJwks().getUrl())) { JWKSConfigurationDTO jwksConfigurationDTO = new JWKSConfigurationDTO(); if (StringUtils.isNotEmpty(certificate.getJwks().getTls())) { @@ -240,160 +191,313 @@ public void addJWTIssuers(List jwtIssuers) { TLSUtils.getCertificateFromContent(certificate.getCertificate()); tokenIssuerDto.setCertificate(signingCertificate); } - Map claimMappingMap = jwtIssuer.getClaimMappingMap(); + Map claimMappingMap = tokenIssuer.getClaimMappingMap(); Map claimMappingDtos = new HashMap<>(); claimMappingMap.forEach((remoteClaim, localClaim) -> claimMappingDtos.put(remoteClaim, new ClaimMappingDto(remoteClaim, localClaim))); tokenIssuerDto.setClaimMappings(claimMappingDtos); JWTValidator jwtValidator = new JWTValidator(tokenIssuerDto); - List environments = getEnvironments(jwtIssuer); + List environments = getEnvironments(tokenIssuer.getEnvironmentsList()); for (String environment : environments) { - String mapKey = getMapKey(environment, jwtIssuer.getIssuer()); + String mapKey = getMapKey(environment, tokenIssuer.getIssuer()); jwtValidatorMap.put(mapKey, jwtValidator); } this.jwtValidatorMap = jwtValidatorMap; } catch (EnforcerException | CertificateException | IOException e) { - log.error("Error occurred while configuring JWT Validator for issuer " + jwtIssuer.getIssuer(), e); + log.error("Error occurred while configuring JWT Validator for issuer " + tokenIssuer.getIssuer(), e); } } - } - @Override - public JWTValidator getJWTValidatorByIssuer(String issuer, String environment) { + @Override + public void removeTokenIssuer(TokenIssuer tokenIssuer) { - String mapKey = getMapKey(Constants.DEFAULT_ALL_ENVIRONMENTS_TOKEN_ISSUER, issuer); - JWTValidator jwtValidator = jwtValidatorMap.get(mapKey); - if (jwtValidator != null) { - return jwtValidator; + List environments = getEnvironments(tokenIssuer.getEnvironmentsList()); + for (String environment : environments) { + String mapKey = getMapKey(environment, tokenIssuer.getIssuer()); + jwtValidatorMap.remove(mapKey); + } } - mapKey = getMapKey(environment, issuer); - return jwtValidatorMap.get(mapKey); - } - @Override - public void addApplication(org.wso2.apk.enforcer.discovery.subscription.Application application) { - - Application resolvedApplication = new Application(); - resolvedApplication.setName(application.getName()); - resolvedApplication.setOwner(application.getOwner()); - resolvedApplication.setUUID(application.getUuid()); - resolvedApplication.setOrganization(application.getOrganization()); - resolvedApplication.setAttributes(application.getAttributesMap()); - if (applicationMap.containsKey(resolvedApplication.getUuid())) { - applicationMap.replace(resolvedApplication.getUuid(), resolvedApplication); - } else { - applicationMap.put(resolvedApplication.getUuid(), resolvedApplication); + @Override + public void addTokenIssuers(List tokenIssuers) { + + Map jwtValidatorMap = new ConcurrentHashMap<>(); + for (TokenIssuerRestDto tokenIssuer : tokenIssuers) { + try { + ExtendedTokenIssuerDto tokenIssuerDto = new ExtendedTokenIssuerDto(tokenIssuer.getIssuer()); + tokenIssuerDto.setName(tokenIssuer.getName()); + tokenIssuerDto.setConsumerKeyClaim(tokenIssuer.getConsumerKeyClaim()); + tokenIssuerDto.setScopesClaim(tokenIssuer.getScopesClaim()); + SignatureValidationRestDto signatureValidation = tokenIssuer.getSignatureValidation(); + if (signatureValidation != null) { + ResolvedCertificate certificate = signatureValidation.getCertificate(); + if (certificate != null && StringUtils.isNotEmpty(certificate.getResolvedCertificate())) { + java.security.cert.Certificate signingCertificate = + TLSUtils.getCertificateFromContent(certificate.getResolvedCertificate()); + tokenIssuerDto.setCertificate(signingCertificate); + } + ResolvedJWKS jwks = signatureValidation.getJwks(); + if (jwks != null) { + if (StringUtils.isNotEmpty(jwks.getUrl())) { + JWKSConfigurationDTO jwksConfigurationDTO = new JWKSConfigurationDTO(); + if (jwks.getTls() != null && StringUtils.isNotEmpty(jwks.getTls().getResolvedCertificate())) { + java.security.cert.Certificate tlsCertificate = + TLSUtils.getCertificateFromContent(jwks.getTls().getResolvedCertificate()); + jwksConfigurationDTO.setCertificate(tlsCertificate); + } + jwksConfigurationDTO.setUrl(jwks.getUrl()); + jwksConfigurationDTO.setEnabled(true); + tokenIssuerDto.setJwksConfigurationDTO(jwksConfigurationDTO); + } + } + } + Map claimMappingMap = tokenIssuer.getClaimMappings(); + Map claimMappingDtos = new HashMap<>(); + claimMappingMap.forEach((remoteClaim, localClaim) -> claimMappingDtos.put(remoteClaim, + new ClaimMappingDto(remoteClaim, localClaim))); + tokenIssuerDto.setClaimMappings(claimMappingDtos); + JWTValidator jwtValidator = new JWTValidator(tokenIssuerDto); + List environments = getEnvironments(tokenIssuer.getEnvironments()); + for (String environment : environments) { + String mapKey = getMapKey(environment, tokenIssuer.getIssuer()); + jwtValidatorMap.put(mapKey, jwtValidator); + } + this.jwtValidatorMap = jwtValidatorMap; + } catch (EnforcerException | CertificateException | IOException e) { + log.error("Error occurred while configuring JWT Validator for issuer " + tokenIssuer.getIssuer(), + e); + } + } } - } - @Override - public void addSubscription(org.wso2.apk.enforcer.discovery.subscription.Subscription subscription) { - - Subscription resolvedSubscription = new Subscription(); - resolvedSubscription.setSubscriptionId(subscription.getUuid()); - resolvedSubscription.setSubscriptionStatus(subscription.getSubStatus()); - resolvedSubscription.setOrganization(subscription.getOrganization()); - resolvedSubscription.setSubscribedApi(new SubscribedAPI(subscription.getSubscribedApi())); - if (subscriptionMap.containsKey(resolvedSubscription.getSubscriptionId())) { - subscriptionMap.replace(resolvedSubscription.getSubscriptionId(), resolvedSubscription); - } else { - subscriptionMap.put(resolvedSubscription.getSubscriptionId(), resolvedSubscription); + @Override + public ApplicationKeyMapping getMatchingApplicationKeyMapping(String applicationIdentifier, String keyType, + String securityScheme, String envType) { + + String cacheKey = SubscriptionDataStoreUtil.getApplicationKeyMappingCacheKey(applicationIdentifier, keyType, + securityScheme, envType); + return applicationKeyMappingMap.get(cacheKey); } - } - @Override - public void addApplicationMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping applicationMapping) { - - ApplicationMapping resolvedApplicationMapping = new ApplicationMapping(); - resolvedApplicationMapping.setUuid(applicationMapping.getUuid()); - resolvedApplicationMapping.setApplicationUUID(applicationMapping.getApplicationRef()); - resolvedApplicationMapping.setSubscriptionUUID(applicationMapping.getSubscriptionRef()); - if (applicationMappingMap.containsKey(resolvedApplicationMapping.getUuid())) { - applicationMappingMap.replace(resolvedApplicationMapping.getUuid(), resolvedApplicationMapping); - } else { - applicationMappingMap.put(resolvedApplicationMapping.getUuid(), resolvedApplicationMapping); + @Override + public Set getMatchingApplicationMappings(String uuid) { + + Set applicationMappings = new HashSet<>(); + if (StringUtils.isNotEmpty(uuid)) { + for (ApplicationMapping applicationMapping : applicationMappingMap.values()) { + if (applicationMapping.getApplicationUUID().equals(uuid)) { + applicationMappings.add(applicationMapping); + } + } + } + return applicationMappings; } - } - @Override - public void addApplicationKeyMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping applicationKeyMapping) { - - ApplicationKeyMapping resolvedApplicationKeyMapping = new ApplicationKeyMapping(); - resolvedApplicationKeyMapping.setApplicationUUID(applicationKeyMapping.getApplicationUUID()); - resolvedApplicationKeyMapping.setSecurityScheme(applicationKeyMapping.getSecurityScheme()); - resolvedApplicationKeyMapping.setApplicationIdentifier(applicationKeyMapping.getApplicationIdentifier()); - resolvedApplicationKeyMapping.setKeyType(applicationKeyMapping.getKeyType()); - resolvedApplicationKeyMapping.setEnvId(applicationKeyMapping.getEnvID()); - Iterator> iterator = applicationKeyMappingMap.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry cachedApplicationKeyMapping = iterator.next(); - ApplicationKeyMapping value = cachedApplicationKeyMapping.getValue(); - if (value.getApplicationIdentifier().equals(resolvedApplicationKeyMapping.getApplicationIdentifier()) && value.getSecurityScheme().equals(resolvedApplicationKeyMapping.getSecurityScheme()) && value.getKeyType().equals(resolvedApplicationKeyMapping.getKeyType()) && value.getEnvId().equals(resolvedApplicationKeyMapping.getEnvId()) && value.getApplicationUUID().equals(resolvedApplicationKeyMapping.getApplicationUUID())) { - iterator.remove(); + @Override + public Application getMatchingApplication(String uuid) { + + for (Application application : applicationMap.values()) { + if (StringUtils.isNotEmpty(uuid)) { + if (application.getUUID().equals(uuid)) { + return application; + } + } } + return null; } - applicationKeyMappingMap.put(resolvedApplicationKeyMapping.getCacheKey(), resolvedApplicationKeyMapping); - } - @Override - public void removeApplicationMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping applicationMapping) { + @Override + public Subscription getMatchingSubscription(String uuid) { - ApplicationMapping resolvedApplicationMapping = new ApplicationMapping(); - resolvedApplicationMapping.setUuid(applicationMapping.getUuid()); - resolvedApplicationMapping.setApplicationUUID(applicationMapping.getApplicationRef()); - resolvedApplicationMapping.setSubscriptionUUID(applicationMapping.getSubscriptionRef()); - applicationMappingMap.remove(resolvedApplicationMapping.getUuid()); - } + for (Subscription subscription : subscriptionMap.values()) { + if (StringUtils.isNotEmpty(uuid)) { + if (subscription.getSubscriptionId().equals(uuid)) { + return subscription; + } + } + } + return null; + } - @Override - public void removeApplicationKeyMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping applicationKeyMapping) { - - ApplicationKeyMapping resolvedApplicationKeyMapping = new ApplicationKeyMapping(); - resolvedApplicationKeyMapping.setApplicationUUID(applicationKeyMapping.getApplicationUUID()); - resolvedApplicationKeyMapping.setSecurityScheme(applicationKeyMapping.getSecurityScheme()); - resolvedApplicationKeyMapping.setApplicationIdentifier(applicationKeyMapping.getApplicationIdentifier()); - resolvedApplicationKeyMapping.setKeyType(applicationKeyMapping.getKeyType()); - resolvedApplicationKeyMapping.setEnvId(applicationKeyMapping.getEnvID()); - Iterator> iterator = applicationKeyMappingMap.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry cachedApplicationKeyMapping = iterator.next(); - ApplicationKeyMapping value = cachedApplicationKeyMapping.getValue(); - if (value.getApplicationIdentifier().equals(resolvedApplicationKeyMapping.getApplicationIdentifier()) && value.getSecurityScheme().equals(resolvedApplicationKeyMapping.getSecurityScheme()) && value.getKeyType().equals(resolvedApplicationKeyMapping.getKeyType()) && value.getEnvId().equals(resolvedApplicationKeyMapping.getEnvId()) && value.getApplicationUUID().equals(resolvedApplicationKeyMapping.getApplicationUUID())) { - iterator.remove(); + @Override + public void addJWTIssuers(List jwtIssuers) { + + Map jwtValidatorMap = new ConcurrentHashMap<>(); + for (JWTIssuer jwtIssuer : jwtIssuers) { + try { + ExtendedTokenIssuerDto tokenIssuerDto = new ExtendedTokenIssuerDto(jwtIssuer.getIssuer()); + tokenIssuerDto.setName(jwtIssuer.getName()); + tokenIssuerDto.setConsumerKeyClaim(jwtIssuer.getConsumerKeyClaim()); + tokenIssuerDto.setScopesClaim(jwtIssuer.getScopesClaim()); + Certificate certificate = jwtIssuer.getCertificate(); + if (StringUtils.isNotEmpty(certificate.getJwks().getUrl())) { + JWKSConfigurationDTO jwksConfigurationDTO = new JWKSConfigurationDTO(); + if (StringUtils.isNotEmpty(certificate.getJwks().getTls())) { + java.security.cert.Certificate tlsCertificate = + TLSUtils.getCertificateFromContent(certificate.getJwks().getTls()); + jwksConfigurationDTO.setCertificate(tlsCertificate); + } + jwksConfigurationDTO.setUrl(certificate.getJwks().getUrl()); + jwksConfigurationDTO.setEnabled(true); + tokenIssuerDto.setJwksConfigurationDTO(jwksConfigurationDTO); + } + if (StringUtils.isNotEmpty(certificate.getCertificate())) { + java.security.cert.Certificate signingCertificate = + TLSUtils.getCertificateFromContent(certificate.getCertificate()); + tokenIssuerDto.setCertificate(signingCertificate); + } + Map claimMappingMap = jwtIssuer.getClaimMappingMap(); + Map claimMappingDtos = new HashMap<>(); + claimMappingMap.forEach((remoteClaim, localClaim) -> claimMappingDtos.put(remoteClaim, + new ClaimMappingDto(remoteClaim, localClaim))); + tokenIssuerDto.setClaimMappings(claimMappingDtos); + JWTValidator jwtValidator = new JWTValidator(tokenIssuerDto); + List environments = getEnvironments(jwtIssuer.getEnvironmentsList()); + for (String environment : environments) { + String mapKey = getMapKey(environment, jwtIssuer.getIssuer()); + jwtValidatorMap.put(mapKey, jwtValidator); + } + this.jwtValidatorMap = jwtValidatorMap; + } catch (EnforcerException | CertificateException | IOException e) { + log.error("Error occurred while configuring JWT Validator for issuer " + jwtIssuer.getIssuer(), e); + } } } - } - @Override - public void removeSubscription(org.wso2.apk.enforcer.discovery.subscription.Subscription subscription) { + @Override + public JWTValidator getJWTValidatorByIssuer(String issuer, String environment) { - subscriptionMap.remove(subscription.getUuid()); - } + String mapKey = getMapKey(Constants.DEFAULT_ALL_ENVIRONMENTS_TOKEN_ISSUER, issuer); + JWTValidator jwtValidator = jwtValidatorMap.get(mapKey); + if (jwtValidator != null) { + return jwtValidator; + } + mapKey = getMapKey(environment, issuer); + return jwtValidatorMap.get(mapKey); + } - @Override - public void removeApplication(org.wso2.apk.enforcer.discovery.subscription.Application application) { + @Override + public void addApplication(org.wso2.apk.enforcer.discovery.subscription.Application application) { + + Application resolvedApplication = new Application(); + resolvedApplication.setName(application.getName()); + resolvedApplication.setOwner(application.getOwner()); + resolvedApplication.setUUID(application.getUuid()); + resolvedApplication.setOrganization(application.getOrganization()); + resolvedApplication.setAttributes(application.getAttributesMap()); + if (applicationMap.containsKey(resolvedApplication.getUuid())) { + applicationMap.replace(resolvedApplication.getUuid(), resolvedApplication); + } else { + applicationMap.put(resolvedApplication.getUuid(), resolvedApplication); + } + } - applicationMap.remove(application.getUuid()); - } + @Override + public void addSubscription(org.wso2.apk.enforcer.discovery.subscription.Subscription subscription) { + + Subscription resolvedSubscription = new Subscription(); + resolvedSubscription.setSubscriptionId(subscription.getUuid()); + resolvedSubscription.setSubscriptionStatus(subscription.getSubStatus()); + resolvedSubscription.setOrganization(subscription.getOrganization()); + resolvedSubscription.setSubscribedApi(new SubscribedAPI(subscription.getSubscribedApi())); + if (subscriptionMap.containsKey(resolvedSubscription.getSubscriptionId())) { + subscriptionMap.replace(resolvedSubscription.getSubscriptionId(), resolvedSubscription); + } else { + subscriptionMap.put(resolvedSubscription.getSubscriptionId(), resolvedSubscription); + } + } + + @Override + public void addApplicationMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping applicationMapping) { + + ApplicationMapping resolvedApplicationMapping = new ApplicationMapping(); + resolvedApplicationMapping.setUuid(applicationMapping.getUuid()); + resolvedApplicationMapping.setApplicationUUID(applicationMapping.getApplicationRef()); + resolvedApplicationMapping.setSubscriptionUUID(applicationMapping.getSubscriptionRef()); + if (applicationMappingMap.containsKey(resolvedApplicationMapping.getUuid())) { + applicationMappingMap.replace(resolvedApplicationMapping.getUuid(), resolvedApplicationMapping); + } else { + applicationMappingMap.put(resolvedApplicationMapping.getUuid(), resolvedApplicationMapping); + } + } - private List getEnvironments(JWTIssuer jwtIssuer) { + @Override + public void addApplicationKeyMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping applicationKeyMapping) { + + ApplicationKeyMapping resolvedApplicationKeyMapping = new ApplicationKeyMapping(); + resolvedApplicationKeyMapping.setApplicationUUID(applicationKeyMapping.getApplicationUUID()); + resolvedApplicationKeyMapping.setSecurityScheme(applicationKeyMapping.getSecurityScheme()); + resolvedApplicationKeyMapping.setApplicationIdentifier(applicationKeyMapping.getApplicationIdentifier()); + resolvedApplicationKeyMapping.setKeyType(applicationKeyMapping.getKeyType()); + resolvedApplicationKeyMapping.setEnvId(applicationKeyMapping.getEnvID()); + Iterator> iterator = + applicationKeyMappingMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry cachedApplicationKeyMapping = iterator.next(); + ApplicationKeyMapping value = cachedApplicationKeyMapping.getValue(); + if (value.getApplicationIdentifier().equals(resolvedApplicationKeyMapping.getApplicationIdentifier()) && value.getSecurityScheme().equals(resolvedApplicationKeyMapping.getSecurityScheme()) && value.getKeyType().equals(resolvedApplicationKeyMapping.getKeyType()) && value.getEnvId().equals(resolvedApplicationKeyMapping.getEnvId()) && value.getApplicationUUID().equals(resolvedApplicationKeyMapping.getApplicationUUID())) { + iterator.remove(); + } + } + applicationKeyMappingMap.put(resolvedApplicationKeyMapping.getCacheKey(), resolvedApplicationKeyMapping); + } - List environmentsList = new ArrayList<>(); - int environmentCount = jwtIssuer.getEnvironmentsCount(); + @Override + public void removeApplicationMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping applicationMapping) { - if (environmentCount > 0) { - for (int i = 0; i < environmentCount; i++) { - environmentsList.add(jwtIssuer.getEnvironments(i)); + ApplicationMapping resolvedApplicationMapping = new ApplicationMapping(); + resolvedApplicationMapping.setUuid(applicationMapping.getUuid()); + resolvedApplicationMapping.setApplicationUUID(applicationMapping.getApplicationRef()); + resolvedApplicationMapping.setSubscriptionUUID(applicationMapping.getSubscriptionRef()); + applicationMappingMap.remove(resolvedApplicationMapping.getUuid()); + } + + @Override + public void removeApplicationKeyMapping(org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping applicationKeyMapping) { + + ApplicationKeyMapping resolvedApplicationKeyMapping = new ApplicationKeyMapping(); + resolvedApplicationKeyMapping.setApplicationUUID(applicationKeyMapping.getApplicationUUID()); + resolvedApplicationKeyMapping.setSecurityScheme(applicationKeyMapping.getSecurityScheme()); + resolvedApplicationKeyMapping.setApplicationIdentifier(applicationKeyMapping.getApplicationIdentifier()); + resolvedApplicationKeyMapping.setKeyType(applicationKeyMapping.getKeyType()); + resolvedApplicationKeyMapping.setEnvId(applicationKeyMapping.getEnvID()); + Iterator> iterator = + applicationKeyMappingMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry cachedApplicationKeyMapping = iterator.next(); + ApplicationKeyMapping value = cachedApplicationKeyMapping.getValue(); + if (value.getApplicationIdentifier().equals(resolvedApplicationKeyMapping.getApplicationIdentifier()) && value.getSecurityScheme().equals(resolvedApplicationKeyMapping.getSecurityScheme()) && value.getKeyType().equals(resolvedApplicationKeyMapping.getKeyType()) && value.getEnvId().equals(resolvedApplicationKeyMapping.getEnvId()) && value.getApplicationUUID().equals(resolvedApplicationKeyMapping.getApplicationUUID())) { + iterator.remove(); + } } - } else { - environmentsList.add(Constants.DEFAULT_ALL_ENVIRONMENTS_TOKEN_ISSUER); } - return environmentsList; - } - private String getMapKey(String environment, String issuer) { + @Override + public void removeSubscription(org.wso2.apk.enforcer.discovery.subscription.Subscription subscription) { - return environment + DELEM_PERIOD + issuer; - } + subscriptionMap.remove(subscription.getUuid()); + } -} + @Override + public void removeApplication(org.wso2.apk.enforcer.discovery.subscription.Application application) { + + applicationMap.remove(application.getUuid()); + } + + private List getEnvironments(List environments) { + + int environmentCount = environments.size(); + + if (environmentCount > 0) { + return environments; + } else { + return Arrays.asList(Constants.DEFAULT_ALL_ENVIRONMENTS_TOKEN_ISSUER); + } + } + + private String getMapKey(String environment, String issuer) { + + return environment + DELEM_PERIOD + issuer; + } + + } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreUtil.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreUtil.java index 22a576d07..c46f2876f 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreUtil.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionDataStoreUtil.java @@ -24,11 +24,11 @@ import feign.slf4j.Slf4jLogger; import org.wso2.apk.enforcer.common.CacheableEntity; import org.wso2.apk.enforcer.config.ConfigHolder; -import org.wso2.apk.enforcer.discovery.JWTIssuerDiscoveryClient; import org.wso2.apk.enforcer.discovery.subscription.Application; import org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping; import org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping; import org.wso2.apk.enforcer.discovery.subscription.Subscription; +import org.wso2.apk.enforcer.discovery.subscription.TokenIssuer; import org.wso2.apk.enforcer.util.ApacheFeignHttpClient; import org.wso2.apk.enforcer.util.FilterUtils; @@ -130,7 +130,6 @@ private static void loadApplicationMappings() { public static void initializeLoadingTasks() { - JWTIssuerDiscoveryClient.getInstance().watchJWTIssuers(); EventingGrpcClient.getInstance().watchEvents(); } @@ -252,12 +251,55 @@ public static void removeApplication(Application application) { } + public static void addTokenIssuer(TokenIssuer tokenIssuer) { + SubscriptionDataStore subscriptionDataStore = getSubscriptionDataStore(tokenIssuer.getOrganization()); + + if (subscriptionDataStore == null) { + subscriptionDataStore = + SubscriptionDataHolder.getInstance().initializeSubscriptionDataStore(tokenIssuer.getOrganization()); + } + subscriptionDataStore.addJWTIssuer(tokenIssuer); + + } + + public static void deleteTokenIssuer(TokenIssuer tokenIssuer) { + SubscriptionDataStore subscriptionDataStore = getSubscriptionDataStore(tokenIssuer.getOrganization()); + + if (subscriptionDataStore == null) { + subscriptionDataStore = + SubscriptionDataHolder.getInstance().initializeSubscriptionDataStore(tokenIssuer.getOrganization()); + } + subscriptionDataStore.removeTokenIssuer(tokenIssuer); + + + } + public void loadStartupArtifacts() { loadApplications(); loadSubscriptions(); loadApplicationMappings(); loadApplicationKeyMappings(); + loadTokenIssuers(); + } + + private void loadTokenIssuers() { + + new Thread(() -> { + TokenIssuerListDto tokenIssuers = subscriptionValidationDataRetrievalRestClient.getAllTokenIssuers(); + List list = tokenIssuers.getList(); + Map> orgWizeMAp = new HashMap<>(); + for (TokenIssuerRestDto tokenIssuerDto : list) { + String organization = tokenIssuerDto.getOrganization(); + List tokenIssuerDtos = orgWizeMAp.computeIfAbsent(organization, + k -> new ArrayList<>()); + tokenIssuerDtos.add(tokenIssuerDto); + } + orgWizeMAp.forEach((k, v) -> { + SubscriptionDataStore subscriptionDataStore = getSubscriptionDataStore(k); + subscriptionDataStore.addTokenIssuers(v); + }); + }).start(); } } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionValidationDataRetrievalRestClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionValidationDataRetrievalRestClient.java index 95af008b6..0f7ed7d83 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionValidationDataRetrievalRestClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/SubscriptionValidationDataRetrievalRestClient.java @@ -1,4 +1,5 @@ package org.wso2.apk.enforcer.subscription; + import feign.Headers; import feign.Param; import feign.RequestLine; @@ -20,4 +21,8 @@ public interface SubscriptionValidationDataRetrievalRestClient { @RequestLine("GET /applicationkeymappings") @Headers("Content-Type: application/json") ApplicationKeyMappingDtoList getAllApplicationKeyMappings(); + + @RequestLine("GET /tokenissuers") + @Headers("Content-Type: application/json") + TokenIssuerListDto getAllTokenIssuers(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerListDto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerListDto.java new file mode 100644 index 000000000..d18145360 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerListDto.java @@ -0,0 +1,15 @@ +package org.wso2.apk.enforcer.subscription; + +import org.wso2.apk.enforcer.commons.dto.TokenIssuerDto; +import org.wso2.apk.enforcer.discovery.subscription.TokenIssuer; + +import java.util.List; + +public class TokenIssuerListDto { +private List list; + + public List getList() { + + return list; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerRestDto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerRestDto.java new file mode 100644 index 000000000..3a12caf18 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/subscription/TokenIssuerRestDto.java @@ -0,0 +1,97 @@ +package org.wso2.apk.enforcer.subscription; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class TokenIssuerRestDto { + private String name; + private String organization; + private String issuer; + private String consumerKeyClaim; + private String scopesClaim; + private List environments = new ArrayList<>(); + private Map claimMappings = new HashMap<>(); + private SignatureValidationRestDto signatureValidation; + + public String getName() { + + return name; + } + + public void setName(String name) { + + this.name = name; + } + + public String getOrganization() { + + return organization; + } + + public void setOrganization(String organization) { + + this.organization = organization; + } + + public String getIssuer() { + + return issuer; + } + + public void setIssuer(String issuer) { + + this.issuer = issuer; + } + + public String getConsumerKeyClaim() { + + return consumerKeyClaim; + } + + public void setConsumerKeyClaim(String consumerKeyClaim) { + + this.consumerKeyClaim = consumerKeyClaim; + } + + public String getScopesClaim() { + + return scopesClaim; + } + + public void setScopesClaim(String scopesClaim) { + + this.scopesClaim = scopesClaim; + } + + public List getEnvironments() { + + return environments; + } + + public void setEnvironments(List environments) { + + this.environments = environments; + } + + public Map getClaimMappings() { + + return claimMappings; + } + + public void setClaimMappings(Map claimMappings) { + + this.claimMappings = claimMappings; + } + + public SignatureValidationRestDto getSignatureValidation() { + + return signatureValidation; + } + + public void setSignatureValidation(SignatureValidationRestDto signatureValidation) { + + this.signatureValidation = signatureValidation; + } +} diff --git a/protos/protogen.sh b/protos/protogen.sh index 2f3dcafd3..83865eaf4 100755 --- a/protos/protogen.sh +++ b/protos/protogen.sh @@ -23,7 +23,7 @@ cd $cur_dir rm -rf target mkdir -p target/deps -ADAPTER_GEN_DIR=$cur_dir/../common-controller/pkg/discovery/api/wso2/ +ADAPTER_GEN_DIR=$cur_dir/../common-go-libs/pkg/discovery/api/wso2/ ENFORCER_GEN_DIR=$cur_dir/../gateway/enforcer/org.wso2.apk.enforcer/src/main/java/ GREEN='\033[0;32m' BOLD="\033[1m" diff --git a/protos/wso2/discovery/subscription/event.proto b/protos/wso2/discovery/subscription/event.proto index ef3c4628b..1e8a1952e 100644 --- a/protos/wso2/discovery/subscription/event.proto +++ b/protos/wso2/discovery/subscription/event.proto @@ -21,6 +21,7 @@ import "wso2/discovery/subscription/application.proto"; import "wso2/discovery/subscription/applicationmapping.proto"; import "wso2/discovery/subscription/application_key_mapping.proto"; + import "wso2/discovery/subscription/token_issuer.proto"; import "wso2/discovery/subscription/subscription.proto"; option go_package = "github.com/wso2/apk/common-go-libs/pkg/discovery/api/wso2/discovery/subscription"; option java_package = "org.wso2.apk.enforcer.discovery.subscription"; @@ -38,5 +39,6 @@ ApplicationMapping applicationMapping = 5; ApplicationKeyMapping applicationKeyMapping = 6; Subscription subscription = 7; + TokenIssuer tokenIssuer = 8; } \ No newline at end of file diff --git a/adapter/api/proto/wso2/discovery/subscription/jwtIssuer.proto b/protos/wso2/discovery/subscription/token_issuer.proto similarity index 59% rename from adapter/api/proto/wso2/discovery/subscription/jwtIssuer.proto rename to protos/wso2/discovery/subscription/token_issuer.proto index 4b8a8f79e..af1b2cfbb 100644 --- a/adapter/api/proto/wso2/discovery/subscription/jwtIssuer.proto +++ b/protos/wso2/discovery/subscription/token_issuer.proto @@ -18,30 +18,30 @@ syntax = "proto3"; package wso2.discovery.subscription; -option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/subscription;subscription"; +option go_package = "github.com/wso2/apk/common-go-libs/pkg/discovery/api/wso2/discovery/subscription"; option java_package = "org.wso2.apk.enforcer.discovery.subscription"; -option java_outer_classname = "JWTIssuerProto"; +option java_outer_classname = "TokenIssuerProto"; option java_multiple_files = true; -// [#protodoc-title: JWTIssuer] +// [#protodoc-title: TokenIssuer] -// JWTIssuer data model -message JWTIssuer { - string eventId = 1; - string name = 2; - string organization = 3; - string issuer = 4; - Certificate certificate = 5; - string consumerKeyClaim = 6; - string scopesClaim = 7; - map claimMapping = 8; - repeated string environments = 9; +// TokenIssuer data model +message TokenIssuer { + string eventId = 1; + string name = 2; + string organization = 3; + string issuer = 4; + Certificate certificate = 5; + string consumerKeyClaim = 6; + string scopesClaim = 7; + map claimMapping = 8; + repeated string environments = 9; } message Certificate { - string certificate = 1; - JWKS jwks = 2; + string certificate = 1; + JWKS jwks = 2; } message JWKS { - string url = 1; - string tls = 2; + string url = 1; + string tls = 2; }