diff --git a/adapter/api/proto/wso2/discovery/api/api.proto b/adapter/api/proto/wso2/discovery/api/api.proto index 5688b1cc6..95524398b 100644 --- a/adapter/api/proto/wso2/discovery/api/api.proto +++ b/adapter/api/proto/wso2/discovery/api/api.proto @@ -55,4 +55,5 @@ message Api { BackendJWTTokenInfo backendJWTTokenInfo = 25; bytes apiDefinitionFile = 26; string environment = 27; + bool subscriptionValidation = 28; } diff --git a/adapter/api/proto/wso2/discovery/service/subscription/app_mapping_ds.proto b/adapter/api/proto/wso2/discovery/service/subscription/app_mapping_ds.proto new file mode 100644 index 000000000..54db7f5ba --- /dev/null +++ b/adapter/api/proto/wso2/discovery/service/subscription/app_mapping_ds.proto @@ -0,0 +1,34 @@ +/* + * 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 discovery.service.subscription; + +import "envoy/service/discovery/v3/discovery.proto"; + +option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/service/subscription"; +option java_package = "org.wso2.apk.enforcer.discovery.service.subscription"; +option java_outer_classname = "AppMappingDSProto"; +option java_multiple_files = true; +option java_generic_services = true; + +// [#protodoc-title: AppMappingDS] +service ApplicationMappingDiscoveryService { + rpc StreamApplicationMappings(stream envoy.service.discovery.v3.DiscoveryRequest) + returns (stream envoy.service.discovery.v3.DiscoveryResponse) { + } +} diff --git a/adapter/api/proto/wso2/discovery/subscription/application.proto b/adapter/api/proto/wso2/discovery/subscription/application.proto index ba8bef8bb..86a15b7ed 100644 --- a/adapter/api/proto/wso2/discovery/subscription/application.proto +++ b/adapter/api/proto/wso2/discovery/subscription/application.proto @@ -1,3 +1,19 @@ +/* + * 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; @@ -11,17 +27,22 @@ option java_multiple_files = true; // Application data model message Application { - string eventId = 1; + string uuid = 1; string name = 2; - string uuid = 3; - string owner = 4; - string policy = 5; - map attributes = 6; - message Key { - string key = 1; - string keyManager = 2; - } - repeated Key keys = 7; - string organization = 8; - string timeStamp = 9; + string owner = 3; + map attributes = 4; +} + +message SecuritySchemes { + OAuth2 oAuth2 = 1; +} + +message OAuth2 { + repeated Environment environments = 1; +} + +message Environment { + string envID = 1; + string applicationIdentifier = 2; + string keyType = 3; } diff --git a/adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto b/adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto index 33a7602f0..07a744805 100644 --- a/adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto +++ b/adapter/api/proto/wso2/discovery/subscription/application_key_mapping.proto @@ -1,3 +1,19 @@ +/* + * 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; @@ -11,12 +27,10 @@ option java_multiple_files = true; // ApplicationKeyMapping data model message ApplicationKeyMapping { - string consumerKey = 1; - string keyType = 2; - string keyManager = 3; - int32 applicationId = 4; - int32 tenantId = 5; - string tenantDomain = 6; - int64 timestamp = 7; - string applicationUUID = 8; + string applicationUUID = 1; + string securityScheme = 2; + string applicationIdentifier = 3; + string keyType = 4; + string envID = 5; + int64 timestamp = 6; } diff --git a/adapter/api/proto/wso2/discovery/subscription/application_key_mapping_list.proto b/adapter/api/proto/wso2/discovery/subscription/application_key_mapping_list.proto index 33dc51228..1a20ce78c 100644 --- a/adapter/api/proto/wso2/discovery/subscription/application_key_mapping_list.proto +++ b/adapter/api/proto/wso2/discovery/subscription/application_key_mapping_list.proto @@ -1,3 +1,19 @@ +/* + * 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; diff --git a/adapter/api/proto/wso2/discovery/subscription/application_list.proto b/adapter/api/proto/wso2/discovery/subscription/application_list.proto index 0a1e0b052..78c83bcce 100644 --- a/adapter/api/proto/wso2/discovery/subscription/application_list.proto +++ b/adapter/api/proto/wso2/discovery/subscription/application_list.proto @@ -1,3 +1,19 @@ +/* + * 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; diff --git a/common-controller/internal/operator/utils/utils.go b/adapter/api/proto/wso2/discovery/subscription/applicationmapping.proto similarity index 56% rename from common-controller/internal/operator/utils/utils.go rename to adapter/api/proto/wso2/discovery/subscription/applicationmapping.proto index 28e2bb513..4930ab844 100644 --- a/common-controller/internal/operator/utils/utils.go +++ b/adapter/api/proto/wso2/discovery/subscription/applicationmapping.proto @@ -14,18 +14,20 @@ * limitations under the License. * */ +syntax = "proto3"; -package utils +package wso2.discovery.subscription; -import ( - "github.com/wso2/apk/common-controller/internal/config" -) +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 = "ApplicationMappingProto"; +option java_multiple_files = true; -// GetEnvironment takes the environment of the API. If the value is empty, -// it will return the default environment that is set in the config of the common controller. -func GetEnvironment(environment string) string { - if environment != "" { - return environment - } - return config.ReadConfigs().CommonController.Environment +// [#protodoc-title: ApplicationMapping] + +// ApplicationMapping data model +message ApplicationMapping { + string uuid = 1; + string applicationRef = 2; + string subscriptionRef = 3; } diff --git a/adapter/api/proto/wso2/discovery/subscription/applicationmapping_list.proto b/adapter/api/proto/wso2/discovery/subscription/applicationmapping_list.proto new file mode 100644 index 000000000..71a11668f --- /dev/null +++ b/adapter/api/proto/wso2/discovery/subscription/applicationmapping_list.proto @@ -0,0 +1,33 @@ +/* + * 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/applicationmapping.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 = "ApplicationMappingListProto"; +option java_multiple_files = true; + +// [#protodoc-title: ApplicationMappingList] + +// ApplicationMappingList data model +message ApplicationMappingList { + repeated ApplicationMapping list = 2; +} diff --git a/adapter/api/proto/wso2/discovery/subscription/subscription.proto b/adapter/api/proto/wso2/discovery/subscription/subscription.proto index b9281ba09..4051c8593 100644 --- a/adapter/api/proto/wso2/discovery/subscription/subscription.proto +++ b/adapter/api/proto/wso2/discovery/subscription/subscription.proto @@ -1,3 +1,19 @@ +/* + * 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; @@ -11,13 +27,13 @@ option java_multiple_files = true; // Subscription data model message Subscription { - string eventId = 1; - string applicationRef = 2; - string apiRef = 3; - string policyId = 4; - string subStatus = 5; - string subscriber = 6; - string uuid = 7; - string timeStamp = 8; - string organization = 9; + 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/subscription_list.proto b/adapter/api/proto/wso2/discovery/subscription/subscription_list.proto index bd7808d3a..a4575218e 100644 --- a/adapter/api/proto/wso2/discovery/subscription/subscription_list.proto +++ b/adapter/api/proto/wso2/discovery/subscription/subscription_list.proto @@ -1,3 +1,19 @@ +/* + * 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; diff --git a/adapter/go.mod b/adapter/go.mod index 6753f0582..c885e3162 100644 --- a/adapter/go.mod +++ b/adapter/go.mod @@ -12,7 +12,6 @@ require ( github.com/pelletier/go-toml v1.8.1 github.com/sirupsen/logrus v1.9.0 golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b - google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 @@ -73,6 +72,7 @@ require ( google.golang.org/appengine v1.6.7 // indirect 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 gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.27.2 // indirect diff --git a/adapter/internal/adapter/adapter.go b/adapter/internal/adapter/adapter.go index 48ccb7e91..56621e1d8 100644 --- a/adapter/internal/adapter/adapter.go +++ b/adapter/internal/adapter/adapter.go @@ -78,9 +78,8 @@ func init() { const grpcMaxConcurrentStreams = 1000000 -func runManagementServer(conf *config.Config, server xdsv3.Server, enforcerServer wso2_server.Server, enforcerSdsServer wso2_server.Server, - enforcerAppDsSrv wso2_server.Server, enforcerAPIDsSrv wso2_server.Server, enforcerAppPolicyDsSrv wso2_server.Server, - enforcerSubPolicyDsSrv wso2_server.Server, enforcerAppKeyMappingDsSrv wso2_server.Server, +func runManagementServer(conf *config.Config, server xdsv3.Server, enforcerServer wso2_server.Server, + enforcerAPIDsSrv wso2_server.Server, enforcerAppPolicyDsSrv wso2_server.Server, enforcerSubPolicyDsSrv wso2_server.Server, enforcerKeyManagerDsSrv wso2_server.Server, enforcerRevokedTokenDsSrv wso2_server.Server, enforcerThrottleDataDsSrv wso2_server.Server, enforcerJwtIssuerDsSrv wso2_server.Server, port uint) { var grpcOptions []grpc.ServerOption @@ -120,12 +119,9 @@ func runManagementServer(conf *config.Config, server xdsv3.Server, enforcerServe discoveryv3.RegisterAggregatedDiscoveryServiceServer(grpcServer, server) configservice.RegisterConfigDiscoveryServiceServer(grpcServer, enforcerServer) apiservice.RegisterApiDiscoveryServiceServer(grpcServer, enforcerServer) - subscriptionservice.RegisterSubscriptionDiscoveryServiceServer(grpcServer, enforcerSdsServer) - subscriptionservice.RegisterApplicationDiscoveryServiceServer(grpcServer, enforcerAppDsSrv) subscriptionservice.RegisterApiListDiscoveryServiceServer(grpcServer, enforcerAPIDsSrv) subscriptionservice.RegisterApplicationPolicyDiscoveryServiceServer(grpcServer, enforcerAppPolicyDsSrv) subscriptionservice.RegisterSubscriptionPolicyDiscoveryServiceServer(grpcServer, enforcerSubPolicyDsSrv) - subscriptionservice.RegisterApplicationKeyMappingDiscoveryServiceServer(grpcServer, enforcerAppKeyMappingDsSrv) keymanagerservice.RegisterKMDiscoveryServiceServer(grpcServer, enforcerKeyManagerDsSrv) keymanagerservice.RegisterRevokedTokenDiscoveryServiceServer(grpcServer, enforcerRevokedTokenDsSrv) subscriptionservice.RegisterJWTIssuerDiscoveryServiceServer(grpcServer, enforcerJwtIssuerDsSrv) @@ -166,32 +162,25 @@ func Run(conf *config.Config) { logger.LoggerAPK.Info("Starting adapter ....") cache := xds.GetXdsCache() enforcerCache := xds.GetEnforcerCache() - enforcerSubscriptionCache := xds.GetEnforcerSubscriptionCache() - enforcerApplicationCache := xds.GetEnforcerApplicationCache() enforcerAPICache := xds.GetEnforcerAPICache() enforcerApplicationPolicyCache := xds.GetEnforcerApplicationPolicyCache() enforcerSubscriptionPolicyCache := xds.GetEnforcerSubscriptionPolicyCache() - enforcerApplicationKeyMappingCache := xds.GetEnforcerApplicationKeyMappingCache() enforcerKeyManagerCache := xds.GetEnforcerKeyManagerCache() enforcerRevokedTokenCache := xds.GetEnforcerRevokedTokenCache() enforcerThrottleDataCache := xds.GetEnforcerThrottleDataCache() enforcerJWtIssuerCache := xds.GetEnforcerJWTIssuerCache() srv := xdsv3.NewServer(ctx, cache, &routercb.Callbacks{}) enforcerXdsSrv := wso2_server.NewServer(ctx, enforcerCache, &enforcerCallbacks.Callbacks{}) - enforcerSdsSrv := wso2_server.NewServer(ctx, enforcerSubscriptionCache, &enforcerCallbacks.Callbacks{}) - enforcerAppDsSrv := wso2_server.NewServer(ctx, enforcerApplicationCache, &enforcerCallbacks.Callbacks{}) enforcerJwtIssuerDsSrv := wso2_server.NewServer(ctx, enforcerJWtIssuerCache, &enforcerCallbacks.Callbacks{}) enforcerAPIDsSrv := wso2_server.NewServer(ctx, enforcerAPICache, &enforcerCallbacks.Callbacks{}) enforcerAppPolicyDsSrv := wso2_server.NewServer(ctx, enforcerApplicationPolicyCache, &enforcerCallbacks.Callbacks{}) enforcerSubPolicyDsSrv := wso2_server.NewServer(ctx, enforcerSubscriptionPolicyCache, &enforcerCallbacks.Callbacks{}) - enforcerAppKeyMappingDsSrv := wso2_server.NewServer(ctx, enforcerApplicationKeyMappingCache, &enforcerCallbacks.Callbacks{}) enforcerKeyManagerDsSrv := wso2_server.NewServer(ctx, enforcerKeyManagerCache, &enforcerCallbacks.Callbacks{}) enforcerRevokedTokenDsSrv := wso2_server.NewServer(ctx, enforcerRevokedTokenCache, &enforcerCallbacks.Callbacks{}) enforcerThrottleDataDsSrv := wso2_server.NewServer(ctx, enforcerThrottleDataCache, &enforcerCallbacks.Callbacks{}) - runManagementServer(conf, srv, enforcerXdsSrv, enforcerSdsSrv, enforcerAppDsSrv, enforcerAPIDsSrv, - enforcerAppPolicyDsSrv, enforcerSubPolicyDsSrv, enforcerAppKeyMappingDsSrv, enforcerKeyManagerDsSrv, - enforcerRevokedTokenDsSrv, enforcerThrottleDataDsSrv, enforcerJwtIssuerDsSrv, port) + runManagementServer(conf, srv, enforcerXdsSrv, enforcerAPIDsSrv, enforcerAppPolicyDsSrv, enforcerSubPolicyDsSrv, + enforcerKeyManagerDsSrv, enforcerRevokedTokenDsSrv, enforcerThrottleDataDsSrv, enforcerJwtIssuerDsSrv, port) // Set enforcer startup configs xds.UpdateEnforcerConfig(conf) diff --git a/adapter/internal/discovery/xds/marshaller.go b/adapter/internal/discovery/xds/marshaller.go index cd7c7f530..e60192fd8 100644 --- a/adapter/internal/discovery/xds/marshaller.go +++ b/adapter/internal/discovery/xds/marshaller.go @@ -279,100 +279,6 @@ func MarshalKeyManager(keyManager *types.KeyManager) *keymgt.KeyManagerConfig { return nil } -// MarshalMultipleApplications is used to update the applicationList during the startup where -// multiple applications are pulled at once. And then it returns the ApplicationList. -func MarshalMultipleApplications(appList *types.ApplicationList) *subscription.ApplicationList { - resourceMap := make(map[string]*subscription.Application) - for item := range appList.List { - application := appList.List[item] - applicationSub := marshalApplication(&application) - resourceMap[application.UUID] = applicationSub - } - ApplicationMap = resourceMap - return marshalApplicationMapToList(ApplicationMap) -} - -// MarshalApplicationEventAndReturnList handles the Application Event corresponding to the event received -// from message broker. And then it returns the ApplicationList. -func MarshalApplicationEventAndReturnList(application *types.Application, - eventType EventType) *subscription.ApplicationList { - if eventType == DeleteEvent { - delete(ApplicationMap, application.UUID) - logger.LoggerXds.Infof("Application %s is deleted.", application.UUID) - } else { - applicationSub := marshalApplication(application) - ApplicationMap[application.UUID] = applicationSub - if eventType == CreateEvent { - logger.LoggerXds.Infof("Application %s is added.", application.UUID) - } else { - logger.LoggerXds.Infof("Application %s is updated.", application.UUID) - } - } - return marshalApplicationMapToList(ApplicationMap) -} - -// MarshalMultipleApplicationKeyMappings is used to update the application key mappings during the startup where -// multiple key mappings are pulled at once. And then it returns the ApplicationKeyMappingList. -func MarshalMultipleApplicationKeyMappings(keymappingList *types.ApplicationKeyMappingList) *subscription.ApplicationKeyMappingList { - resourceMap := make(map[string]*subscription.ApplicationKeyMapping) - for item := range keymappingList.List { - keyMapping := keymappingList.List[item] - applicationKeyMappingReference := GetApplicationKeyMappingReference(&keyMapping) - keyMappingSub := marshalKeyMapping(&keyMapping) - resourceMap[applicationKeyMappingReference] = keyMappingSub - } - ApplicationKeyMappingMap = resourceMap - return marshalKeyMappingMapToList(ApplicationKeyMappingMap) -} - -// MarshalApplicationKeyMappingEventAndReturnList handles the Application Key Mapping Event corresponding to the event received -// from message broker. And then it returns the ApplicationKeyMappingList. -func MarshalApplicationKeyMappingEventAndReturnList(keyMapping *types.ApplicationKeyMapping, - eventType EventType) *subscription.ApplicationKeyMappingList { - applicationKeyMappingReference := GetApplicationKeyMappingReference(keyMapping) - if eventType == DeleteEvent { - delete(ApplicationKeyMappingMap, applicationKeyMappingReference) - logger.LoggerXds.Infof("Application Key Mapping for the applicationKeyMappingReference %s is removed.", - applicationKeyMappingReference) - } else { - keyMappingSub := marshalKeyMapping(keyMapping) - ApplicationKeyMappingMap[applicationKeyMappingReference] = keyMappingSub - logger.LoggerXds.Infof("Application Key Mapping for the applicationKeyMappingReference %s is added.", - applicationKeyMappingReference) - } - return marshalKeyMappingMapToList(ApplicationKeyMappingMap) -} - -// MarshalMultipleSubscriptions is used to update the subscriptions during the startup where -// multiple subscriptions are pulled at once. And then it returns the SubscriptionList. -func MarshalMultipleSubscriptions(subscriptionsList *types.SubscriptionList) *subscription.SubscriptionList { - resourceMap := make(map[int32]*subscription.Subscription) - for item := range subscriptionsList.List { - sb := subscriptionsList.List[item] - resourceMap[sb.SubscriptionID] = marshalSubscription(&sb) - } - SubscriptionMap = resourceMap - return marshalSubscriptionMapToList(SubscriptionMap) -} - -// MarshalSubscriptionEventAndReturnList handles the Subscription Event corresponding to the event received -// from message broker. And then it returns the SubscriptionList. -func MarshalSubscriptionEventAndReturnList(sub *types.Subscription, eventType EventType) *subscription.SubscriptionList { - if eventType == DeleteEvent { - delete(SubscriptionMap, sub.SubscriptionID) - logger.LoggerXds.Infof("Subscription for %s:%s is deleted.", sub.APIUUID, sub.ApplicationUUID) - } else { - subscriptionSub := marshalSubscription(sub) - SubscriptionMap[sub.SubscriptionID] = subscriptionSub - if eventType == UpdateEvent { - logger.LoggerXds.Infof("Subscription for %s:%s is updated.", sub.APIUUID, sub.ApplicationUUID) - } else { - logger.LoggerXds.Infof("Subscription for %s:%s is added.", sub.APIUUID, sub.ApplicationUUID) - } - } - return marshalSubscriptionMapToList(SubscriptionMap) -} - // MarshalMultipleApplicationPolicies is used to update the applicationPolicies during the startup where // multiple application policies are pulled at once. And then it returns the ApplicationPolicyList. func MarshalMultipleApplicationPolicies(policies *types.ApplicationPolicyList) *subscription.ApplicationPolicyList { @@ -499,45 +405,6 @@ func MarshalAPIForLifeCycleChangeEventAndReturnList(apiUUID, status, gatewayLabe return marshalAPIListMapToList(APIListMap[gatewayLabel]) } -func marshalSubscription(subscriptionInternal *types.Subscription) *subscription.Subscription { - sub := &subscription.Subscription{ - Uuid: subscriptionInternal.SubscriptionUUID, - PolicyId: subscriptionInternal.PolicyID, - ApiRef: subscriptionInternal.APIUUID, - ApplicationRef: subscriptionInternal.ApplicationUUID, - SubStatus: subscriptionInternal.SubscriptionState, - //TimeStamp: subscriptionInternal.TimeStamp, - Organization: subscriptionInternal.TenantDomain, - } - return sub -} - -func marshalApplication(appInternal *types.Application) *subscription.Application { - app := &subscription.Application{ - Uuid: appInternal.UUID, - Name: appInternal.Name, - Policy: appInternal.Policy, - //Owner: appInternal.Owner, - Attributes: appInternal.Attributes, - Organization: appInternal.TenantDomain, - //Timestamp: appInternal.TimeStamp, - } - return app -} - -func marshalKeyMapping(keyMappingInternal *types.ApplicationKeyMapping) *subscription.ApplicationKeyMapping { - return &subscription.ApplicationKeyMapping{ - ConsumerKey: keyMappingInternal.ConsumerKey, - KeyType: keyMappingInternal.KeyType, - KeyManager: keyMappingInternal.KeyManager, - ApplicationId: keyMappingInternal.ApplicationID, - ApplicationUUID: keyMappingInternal.ApplicationUUID, - TenantId: keyMappingInternal.TenantID, - TenantDomain: keyMappingInternal.TenantDomain, - Timestamp: keyMappingInternal.TimeStamp, - } -} - func marshalAPIMetadata(api *types.API) *subscription.APIs { return &subscription.APIs{ ApiId: strconv.Itoa(api.APIID), @@ -578,12 +445,6 @@ func marshalSubscriptionPolicy(policy *types.SubscriptionPolicy) *subscription.S } } -// GetApplicationKeyMappingReference returns unique reference for each key Mapping event. -// It is the combination of consumerKey:keyManager -func GetApplicationKeyMappingReference(keyMapping *types.ApplicationKeyMapping) string { - return keyMapping.ConsumerKey + ":" + keyMapping.KeyManager -} - // CheckIfAPIMetadataIsAlreadyAvailable returns true only if the API Metadata for the given API UUID // is already available func CheckIfAPIMetadataIsAlreadyAvailable(apiUUID, label string) bool { diff --git a/adapter/internal/discovery/xds/server.go b/adapter/internal/discovery/xds/server.go index 866a35bae..faa0e09be 100644 --- a/adapter/internal/discovery/xds/server.go +++ b/adapter/internal/discovery/xds/server.go @@ -79,12 +79,9 @@ type EnvoyGatewayConfig struct { type EnforcerInternalAPI struct { configs []types.Resource keyManagers []types.Resource - subscriptions []types.Resource - applications []types.Resource apiList []types.Resource applicationPolicies []types.Resource subscriptionPolicies []types.Resource - applicationKeyMappings []types.Resource revokedTokens []types.Resource jwtIssuers []types.Resource } @@ -97,12 +94,9 @@ var ( cache envoy_cachev3.SnapshotCache enforcerCache wso2_cache.SnapshotCache enforcerJwtIssuerCache wso2_cache.SnapshotCache - enforcerSubscriptionCache wso2_cache.SnapshotCache - enforcerApplicationCache wso2_cache.SnapshotCache enforcerAPICache wso2_cache.SnapshotCache enforcerApplicationPolicyCache wso2_cache.SnapshotCache enforcerSubscriptionPolicyCache wso2_cache.SnapshotCache - enforcerApplicationKeyMappingCache wso2_cache.SnapshotCache enforcerKeyManagerCache wso2_cache.SnapshotCache enforcerRevokedTokensCache wso2_cache.SnapshotCache enforcerThrottleDataCache wso2_cache.SnapshotCache @@ -158,12 +152,9 @@ 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) enforcerAPICache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) enforcerApplicationPolicyCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) enforcerSubscriptionPolicyCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) - enforcerApplicationKeyMappingCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) enforcerKeyManagerCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) enforcerRevokedTokensCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) enforcerThrottleDataCache = wso2_cache.NewSnapshotCache(false, IDHash{}, nil) @@ -192,16 +183,6 @@ 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 -} - // GetEnforcerJWTIssuerCache returns xds server cache. func GetEnforcerJWTIssuerCache() wso2_cache.SnapshotCache { return enforcerJwtIssuerCache @@ -222,11 +203,6 @@ func GetEnforcerSubscriptionPolicyCache() wso2_cache.SnapshotCache { return enforcerSubscriptionPolicyCache } -// GetEnforcerApplicationKeyMappingCache returns xds server cache. -func GetEnforcerApplicationKeyMappingCache() wso2_cache.SnapshotCache { - return enforcerApplicationKeyMappingCache -} - // GetEnforcerKeyManagerCache returns xds server cache. func GetEnforcerKeyManagerCache() wso2_cache.SnapshotCache { return enforcerKeyManagerCache @@ -581,48 +557,6 @@ func UpdateEnforcerApis(label string, apis []types.Resource, version string) { UpdateEnforcerAPIList(label, subAPIList) } -// UpdateEnforcerSubscriptions sets new update to the enforcer's Subscriptions -func UpdateEnforcerSubscriptions(subscriptions *subscription.SubscriptionList) { - //TODO: (Dinusha) check this hardcoded value - logger.LoggerXds.Debug("Updating Enforcer Subscription Cache") - label := commonEnforcerLabel - subscriptionList := append(enforcerLabelMap[label].subscriptions, subscriptions) - - // TODO: (VirajSalaka) Decide if a map is required to keep version (just to avoid having the same version) - version, _ := crand.Int(crand.Reader, maxRandomBigInt()) - snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ - wso2_resource.SubscriptionListType: subscriptionList, - }) - snap.Consistent() - - errSetSnap := enforcerSubscriptionCache.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].subscriptions = subscriptionList - logger.LoggerXds.Infof("New Subscription cache update for the label: " + label + " version: " + fmt.Sprint(version)) -} - -// UpdateEnforcerApplications sets new update to the enforcer's Applications -func UpdateEnforcerApplications(applications *subscription.ApplicationList) { - logger.LoggerXds.Debug("Updating Enforcer Application Cache") - label := commonEnforcerLabel - applicationList := append(enforcerLabelMap[label].applications, applications) - - version, _ := crand.Int(crand.Reader, maxRandomBigInt()) - snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ - wso2_resource.ApplicationListType: applicationList, - }) - snap.Consistent() - - errSetSnap := enforcerApplicationCache.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].applications = applicationList - logger.LoggerXds.Infof("New Application cache update for the label: " + label + " version: " + fmt.Sprint(version)) -} - // UpdateEnforcerJWTIssuers sets new update to the enforcer's Applications func UpdateEnforcerJWTIssuers(jwtIssuers *subscription.JWTIssuerList) { logger.LoggerXds.Debug("Updating Enforcer JWT Issuer Cache") @@ -702,26 +636,6 @@ func UpdateEnforcerSubscriptionPolicies(subscriptionPolicies *subscription.Subsc logger.LoggerXds.Infof("New Subscription Policy cache update for the label: " + label + " version: " + fmt.Sprint(version)) } -// UpdateEnforcerApplicationKeyMappings sets new update to the enforcer's Application Key Mappings -func UpdateEnforcerApplicationKeyMappings(applicationKeyMappings *subscription.ApplicationKeyMappingList) { - logger.LoggerXds.Debug("Updating Application Key Mapping Cache") - label := commonEnforcerLabel - applicationKeyMappingList := append(enforcerLabelMap[label].applicationKeyMappings, applicationKeyMappings) - - version, _ := crand.Int(crand.Reader, maxRandomBigInt()) - snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ - wso2_resource.ApplicationKeyMappingListType: applicationKeyMappingList, - }) - snap.Consistent() - - errSetSnap := enforcerApplicationKeyMappingCache.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].applicationKeyMappings = applicationKeyMappingList - logger.LoggerXds.Infof("New Application Key Mapping 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/management-server/xds/application_event_listener.go b/adapter/internal/management-server/xds/application_event_listener.go deleted file mode 100644 index 76614f6bc..000000000 --- a/adapter/internal/management-server/xds/application_event_listener.go +++ /dev/null @@ -1,83 +0,0 @@ -package xds - -import ( - "context" - "errors" - - "github.com/wso2/apk/adapter/internal/loggers" - logging "github.com/wso2/apk/adapter/internal/logging" - cpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// HandleApplicationEventsFromMgtServer handles the Application events -func HandleApplicationEventsFromMgtServer(c client.Client, cReader client.Reader) { - for applicationEvent := range applicationChannel { - switch applicationEvent.Type { - case ApplicationCreate: - if found, _, err := checkApplicationExists(applicationEvent.Application, c, cReader); err == nil && !found { - if err := c.Create(context.Background(), *&applicationEvent.Application); err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1707, logging.CRITICAL, "Error creating application: %v", err.Error())) - } else { - loggers.LoggerXds.Info("Application created: " + applicationEvent.Application.Name) - } - } - break - case ApplicationUpdate: - if found, application, err := checkApplicationExists(applicationEvent.Application, c, cReader); err == nil && found { - application.Spec = applicationEvent.Application.Spec - err := c.Update(context.Background(), application) - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1709, logging.CRITICAL, "Error updating application: %v", err.Error())) - } else { - loggers.LoggerXds.Info("Application updated: " + applicationEvent.Application.Name) - } - } - break - case ApplicationDelete: - err := c.Delete(context.Background(), *&applicationEvent.Application) - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1710, logging.CRITICAL, "Error deleting application: %v", err.Error())) - } else { - loggers.LoggerXds.Info("Application deleted: " + applicationEvent.Application.Name) - } - break - default: - loggers.LoggerXds.Info("Unknown Application Event Type") - } - } -} - -func checkApplicationExists(application *cpv1alpha1.Application, c client.Client, cReader client.Reader) (bool, *cpv1alpha1.Application, error) { - var retrivedApplication = new(cpv1alpha1.Application) - // Try reading from cache - if err := c.Get(context.Background(), types.NamespacedName{ - Name: application.Name, - Namespace: application.Namespace}, retrivedApplication); err != nil { - - target := &ctrlcache.ErrCacheNotStarted{} - if errors.As(err, &target) { - // Try reading from api server directly - if err := cReader.Get(context.Background(), types.NamespacedName{ - Name: application.Name, - Namespace: application.Namespace}, retrivedApplication); err != nil { - - if !apierrors.IsNotFound(err) { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1711, logging.CRITICAL, "Error retrieving application: %v", err.Error())) - return false, nil, err - } - return false, nil, nil - } - } else if !apierrors.IsNotFound(err) { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1711, logging.CRITICAL, "Error retrieving application: %v", err.Error())) - return false, nil, err - } else { - return false, nil, nil - } - } - return true, retrivedApplication, nil -} diff --git a/adapter/internal/management-server/xds/client.go b/adapter/internal/management-server/xds/client.go deleted file mode 100644 index e4e705b44..000000000 --- a/adapter/internal/management-server/xds/client.go +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (c) 2021, 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 xds - -import ( - "context" - "fmt" - "io" - "reflect" - - core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" - discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" - "github.com/golang/protobuf/ptypes" - "github.com/wso2/apk/adapter/config" - "github.com/wso2/apk/adapter/internal/loggers" - logging "github.com/wso2/apk/adapter/internal/logging" - "github.com/wso2/apk/adapter/internal/management-server/utils" - cpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1" - - stub "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/service/subscription" - sub_model "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription" - - operatorutils "github.com/wso2/apk/adapter/internal/operator/utils" - "github.com/wso2/apk/adapter/pkg/utils/stringutils" - "google.golang.org/genproto/googleapis/rpc/status" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - grpcStatus "google.golang.org/grpc/status" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var ( - // Last Acknowledged Response from the apkmgt server - lastAckedResponse *discovery.DiscoveryResponse - // Last Received Response from the apkmgt server - // Last Received Response is always is equal to the lastAckedResponse according to current implementation as there is no - // validation performed on successfully received response. - lastReceivedResponse *discovery.DiscoveryResponse - // XDS stream for streaming Aplications from APK Mgt client - xdsStream stub.ApplicationDiscoveryService_StreamApplicationsClient - // applicationMap contains the application cache - applicationMap map[string]cpv1alpha1.Application - // applicationChannel is used to notifiy the application updates - applicationChannel chan ApplicationEvent - // subscriptionMap contains the application cache - subscriptionMap map[string]cpv1alpha1.Subscription - // subscriptionChannel is used to notifiy the subscription updates - subscriptionChannel chan SubscriptionEvent - // XDS stream for streaming Subscriptions from client - xdsSubStream stub.SubscriptionDiscoveryService_StreamSubscriptionsClient - // Last Acknowledged Response from the apkmgt server - lastAckedResponseSub *discovery.DiscoveryResponse - // Last Received Response from the apkmgt server - // Last Received Response is always is equal to the lastAckedResponse according to current implementation as there is no - // validation performed on successfully received response. - lastReceivedResponseSub *discovery.DiscoveryResponse -) - -// EventType is the type of the event -type EventType int - -const ( - // ApplicationCreate is application create event type - ApplicationCreate = 0 - // ApplicationUpdate is application update event type - ApplicationUpdate = 1 - // ApplicationDelete is application delete event type - ApplicationDelete = 2 -) - -const ( - // SubscriptionCreate is subscription create event type - SubscriptionCreate = 0 - // SubscriptionUpdate is subscription update event type - SubscriptionUpdate = 1 - // SubscriptionDelete is subscription delete event type - SubscriptionDelete = 2 -) - -// ApplicationEvent is the application event data holder -type ApplicationEvent struct { - Type EventType - Application *cpv1alpha1.Application -} - -// SubscriptionEvent is the subsctiption event data holder -type SubscriptionEvent struct { - Type EventType - Subscription *cpv1alpha1.Subscription -} - -const ( - // The type url for requesting Application Entries from apkmgt server. - applicationTypeURL string = "type.googleapis.com/wso2.discovery.subscription.Application" - // The type url for requesting Subscription Entries from apkmgt server. - subscriptionTypeURL string = "type.googleapis.com/wso2.discovery.subscription.Subscription" -) - -func init() { - lastAckedResponse = &discovery.DiscoveryResponse{} - lastAckedResponseSub = &discovery.DiscoveryResponse{} - applicationChannel = make(chan ApplicationEvent, 1000) - applicationMap = make(map[string]cpv1alpha1.Application) - subscriptionChannel = make(chan SubscriptionEvent, 1000) - subscriptionMap = make(map[string]cpv1alpha1.Subscription) -} - -func initConnection(xdsURL string) error { - // TODO: (AmaliMatharaarachchi) Bring in connection level configurations - transportCredentials, err := utils.GenerateTLSCredentials() - conn, err := grpc.Dial(xdsURL, grpc.WithTransportCredentials(transportCredentials), grpc.WithBlock()) - if err != nil { - // TODO: (AmaliMatharaarachchi) retries - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1700, logging.BLOCKER, "Error while connecting to the APK Management Server. %v", err.Error())) - return err - } - - client := stub.NewApplicationDiscoveryServiceClient(conn) - clientSub := stub.NewSubscriptionDiscoveryServiceClient(conn) - streamContext := context.Background() - xdsStream, err = client.StreamApplications(streamContext) - xdsSubStream, err = clientSub.StreamSubscriptions(streamContext) - - if err != nil { - // TODO: (AmaliMatharaarachchi) handle error. - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1701, logging.BLOCKER, "Error while starting APK Management application stream. %v", err.Error())) - return err - } - loggers.LoggerXds.Infof("Connection to the APK Management Server: %s is successful.", xdsURL) - return nil -} - -func watchApplications() { - for { - discoveryResponse, err := xdsStream.Recv() - if err == io.EOF { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1702, logging.CRITICAL, "EOF is received from the APK Management Server application stream. %v", err.Error())) - return - } - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1703, logging.CRITICAL, "Failed to receive the discovery response from the APK Management Server application stream. %v", err.Error())) - errStatus, _ := grpcStatus.FromError(err) - if errStatus.Code() == codes.Unavailable { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1704, logging.MINOR, "The APK Management Server application stream connection stopped: %v", err.Error())) - return - } - nack(err.Error()) - } else { - lastReceivedResponse = discoveryResponse - loggers.LoggerXds.Debugf("Discovery response is received : %s", discoveryResponse.VersionInfo) - addApplicationsToChannel(discoveryResponse) - ack() - } - } -} - -func watchSubscriptions() { - for { - discoveryResponse, err := xdsSubStream.Recv() - if err == io.EOF { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1717, logging.CRITICAL, "EOF is received from the APK Management Server subscription stream. %v", err.Error())) - return - } - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1718, logging.CRITICAL, "Failed to receive the discovery response from the APK Management Server subscription stream. %v", err.Error())) - errStatus, _ := grpcStatus.FromError(err) - if errStatus.Code() == codes.Unavailable { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1719, logging.MINOR, "The APK Management Server subscription stream connection stopped: %v", err.Error())) - return - } - nackSub(err.Error()) - } else { - lastReceivedResponseSub = discoveryResponse - loggers.LoggerXds.Debugf("Discovery response is received : %s", discoveryResponse.VersionInfo) - addSubscriptionsToChannel(discoveryResponse) - ackSub() - } - } -} - -func ack() { - lastAckedResponse = lastReceivedResponse - discoveryRequest := &discovery.DiscoveryRequest{ - Node: getAdapterNode(), - VersionInfo: lastAckedResponse.VersionInfo, - TypeUrl: applicationTypeURL, - ResponseNonce: lastReceivedResponse.Nonce, - } - xdsStream.Send(discoveryRequest) -} - -func ackSub() { - lastAckedResponseSub = lastReceivedResponseSub - discoveryRequest := &discovery.DiscoveryRequest{ - Node: getAdapterNode(), - VersionInfo: lastAckedResponseSub.VersionInfo, - TypeUrl: subscriptionTypeURL, - ResponseNonce: lastReceivedResponseSub.Nonce, - } - xdsSubStream.Send(discoveryRequest) -} - -func nack(errorMessage string) { - if lastAckedResponse == nil { - return - } - discoveryRequest := &discovery.DiscoveryRequest{ - Node: getAdapterNode(), - VersionInfo: lastAckedResponse.VersionInfo, - TypeUrl: applicationTypeURL, - ResponseNonce: lastReceivedResponse.Nonce, - ErrorDetail: &status.Status{ - Message: errorMessage, - }, - } - xdsStream.Send(discoveryRequest) -} - -func nackSub(errorMessage string) { - if lastAckedResponseSub == nil { - return - } - discoveryRequest := &discovery.DiscoveryRequest{ - Node: getAdapterNode(), - VersionInfo: lastAckedResponseSub.VersionInfo, - TypeUrl: subscriptionTypeURL, - ResponseNonce: lastReceivedResponseSub.Nonce, - ErrorDetail: &status.Status{ - Message: errorMessage, - }, - } - xdsSubStream.Send(discoveryRequest) -} - -func getAdapterNode() *core.Node { - config := config.ReadConfigs() - return &core.Node{ - Id: config.ManagementServer.NodeLabel, - } -} - -// InitApkMgtXDSClient initializes the connection to the apkmgt server. -func InitApkMgtXDSClient() { - loggers.LoggerXds.Info("Starting the XDS Client connection to APK Management server.") - config := config.ReadConfigs() - err := initConnection(fmt.Sprintf("%s:%d", config.ManagementServer.Host, config.ManagementServer.XDSPort)) - if err == nil { - go watchApplications() - discoveryRequest := &discovery.DiscoveryRequest{ - Node: getAdapterNode(), - VersionInfo: "", - TypeUrl: applicationTypeURL, - } - xdsStream.Send(discoveryRequest) - go watchSubscriptions() - discoveryRequestSub := &discovery.DiscoveryRequest{ - Node: getAdapterNode(), - VersionInfo: "", - TypeUrl: subscriptionTypeURL, - } - xdsSubStream.Send(discoveryRequestSub) - } else { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1705, logging.BLOCKER, "Error while starting the APK Management Server: %v", err.Error())) - } -} - -func addApplicationsToChannel(resp *discovery.DiscoveryResponse) { - var newApplicationUUIDs []string - - for _, res := range resp.Resources { - application := &sub_model.Application{} - err := ptypes.UnmarshalAny(res, application) - - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1706, logging.MINOR, "Error while unmarshalling APK Management Server Application discovery response: %v", err.Error())) - continue - } - - applicationUUID := application.Uuid - newApplicationUUIDs = append(newApplicationUUIDs, applicationUUID) - - applicationResource := &cpv1alpha1.Application{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: operatorutils.GetOperatorPodNamespace(), - Name: application.Uuid, - }, - Spec: cpv1alpha1.ApplicationSpec{ - Name: application.Name, - Owner: application.Owner, - Attributes: application.Attributes, - Policy: application.Policy, - Organization: application.Organization, - }, - } - - var consumerKeys []cpv1alpha1.Key - for _, consumerKey := range application.Keys { - consumerKeys = append(consumerKeys, cpv1alpha1.Key{Key: consumerKey.Key, KeyManager: consumerKey.KeyManager}) - } - applicationResource.Spec.Keys = consumerKeys - - // Todo:(Sampath) Need to handle adding the subscriptions coming from management server seperately - // var subscriptions []cpv1alpha1.Subscription - // for _, subscription := range application.Subscriptions { - // subscriptions = append(subscriptions, cpv1alpha1.Subscription{ - // UUID: subscription.Name, - // SubscriptionStatus: subscription.Spec.SubscriptionStatus, - // PolicyID: subscription.PolicyId, - // APIRef: subscription.ApiUuid, - // }) - // } - // applicationResource.Spec.Subscriptions = subscriptions - - var event ApplicationEvent - - if currentApplication, found := applicationMap[applicationUUID]; found { - if reflect.DeepEqual(currentApplication.Spec, applicationResource.Spec) { - continue - } - // Application update event - event = ApplicationEvent{ - Type: ApplicationUpdate, - Application: applicationResource, - } - applicationMap[applicationUUID] = *applicationResource - } else { - // Application create event - event = ApplicationEvent{ - Type: ApplicationCreate, - Application: applicationResource, - } - applicationMap[applicationUUID] = *applicationResource - } - - applicationChannel <- event - - } - // Send delete events for removed applications - for item := range applicationMap { - application := applicationMap[item] - if !stringutils.StringInSlice(application.Name, newApplicationUUIDs) { - // Application delete event - event := ApplicationEvent{ - Type: ApplicationDelete, - Application: &application, - } - applicationChannel <- event - delete(applicationMap, application.Name) - } - } -} - -func addSubscriptionsToChannel(resp *discovery.DiscoveryResponse) { - var newSubscriptionUUIDs []string - - for _, res := range resp.Resources { - subscription := &sub_model.Subscription{} - err := ptypes.UnmarshalAny(res, subscription) - - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1720, logging.MINOR, "Error while unmarshalling APK Management Server Subscription discovery response: %v", err.Error())) - continue - } - - subscriptionUUID := subscription.Uuid - newSubscriptionUUIDs = append(newSubscriptionUUIDs, subscriptionUUID) - - subscriptionResource := &cpv1alpha1.Subscription{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: operatorutils.GetOperatorPodNamespace(), - Name: subscription.Uuid, - }, - Spec: cpv1alpha1.SubscriptionSpec{ - APIRef: subscription.ApiRef, - ApplicationRef: subscription.ApplicationRef, - PolicyID: subscription.PolicyId, - SubscriptionStatus: subscription.SubStatus, - Subscriber: subscription.Subscriber, - Organization: subscription.Organization, - }, - } - - var event SubscriptionEvent - - if currentSubscription, found := subscriptionMap[subscriptionUUID]; found { - if reflect.DeepEqual(currentSubscription.Spec, subscriptionResource.Spec) { - continue - } - // Subscription update event - event = SubscriptionEvent{ - Type: SubscriptionUpdate, - Subscription: subscriptionResource, - } - subscriptionMap[subscriptionUUID] = *subscriptionResource - } else { - // Subscription create event - event = SubscriptionEvent{ - Type: SubscriptionCreate, - Subscription: subscriptionResource, - } - subscriptionMap[subscriptionUUID] = *subscriptionResource - } - - subscriptionChannel <- event - - } - // Send delete events for removed subscriptions - for item := range subscriptionMap { - subscription := subscriptionMap[item] - if !stringutils.StringInSlice(subscription.Name, newSubscriptionUUIDs) { - // Subscription delete event - event := SubscriptionEvent{ - Type: SubscriptionDelete, - Subscription: &subscription, - } - subscriptionChannel <- event - delete(subscriptionMap, subscription.Name) - } - } -} diff --git a/adapter/internal/management-server/xds/subscription_event_listener.go b/adapter/internal/management-server/xds/subscription_event_listener.go deleted file mode 100644 index 4af32c5c9..000000000 --- a/adapter/internal/management-server/xds/subscription_event_listener.go +++ /dev/null @@ -1,83 +0,0 @@ -package xds - -import ( - "context" - "errors" - - "github.com/wso2/apk/adapter/internal/loggers" - logging "github.com/wso2/apk/adapter/internal/logging" - cpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - ctrlcache "sigs.k8s.io/controller-runtime/pkg/cache" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// HandleSubscriptionEventsFromMgtServer handles the Subscription events -func HandleSubscriptionEventsFromMgtServer(c client.Client, cReader client.Reader) { - for subscriptionEvent := range subscriptionChannel { - switch subscriptionEvent.Type { - case SubscriptionCreate: - if found, _, err := checkSubscriptionExists(subscriptionEvent.Subscription, c, cReader); err == nil && !found { - if err := c.Create(context.Background(), *&subscriptionEvent.Subscription); err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1721, logging.CRITICAL, "Error creating subscription: %v", err.Error())) - } else { - loggers.LoggerXds.Info("Subscription created: " + subscriptionEvent.Subscription.Name) - } - } - break - case SubscriptionUpdate: - if found, subscription, err := checkSubscriptionExists(subscriptionEvent.Subscription, c, cReader); err == nil && found { - subscription.Spec = subscriptionEvent.Subscription.Spec - err := c.Update(context.Background(), subscription) - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1722, logging.CRITICAL, "Error updating subscription: %v", err.Error())) - } else { - loggers.LoggerXds.Info("Subscription updated: " + subscriptionEvent.Subscription.Name) - } - } - break - case SubscriptionDelete: - err := c.Delete(context.Background(), *&subscriptionEvent.Subscription) - if err != nil { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1723, logging.CRITICAL, "Error deleting subscription: %v", err.Error())) - } else { - loggers.LoggerXds.Info("Subscription deleted: " + subscriptionEvent.Subscription.Name) - } - break - default: - loggers.LoggerXds.Info("Unknown Subscription Event Type") - } - } -} - -func checkSubscriptionExists(subscription *cpv1alpha1.Subscription, c client.Client, cReader client.Reader) (bool, *cpv1alpha1.Subscription, error) { - var retrivedSubscription = new(cpv1alpha1.Subscription) - // Try reading from cache - if err := c.Get(context.Background(), types.NamespacedName{ - Name: subscription.Name, - Namespace: subscription.Namespace}, retrivedSubscription); err != nil { - - target := &ctrlcache.ErrCacheNotStarted{} - if errors.As(err, &target) { - // Try reading from api server directly - if err := cReader.Get(context.Background(), types.NamespacedName{ - Name: subscription.Name, - Namespace: subscription.Namespace}, retrivedSubscription); err != nil { - - if !apierrors.IsNotFound(err) { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1724, logging.CRITICAL, "Error retrieving subscription: %v", err.Error())) - return false, nil, err - } - return false, nil, nil - } - } else if !apierrors.IsNotFound(err) { - loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1724, logging.CRITICAL, "Error retrieving subscription: %v", err.Error())) - return false, nil, err - } else { - return false, nil, nil - } - } - return true, retrivedSubscription, nil -} diff --git a/adapter/internal/oasparser/config_generator.go b/adapter/internal/oasparser/config_generator.go index 5042bddb3..acf6174ff 100644 --- a/adapter/internal/oasparser/config_generator.go +++ b/adapter/internal/oasparser/config_generator.go @@ -211,9 +211,10 @@ func GetEnforcerAPI(adapterInternalAPI model.AdapterInternalAPI, vhost string) * ApplicationSecurity: adapterInternalAPI.GetXWSO2ApplicationSecurity(), // GraphQLSchema: adapterInternalAPI.GraphQLSchema, // GraphqlComplexityInfo: adapterInternalAPI.GraphQLComplexities.Data.List, - SystemAPI: adapterInternalAPI.IsSystemAPI, - ApiDefinitionFile: adapterInternalAPI.GetAPIDefinitionFile(), - Environment: adapterInternalAPI.GetEnvironment(), + SystemAPI: adapterInternalAPI.IsSystemAPI, + ApiDefinitionFile: adapterInternalAPI.GetAPIDefinitionFile(), + Environment: adapterInternalAPI.GetEnvironment(), + SubscriptionValidation: adapterInternalAPI.GetSubscriptionValidation(), } } diff --git a/adapter/internal/oasparser/model/adapter_internal_api.go b/adapter/internal/oasparser/model/adapter_internal_api.go index b7d9f7b03..aadc9706d 100644 --- a/adapter/internal/oasparser/model/adapter_internal_api.go +++ b/adapter/internal/oasparser/model/adapter_internal_api.go @@ -66,6 +66,7 @@ type AdapterInternalAPI struct { backendJWTTokenInfo *BackendJWTTokenInfo apiDefinitionFile []byte apiDefinitionEndpoint string + subscriptionValidation bool APIProperties []dpv1alpha2.Property // GraphQLSchema string // GraphQLComplexities GraphQLComplexityYaml @@ -233,6 +234,11 @@ func (swagger *AdapterInternalAPI) GetAPIDefinitionEndpoint() string { return swagger.apiDefinitionEndpoint } +// GetSubscriptionValidation returns the subscription validation status. +func (swagger *AdapterInternalAPI) GetSubscriptionValidation() bool { + return swagger.subscriptionValidation +} + // GetBackendJWTTokenInfo returns the BackendJWTTokenInfo Object. func (swagger *AdapterInternalAPI) GetBackendJWTTokenInfo() *BackendJWTTokenInfo { return swagger.backendJWTTokenInfo @@ -340,6 +346,11 @@ func (swagger *AdapterInternalAPI) SetAPIDefinitionEndpoint(endpoint string) { swagger.apiDefinitionEndpoint = endpoint } +// SetSubscriptionValidation sets the subscription validation status. +func (swagger *AdapterInternalAPI) SetSubscriptionValidation(subscriptionValidation bool) { + swagger.subscriptionValidation = subscriptionValidation +} + // SetName sets the name of the API func (swagger *AdapterInternalAPI) SetName(name string) { swagger.title = name diff --git a/adapter/internal/oasparser/model/http_route.go b/adapter/internal/oasparser/model/http_route.go index 4fa02b0df..1a41b7eb0 100644 --- a/adapter/internal/oasparser/model/http_route.go +++ b/adapter/internal/oasparser/model/http_route.go @@ -37,8 +37,8 @@ import ( type ResourceParams struct { AuthSchemes map[string]dpv1alpha1.Authentication ResourceAuthSchemes map[string]dpv1alpha1.Authentication - APIPolicies map[string]dpv1alpha1.APIPolicy - ResourceAPIPolicies map[string]dpv1alpha1.APIPolicy + APIPolicies map[string]dpv1alpha2.APIPolicy + ResourceAPIPolicies map[string]dpv1alpha2.APIPolicy InterceptorServiceMapping map[string]dpv1alpha1.InterceptorService BackendJWTMapping map[string]dpv1alpha1.BackendJWT BackendMapping map[string]*dpv1alpha1.ResolvedBackend @@ -62,7 +62,7 @@ func (swagger *AdapterInternalAPI) SetInfoHTTPRouteCR(httpRoute *gwapiv1b1.HTTPR if outputAuthScheme != nil { authScheme = *outputAuthScheme } - var apiPolicy *dpv1alpha1.APIPolicy + var apiPolicy *dpv1alpha2.APIPolicy if outputAPIPolicy != nil { apiPolicy = *outputAPIPolicy } @@ -282,7 +282,6 @@ func (swagger *AdapterInternalAPI) SetInfoHTTPRouteCR(httpRoute *gwapiv1b1.HTTPR resourceAPIPolicy = concatAPIPolicies(resourceAPIPolicy, nil) resourceAuthScheme = concatAuthSchemes(resourceAuthScheme, nil) resourceRatelimitPolicy = concatRateLimitPolicies(resourceRatelimitPolicy, nil) - addOperationLevelInterceptors(&policies, resourceAPIPolicy, resourceParams.InterceptorServiceMapping, resourceParams.BackendMapping, httpRoute.Namespace) loggers.LoggerOasparser.Debugf("Calculating auths for API ..., API_UUID = %v", swagger.UUID) @@ -408,7 +407,7 @@ func parseBackendJWTTokenToInternal(backendJWTToken dpv1alpha1.BackendJWTSpec) * return backendJWTTokenInternal } -func getCorsConfigFromAPIPolicy(apiPolicy *dpv1alpha1.APIPolicy) *CorsConfig { +func getCorsConfigFromAPIPolicy(apiPolicy *dpv1alpha2.APIPolicy) *CorsConfig { var corsConfig *CorsConfig if apiPolicy != nil && apiPolicy.Spec.Override != nil { if apiPolicy.Spec.Override.CORSPolicy != nil { @@ -442,7 +441,7 @@ func parseRateLimitPolicyToInternal(ratelimitPolicy *dpv1alpha1.RateLimitPolicy) } // addOperationLevelInterceptors add the operation level interceptor policy to the policies -func addOperationLevelInterceptors(policies *OperationPolicies, apiPolicy *dpv1alpha1.APIPolicy, +func addOperationLevelInterceptors(policies *OperationPolicies, apiPolicy *dpv1alpha2.APIPolicy, interceptorServicesMapping map[string]dpv1alpha1.InterceptorService, backendMapping map[string]*dpv1alpha1.ResolvedBackend, namespace string) { if apiPolicy != nil && apiPolicy.Spec.Override != nil { @@ -534,8 +533,8 @@ func concatRateLimitPolicies(schemeUp *dpv1alpha1.RateLimitPolicy, schemeDown *d return &finalRateLimit } -func concatAPIPolicies(schemeUp *dpv1alpha1.APIPolicy, schemeDown *dpv1alpha1.APIPolicy) *dpv1alpha1.APIPolicy { - apiPolicy := dpv1alpha1.APIPolicy{} +func concatAPIPolicies(schemeUp *dpv1alpha2.APIPolicy, schemeDown *dpv1alpha2.APIPolicy) *dpv1alpha2.APIPolicy { + apiPolicy := dpv1alpha2.APIPolicy{} if schemeUp != nil && schemeDown != nil { apiPolicy.Spec.Override = utils.SelectPolicy(&schemeUp.Spec.Override, &schemeUp.Spec.Default, &schemeDown.Spec.Override, &schemeDown.Spec.Default) } else if schemeUp != nil { diff --git a/adapter/internal/oasparser/model/http_route_test.go b/adapter/internal/oasparser/model/http_route_test.go index d9dd2b863..0ce0826b0 100644 --- a/adapter/internal/oasparser/model/http_route_test.go +++ b/adapter/internal/oasparser/model/http_route_test.go @@ -22,6 +22,7 @@ import ( "github.com/stretchr/testify/assert" dpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha2" ) func TestConcatRateLimitPolicies(t *testing.T) { @@ -198,35 +199,35 @@ func TestConcatRateLimitPolicies(t *testing.T) { func TestConcatAPIPolicies(t *testing.T) { type testItem struct { - schemeUpSpec dpv1alpha1.APIPolicySpec - schemeDownSpec dpv1alpha1.APIPolicySpec - result dpv1alpha1.APIPolicySpec + schemeUpSpec dpv1alpha2.APIPolicySpec + schemeDownSpec dpv1alpha2.APIPolicySpec + result dpv1alpha2.APIPolicySpec message string } - schemeUp := &dpv1alpha1.APIPolicy{} - schemeDown := &dpv1alpha1.APIPolicy{} - resultScheme := &dpv1alpha1.APIPolicy{} + schemeUp := &dpv1alpha2.APIPolicy{} + schemeDown := &dpv1alpha2.APIPolicy{} + resultScheme := &dpv1alpha2.APIPolicy{} dataItems := []testItem{ { - schemeUpSpec: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeUpSpec: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, }, - schemeDownSpec: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeDownSpec: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i2"}, }, }, }, - result: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + result: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, @@ -234,23 +235,23 @@ func TestConcatAPIPolicies(t *testing.T) { message: "only schemeUp override policies should be provided", }, { - schemeUpSpec: dpv1alpha1.APIPolicySpec{ - Default: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeUpSpec: dpv1alpha2.APIPolicySpec{ + Default: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, }, - schemeDownSpec: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeDownSpec: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i2"}, }, }, }, - result: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + result: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i2"}, }, }, @@ -258,23 +259,23 @@ func TestConcatAPIPolicies(t *testing.T) { message: "only schemeDown override policies should be provided", }, { - schemeUpSpec: dpv1alpha1.APIPolicySpec{ - Default: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeUpSpec: dpv1alpha2.APIPolicySpec{ + Default: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, }, - schemeDownSpec: dpv1alpha1.APIPolicySpec{ - Default: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeDownSpec: dpv1alpha2.APIPolicySpec{ + Default: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i2"}, }, }, }, - result: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + result: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i2"}, }, }, @@ -282,16 +283,16 @@ func TestConcatAPIPolicies(t *testing.T) { message: "only schemeDown default policies should be provided", }, { - schemeUpSpec: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeUpSpec: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, }, - result: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + result: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, @@ -299,16 +300,16 @@ func TestConcatAPIPolicies(t *testing.T) { message: "only schemeUp override policies is provided", }, { - schemeUpSpec: dpv1alpha1.APIPolicySpec{ - Default: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeUpSpec: dpv1alpha2.APIPolicySpec{ + Default: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, }, - result: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + result: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ {Name: "i1"}, }, }, @@ -316,39 +317,39 @@ func TestConcatAPIPolicies(t *testing.T) { message: "only schemeUp default policies is provided", }, { - schemeUpSpec: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeUpSpec: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ { Name: "up-request-interceptor", }, }, }, }, - schemeDownSpec: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + schemeDownSpec: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ { Name: "down-request-interceptor", }, }, }, - Default: &dpv1alpha1.PolicySpec{ - ResponseInterceptors: []dpv1alpha1.InterceptorReference{ + Default: &dpv1alpha2.PolicySpec{ + ResponseInterceptors: []dpv1alpha2.InterceptorReference{ { Name: "down-response-interceptor", }, }, }, }, - result: dpv1alpha1.APIPolicySpec{ - Override: &dpv1alpha1.PolicySpec{ - RequestInterceptors: []dpv1alpha1.InterceptorReference{ + result: dpv1alpha2.APIPolicySpec{ + Override: &dpv1alpha2.PolicySpec{ + RequestInterceptors: []dpv1alpha2.InterceptorReference{ { Name: "up-request-interceptor", }, }, - ResponseInterceptors: []dpv1alpha1.InterceptorReference{ + ResponseInterceptors: []dpv1alpha2.InterceptorReference{ { Name: "down-response-interceptor", }, diff --git a/adapter/internal/operator/PROJECT b/adapter/internal/operator/PROJECT index 04d0992dc..8960d64ab 100644 --- a/adapter/internal/operator/PROJECT +++ b/adapter/internal/operator/PROJECT @@ -22,15 +22,6 @@ resources: defaulting: true validation: true webhookVersion: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: wso2.com - group: cp - kind: Application - path: github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1 - version: v1alpha1 - api: crdVersion: v1 namespaced: true @@ -53,15 +44,6 @@ resources: defaulting: true validation: true webhookVersion: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: wso2.com - group: cp - kind: Subscription - path: github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1 - version: v1alpha1 - api: crdVersion: v1 namespaced: true @@ -135,6 +117,14 @@ resources: defaulting: true validation: true webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + domain: wso2.com + group: dp + kind: APIPolicy + path: github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha2 + version: v1alpha2 - api: crdVersion: v1 namespaced: true diff --git a/adapter/internal/operator/apis/dp/v1alpha2/apipolicy_types.go b/adapter/internal/operator/apis/dp/v1alpha2/apipolicy_types.go new file mode 100644 index 000000000..4bb4008a4 --- /dev/null +++ b/adapter/internal/operator/apis/dp/v1alpha2/apipolicy_types.go @@ -0,0 +1,148 @@ +/* + * 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1alpha2" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// APIPolicySpec defines the desired state of APIPolicy +type APIPolicySpec struct { + Default *PolicySpec `json:"default,omitempty"` + Override *PolicySpec `json:"override,omitempty"` + TargetRef gwapiv1b1.PolicyTargetReference `json:"targetRef,omitempty"` +} + +// PolicySpec contains API policies +type PolicySpec struct { + // RequestInterceptors referenced to intercetor services to be applied + // to the request flow. + // + // +optional + // +nullable + // +kubebuilder:validation:MaxItems=1 + RequestInterceptors []InterceptorReference `json:"requestInterceptors,omitempty"` + + // ResponseInterceptors referenced to intercetor services to be applied + // to the response flow. + // + // +optional + // +nullable + // +kubebuilder:validation:MaxItems=1 + ResponseInterceptors []InterceptorReference `json:"responseInterceptors,omitempty"` + + // BackendJWTPolicy holds reference to backendJWT policy configurations + BackendJWTPolicy *BackendJWTToken `json:"backendJwtPolicy,omitempty"` + + // CORS policy to be applied to the API. + CORSPolicy *CORSPolicy `json:"cORSPolicy,omitempty"` + + // SubscriptionValidation denotes whether subscription validation is enabled for the API + // + // +kubebuilder:default:=false + // +optional + SubscriptionValidation bool `json:"subscriptionValidation,omitempty"` +} + +// BackendJWTToken holds backend JWT token information +type BackendJWTToken struct { + // Name holds the name of the BackendJWT resource. + Name string `json:"name,omitempty"` +} + +// CORSPolicy holds CORS policy information +type CORSPolicy struct { + // AllowCredentials indicates whether the request can include user credentials like + // cookies, HTTP authentication or client side SSL certificates. + // + // +optional + AccessControlAllowCredentials bool `json:"accessControlAllowCredentials,omitempty"` + + // AccessControlAllowHeaders indicates which headers can be used + // during the actual request. + // + // +optional + AccessControlAllowHeaders []string `json:"accessControlAllowHeaders,omitempty"` + + // AccessControlAllowMethods indicates which methods can be used + // during the actual request. + // + // +optional + AccessControlAllowMethods []string `json:"accessControlAllowMethods,omitempty"` + + // AccessControlAllowOrigins indicates which origins can be used + // during the actual request. + // + // +optional + AccessControlAllowOrigins []string `json:"accessControlAllowOrigins,omitempty"` + + // AccessControlExposeHeaders indicates which headers can be exposed + // as part of the response by listing their names. + // + // +optional + AccessControlExposeHeaders []string `json:"accessControlExposeHeaders,omitempty"` + + // AccessControlMaxAge indicates how long the results of a preflight request + // can be cached in a preflight result cache. + // + // +optional + AccessControlMaxAge *int `json:"accessControlMaxAge,omitempty"` +} + +// InterceptorReference holds InterceptorService reference using name and namespace +type InterceptorReference struct { + // Name is the referced CR's name of InterceptorService resource. + Name string `json:"name"` +} + +// APIPolicyStatus defines the observed state of APIPolicy +type APIPolicyStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +// +genclient +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:storageversion + +// APIPolicy is the Schema for the apipolicies API +type APIPolicy struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec APIPolicySpec `json:"spec,omitempty"` + Status APIPolicyStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// APIPolicyList contains a list of APIPolicy +type APIPolicyList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []APIPolicy `json:"items"` +} + +func init() { + SchemeBuilder.Register(&APIPolicy{}, &APIPolicyList{}) +} diff --git a/adapter/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go b/adapter/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go index 566b24869..3763bcbd4 100644 --- a/adapter/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go +++ b/adapter/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go @@ -86,6 +86,106 @@ func (in *APIList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicy) DeepCopyInto(out *APIPolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicy. +func (in *APIPolicy) DeepCopy() *APIPolicy { + if in == nil { + return nil + } + out := new(APIPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIPolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicyList) DeepCopyInto(out *APIPolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]APIPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyList. +func (in *APIPolicyList) DeepCopy() *APIPolicyList { + if in == nil { + return nil + } + out := new(APIPolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIPolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicySpec) DeepCopyInto(out *APIPolicySpec) { + *out = *in + if in.Default != nil { + in, out := &in.Default, &out.Default + *out = new(PolicySpec) + (*in).DeepCopyInto(*out) + } + if in.Override != nil { + in, out := &in.Override, &out.Override + *out = new(PolicySpec) + (*in).DeepCopyInto(*out) + } + in.TargetRef.DeepCopyInto(&out.TargetRef) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicySpec. +func (in *APIPolicySpec) DeepCopy() *APIPolicySpec { + if in == nil { + return nil + } + out := new(APIPolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicyStatus) DeepCopyInto(out *APIPolicyStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyStatus. +func (in *APIPolicyStatus) DeepCopy() *APIPolicyStatus { + if in == nil { + return nil + } + out := new(APIPolicyStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *APISpec) DeepCopyInto(out *APISpec) { *out = *in @@ -136,6 +236,21 @@ func (in *APIStatus) DeepCopy() *APIStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackendJWTToken) DeepCopyInto(out *BackendJWTToken) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWTToken. +func (in *BackendJWTToken) DeepCopy() *BackendJWTToken { + if in == nil { + return nil + } + out := new(BackendJWTToken) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CERTConfig) DeepCopyInto(out *CERTConfig) { *out = *in @@ -166,6 +281,46 @@ func (in *CERTConfig) DeepCopy() *CERTConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CORSPolicy) DeepCopyInto(out *CORSPolicy) { + *out = *in + if in.AccessControlAllowHeaders != nil { + in, out := &in.AccessControlAllowHeaders, &out.AccessControlAllowHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlAllowMethods != nil { + in, out := &in.AccessControlAllowMethods, &out.AccessControlAllowMethods + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlAllowOrigins != nil { + in, out := &in.AccessControlAllowOrigins, &out.AccessControlAllowOrigins + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlExposeHeaders != nil { + in, out := &in.AccessControlExposeHeaders, &out.AccessControlExposeHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlMaxAge != nil { + in, out := &in.AccessControlMaxAge, &out.AccessControlMaxAge + *out = new(int) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CORSPolicy. +func (in *CORSPolicy) DeepCopy() *CORSPolicy { + if in == nil { + return nil + } + out := new(CORSPolicy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClaimMapping) DeepCopyInto(out *ClaimMapping) { *out = *in @@ -225,6 +380,21 @@ func (in *EnvConfig) DeepCopy() *EnvConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InterceptorReference) DeepCopyInto(out *InterceptorReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorReference. +func (in *InterceptorReference) DeepCopy() *InterceptorReference { + if in == nil { + return nil + } + out := new(InterceptorReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JWKS) DeepCopyInto(out *JWKS) { *out = *in @@ -245,6 +415,41 @@ func (in *JWKS) DeepCopy() *JWKS { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PolicySpec) DeepCopyInto(out *PolicySpec) { + *out = *in + if in.RequestInterceptors != nil { + in, out := &in.RequestInterceptors, &out.RequestInterceptors + *out = make([]InterceptorReference, len(*in)) + copy(*out, *in) + } + if in.ResponseInterceptors != nil { + in, out := &in.ResponseInterceptors, &out.ResponseInterceptors + *out = make([]InterceptorReference, len(*in)) + copy(*out, *in) + } + if in.BackendJWTPolicy != nil { + in, out := &in.BackendJWTPolicy, &out.BackendJWTPolicy + *out = new(BackendJWTToken) + **out = **in + } + if in.CORSPolicy != nil { + in, out := &in.CORSPolicy, &out.CORSPolicy + *out = new(CORSPolicy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicySpec. +func (in *PolicySpec) DeepCopy() *PolicySpec { + if in == nil { + return nil + } + out := new(PolicySpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Property) DeepCopyInto(out *Property) { *out = *in diff --git a/adapter/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml b/adapter/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml index 562864106..d05fe5fd6 100644 --- a/adapter/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml +++ b/adapter/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml @@ -248,6 +248,252 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - name: v1alpha2 + schema: + openAPIV3Schema: + description: APIPolicy is the Schema for the apipolicies API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: APIPolicySpec defines the desired state of APIPolicy + properties: + default: + description: PolicySpec contains API policies + properties: + backendJwtPolicy: + description: BackendJWTPolicy holds reference to backendJWT policy + configurations + properties: + name: + description: Name holds the name of the BackendJWT resource. + type: string + type: object + cORSPolicy: + description: CORS policy to be applied to the API. + properties: + accessControlAllowCredentials: + description: AllowCredentials indicates whether the request + can include user credentials like cookies, HTTP authentication + or client side SSL certificates. + type: boolean + accessControlAllowHeaders: + description: AccessControlAllowHeaders indicates which headers + can be used during the actual request. + items: + type: string + type: array + accessControlAllowMethods: + description: AccessControlAllowMethods indicates which methods + can be used during the actual request. + items: + type: string + type: array + accessControlAllowOrigins: + description: AccessControlAllowOrigins indicates which origins + can be used during the actual request. + items: + type: string + type: array + accessControlExposeHeaders: + description: AccessControlExposeHeaders indicates which headers + can be exposed as part of the response by listing their + names. + items: + type: string + type: array + accessControlMaxAge: + description: AccessControlMaxAge indicates how long the results + of a preflight request can be cached in a preflight result + cache. + type: integer + type: object + requestInterceptors: + description: RequestInterceptors referenced to intercetor services + to be applied to the request flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + responseInterceptors: + description: ResponseInterceptors referenced to intercetor services + to be applied to the response flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + subscriptionValidation: + default: false + description: SubscriptionValidation denotes whether subscription + validation is enabled for the API + type: boolean + type: object + override: + description: PolicySpec contains API policies + properties: + backendJwtPolicy: + description: BackendJWTPolicy holds reference to backendJWT policy + configurations + properties: + name: + description: Name holds the name of the BackendJWT resource. + type: string + type: object + cORSPolicy: + description: CORS policy to be applied to the API. + properties: + accessControlAllowCredentials: + description: AllowCredentials indicates whether the request + can include user credentials like cookies, HTTP authentication + or client side SSL certificates. + type: boolean + accessControlAllowHeaders: + description: AccessControlAllowHeaders indicates which headers + can be used during the actual request. + items: + type: string + type: array + accessControlAllowMethods: + description: AccessControlAllowMethods indicates which methods + can be used during the actual request. + items: + type: string + type: array + accessControlAllowOrigins: + description: AccessControlAllowOrigins indicates which origins + can be used during the actual request. + items: + type: string + type: array + accessControlExposeHeaders: + description: AccessControlExposeHeaders indicates which headers + can be exposed as part of the response by listing their + names. + items: + type: string + type: array + accessControlMaxAge: + description: AccessControlMaxAge indicates how long the results + of a preflight request can be cached in a preflight result + cache. + type: integer + type: object + requestInterceptors: + description: RequestInterceptors referenced to intercetor services + to be applied to the request flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + responseInterceptors: + description: ResponseInterceptors referenced to intercetor services + to be applied to the response flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + subscriptionValidation: + default: false + description: SubscriptionValidation denotes whether subscription + validation is enabled for the API + type: boolean + type: object + targetRef: + description: PolicyTargetReference identifies an API object to apply + policy to. This should be used as part of Policy resources that + can target Gateway API resources. For more information on how this + policy attachment model works, and a sample Policy resource, refer + to the policy attachment documentation for Gateway API. + properties: + group: + description: Group is the group of the target resource. + maxLength: 253 + pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + kind: + description: Kind is kind of the target resource. + maxLength: 63 + minLength: 1 + pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ + type: string + name: + description: Name is the name of the target resource. + maxLength: 253 + minLength: 1 + type: string + namespace: + description: Namespace is the namespace of the referent. When + unspecified, the local namespace is inferred. Even when policy + targets a resource in a different namespace, it MUST only apply + to traffic originating from the same namespace as the policy. + maxLength: 63 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + type: string + required: + - group + - kind + - name + type: object + type: object + status: + description: APIPolicyStatus defines the observed state of APIPolicy + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/adapter/internal/operator/config/rbac/role.yaml b/adapter/internal/operator/config/rbac/role.yaml index b545c4da4..5656192a7 100644 --- a/adapter/internal/operator/config/rbac/role.yaml +++ b/adapter/internal/operator/config/rbac/role.yaml @@ -5,58 +5,6 @@ metadata: creationTimestamp: null name: manager-role rules: -- apiGroups: - - cp.wso2.com - resources: - - applications - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - cp.wso2.com - resources: - - applications/finalizers - verbs: - - update -- apiGroups: - - cp.wso2.com - resources: - - applications/status - verbs: - - get - - patch - - update -- apiGroups: - - cp.wso2.com - resources: - - subscriptions - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - cp.wso2.com - resources: - - subscriptions/finalizers - verbs: - - update -- apiGroups: - - cp.wso2.com - resources: - - subscriptions/status - verbs: - - get - - patch - - update - apiGroups: - dp.wso2.com resources: diff --git a/adapter/internal/operator/config/samples/cp_v1alpha1_application_1.yaml b/adapter/internal/operator/config/samples/cp_v1alpha1_application_1.yaml deleted file mode 100644 index 64bb7ff6f..000000000 --- a/adapter/internal/operator/config/samples/cp_v1alpha1_application_1.yaml +++ /dev/null @@ -1,35 +0,0 @@ -apiVersion: cp.wso2.com/v1alpha1 -kind: Application -metadata: - labels: - app.kubernetes.io/name: application - app.kubernetes.io/instance: application-sample - app.kubernetes.io/part-of: test - app.kuberentes.io/managed-by: kustomize - app.kubernetes.io/created-by: test - name: application-sample-1 -spec: - uuid: 9ec2b927-47aa-456f-b6de-1959274f3asdasdw - name: app1 - owner: admin - policy: 10PerMin - organization: wso2 # not in the current application.proto - attributes: - attb1: value1 - attb2: value2 - consumerKeys: - - key: yef14gh8syDvTt56rdtIHYbjF_Ya - keyManager: Resident Key Manager - subscriptions: - - uuid: ff041d1b-be19-4529-a861-86a79905a1aq - name: sub1 - apiRef: SwaggerPetstore - policyId: Unlimited - subscriptionStatus: ACTIVE - subscriber: Tom # not in the current application_key_mapping.proto - - uuid: ff041d1b-be19-4529-a861-86a79905a1ad - name: sub2 - apiRef: PizzaShack - policyId: Unlimited - subscriptionStatus: ACTIVE - subscriber: Bob diff --git a/adapter/internal/operator/config/samples/cp_v1alpha1_application_2.yaml b/adapter/internal/operator/config/samples/cp_v1alpha1_application_2.yaml deleted file mode 100644 index cc4eee289..000000000 --- a/adapter/internal/operator/config/samples/cp_v1alpha1_application_2.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: cp.wso2.com/v1alpha1 -kind: Application -metadata: - labels: - app.kubernetes.io/name: application - app.kubernetes.io/instance: application-sample - app.kubernetes.io/part-of: test - app.kuberentes.io/managed-by: kustomize - app.kubernetes.io/created-by: test - name: application-sample-2 -spec: - uuid: f46b39bf-2f22-4224-ae8b-bc295dcf9d78 - name: app2 - owner: Alice - policy: 20PerMin - organization: wso2 - attributes: - attb3: value3 - attb4: value4 - consumerKeys: - - key: hef14gh8syDvTtvoWYeIHYbjF_Ya - keyManager: Resident Key Manager - subscriptions: - - uuid: ff041d1b-be19-4529-a861-86a79905a1ad - name: sub1 - apiRef: SwaggerPetstore - policyId: Unlimited - subscriptionStatus: ACTIVE - subscriber: Tom diff --git a/adapter/internal/operator/config/samples/cp_v1alpha1_application_3.yaml b/adapter/internal/operator/config/samples/cp_v1alpha1_application_3.yaml deleted file mode 100644 index b7fba0e4f..000000000 --- a/adapter/internal/operator/config/samples/cp_v1alpha1_application_3.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: cp.wso2.com/v1alpha1 -kind: Application -metadata: - labels: - app.kubernetes.io/name: application - app.kubernetes.io/instance: application-sample - app.kubernetes.io/part-of: test - app.kuberentes.io/managed-by: kustomize - app.kubernetes.io/created-by: test - name: application-sample-3 -spec: - uuid: 77557d54-fcba-4da8-8300-2ab82b11347d - name: app3 - owner: Bob - policy: 10PerMin - organization: wso2 - consumerKeys: - - key: hef14gh8syDvTtvoWYeIHYbjF_Ya - keyManager: Resident Key Manager - subscriptions: - - uuid: ff041d1b-be19-4529-a861-86a79905a1ad - name: sub1 - apiRef: SwaggerPetstore - policyId: Unlimited - subscriptionStatus: ACTIVE - subscriber: Tom diff --git a/adapter/internal/operator/config/samples/dp_v1alpha2_apipolicy.yaml b/adapter/internal/operator/config/samples/dp_v1alpha2_apipolicy.yaml new file mode 100644 index 000000000..624f23869 --- /dev/null +++ b/adapter/internal/operator/config/samples/dp_v1alpha2_apipolicy.yaml @@ -0,0 +1,17 @@ +apiVersion: dp.wso2.com/v1alpha2 +kind: APIPolicy +metadata: + labels: + app.kubernetes.io/name: apipolicy + app.kubernetes.io/instance: apipolicy-sample + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: operator + name: apipolicy-sample +spec: + override: + subscriptionValidation: true + targetRef: + group: dp.wso2.com + kind: API + name: 5be9683b59c60816f0d6bf8debbc8f59610810df diff --git a/adapter/internal/operator/config/webhook/manifests.yaml b/adapter/internal/operator/config/webhook/manifests.yaml index 07c76c4b2..30633a719 100644 --- a/adapter/internal/operator/config/webhook/manifests.yaml +++ b/adapter/internal/operator/config/webhook/manifests.yaml @@ -31,7 +31,7 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-dp-wso2-com-v1alpha1-apipolicy + path: /mutate-dp-wso2-com-v1alpha2-apipolicy failurePolicy: Fail name: mapipolicy.kb.io rules: @@ -158,7 +158,7 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-dp-wso2-com-v1alpha1-apipolicy + path: /validate-dp-wso2-com-v1alpha2-apipolicy failurePolicy: Fail name: vapipolicy.kb.io rules: diff --git a/adapter/internal/operator/controllers/dp/api_controller.go b/adapter/internal/operator/controllers/dp/api_controller.go index 77eafcf10..1151abca0 100644 --- a/adapter/internal/operator/controllers/dp/api_controller.go +++ b/adapter/internal/operator/controllers/dp/api_controller.go @@ -159,7 +159,7 @@ func NewAPIController(mgr manager.Manager, operatorDataStore *synchronizer.Opera return err } - if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha1.APIPolicy{}), handler.EnqueueRequestsFromMapFunc(apiReconciler.getAPIsForAPIPolicy), + if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha2.APIPolicy{}), handler.EnqueueRequestsFromMapFunc(apiReconciler.getAPIsForAPIPolicy), predicates...); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2617, logging.BLOCKER, "Error watching APIPolicy resources: %v", err)) return err @@ -314,10 +314,10 @@ func (apiReconciler *APIReconciler) resolveAPIRefs(ctx context.Context, api dpv1 return nil, fmt.Errorf("error while getting httproute resource apipolicy %s in namespace : %s with API UUID : %v, %s", apiRef.String(), namespace, string(api.ObjectMeta.UID), err.Error()) } - if apiState.InterceptorServiceMapping, apiState.BackendJWTMapping, err = + if apiState.InterceptorServiceMapping, apiState.BackendJWTMapping, apiState.SubscriptionValidation, err = apiReconciler.getAPIPolicyChildrenRefs(ctx, apiState.APIPolicies, apiState.ResourceAPIPolicies, api); err != nil { - return nil, fmt.Errorf("error while getting interceptor services %s in namespace : %s with API UUID : %v, %s", + return nil, fmt.Errorf("error while getting referenced policies in apipolicy %s in namespace : %s with API UUID : %v, %s", apiRef.String(), namespace, string(api.ObjectMeta.UID), err.Error()) } if api.Spec.DefinitionFileRef != "" { @@ -640,11 +640,10 @@ func (apiReconciler *APIReconciler) getRatelimitPoliciesForResources(ctx context return ratelimitpolicies, nil } -func (apiReconciler *APIReconciler) getAPIPoliciesForAPI(ctx context.Context, - api dpv1alpha2.API) (map[string]dpv1alpha1.APIPolicy, error) { +func (apiReconciler *APIReconciler) getAPIPoliciesForAPI(ctx context.Context, api dpv1alpha2.API) (map[string]dpv1alpha2.APIPolicy, error) { nameSpacedName := utils.NamespacedName(&api).String() - apiPolicies := make(map[string]dpv1alpha1.APIPolicy) - apiPolicyList := &dpv1alpha1.APIPolicyList{} + apiPolicies := make(map[string]dpv1alpha2.APIPolicy) + apiPolicyList := &dpv1alpha2.APIPolicyList{} if err := apiReconciler.client.List(ctx, apiPolicyList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(apiAPIPolicyIndex, nameSpacedName), }); err != nil { @@ -677,10 +676,10 @@ func (apiReconciler *APIReconciler) getAPIDefinitionForAPI(ctx context.Context, } func (apiReconciler *APIReconciler) getAPIPoliciesForResources(ctx context.Context, - api dpv1alpha2.API) (map[string]dpv1alpha1.APIPolicy, error) { + api dpv1alpha2.API) (map[string]dpv1alpha2.APIPolicy, error) { nameSpacedName := utils.NamespacedName(&api).String() - apiPolicies := make(map[string]dpv1alpha1.APIPolicy) - apiPolicyList := &dpv1alpha1.APIPolicyList{} + apiPolicies := make(map[string]dpv1alpha2.APIPolicy) + apiPolicyList := &dpv1alpha2.APIPolicyList{} if err := apiReconciler.client.List(ctx, apiPolicyList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(apiAPIPolicyResourceIndex, nameSpacedName), }); err != nil { @@ -699,12 +698,14 @@ func (apiReconciler *APIReconciler) getAPIPoliciesForResources(ctx context.Conte // getAPIPolicyChildrenRefs gets all the referenced policies in apipolicy for the resolving API // - interceptor services // - backend JWTs +// - subscription validation func (apiReconciler *APIReconciler) getAPIPolicyChildrenRefs(ctx context.Context, - apiPolicies, resourceAPIPolicies map[string]dpv1alpha1.APIPolicy, - api dpv1alpha2.API) (map[string]dpv1alpha1.InterceptorService, map[string]dpv1alpha1.BackendJWT, error) { + apiPolicies, resourceAPIPolicies map[string]dpv1alpha2.APIPolicy, + api dpv1alpha2.API) (map[string]dpv1alpha1.InterceptorService, map[string]dpv1alpha1.BackendJWT, bool, error) { allAPIPolicies := append(maps.Values(apiPolicies), maps.Values(resourceAPIPolicies)...) interceptorServices := make(map[string]dpv1alpha1.InterceptorService) backendJWTs := make(map[string]dpv1alpha1.BackendJWT) + subscriptionValidation := false for _, apiPolicy := range allAPIPolicies { if apiPolicy.Spec.Default != nil { if len(apiPolicy.Spec.Default.RequestInterceptors) > 0 { @@ -714,15 +715,6 @@ func (apiReconciler *APIReconciler) getAPIPolicyChildrenRefs(ctx context.Context interceptorServices[utils.NamespacedName(interceptorPtr).String()] = *interceptorPtr } } - if apiPolicy.Spec.Default.BackendJWTPolicy != nil { - backendJWTPtr := utils.GetBackendJWT(ctx, apiReconciler.client, apiPolicy.Namespace, - apiPolicy.Spec.Default.BackendJWTPolicy.Name, &api) - if backendJWTPtr != nil { - backendJWTs[utils.NamespacedName(backendJWTPtr).String()] = *backendJWTPtr - } - } - } - if apiPolicy.Spec.Default != nil { if len(apiPolicy.Spec.Default.ResponseInterceptors) > 0 { interceptorPtr := utils.GetInterceptorService(ctx, apiReconciler.client, apiPolicy.Namespace, &apiPolicy.Spec.Default.ResponseInterceptors[0], &api) @@ -737,6 +729,7 @@ func (apiReconciler *APIReconciler) getAPIPolicyChildrenRefs(ctx context.Context backendJWTs[utils.NamespacedName(backendJWTPtr).String()] = *backendJWTPtr } } + subscriptionValidation = apiPolicy.Spec.Default.SubscriptionValidation } if apiPolicy.Spec.Override != nil { if len(apiPolicy.Spec.Override.RequestInterceptors) > 0 { @@ -746,15 +739,6 @@ func (apiReconciler *APIReconciler) getAPIPolicyChildrenRefs(ctx context.Context interceptorServices[utils.NamespacedName(interceptorPtr).String()] = *interceptorPtr } } - if apiPolicy.Spec.Override.BackendJWTPolicy != nil { - backendJWTPtr := utils.GetBackendJWT(ctx, apiReconciler.client, apiPolicy.Namespace, - apiPolicy.Spec.Override.BackendJWTPolicy.Name, &api) - if backendJWTPtr != nil { - backendJWTs[utils.NamespacedName(backendJWTPtr).String()] = *backendJWTPtr - } - } - } - if apiPolicy.Spec.Override != nil { if len(apiPolicy.Spec.Override.ResponseInterceptors) > 0 { interceptorPtr := utils.GetInterceptorService(ctx, apiReconciler.client, apiPolicy.Namespace, &apiPolicy.Spec.Override.ResponseInterceptors[0], &api) @@ -769,9 +753,10 @@ func (apiReconciler *APIReconciler) getAPIPolicyChildrenRefs(ctx context.Context backendJWTs[utils.NamespacedName(backendJWTPtr).String()] = *backendJWTPtr } } + subscriptionValidation = apiPolicy.Spec.Override.SubscriptionValidation } } - return interceptorServices, backendJWTs, nil + return interceptorServices, backendJWTs, subscriptionValidation, nil } func (apiReconciler *APIReconciler) getResolvedBackendsMapping(ctx context.Context, @@ -935,7 +920,7 @@ func (apiReconciler *APIReconciler) getAPIsForAuthentication(ctx context.Context // from Authentication objects. If the changes are done for an API stored in the Operator Data store, // a new reconcile event will be created and added to the reconcile event queue. func (apiReconciler *APIReconciler) getAPIsForAPIPolicy(ctx context.Context, obj k8client.Object) []reconcile.Request { - apiPolicy, ok := obj.(*dpv1alpha1.APIPolicy) + apiPolicy, ok := obj.(*dpv1alpha2.APIPolicy) requests := []reconcile.Request{} if !ok { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2622, logging.TRIVIAL, "Unexpected object type, bypassing reconciliation: %v", apiPolicy)) @@ -974,7 +959,7 @@ func (apiReconciler *APIReconciler) getAPIsForInterceptorService(ctx context.Con return []reconcile.Request{} } - apiPolicyList := &dpv1alpha1.APIPolicyList{} + apiPolicyList := &dpv1alpha2.APIPolicyList{} if err := apiReconciler.client.List(ctx, apiPolicyList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(interceptorServiceAPIPolicyIndex, utils.NamespacedName(interceptorService).String()), }); err != nil { @@ -999,7 +984,7 @@ func (apiReconciler *APIReconciler) getAPIsForBackendJWT(ctx context.Context, ob return []reconcile.Request{} } - apiPolicyList := &dpv1alpha1.APIPolicyList{} + apiPolicyList := &dpv1alpha2.APIPolicyList{} if err := apiReconciler.client.List(ctx, apiPolicyList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(backendJWTAPIPolicyIndex, utils.NamespacedName(backendJWT).String()), }); err != nil { @@ -1426,9 +1411,9 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { } // interceptorService to APIPolicy indexer - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.APIPolicy{}, interceptorServiceAPIPolicyIndex, + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha2.APIPolicy{}, interceptorServiceAPIPolicyIndex, func(rawObj k8client.Object) []string { - apiPolicy := rawObj.(*dpv1alpha1.APIPolicy) + apiPolicy := rawObj.(*dpv1alpha2.APIPolicy) var interceptorServices []string if apiPolicy.Spec.Default != nil && len(apiPolicy.Spec.Default.RequestInterceptors) > 0 { interceptorServices = append(interceptorServices, @@ -1464,9 +1449,9 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { } // backendjwt to APIPolicy indexer - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.APIPolicy{}, backendJWTAPIPolicyIndex, + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha2.APIPolicy{}, backendJWTAPIPolicyIndex, func(rawObj k8client.Object) []string { - apiPolicy := rawObj.(*dpv1alpha1.APIPolicy) + apiPolicy := rawObj.(*dpv1alpha2.APIPolicy) var backendJWTs []string if apiPolicy.Spec.Default != nil && apiPolicy.Spec.Default.BackendJWTPolicy != nil { backendJWTs = append(backendJWTs, @@ -1502,9 +1487,9 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { } // httpRoute to APIPolicy indexer - if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.APIPolicy{}, apiAPIPolicyIndex, + if err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha2.APIPolicy{}, apiAPIPolicyIndex, func(rawObj k8client.Object) []string { - apiPolicy := rawObj.(*dpv1alpha1.APIPolicy) + apiPolicy := rawObj.(*dpv1alpha2.APIPolicy) var apis []string if apiPolicy.Spec.TargetRef.Kind == constants.KindAPI { @@ -1532,9 +1517,9 @@ func addIndexes(ctx context.Context, mgr manager.Manager) error { // https://gateway-api.sigs.k8s.io/geps/gep-713/?h=multiple+targetrefs#apply-policies-to-sections-of-a-resource-future-extension // we will use a temporary kindName called Resource for policy attachments // TODO(amali) Fix after the official support is available - err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.APIPolicy{}, apiAPIPolicyResourceIndex, + err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha2.APIPolicy{}, apiAPIPolicyResourceIndex, func(rawObj k8client.Object) []string { - apiPolicy := rawObj.(*dpv1alpha1.APIPolicy) + apiPolicy := rawObj.(*dpv1alpha2.APIPolicy) var apis []string if apiPolicy.Spec.TargetRef.Kind == constants.KindResource { diff --git a/adapter/internal/operator/controllers/dp/gateway_controller.go b/adapter/internal/operator/controllers/dp/gateway_controller.go index 271c0b040..cb8a98934 100644 --- a/adapter/internal/operator/controllers/dp/gateway_controller.go +++ b/adapter/internal/operator/controllers/dp/gateway_controller.go @@ -34,6 +34,7 @@ import ( "k8s.io/apimachinery/pkg/types" dpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha2" "github.com/wso2/apk/adapter/internal/operator/constants" "github.com/wso2/apk/adapter/internal/operator/status" "github.com/wso2/apk/adapter/internal/operator/synchronizer" @@ -104,7 +105,7 @@ func NewGatewayController(mgr manager.Manager, operatorDataStore *synchronizer.O return err } - if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha1.APIPolicy{}), handler.EnqueueRequestsFromMapFunc(r.getGatewaysForAPIPolicy), + if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha2.APIPolicy{}), handler.EnqueueRequestsFromMapFunc(r.getGatewaysForAPIPolicy), predicates...); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3101, logging.BLOCKER, "Error watching APIPolicy resources: %v", err)) return err @@ -247,9 +248,9 @@ func (gatewayReconciler *GatewayReconciler) resolveGatewayState(ctx context.Cont } func (gatewayReconciler *GatewayReconciler) getAPIPoliciesForGateway(ctx context.Context, - gateway *gwapiv1b1.Gateway) (map[string]dpv1alpha1.APIPolicy, error) { - apiPolicies := make(map[string]dpv1alpha1.APIPolicy) - apiPolicyList := &dpv1alpha1.APIPolicyList{} + gateway *gwapiv1b1.Gateway) (map[string]dpv1alpha2.APIPolicy, error) { + apiPolicies := make(map[string]dpv1alpha2.APIPolicy) + apiPolicyList := &dpv1alpha2.APIPolicyList{} if err := gatewayReconciler.client.List(ctx, apiPolicyList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(gatewayAPIPolicyIndex, utils.NamespacedName(gateway).String()), }); err != nil { @@ -264,7 +265,7 @@ func (gatewayReconciler *GatewayReconciler) getAPIPoliciesForGateway(ctx context // getInterceptorServicesForGateway returns the list of interceptor services for the given gateway func (gatewayReconciler *GatewayReconciler) getInterceptorServicesForGateway(ctx context.Context, - gatewayAPIPolicies map[string]dpv1alpha1.APIPolicy) (map[string]dpv1alpha1.InterceptorService, error) { + gatewayAPIPolicies map[string]dpv1alpha2.APIPolicy) (map[string]dpv1alpha1.InterceptorService, error) { allGatewayAPIPolicies := maps.Values(gatewayAPIPolicies) interceptorServices := make(map[string]dpv1alpha1.InterceptorService) for _, apiPolicy := range allGatewayAPIPolicies { @@ -297,7 +298,7 @@ func (gatewayReconciler *GatewayReconciler) getInterceptorServicesForGateway(ctx } } } - return interceptorServices, nil + return interceptorServices, nil // TODO(Ashera): Handle global subscription validation enable disable } func (gatewayReconciler *GatewayReconciler) getResolvedBackendsMapping(ctx context.Context, @@ -351,7 +352,7 @@ func (gatewayReconciler *GatewayReconciler) getAPIsForInterceptorService(ctx con requests := []reconcile.Request{} - apiPolicyList := &dpv1alpha1.APIPolicyList{} + apiPolicyList := &dpv1alpha2.APIPolicyList{} if err := gatewayReconciler.client.List(ctx, apiPolicyList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(interceptorServiceAPIPolicyIndex, utils.NamespacedName(interceptorService).String()), }); err != nil { @@ -378,7 +379,7 @@ func (gatewayReconciler *GatewayReconciler) getAPIsForBackendJWT(ctx context.Con requests := []reconcile.Request{} - apiPolicyList := &dpv1alpha1.APIPolicyList{} + apiPolicyList := &dpv1alpha2.APIPolicyList{} if err := gatewayReconciler.client.List(ctx, apiPolicyList, &k8client.ListOptions{ FieldSelector: fields.OneTermEqualSelector(backendJWTAPIPolicyIndex, utils.NamespacedName(backendJWT).String()), }); err != nil { @@ -536,7 +537,7 @@ func (gatewayReconciler *GatewayReconciler) getCustomRateLimitPoliciesForGateway // getGatewaysForAPIPolicy triggers the Gateway controller reconcile method // based on the changes detected from APIPolicy objects. func (gatewayReconciler *GatewayReconciler) getGatewaysForAPIPolicy(ctx context.Context, obj k8client.Object) []reconcile.Request { - apiPolicy, ok := obj.(*dpv1alpha1.APIPolicy) + apiPolicy, ok := obj.(*dpv1alpha2.APIPolicy) if !ok { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3107, logging.TRIVIAL, "Unexpected object type, bypassing reconciliation: %v", apiPolicy)) return nil @@ -591,9 +592,9 @@ func addGatewayIndexes(ctx context.Context, mgr manager.Manager) error { } // Gateway to APIPolicy indexer - err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha1.APIPolicy{}, gatewayAPIPolicyIndex, + err := mgr.GetFieldIndexer().IndexField(ctx, &dpv1alpha2.APIPolicy{}, gatewayAPIPolicyIndex, func(rawObj k8client.Object) []string { - apiPolicy := rawObj.(*dpv1alpha1.APIPolicy) + apiPolicy := rawObj.(*dpv1alpha2.APIPolicy) var httpRoutes []string if apiPolicy.Spec.TargetRef.Kind == constants.KindGateway { diff --git a/adapter/internal/operator/operator.go b/adapter/internal/operator/operator.go index ea2631672..12460c4d4 100644 --- a/adapter/internal/operator/operator.go +++ b/adapter/internal/operator/operator.go @@ -22,7 +22,7 @@ import ( "github.com/wso2/apk/adapter/config" "github.com/wso2/apk/adapter/internal/loggers" - "github.com/wso2/apk/adapter/internal/management-server/xds" + "github.com/wso2/apk/adapter/pkg/logging" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" @@ -44,7 +44,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - cpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1" dpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha1" dpv1alpha2 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha2" //+kubebuilder:scaffold:imports @@ -63,7 +62,6 @@ func init() { utilruntime.Must(gwapiv1a2.AddToScheme(scheme)) - utilruntime.Must(cpv1alpha1.AddToScheme(scheme)) utilruntime.Must(dpv1alpha2.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -141,11 +139,6 @@ func InitOperator() { go synchronizer.HandleAPILifeCycleEvents(&ch, &successChannel) go synchronizer.HandleGatewayLifeCycleEvents(&gatewaych) - if config.ReadConfigs().ManagementServer.Enabled { - go xds.InitApkMgtXDSClient() - go xds.HandleApplicationEventsFromMgtServer(mgr.GetClient(), mgr.GetAPIReader()) - go xds.HandleSubscriptionEventsFromMgtServer(mgr.GetClient(), mgr.GetAPIReader()) - } if config.ReadConfigs().PartitionServer.Enabled { go synchronizer.SendEventToPartitionServer() } diff --git a/adapter/internal/operator/synchronizer/api_state.go b/adapter/internal/operator/synchronizer/api_state.go index 38f21ad45..021c4e0ff 100644 --- a/adapter/internal/operator/synchronizer/api_state.go +++ b/adapter/internal/operator/synchronizer/api_state.go @@ -34,12 +34,13 @@ type APIState struct { RateLimitPolicies map[string]v1alpha1.RateLimitPolicy ResourceAuthentications map[string]v1alpha1.Authentication ResourceRateLimitPolicies map[string]v1alpha1.RateLimitPolicy - ResourceAPIPolicies map[string]v1alpha1.APIPolicy - APIPolicies map[string]v1alpha1.APIPolicy + ResourceAPIPolicies map[string]v1alpha2.APIPolicy + APIPolicies map[string]v1alpha2.APIPolicy InterceptorServiceMapping map[string]v1alpha1.InterceptorService BackendJWTMapping map[string]v1alpha1.BackendJWT APIDefinitionFile []byte OldOrganizationID string + SubscriptionValidation bool } // HTTPRouteState holds the state of the deployed httpRoutes. This state is compared with diff --git a/adapter/internal/operator/synchronizer/data_store.go b/adapter/internal/operator/synchronizer/data_store.go index b3b03c619..4eee0495e 100644 --- a/adapter/internal/operator/synchronizer/data_store.go +++ b/adapter/internal/operator/synchronizer/data_store.go @@ -151,6 +151,10 @@ func (ods *OperatorDataStore) processAPIState(apiNamespacedName types.Namespaced } } + if cachedAPI.SubscriptionValidation != apiState.SubscriptionValidation { + cachedAPI.SubscriptionValidation = apiState.SubscriptionValidation + } + if len(apiState.APIPolicies) != len(cachedAPI.APIPolicies) { cachedAPI.APIPolicies = apiState.APIPolicies updated = true diff --git a/adapter/internal/operator/synchronizer/gateway_state.go b/adapter/internal/operator/synchronizer/gateway_state.go index 47f318cd6..3ae7ee4a7 100644 --- a/adapter/internal/operator/synchronizer/gateway_state.go +++ b/adapter/internal/operator/synchronizer/gateway_state.go @@ -19,6 +19,7 @@ package synchronizer import ( "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha1" + "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha2" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) @@ -34,7 +35,7 @@ type GatewayState struct { // +k8s:deepcopy-gen=true type GatewayStateData struct { GatewayResolvedListenerCerts map[string]map[string][]byte - GatewayAPIPolicies map[string]v1alpha1.APIPolicy + GatewayAPIPolicies map[string]v1alpha2.APIPolicy GatewayBackendMapping map[string]*v1alpha1.ResolvedBackend GatewayInterceptorServiceMapping map[string]v1alpha1.InterceptorService GatewayCustomRateLimitPolicies map[string]*v1alpha1.RateLimitPolicy diff --git a/adapter/internal/operator/synchronizer/gateway_synchronizer.go b/adapter/internal/operator/synchronizer/gateway_synchronizer.go index 73d01a6cd..40a7e4ad9 100644 --- a/adapter/internal/operator/synchronizer/gateway_synchronizer.go +++ b/adapter/internal/operator/synchronizer/gateway_synchronizer.go @@ -27,6 +27,7 @@ import ( "github.com/wso2/apk/adapter/internal/oasparser/envoyconf" "github.com/wso2/apk/adapter/internal/oasparser/model" dpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/adapter/internal/operator/apis/dp/v1alpha2" "github.com/wso2/apk/adapter/internal/operator/constants" "github.com/wso2/apk/adapter/internal/operator/utils" "github.com/wso2/apk/adapter/pkg/logging" @@ -131,7 +132,7 @@ func getCustomRateLimitPolicies(customRateLimitPoliciesDef map[string]*dpv1alpha return customRateLimitPolicies } -func generateGlobalInterceptorResource(gatewayAPIPolicies map[string]dpv1alpha1.APIPolicy, +func generateGlobalInterceptorResource(gatewayAPIPolicies map[string]dpv1alpha2.APIPolicy, gatewayInterceptorServiceMapping map[string]dpv1alpha1.InterceptorService, gatewayBackendMapping map[string]*dpv1alpha1.ResolvedBackend) (string, *clusterv3.Cluster, []*corev3.Address, *clusterv3.Cluster, []*corev3.Address) { @@ -152,7 +153,7 @@ func generateGlobalInterceptorResource(gatewayAPIPolicies map[string]dpv1alpha1. return gwLuaScript, gwReqICluster, gwReqIAddresses, gwResICluster, gwResIAddresses } -func getGlobalInterceptorScript(gatewayAPIPolicies map[string]dpv1alpha1.APIPolicy, +func getGlobalInterceptorScript(gatewayAPIPolicies map[string]dpv1alpha2.APIPolicy, gatewayInterceptorServiceMapping map[string]dpv1alpha1.InterceptorService, gatewayBackendMapping map[string]*dpv1alpha1.ResolvedBackend) string { iInvCtx := &interceptor.InvocationContext{ @@ -179,13 +180,13 @@ end ` } -func createInterceptors(gatewayAPIPolicies map[string]dpv1alpha1.APIPolicy, +func createInterceptors(gatewayAPIPolicies map[string]dpv1alpha2.APIPolicy, gatewayInterceptorServiceMapping map[string]dpv1alpha1.InterceptorService, gatewayBackendMapping map[string]*dpv1alpha1.ResolvedBackend) (requestInterceptor map[string]model.InterceptEndpoint, responseInterceptor map[string]model.InterceptEndpoint) { requestInterceptorMap := make(map[string]model.InterceptEndpoint) responseInterceptorMap := make(map[string]model.InterceptEndpoint) - var apiPolicy *dpv1alpha1.APIPolicy + var apiPolicy *dpv1alpha2.APIPolicy outputAPIPolicy := utils.TieBreaker(utils.GetPtrSlice(maps.Values(gatewayAPIPolicies))) if outputAPIPolicy != nil { apiPolicy = *outputAPIPolicy @@ -222,7 +223,7 @@ func createInterceptors(gatewayAPIPolicies map[string]dpv1alpha1.APIPolicy, return requestInterceptorMap, responseInterceptorMap } -func getInterceptorEndpoint(namespace string, interceptorRef *dpv1alpha1.InterceptorReference, +func getInterceptorEndpoint(namespace string, interceptorRef *dpv1alpha2.InterceptorReference, gatewayInterceptorServiceMapping map[string]dpv1alpha1.InterceptorService, gatewayBackendMapping map[string]*dpv1alpha1.ResolvedBackend, isReq bool) *model.InterceptEndpoint { interceptor := gatewayInterceptorServiceMapping[types.NamespacedName{ Namespace: namespace, diff --git a/adapter/internal/operator/synchronizer/synchronizer.go b/adapter/internal/operator/synchronizer/synchronizer.go index ce22c4ea9..3dc7e8e5d 100644 --- a/adapter/internal/operator/synchronizer/synchronizer.go +++ b/adapter/internal/operator/synchronizer/synchronizer.go @@ -157,6 +157,7 @@ func GenerateAdapterInternalAPI(apiState APIState, httpRoute *HTTPRouteState, en adapterInternalAPI.SetInfoAPICR(*apiState.APIDefinition) adapterInternalAPI.SetAPIDefinitionFile(apiState.APIDefinitionFile) adapterInternalAPI.SetAPIDefinitionEndpoint(apiState.APIDefinition.Spec.DefinitionPath) + adapterInternalAPI.SetSubscriptionValidation(apiState.SubscriptionValidation) adapterInternalAPI.EnvType = envType environment := apiState.APIDefinition.Spec.Environment diff --git a/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go b/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go index 3397623bb..c82cafd03 100644 --- a/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go +++ b/adapter/internal/operator/synchronizer/zz_generated.deepcopy.go @@ -76,14 +76,14 @@ func (in *APIState) DeepCopyInto(out *APIState) { } if in.ResourceAPIPolicies != nil { in, out := &in.ResourceAPIPolicies, &out.ResourceAPIPolicies - *out = make(map[string]v1alpha1.APIPolicy, len(*in)) + *out = make(map[string]v1alpha2.APIPolicy, len(*in)) for key, val := range *in { (*out)[key] = *val.DeepCopy() } } if in.APIPolicies != nil { in, out := &in.APIPolicies, &out.APIPolicies - *out = make(map[string]v1alpha1.APIPolicy, len(*in)) + *out = make(map[string]v1alpha2.APIPolicy, len(*in)) for key, val := range *in { (*out)[key] = *val.DeepCopy() } @@ -174,7 +174,7 @@ func (in *GatewayStateData) DeepCopyInto(out *GatewayStateData) { } if in.GatewayAPIPolicies != nil { in, out := &in.GatewayAPIPolicies, &out.GatewayAPIPolicies - *out = make(map[string]v1alpha1.APIPolicy, len(*in)) + *out = make(map[string]v1alpha2.APIPolicy, len(*in)) for key, val := range *in { (*out)[key] = *val.DeepCopy() } diff --git a/adapter/internal/operator/utils/utils.go b/adapter/internal/operator/utils/utils.go index 327f1ca1f..90cdc18f0 100644 --- a/adapter/internal/operator/utils/utils.go +++ b/adapter/internal/operator/utils/utils.go @@ -506,7 +506,7 @@ func RetrieveNamespaceListOptions(namespaces []string) k8client.ListOptions { // GetInterceptorService reads InterceptorService when interceptorReference is given func GetInterceptorService(ctx context.Context, client k8client.Client, namespace string, - interceptorReference *dpv1alpha1.InterceptorReference, api *dpv1alpha2.API) *dpv1alpha1.InterceptorService { + interceptorReference *dpv1alpha2.InterceptorReference, api *dpv1alpha2.API) *dpv1alpha1.InterceptorService { interceptorService := &dpv1alpha1.InterceptorService{} interceptorRef := types.NamespacedName{ Namespace: namespace, diff --git a/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go b/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go index d031764f0..411c3af8b 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/api/api.pb.go @@ -61,10 +61,11 @@ type Api struct { ApplicationSecurity bool `protobuf:"varint,16,opt,name=applicationSecurity,proto3" json:"applicationSecurity,omitempty"` /// string graphQLSchema = 22; // repeated GraphqlComplexity graphqlComplexityInfo = 23; - SystemAPI bool `protobuf:"varint,24,opt,name=systemAPI,proto3" json:"systemAPI,omitempty"` - BackendJWTTokenInfo *BackendJWTTokenInfo `protobuf:"bytes,25,opt,name=backendJWTTokenInfo,proto3" json:"backendJWTTokenInfo,omitempty"` - ApiDefinitionFile []byte `protobuf:"bytes,26,opt,name=apiDefinitionFile,proto3" json:"apiDefinitionFile,omitempty"` - Environment string `protobuf:"bytes,27,opt,name=environment,proto3" json:"environment,omitempty"` + SystemAPI bool `protobuf:"varint,24,opt,name=systemAPI,proto3" json:"systemAPI,omitempty"` + BackendJWTTokenInfo *BackendJWTTokenInfo `protobuf:"bytes,25,opt,name=backendJWTTokenInfo,proto3" json:"backendJWTTokenInfo,omitempty"` + ApiDefinitionFile []byte `protobuf:"bytes,26,opt,name=apiDefinitionFile,proto3" json:"apiDefinitionFile,omitempty"` + Environment string `protobuf:"bytes,27,opt,name=environment,proto3" json:"environment,omitempty"` + SubscriptionValidation bool `protobuf:"varint,28,opt,name=subscriptionValidation,proto3" json:"subscriptionValidation,omitempty"` } func (x *Api) Reset() { @@ -239,6 +240,13 @@ func (x *Api) GetEnvironment() string { return "" } +func (x *Api) GetSubscriptionValidation() bool { + if x != nil { + return x.SubscriptionValidation + } + return false +} + var File_wso2_discovery_api_api_proto protoreflect.FileDescriptor var file_wso2_discovery_api_api_proto_rawDesc = []byte{ @@ -252,7 +260,7 @@ var file_wso2_discovery_api_api_proto_rawDesc = []byte{ 0x69, 0x63, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2c, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x42, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x4a, 0x57, 0x54, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, - 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x06, 0x0a, 0x03, 0x41, 0x70, + 0x6e, 0x66, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd1, 0x06, 0x0a, 0x03, 0x41, 0x70, 0x69, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, @@ -302,14 +310,18 @@ var file_wso2_discovery_api_api_proto_rawDesc = []byte{ 0x52, 0x11, 0x61, 0x70, 0x69, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, - 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x70, 0x0a, 0x23, 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, 0x61, 0x70, 0x69, 0x42, 0x08, 0x41, 0x70, - 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 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, - 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x16, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x1c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x70, 0x0a, + 0x23, 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, 0x61, 0x70, 0x69, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x3d, 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, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/adapter/pkg/discovery/api/wso2/discovery/service/subscription/app_mapping_ds.pb.go b/adapter/pkg/discovery/api/wso2/discovery/service/subscription/app_mapping_ds.pb.go new file mode 100644 index 000000000..a4a61c43a --- /dev/null +++ b/adapter/pkg/discovery/api/wso2/discovery/service/subscription/app_mapping_ds.pb.go @@ -0,0 +1,226 @@ +// +// 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/service/subscription/app_mapping_ds.proto + +package subscription + +import ( + context "context" + v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" + 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" +) + +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) +) + +var File_wso2_discovery_service_subscription_app_mapping_ds_proto protoreflect.FileDescriptor + +var file_wso2_discovery_service_subscription_app_mapping_ds_proto_rawDesc = []byte{ + 0x0a, 0x38, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x5f, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x5f, 0x64, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x64, 0x69, 0x73, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x73, 0x75, + 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x2a, 0x65, 0x6e, 0x76, 0x6f, + 0x79, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2f, 0x76, 0x33, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xa4, 0x01, 0x0a, 0x22, 0x41, 0x70, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x44, 0x69, 0x73, + 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7e, 0x0a, + 0x19, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x2c, 0x2e, 0x65, 0x6e, 0x76, + 0x6f, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x79, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x9a, 0x01, + 0x0a, 0x34, 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, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x11, 0x41, 0x70, 0x70, 0x4d, 0x61, 0x70, 0x70, 0x69, + 0x6e, 0x67, 0x44, 0x53, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4a, 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, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var file_wso2_discovery_service_subscription_app_mapping_ds_proto_goTypes = []interface{}{ + (*v3.DiscoveryRequest)(nil), // 0: envoy.service.discovery.v3.DiscoveryRequest + (*v3.DiscoveryResponse)(nil), // 1: envoy.service.discovery.v3.DiscoveryResponse +} +var file_wso2_discovery_service_subscription_app_mapping_ds_proto_depIdxs = []int32{ + 0, // 0: discovery.service.subscription.ApplicationMappingDiscoveryService.StreamApplicationMappings:input_type -> envoy.service.discovery.v3.DiscoveryRequest + 1, // 1: discovery.service.subscription.ApplicationMappingDiscoveryService.StreamApplicationMappings:output_type -> envoy.service.discovery.v3.DiscoveryResponse + 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_subscription_app_mapping_ds_proto_init() } +func file_wso2_discovery_service_subscription_app_mapping_ds_proto_init() { + if File_wso2_discovery_service_subscription_app_mapping_ds_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_wso2_discovery_service_subscription_app_mapping_ds_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_wso2_discovery_service_subscription_app_mapping_ds_proto_goTypes, + DependencyIndexes: file_wso2_discovery_service_subscription_app_mapping_ds_proto_depIdxs, + }.Build() + File_wso2_discovery_service_subscription_app_mapping_ds_proto = out.File + file_wso2_discovery_service_subscription_app_mapping_ds_proto_rawDesc = nil + file_wso2_discovery_service_subscription_app_mapping_ds_proto_goTypes = nil + file_wso2_discovery_service_subscription_app_mapping_ds_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 + +// ApplicationMappingDiscoveryServiceClient is the client API for ApplicationMappingDiscoveryService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ApplicationMappingDiscoveryServiceClient interface { + StreamApplicationMappings(ctx context.Context, opts ...grpc.CallOption) (ApplicationMappingDiscoveryService_StreamApplicationMappingsClient, error) +} + +type applicationMappingDiscoveryServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewApplicationMappingDiscoveryServiceClient(cc grpc.ClientConnInterface) ApplicationMappingDiscoveryServiceClient { + return &applicationMappingDiscoveryServiceClient{cc} +} + +func (c *applicationMappingDiscoveryServiceClient) StreamApplicationMappings(ctx context.Context, opts ...grpc.CallOption) (ApplicationMappingDiscoveryService_StreamApplicationMappingsClient, error) { + stream, err := c.cc.NewStream(ctx, &_ApplicationMappingDiscoveryService_serviceDesc.Streams[0], "/discovery.service.subscription.ApplicationMappingDiscoveryService/StreamApplicationMappings", opts...) + if err != nil { + return nil, err + } + x := &applicationMappingDiscoveryServiceStreamApplicationMappingsClient{stream} + return x, nil +} + +type ApplicationMappingDiscoveryService_StreamApplicationMappingsClient interface { + Send(*v3.DiscoveryRequest) error + Recv() (*v3.DiscoveryResponse, error) + grpc.ClientStream +} + +type applicationMappingDiscoveryServiceStreamApplicationMappingsClient struct { + grpc.ClientStream +} + +func (x *applicationMappingDiscoveryServiceStreamApplicationMappingsClient) Send(m *v3.DiscoveryRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *applicationMappingDiscoveryServiceStreamApplicationMappingsClient) Recv() (*v3.DiscoveryResponse, error) { + m := new(v3.DiscoveryResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// ApplicationMappingDiscoveryServiceServer is the server API for ApplicationMappingDiscoveryService service. +type ApplicationMappingDiscoveryServiceServer interface { + StreamApplicationMappings(ApplicationMappingDiscoveryService_StreamApplicationMappingsServer) error +} + +// UnimplementedApplicationMappingDiscoveryServiceServer can be embedded to have forward compatible implementations. +type UnimplementedApplicationMappingDiscoveryServiceServer struct { +} + +func (*UnimplementedApplicationMappingDiscoveryServiceServer) StreamApplicationMappings(ApplicationMappingDiscoveryService_StreamApplicationMappingsServer) error { + return status.Errorf(codes.Unimplemented, "method StreamApplicationMappings not implemented") +} + +func RegisterApplicationMappingDiscoveryServiceServer(s *grpc.Server, srv ApplicationMappingDiscoveryServiceServer) { + s.RegisterService(&_ApplicationMappingDiscoveryService_serviceDesc, srv) +} + +func _ApplicationMappingDiscoveryService_StreamApplicationMappings_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(ApplicationMappingDiscoveryServiceServer).StreamApplicationMappings(&applicationMappingDiscoveryServiceStreamApplicationMappingsServer{stream}) +} + +type ApplicationMappingDiscoveryService_StreamApplicationMappingsServer interface { + Send(*v3.DiscoveryResponse) error + Recv() (*v3.DiscoveryRequest, error) + grpc.ServerStream +} + +type applicationMappingDiscoveryServiceStreamApplicationMappingsServer struct { + grpc.ServerStream +} + +func (x *applicationMappingDiscoveryServiceStreamApplicationMappingsServer) Send(m *v3.DiscoveryResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *applicationMappingDiscoveryServiceStreamApplicationMappingsServer) Recv() (*v3.DiscoveryRequest, error) { + m := new(v3.DiscoveryRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _ApplicationMappingDiscoveryService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "discovery.service.subscription.ApplicationMappingDiscoveryService", + HandlerType: (*ApplicationMappingDiscoveryServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "StreamApplicationMappings", + Handler: _ApplicationMappingDiscoveryService_StreamApplicationMappings_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "wso2/discovery/service/subscription/app_mapping_ds.proto", +} diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/application.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/application.pb.go index 396466725..aeff003c2 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/application.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/application.pb.go @@ -1,3 +1,19 @@ +// +// 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 @@ -26,15 +42,10 @@ type Application struct { 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"` - Uuid string `protobuf:"bytes,3,opt,name=uuid,proto3" json:"uuid,omitempty"` - Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty"` - Policy string `protobuf:"bytes,5,opt,name=policy,proto3" json:"policy,omitempty"` - Attributes map[string]string `protobuf:"bytes,6,rep,name=attributes,proto3" json:"attributes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Keys []*Application_Key `protobuf:"bytes,7,rep,name=keys,proto3" json:"keys,omitempty"` - Organization string `protobuf:"bytes,8,opt,name=organization,proto3" json:"organization,omitempty"` - TimeStamp string `protobuf:"bytes,9,opt,name=timeStamp,proto3" json:"timeStamp,omitempty"` + 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"` + Attributes map[string]string `protobuf:"bytes,4,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() { @@ -69,9 +80,9 @@ func (*Application) Descriptor() ([]byte, []int) { return file_wso2_discovery_subscription_application_proto_rawDescGZIP(), []int{0} } -func (x *Application) GetEventId() string { +func (x *Application) GetUuid() string { if x != nil { - return x.EventId + return x.Uuid } return "" } @@ -83,81 +94,141 @@ func (x *Application) GetName() string { return "" } -func (x *Application) GetUuid() string { +func (x *Application) GetOwner() string { if x != nil { - return x.Uuid + return x.Owner } return "" } -func (x *Application) GetOwner() string { +func (x *Application) GetAttributes() map[string]string { if x != nil { - return x.Owner + return x.Attributes } - return "" + return nil } -func (x *Application) GetPolicy() string { - if x != nil { - return x.Policy +type SecuritySchemes struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OAuth2 *OAuth2 `protobuf:"bytes,1,opt,name=oAuth2,proto3" json:"oAuth2,omitempty"` +} + +func (x *SecuritySchemes) Reset() { + *x = SecuritySchemes{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_subscription_application_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return "" } -func (x *Application) GetAttributes() map[string]string { - if x != nil { - return x.Attributes +func (x *SecuritySchemes) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecuritySchemes) ProtoMessage() {} + +func (x *SecuritySchemes) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_subscription_application_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 nil + return mi.MessageOf(x) +} + +// Deprecated: Use SecuritySchemes.ProtoReflect.Descriptor instead. +func (*SecuritySchemes) Descriptor() ([]byte, []int) { + return file_wso2_discovery_subscription_application_proto_rawDescGZIP(), []int{1} } -func (x *Application) GetKeys() []*Application_Key { +func (x *SecuritySchemes) GetOAuth2() *OAuth2 { if x != nil { - return x.Keys + return x.OAuth2 } return nil } -func (x *Application) GetOrganization() string { - if x != nil { - return x.Organization +type OAuth2 struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Environments []*Environment `protobuf:"bytes,1,rep,name=environments,proto3" json:"environments,omitempty"` +} + +func (x *OAuth2) Reset() { + *x = OAuth2{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_subscription_application_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return "" } -func (x *Application) GetTimeStamp() string { +func (x *OAuth2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OAuth2) ProtoMessage() {} + +func (x *OAuth2) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_subscription_application_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 OAuth2.ProtoReflect.Descriptor instead. +func (*OAuth2) Descriptor() ([]byte, []int) { + return file_wso2_discovery_subscription_application_proto_rawDescGZIP(), []int{2} +} + +func (x *OAuth2) GetEnvironments() []*Environment { if x != nil { - return x.TimeStamp + return x.Environments } - return "" + return nil } -type Application_Key struct { +type Environment struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - KeyManager string `protobuf:"bytes,2,opt,name=keyManager,proto3" json:"keyManager,omitempty"` + EnvID string `protobuf:"bytes,1,opt,name=envID,proto3" json:"envID,omitempty"` + ApplicationIdentifier string `protobuf:"bytes,2,opt,name=applicationIdentifier,proto3" json:"applicationIdentifier,omitempty"` + KeyType string `protobuf:"bytes,3,opt,name=keyType,proto3" json:"keyType,omitempty"` } -func (x *Application_Key) Reset() { - *x = Application_Key{} +func (x *Environment) Reset() { + *x = Environment{} if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_subscription_application_proto_msgTypes[2] + mi := &file_wso2_discovery_subscription_application_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *Application_Key) String() string { +func (x *Environment) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Application_Key) ProtoMessage() {} +func (*Environment) ProtoMessage() {} -func (x *Application_Key) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_subscription_application_proto_msgTypes[2] +func (x *Environment) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_subscription_application_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -168,21 +239,28 @@ func (x *Application_Key) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Application_Key.ProtoReflect.Descriptor instead. -func (*Application_Key) Descriptor() ([]byte, []int) { - return file_wso2_discovery_subscription_application_proto_rawDescGZIP(), []int{0, 1} +// Deprecated: Use Environment.ProtoReflect.Descriptor instead. +func (*Environment) Descriptor() ([]byte, []int) { + return file_wso2_discovery_subscription_application_proto_rawDescGZIP(), []int{3} } -func (x *Application_Key) GetKey() string { +func (x *Environment) GetEnvID() string { if x != nil { - return x.Key + return x.EnvID } return "" } -func (x *Application_Key) GetKeyManager() string { +func (x *Environment) GetApplicationIdentifier() string { if x != nil { - return x.KeyManager + return x.ApplicationIdentifier + } + return "" +} + +func (x *Environment) GetKeyType() string { + if x != nil { + return x.KeyType } return "" } @@ -194,46 +272,49 @@ var file_wso2_discovery_subscription_application_proto_rawDesc = []byte{ 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, 0xd3, 0x03, 0x0a, - 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 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, 0x12, 0x0a, 0x04, 0x75, 0x75, - 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, - 0x77, 0x6e, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x58, 0x0a, 0x0a, - 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x06, 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, 0x12, 0x40, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x07, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 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, 0x4b, - 0x65, 0x79, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, 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, 0x1a, 0x37, 0x0a, 0x03, 0x4b, 0x65, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x6b, 0x65, 0x79, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6b, 0x65, 0x79, 0x4d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x42, 0x93, 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, 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, + 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xe4, 0x01, 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, 0x58, 0x0a, 0x0a, 0x61, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x04, 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, 0x22, 0x4e, 0x0a, 0x0f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x12, 0x3b, 0x0a, 0x06, 0x6f, 0x41, 0x75, 0x74, 0x68, 0x32, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 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, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x32, 0x52, 0x06, 0x6f, 0x41, 0x75, + 0x74, 0x68, 0x32, 0x22, 0x56, 0x0a, 0x06, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x32, 0x12, 0x4c, 0x0a, + 0x0c, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, + 0x03, 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, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0c, 0x65, + 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x73, 0x0a, 0x0b, 0x45, + 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, + 0x76, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6e, 0x76, 0x49, 0x44, + 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, 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, + 0x42, 0x93, 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, 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 ( @@ -248,20 +329,23 @@ func file_wso2_discovery_subscription_application_proto_rawDescGZIP() []byte { return file_wso2_discovery_subscription_application_proto_rawDescData } -var file_wso2_discovery_subscription_application_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_wso2_discovery_subscription_application_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_wso2_discovery_subscription_application_proto_goTypes = []interface{}{ (*Application)(nil), // 0: wso2.discovery.subscription.Application - nil, // 1: wso2.discovery.subscription.Application.AttributesEntry - (*Application_Key)(nil), // 2: wso2.discovery.subscription.Application.Key + (*SecuritySchemes)(nil), // 1: wso2.discovery.subscription.SecuritySchemes + (*OAuth2)(nil), // 2: wso2.discovery.subscription.OAuth2 + (*Environment)(nil), // 3: wso2.discovery.subscription.Environment + nil, // 4: 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 - 2, // 1: wso2.discovery.subscription.Application.keys:type_name -> wso2.discovery.subscription.Application.Key - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 4, // 0: wso2.discovery.subscription.Application.attributes:type_name -> wso2.discovery.subscription.Application.AttributesEntry + 2, // 1: wso2.discovery.subscription.SecuritySchemes.oAuth2:type_name -> wso2.discovery.subscription.OAuth2 + 3, // 2: wso2.discovery.subscription.OAuth2.environments:type_name -> wso2.discovery.subscription.Environment + 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_application_proto_init() } @@ -282,8 +366,32 @@ func file_wso2_discovery_subscription_application_proto_init() { return nil } } + file_wso2_discovery_subscription_application_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SecuritySchemes); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } file_wso2_discovery_subscription_application_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Application_Key); i { + switch v := v.(*OAuth2); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_wso2_discovery_subscription_application_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Environment); i { case 0: return &v.state case 1: @@ -301,7 +409,7 @@ func file_wso2_discovery_subscription_application_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_wso2_discovery_subscription_application_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go index 207e5f388..146019418 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping.pb.go @@ -1,3 +1,19 @@ +// +// 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 @@ -26,14 +42,12 @@ type ApplicationKeyMapping struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ConsumerKey string `protobuf:"bytes,1,opt,name=consumerKey,proto3" json:"consumerKey,omitempty"` - KeyType string `protobuf:"bytes,2,opt,name=keyType,proto3" json:"keyType,omitempty"` - KeyManager string `protobuf:"bytes,3,opt,name=keyManager,proto3" json:"keyManager,omitempty"` - ApplicationId int32 `protobuf:"varint,4,opt,name=applicationId,proto3" json:"applicationId,omitempty"` - TenantId int32 `protobuf:"varint,5,opt,name=tenantId,proto3" json:"tenantId,omitempty"` - TenantDomain string `protobuf:"bytes,6,opt,name=tenantDomain,proto3" json:"tenantDomain,omitempty"` - Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - ApplicationUUID string `protobuf:"bytes,8,opt,name=applicationUUID,proto3" json:"applicationUUID,omitempty"` + 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"` } func (x *ApplicationKeyMapping) Reset() { @@ -68,44 +82,37 @@ func (*ApplicationKeyMapping) Descriptor() ([]byte, []int) { return file_wso2_discovery_subscription_application_key_mapping_proto_rawDescGZIP(), []int{0} } -func (x *ApplicationKeyMapping) GetConsumerKey() string { +func (x *ApplicationKeyMapping) GetApplicationUUID() string { if x != nil { - return x.ConsumerKey + return x.ApplicationUUID } return "" } -func (x *ApplicationKeyMapping) GetKeyType() string { +func (x *ApplicationKeyMapping) GetSecurityScheme() string { if x != nil { - return x.KeyType + return x.SecurityScheme } return "" } -func (x *ApplicationKeyMapping) GetKeyManager() string { +func (x *ApplicationKeyMapping) GetApplicationIdentifier() string { if x != nil { - return x.KeyManager + return x.ApplicationIdentifier } return "" } -func (x *ApplicationKeyMapping) GetApplicationId() int32 { - if x != nil { - return x.ApplicationId - } - return 0 -} - -func (x *ApplicationKeyMapping) GetTenantId() int32 { +func (x *ApplicationKeyMapping) GetKeyType() string { if x != nil { - return x.TenantId + return x.KeyType } - return 0 + return "" } -func (x *ApplicationKeyMapping) GetTenantDomain() string { +func (x *ApplicationKeyMapping) GetEnvID() string { if x != nil { - return x.TenantDomain + return x.EnvID } return "" } @@ -117,13 +124,6 @@ func (x *ApplicationKeyMapping) GetTimestamp() int64 { return 0 } -func (x *ApplicationKeyMapping) GetApplicationUUID() string { - if x != nil { - return x.ApplicationUUID - } - return "" -} - var File_wso2_discovery_subscription_application_key_mapping_proto protoreflect.FileDescriptor var file_wso2_discovery_subscription_application_key_mapping_proto_rawDesc = []byte{ @@ -132,36 +132,32 @@ var file_wso2_discovery_subscription_application_key_mapping_proto_rawDesc = []b 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, 0xa1, 0x02, 0x0a, 0x15, 0x41, 0x70, 0x70, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xed, 0x01, 0x0a, 0x15, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x61, 0x70, 0x70, 0x69, - 0x6e, 0x67, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x4b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, - 0x72, 0x4b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, - 0x0a, 0x0a, 0x6b, 0x65, 0x79, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x6b, 0x65, 0x79, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x12, 0x24, - 0x0a, 0x0d, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x49, 0x64, - 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x0f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x55, 0x55, 0x49, 0x44, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x70, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x55, 0x49, 0x44, 0x42, 0x9d, 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, 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, + 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, 0x42, 0x9d, 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, 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 ( diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping_list.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping_list.pb.go index 7752d7d3a..57e890c27 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping_list.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/application_key_mapping_list.pb.go @@ -1,3 +1,19 @@ +// +// 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 diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/application_list.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/application_list.pb.go index 0827dcf7f..e598420c4 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/application_list.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/application_list.pb.go @@ -1,3 +1,19 @@ +// +// 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 diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go new file mode 100644 index 000000000..75b502379 --- /dev/null +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/applicationmapping.pb.go @@ -0,0 +1,193 @@ +// +// 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"` +} + +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 "" +} + +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, 0x7a, 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, 0x42, + 0x9a, 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, 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_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/adapter/pkg/discovery/api/wso2/discovery/subscription/applicationmapping_list.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/applicationmapping_list.pb.go new file mode 100644 index 000000000..00f95b7a1 --- /dev/null +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/applicationmapping_list.pb.go @@ -0,0 +1,182 @@ +// +// 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_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) +) + +// ApplicationMappingList data model +type ApplicationMappingList struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []*ApplicationMapping `protobuf:"bytes,2,rep,name=list,proto3" json:"list,omitempty"` +} + +func (x *ApplicationMappingList) Reset() { + *x = ApplicationMappingList{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_subscription_applicationmapping_list_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApplicationMappingList) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApplicationMappingList) ProtoMessage() {} + +func (x *ApplicationMappingList) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_subscription_applicationmapping_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 ApplicationMappingList.ProtoReflect.Descriptor instead. +func (*ApplicationMappingList) Descriptor() ([]byte, []int) { + return file_wso2_discovery_subscription_applicationmapping_list_proto_rawDescGZIP(), []int{0} +} + +func (x *ApplicationMappingList) GetList() []*ApplicationMapping { + if x != nil { + return x.List + } + return nil +} + +var File_wso2_discovery_subscription_applicationmapping_list_proto protoreflect.FileDescriptor + +var file_wso2_discovery_subscription_applicationmapping_list_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, 0x6d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, + 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, 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, 0x22, 0x5d, + 0x0a, 0x16, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, + 0x70, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, + 0x18, 0x02, 0x20, 0x03, 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, 0x04, 0x6c, 0x69, 0x73, 0x74, 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, 0x1b, + 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x70, 0x69, + 0x6e, 0x67, 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_applicationmapping_list_proto_rawDescOnce sync.Once + file_wso2_discovery_subscription_applicationmapping_list_proto_rawDescData = file_wso2_discovery_subscription_applicationmapping_list_proto_rawDesc +) + +func file_wso2_discovery_subscription_applicationmapping_list_proto_rawDescGZIP() []byte { + file_wso2_discovery_subscription_applicationmapping_list_proto_rawDescOnce.Do(func() { + file_wso2_discovery_subscription_applicationmapping_list_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_subscription_applicationmapping_list_proto_rawDescData) + }) + return file_wso2_discovery_subscription_applicationmapping_list_proto_rawDescData +} + +var file_wso2_discovery_subscription_applicationmapping_list_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_wso2_discovery_subscription_applicationmapping_list_proto_goTypes = []interface{}{ + (*ApplicationMappingList)(nil), // 0: wso2.discovery.subscription.ApplicationMappingList + (*ApplicationMapping)(nil), // 1: wso2.discovery.subscription.ApplicationMapping +} +var file_wso2_discovery_subscription_applicationmapping_list_proto_depIdxs = []int32{ + 1, // 0: wso2.discovery.subscription.ApplicationMappingList.list:type_name -> wso2.discovery.subscription.ApplicationMapping + 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_applicationmapping_list_proto_init() } +func file_wso2_discovery_subscription_applicationmapping_list_proto_init() { + if File_wso2_discovery_subscription_applicationmapping_list_proto != nil { + return + } + file_wso2_discovery_subscription_applicationmapping_proto_init() + if !protoimpl.UnsafeEnabled { + file_wso2_discovery_subscription_applicationmapping_list_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApplicationMappingList); 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_list_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_wso2_discovery_subscription_applicationmapping_list_proto_goTypes, + DependencyIndexes: file_wso2_discovery_subscription_applicationmapping_list_proto_depIdxs, + MessageInfos: file_wso2_discovery_subscription_applicationmapping_list_proto_msgTypes, + }.Build() + File_wso2_discovery_subscription_applicationmapping_list_proto = out.File + file_wso2_discovery_subscription_applicationmapping_list_proto_rawDesc = nil + file_wso2_discovery_subscription_applicationmapping_list_proto_goTypes = nil + file_wso2_discovery_subscription_applicationmapping_list_proto_depIdxs = nil +} diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go index 054271a1a..e4c9d7bc0 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go @@ -1,3 +1,19 @@ +// +// 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 @@ -26,15 +42,10 @@ type Subscription struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EventId string `protobuf:"bytes,1,opt,name=eventId,proto3" json:"eventId,omitempty"` - ApplicationRef string `protobuf:"bytes,2,opt,name=applicationRef,proto3" json:"applicationRef,omitempty"` - ApiRef string `protobuf:"bytes,3,opt,name=apiRef,proto3" json:"apiRef,omitempty"` - PolicyId string `protobuf:"bytes,4,opt,name=policyId,proto3" json:"policyId,omitempty"` - SubStatus string `protobuf:"bytes,5,opt,name=subStatus,proto3" json:"subStatus,omitempty"` - Subscriber string `protobuf:"bytes,6,opt,name=subscriber,proto3" json:"subscriber,omitempty"` - Uuid string `protobuf:"bytes,7,opt,name=uuid,proto3" json:"uuid,omitempty"` - TimeStamp string `protobuf:"bytes,8,opt,name=timeStamp,proto3" json:"timeStamp,omitempty"` - Organization string `protobuf:"bytes,9,opt,name=organization,proto3" json:"organization,omitempty"` + 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() { @@ -69,65 +80,85 @@ func (*Subscription) Descriptor() ([]byte, []int) { return file_wso2_discovery_subscription_subscription_proto_rawDescGZIP(), []int{0} } -func (x *Subscription) GetEventId() string { +func (x *Subscription) GetSubStatus() string { if x != nil { - return x.EventId + return x.SubStatus } return "" } -func (x *Subscription) GetApplicationRef() string { +func (x *Subscription) GetUuid() string { if x != nil { - return x.ApplicationRef + return x.Uuid } return "" } -func (x *Subscription) GetApiRef() string { +func (x *Subscription) GetOrganization() string { if x != nil { - return x.ApiRef + return x.Organization } return "" } -func (x *Subscription) GetPolicyId() string { +func (x *Subscription) GetSubscribedApi() *SubscribedAPI { if x != nil { - return x.PolicyId + return x.SubscribedApi } - return "" + return nil } -func (x *Subscription) GetSubStatus() string { - if x != nil { - return x.SubStatus - } - return "" +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 *Subscription) GetSubscriber() string { - if x != nil { - return x.Subscriber +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) } - return "" } -func (x *Subscription) GetUuid() string { - if x != nil { - return x.Uuid +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 "" + 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 *Subscription) GetTimeStamp() string { +func (x *SubscribedAPI) GetName() string { if x != nil { - return x.TimeStamp + return x.Name } return "" } -func (x *Subscription) GetOrganization() string { +func (x *SubscribedAPI) GetVersion() string { if x != nil { - return x.Organization + return x.Version } return "" } @@ -139,35 +170,33 @@ var file_wso2_discovery_subscription_subscription_proto_rawDesc = []byte{ 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, 0x98, 0x02, - 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 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, 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, 0x16, 0x0a, 0x06, 0x61, 0x70, 0x69, 0x52, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x61, 0x70, 0x69, 0x52, 0x65, 0x66, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, - 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, - 0x74, 0x61, 0x6d, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, - 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 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, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 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, + 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, 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, 0x11, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 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 ( @@ -182,16 +211,18 @@ func file_wso2_discovery_subscription_subscription_proto_rawDescGZIP() []byte { return file_wso2_discovery_subscription_subscription_proto_rawDescData } -var file_wso2_discovery_subscription_subscription_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +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 + (*Subscription)(nil), // 0: wso2.discovery.subscription.Subscription + (*SubscribedAPI)(nil), // 1: wso2.discovery.subscription.SubscribedAPI } var file_wso2_discovery_subscription_subscription_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 + 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() } @@ -212,6 +243,18 @@ func file_wso2_discovery_subscription_subscription_proto_init() { 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{ @@ -219,7 +262,7 @@ func file_wso2_discovery_subscription_subscription_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_wso2_discovery_subscription_subscription_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription_list.pb.go b/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription_list.pb.go index 7cf42c9ba..5a493f3f5 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription_list.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription_list.pb.go @@ -1,3 +1,19 @@ +// +// 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 diff --git a/adapter/pkg/discovery/protocol/cache/types/types.go b/adapter/pkg/discovery/protocol/cache/types/types.go index 76cb48ba2..1d8cce360 100644 --- a/adapter/pkg/discovery/protocol/cache/types/types.go +++ b/adapter/pkg/discovery/protocol/cache/types/types.go @@ -34,6 +34,8 @@ const ( APKMgtApplicationList Application Subscription + ApplicationMapping + ApplicationMappingList JWTIssuer UnknownType // token to count the total number of supported types ) diff --git a/adapter/pkg/discovery/protocol/cache/v3/resource.go b/adapter/pkg/discovery/protocol/cache/v3/resource.go index 6b6a358a7..710f1e3d6 100644 --- a/adapter/pkg/discovery/protocol/cache/v3/resource.go +++ b/adapter/pkg/discovery/protocol/cache/v3/resource.go @@ -48,6 +48,8 @@ func GetResponseType(typeURL string) types.ResponseType { return types.SubscriptionPolicyList case resource.ApplicationKeyMappingListType: return types.ApplicationKeyMappingList + case resource.ApplicationMappingListType: + return types.ApplicationMappingList case resource.KeyManagerType: return types.KeyManagerConfig case resource.RevokedTokensType: @@ -84,6 +86,8 @@ func GetResourceName(res envoy_types.Resource) string { return "JWTIssuer" case *subscription.ApplicationKeyMappingList: return "ApplicationKeyMapping" + case *subscription.ApplicationMappingList: + return "ApplicationMapping" case *subscription.APIList: return "APIList" case *subscription.ApplicationPolicyList: diff --git a/adapter/pkg/discovery/protocol/resource/v3/resource.go b/adapter/pkg/discovery/protocol/resource/v3/resource.go index 88c6ee85f..e1d85e105 100644 --- a/adapter/pkg/discovery/protocol/resource/v3/resource.go +++ b/adapter/pkg/discovery/protocol/resource/v3/resource.go @@ -21,6 +21,7 @@ const ( APIType = apiTypePrefix + "wso2.discovery.api.Api" SubscriptionListType = apiTypePrefix + "wso2.discovery.subscription.SubscriptionList" ApplicationListType = apiTypePrefix + "wso2.discovery.subscription.ApplicationList" + ApplicationMappingListType = apiTypePrefix + "wso2.discovery.subscription.ApplicationMappingList" APIListType = apiTypePrefix + "wso2.discovery.subscription.APIList" ApplicationPolicyListType = apiTypePrefix + "wso2.discovery.subscription.ApplicationPolicyList" SubscriptionPolicyListType = apiTypePrefix + "wso2.discovery.subscription.SubscriptionPolicyList" diff --git a/adapter/pkg/discovery/protocol/server/sotw/v3/server.go b/adapter/pkg/discovery/protocol/server/sotw/v3/server.go index 83cf6904b..a764b18ec 100644 --- a/adapter/pkg/discovery/protocol/server/sotw/v3/server.go +++ b/adapter/pkg/discovery/protocol/server/sotw/v3/server.go @@ -57,6 +57,7 @@ type watches struct { jwtIssuerList chan cache.Response subscriptionPolicyList chan cache.Response applicationKeyMappingList chan cache.Response + applicationMappingList chan cache.Response keyManagers chan cache.Response revokedTokens chan cache.Response throttleData chan cache.Response @@ -71,6 +72,7 @@ type watches struct { applicationPolicyListCancel func() subscriptionPolicyListCancel func() applicationKeyMappingListCancel func() + applicationMappingListCancel func() keyManagerCancel func() revokedTokenCancel func() throttleDataCancel func() @@ -85,6 +87,7 @@ type watches struct { applicationPolicyListNonce string subscriptionPolicyListNonce string applicationKeyMappingListNonce string + applicationMappingListNonce string keyManagerNonce string revokedTokenNonce string throttleDataNonce string @@ -145,6 +148,9 @@ func (values *watches) Cancel() { if values.applicationKeyMappingListCancel != nil { values.applicationKeyMappingListCancel() } + if values.applicationMappingListCancel != nil { + values.applicationMappingListCancel() + } if values.keyManagerCancel != nil { values.keyManagerCancel() } @@ -320,6 +326,16 @@ func (s *server) process(stream streamv3.Stream, reqCh <-chan *discovery.Discove } values.applicationKeyMappingListNonce = nonce + case resp, more := <-values.applicationMappingList: + if !more { + return status.Errorf(codes.Unavailable, "applicationMappingList watch failed") + } + nonce, err := send(resp) + if err != nil { + return err + } + values.applicationMappingListNonce = nonce + case resp, more := <-values.keyManagers: if !more { return status.Errorf(codes.Unavailable, "keyManagers watch failed") @@ -487,6 +503,14 @@ func (s *server) process(stream streamv3.Stream, reqCh <-chan *discovery.Discove values.applicationKeyMappingList = make(chan cache.Response, 1) values.applicationKeyMappingListCancel = s.cache.CreateWatch(req, streamState, values.applicationKeyMappingList) } + case req.TypeUrl == resource.ApplicationMappingListType: + if values.applicationMappingListNonce == "" || values.applicationMappingListNonce == nonce { + if values.applicationMappingListCancel != nil { + values.applicationMappingListCancel() + } + values.applicationMappingList = make(chan cache.Response, 1) + values.applicationMappingListCancel = s.cache.CreateWatch(req, streamState, values.applicationMappingList) + } case req.TypeUrl == resource.KeyManagerType: if values.keyManagerNonce == "" || values.keyManagerNonce == nonce { if values.keyManagerCancel != nil { diff --git a/adapter/pkg/discovery/protocol/server/v3/server.go b/adapter/pkg/discovery/protocol/server/v3/server.go index 1426697c6..23877b7b6 100644 --- a/adapter/pkg/discovery/protocol/server/v3/server.go +++ b/adapter/pkg/discovery/protocol/server/v3/server.go @@ -46,6 +46,7 @@ type Server interface { subscription.JWTIssuerDiscoveryServiceServer subscription.SubscriptionPolicyDiscoveryServiceServer subscription.ApplicationKeyMappingDiscoveryServiceServer + subscription.ApplicationMappingDiscoveryServiceServer keymgt.KMDiscoveryServiceServer keymgt.RevokedTokenDiscoveryServiceServer apkmgt.APKMgtDiscoveryServiceServer @@ -76,6 +77,7 @@ type server struct { subscription.UnimplementedApplicationPolicyDiscoveryServiceServer subscription.UnimplementedSubscriptionPolicyDiscoveryServiceServer subscription.UnimplementedApplicationKeyMappingDiscoveryServiceServer + subscription.UnimplementedApplicationMappingDiscoveryServiceServer keymgt.UnimplementedKMDiscoveryServiceServer keymgt.UnimplementedRevokedTokenDiscoveryServiceServer apkmgt.UnimplementedAPKMgtDiscoveryServiceServer @@ -120,6 +122,10 @@ func (s *server) StreamApplicationKeyMappings(stream subscription.ApplicationKey return s.StreamHandler(stream, resource.ApplicationKeyMappingListType) } +func (s *server) StreamApplicationMappings(stream subscription.ApplicationMappingDiscoveryService_StreamApplicationMappingsServer) error { + return s.StreamHandler(stream, resource.ApplicationMappingListType) +} + func (s *server) StreamKeyManagers(stream keymgt.KMDiscoveryService_StreamKeyManagersServer) error { return s.StreamHandler(stream, resource.KeyManagerType) } diff --git a/adapter/pkg/eventhub/types/types.go b/adapter/pkg/eventhub/types/types.go index f8a3dec3c..dc7c03b62 100644 --- a/adapter/pkg/eventhub/types/types.go +++ b/adapter/pkg/eventhub/types/types.go @@ -17,62 +17,6 @@ package types -// Subscription for struct subscription -type Subscription struct { - SubscriptionID int32 `json:"subscriptionId"` - SubscriptionUUID string `json:"subscriptionUUID"` - PolicyID string `json:"policyId"` - APIID int32 `json:"apiId"` - APIUUID string `json:"apiUUID"` - AppID int32 `json:"appId" json:"applicationId"` - ApplicationUUID string `json:"applicationUUID"` - SubscriptionState string `json:"subscriptionState"` - TenantID int32 `json:"tenanId,omitempty"` - TenantDomain string `json:"tenanDomain,omitempty"` - TimeStamp int64 `json:"timeStamp,omitempty"` -} - -// SubscriptionList for struct list of applications -type SubscriptionList struct { - List []Subscription `json:"list"` -} - -// Application for struct application -type Application struct { - UUID string `json:"uuid"` - ID int32 `json:"id" json:"applicationId"` - Name string `json:"name" json:"applicationName"` - SubName string `json:"subName" json:"subscriber"` - Policy string `json:"policy" json:"applicationPolicy"` - TokenType string `json:"tokenType"` - Attributes map[string]string `json:"attributes"` - TenantID int32 `json:"tenanId,omitempty"` - TenantDomain string `json:"tenanDomain,omitempty"` - TimeStamp int64 `json:"timeStamp,omitempty"` -} - -// ApplicationList for struct list of application -type ApplicationList struct { - List []Application `json:"list"` -} - -// ApplicationKeyMapping for struct applicationKeyMapping -type ApplicationKeyMapping struct { - ApplicationID int32 `json:"applicationId"` - ApplicationUUID string `json:"applicationUUID"` - ConsumerKey string `json:"consumerKey"` - KeyType string `json:"keyType"` - KeyManager string `json:"keyManager"` - TenantID int32 `json:"tenanId,omitempty"` - TenantDomain string `json:"tenanDomain,omitempty"` - TimeStamp int64 `json:"timeStamp,omitempty"` -} - -// ApplicationKeyMappingList for struct list of applicationKeyMapping -type ApplicationKeyMappingList struct { - List []ApplicationKeyMapping `json:"list"` -} - // API for struct Api type API struct { APIID int `json:"apiId"` diff --git a/adapter/pkg/health/health.go b/adapter/pkg/health/health.go index f4d177e23..4f65c16dd 100644 --- a/adapter/pkg/health/health.go +++ b/adapter/pkg/health/health.go @@ -36,7 +36,9 @@ var ( // Service components to be set health status const ( - RestService service = "adapter.internal.RestService" + RestService service = "adapter.internal.RestService" + RateLimiterGrpcService service = "adapter.internal.RateLimiterGrpcService" + CommonEnforcerGrpcService service = "adapter.internal.CommonEnforcerGrpcService" ) type service string diff --git a/adapter/pkg/logging/logging_constant.go b/adapter/pkg/logging/logging_constant.go index 9e48604ab..45e83a7ff 100644 --- a/adapter/pkg/logging/logging_constant.go +++ b/adapter/pkg/logging/logging_constant.go @@ -46,6 +46,19 @@ const ( Error1105 = 1105 ) +// Error Log Internal discovery(1400-1499) Config Constants +// - LoggerXds +const ( + Error1400 = 1400 + Error1401 = 1401 + Error1402 = 1402 + Error1403 = 1403 + Error1410 = 1410 + Error1411 = 1411 + Error1413 = 1413 + Error1414 = 1414 +) + // Error Log Internal XDS(1700-1799) Config Constants // - LoggerXds const ( diff --git a/common-controller/build.gradle b/common-controller/build.gradle index 42ea71537..94530bef3 100644 --- a/common-controller/build.gradle +++ b/common-controller/build.gradle @@ -65,11 +65,31 @@ tasks.register('go_test', Exec) { tasks.named('go_revive_run').configure { finalizedBy go_tidy finalizedBy go_test + dependsOn operator_make + dependsOn operator_make_manifests +} + +tasks.register('operator_make', Exec) { + println("Running make -C $rootDir/../common-controller/internal/operator") + group 'go' + description 'Running go mod tidy.' + commandLine 'make', '-C', "$rootDir/../common-controller/internal/operator" + finalizedBy operator_make_manifests +} + +tasks.register('operator_make_manifests', Exec) { + group 'go' + description 'Running go mod tidy.' + commandLine 'make', 'manifests', '-C', "$rootDir/../common-controller/internal/operator" + dependsOn operator_make + finalizedBy go_build } tasks.named('go_build').configure { + dependsOn operator_make_manifests dependsOn go_revive_run dependsOn go_vet + println("Running go build") finalizedBy docker_build } diff --git a/common-controller/commoncontroller/common_controller.go b/common-controller/commoncontroller/common_controller.go index 73d6ff889..52e219e62 100644 --- a/common-controller/commoncontroller/common_controller.go +++ b/common-controller/commoncontroller/common_controller.go @@ -31,29 +31,44 @@ import ( discoveryv3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" envoy_cachev3 "github.com/envoyproxy/go-control-plane/pkg/cache/v3" xdsv3 "github.com/envoyproxy/go-control-plane/pkg/server/v3" - logger "github.com/sirupsen/logrus" + enforcerCallbacks "github.com/wso2/apk/common-controller/internal/xds/enforcercallbacks" + routercb "github.com/wso2/apk/common-controller/internal/xds/routercallbacks" + apiservice "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/service/api" + configservice "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/service/config" + subscriptionservice "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/service/subscription" + wso2_server "github.com/wso2/apk/adapter/pkg/discovery/protocol/server/v3" "github.com/wso2/apk/adapter/pkg/health" healthservice "github.com/wso2/apk/adapter/pkg/health/api/wso2/health/service" - "github.com/wso2/apk/adapter/pkg/logging" "github.com/wso2/apk/common-controller/internal/config" - "github.com/wso2/apk/common-controller/internal/loggers" "github.com/wso2/apk/common-controller/internal/operator" utils "github.com/wso2/apk/common-controller/internal/utils" xds "github.com/wso2/apk/common-controller/internal/xds" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/keepalive" + "github.com/wso2/apk/adapter/pkg/logging" + "github.com/wso2/apk/common-controller/internal/loggers" ) var ( rlsPort uint cache envoy_cachev3.SnapshotCache + + debug bool + onlyLogging bool + + port uint + alsPort uint + + mode string ) const ( maxRandomInt int = 999999999 grpcMaxConcurrentStreams = 1000000 apiKeyFieldSeparator string = ":" + ads = "ads" + amqpProtocol = "amqp" ) // IDHash uses ID field as the node hash. @@ -72,6 +87,12 @@ var _ envoy_cachev3.NodeHash = IDHash{} func init() { cache = envoy_cachev3.NewSnapshotCache(false, IDHash{}, nil) flag.UintVar(&rlsPort, "rls-port", 18005, "Rate Limiter management server port") + + flag.BoolVar(&debug, "debug", true, "Use debug logging") + flag.BoolVar(&onlyLogging, "onlyLogging", false, "Only demo AccessLogging Service") + flag.UintVar(&port, "port", 18002, "Enforcer server port") + flag.UintVar(&alsPort, "als", 18090, "Accesslog server port") + flag.StringVar(&mode, "ads", ads, "Enforcer server type (ads, xds, rest)") } func runRatelimitServer(rlsServer xdsv3.Server) { @@ -82,7 +103,7 @@ func runRatelimitServer(rlsServer xdsv3.Server) { caCertPool := utils.GetTrustedCertPool(truststoreLocation) if err == nil { - logger.Info("initiate the ssl context: ", err) + loggers.LoggerAPKOperator.Info("initiate the ssl context: ", err) grpcOptions = append(grpcOptions, grpc.Creds( credentials.NewTLS(&tls.Config{ Certificates: []tls.Certificate{cert}, @@ -117,13 +138,74 @@ func runRatelimitServer(rlsServer xdsv3.Server) { healthservice.RegisterHealthServer(rlsGrpcServer, &health.Server{}) go func() { loggers.LoggerAPKOperator.Info("Starting Rate Limiter xDS gRPC server.") + health.RateLimiterGrpcService.SetStatus(true) if err = rlsGrpcServer.Serve(rlsLis); err != nil { + health.RateLimiterGrpcService.SetStatus(false) loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error1105, logging.BLOCKER, "Error serving Rate Limiter xDS gRPC server on port %v, error: %v", rlsPort, err.Error())) } }() } +func runCommonEnforcerServer(server xdsv3.Server, enforcerServer wso2_server.Server, enforcerSdsServer wso2_server.Server, + enforcerAppDsSrv wso2_server.Server, enforcerAppKeyMappingDsSrv wso2_server.Server, enforcerAppMappingDsSrv wso2_server.Server, + port uint) { + var grpcOptions []grpc.ServerOption + grpcOptions = append(grpcOptions, grpc.MaxConcurrentStreams(grpcMaxConcurrentStreams)) + // TODO(Ashera): Add TLS support for Common Controller - Enforcer connection + publicKeyLocation, privateKeyLocation, truststoreLocation := utils.GetKeyLocations() + cert, err := utils.GetServerCertificate(publicKeyLocation, privateKeyLocation) + + caCertPool := utils.GetTrustedCertPool(truststoreLocation) + + if err == nil { + grpcOptions = append(grpcOptions, grpc.Creds( + credentials.NewTLS(&tls.Config{ + Certificates: []tls.Certificate{cert}, + ClientAuth: tls.RequireAndVerifyClientCert, + ClientCAs: caCertPool, + }), + )) + } else { + loggers.LoggerAPKOperator.Warn("failed to initiate the ssl context: ", err) + panic(err) + } + + grpcOptions = append(grpcOptions, grpc.KeepaliveParams( + keepalive.ServerParameters{ + Time: time.Duration(5 * time.Minute), + Timeout: time.Duration(20 * time.Second), + }), + ) + grpcServer := grpc.NewServer(grpcOptions...) + + lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) + if err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error1100, logging.BLOCKER, "Failed to listen on port: %v, error: %v", port, err.Error())) + } + + // register services + discoveryv3.RegisterAggregatedDiscoveryServiceServer(grpcServer, server) + configservice.RegisterConfigDiscoveryServiceServer(grpcServer, enforcerServer) + apiservice.RegisterApiDiscoveryServiceServer(grpcServer, enforcerServer) + subscriptionservice.RegisterSubscriptionDiscoveryServiceServer(grpcServer, enforcerSdsServer) + subscriptionservice.RegisterApplicationDiscoveryServiceServer(grpcServer, enforcerAppDsSrv) + subscriptionservice.RegisterApplicationKeyMappingDiscoveryServiceServer(grpcServer, enforcerAppKeyMappingDsSrv) + subscriptionservice.RegisterApplicationMappingDiscoveryServiceServer(grpcServer, enforcerAppMappingDsSrv) + // register health service + healthservice.RegisterHealthServer(grpcServer, &health.Server{}) + + loggers.LoggerAPKOperator.Info("port: ", port, " common enforcer server listening") + go func() { + loggers.LoggerAPKOperator.Info("Starting XDS GRPC server.") + health.CommonEnforcerGrpcService.SetStatus(true) + if err = grpcServer.Serve(lis); err != nil { + health.CommonEnforcerGrpcService.SetStatus(false) + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error1101, logging.BLOCKER, "Failed to start XDS GRPS server, error: %v", err.Error())) + } + }() +} + // InitCommonControllerServer initializes the gRPC server for the common controller. func InitCommonControllerServer(conf *config.Config) { sig := make(chan os.Signal, 2) @@ -133,19 +215,41 @@ func InitCommonControllerServer(conf *config.Config) { defer cancel() loggers.LoggerAPKOperator.Info("Starting common controller ....") + rateLimiterCache := xds.GetRateLimiterCache() rlsSrv := xdsv3.NewServer(ctx, rateLimiterCache, &xds.Callbacks{}) + // Start Rate Limiter xDS gRPC server runRatelimitServer(rlsSrv) // Set empty snapshot to initiate ratelimit service xds.SetEmptySnapshotupdate(conf.CommonController.Server.Label) + + cache := xds.GetXdsCache() + enforcerCache := xds.GetEnforcerCache() + enforcerSubscriptionCache := xds.GetEnforcerSubscriptionCache() + enforcerApplicationCache := xds.GetEnforcerApplicationCache() + enforcerApplicationKeyMappingCache := xds.GetEnforcerApplicationKeyMappingCache() + enforcerApplicationMappingCache := xds.GetEnforcerApplicationMappingCache() + srv := xdsv3.NewServer(ctx, cache, &routercb.Callbacks{}) + enforcerXdsSrv := wso2_server.NewServer(ctx, enforcerCache, &enforcerCallbacks.Callbacks{}) + enforcerSdsSrv := wso2_server.NewServer(ctx, enforcerSubscriptionCache, &enforcerCallbacks.Callbacks{}) + enforcerAppDsSrv := wso2_server.NewServer(ctx, enforcerApplicationCache, &enforcerCallbacks.Callbacks{}) + enforcerAppKeyMappingDsSrv := wso2_server.NewServer(ctx, enforcerApplicationKeyMappingCache, &enforcerCallbacks.Callbacks{}) + enforcerAppMappingDsSrv := wso2_server.NewServer(ctx, enforcerApplicationMappingCache, &enforcerCallbacks.Callbacks{}) + + // Start Enforcer xDS gRPC server + runCommonEnforcerServer(srv, enforcerXdsSrv, enforcerSdsSrv, enforcerAppDsSrv, enforcerAppKeyMappingDsSrv, + enforcerAppMappingDsSrv, port) + go operator.InitOperator() + OUTER: for { select { case s := <-sig: switch s { case os.Interrupt: + loggers.LoggerAPKOperator.Info("Shutting down...") break OUTER } } diff --git a/common-controller/coverage.out b/common-controller/coverage.out deleted file mode 100644 index d651655b8..000000000 --- a/common-controller/coverage.out +++ /dev/null @@ -1,610 +0,0 @@ -mode: atomic -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_types.go:109.13,111.2 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:34.70,38.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:47.33,49.2 0 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:57.67,60.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:63.85,66.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:68.48,71.31 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:97.2,97.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:102.2,102.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:71.31,73.18 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:74.14,75.55 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:78.16,79.65 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:82.15,83.60 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:86.15,87.67 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:90.15,91.67 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:75.55,77.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:79.65,81.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:83.60,85.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:87.67,89.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:91.67,93.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:97.22,101.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go:106.67,109.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:33.75,37.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:46.38,48.2 0 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:56.72,60.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:63.90,67.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:70.72,74.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:77.52,79.33 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:83.2,84.51 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:88.2,88.107 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:93.2,93.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:98.2,98.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:79.33,82.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:84.51,87.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:88.107,91.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go:93.22,97.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:27.56,45.43 13 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:48.2,52.40 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:55.2,58.37 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:61.2,66.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:45.43,47.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:52.40,54.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:58.37,60.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:71.58,89.43 13 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:92.2,96.40 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:99.2,102.37 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:105.2,110.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:89.43,91.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:96.40,98.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go:102.37,104.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_types.go:194.13,196.2 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:35.67,39.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:48.29,52.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:60.64,62.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:65.82,67.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:70.64,75.2 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:77.47,80.24 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:89.2,89.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:94.2,94.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:80.24,81.54 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:81.54,82.44 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:82.44,85.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go:89.22,93.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_types.go:138.13,140.2 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/custom_ratelimit_policy.go:32.94,40.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_types.go:91.13,93.2 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_webhook.go:28.78,32.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_webhook.go:41.41,41.42 0 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_webhook.go:49.75,52.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_webhook.go:55.93,58.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_webhook.go:61.75,64.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_types.go:114.13,116.2 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:30.39,36.2 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:39.32,40.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:43.2,45.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:40.15,42.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:49.48,50.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:53.2,53.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:50.34,52.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:57.47,61.21 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:61.21,64.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:64.22,66.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:71.40,72.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:75.2,77.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:72.15,74.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:81.52,82.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:85.2,85.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:82.34,84.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:89.51,95.2 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:98.44,99.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:102.2,104.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:99.15,101.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:108.54,109.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:112.2,112.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:109.34,111.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:116.59,120.21 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:120.21,123.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:123.22,125.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:130.52,131.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:134.2,136.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:131.15,133.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:140.58,141.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:144.2,144.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:141.34,143.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:148.59,150.23 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:155.2,155.24 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:160.2,160.43 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:150.23,154.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:155.24,159.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:164.52,165.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:168.2,170.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:165.15,167.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:174.63,176.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:179.56,180.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:183.2,185.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:180.15,182.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:189.69,191.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:194.62,195.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:198.2,200.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:195.15,197.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:204.47,206.26 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:213.2,213.23 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:220.2,220.29 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:206.26,209.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:209.22,211.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:213.23,216.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:216.22,218.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:220.29,224.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:228.40,229.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:232.2,234.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:229.15,231.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:238.51,241.2 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:244.44,245.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:248.2,250.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:245.15,247.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:254.47,260.2 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:263.40,264.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:267.2,269.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:264.15,266.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:273.52,274.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:277.2,277.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:274.34,276.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:281.53,287.2 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:290.46,291.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:294.2,296.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:291.15,293.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:300.55,301.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:304.2,304.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:301.34,303.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:308.61,312.21 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:312.21,315.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:315.22,317.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:322.54,323.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:326.2,328.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:323.15,325.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:332.59,333.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:336.2,336.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:333.34,335.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:340.61,342.28 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:342.28,346.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:350.54,351.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:354.2,356.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:351.15,353.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:360.65,362.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:365.58,366.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:369.2,371.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:366.15,368.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:375.63,377.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:380.56,381.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:384.2,386.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:381.15,383.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:390.55,394.21 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:394.21,397.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:397.22,399.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:404.48,405.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:408.2,410.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:405.15,407.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:414.56,415.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:418.2,418.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:415.34,417.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:422.65,424.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:427.58,428.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:431.2,433.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:428.15,430.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:437.55,439.24 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:444.2,444.19 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:449.2,449.24 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:454.2,454.30 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:459.2,459.23 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:464.2,464.21 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:469.2,469.27 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:439.24,443.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:444.19,448.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:449.24,453.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:454.30,458.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:459.23,463.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:464.21,468.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:469.27,473.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:477.48,478.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:481.2,483.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:478.15,480.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:487.59,489.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:492.52,493.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:496.2,498.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:493.15,495.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:502.71,505.2 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:508.64,509.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:512.2,514.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:509.15,511.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:518.53,520.41 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:525.2,525.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:530.2,530.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:535.2,535.42 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:540.2,540.35 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:520.41,524.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:525.41,529.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:530.41,534.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:535.42,539.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:540.35,544.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:548.46,549.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:552.2,554.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:549.15,551.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:558.61,560.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:563.54,564.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:567.2,569.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:564.15,566.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:573.55,575.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:578.48,579.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:582.2,584.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:579.15,581.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:588.75,590.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:593.68,594.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:597.2,599.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:594.15,596.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:603.81,605.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:608.74,609.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:612.2,614.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:609.15,611.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:618.65,620.30 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:624.2,624.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:620.30,623.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:624.22,628.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:632.58,633.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:636.2,638.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:633.15,635.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:642.51,644.29 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:644.29,648.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:652.44,653.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:656.2,658.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:653.15,655.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:662.55,664.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:667.48,668.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:671.2,673.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:668.15,670.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:677.73,679.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:682.66,683.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:686.2,688.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:683.15,685.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:692.69,698.2 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:701.62,702.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:705.2,707.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:702.15,704.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:711.63,712.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:715.2,715.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:712.34,714.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:719.77,723.21 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:723.21,726.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:726.22,728.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:733.70,734.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:737.2,739.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:734.15,736.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:743.67,744.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:747.2,747.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:744.34,746.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:751.77,754.24 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:754.24,758.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:762.70,763.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:766.2,768.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:763.15,765.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:772.81,774.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:777.74,778.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:781.2,783.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:778.15,780.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:787.53,789.35 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:794.2,794.36 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:799.2,799.32 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:804.2,804.26 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:789.35,793.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:794.36,798.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:799.32,803.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:804.26,808.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:812.46,813.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:816.2,818.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:813.15,815.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:822.49,824.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:827.42,828.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:831.2,833.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:828.15,830.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:837.69,839.19 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:844.2,844.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:839.19,843.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:844.22,848.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:852.62,853.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:856.2,858.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:853.15,855.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:862.63,868.2 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:871.56,872.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:875.2,877.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:872.15,874.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:881.60,882.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:885.2,885.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:882.34,884.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:889.71,893.21 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:893.21,896.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:896.22,898.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:903.64,904.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:907.2,909.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:904.15,906.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:913.64,914.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:917.2,917.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:914.34,916.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:921.71,923.23 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:928.2,928.24 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:933.2,933.43 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:923.23,927.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:928.24,932.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:937.64,938.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:941.2,943.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:938.15,940.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:947.75,949.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:952.68,953.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:956.2,958.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:953.15,955.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:962.51,964.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:967.44,968.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:971.2,973.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:968.15,970.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:977.65,979.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:982.58,983.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:986.2,988.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:983.15,985.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:992.83,995.25 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:995.25,999.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1003.76,1004.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1007.2,1009.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1004.15,1006.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1013.63,1016.2 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1019.56,1020.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1023.2,1025.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1020.15,1022.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1029.55,1031.27 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1031.27,1035.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1039.48,1040.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1043.2,1045.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1040.15,1042.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1049.51,1051.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1054.44,1055.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1058.2,1060.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1055.15,1057.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1064.61,1066.21 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1066.21,1070.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1074.54,1075.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1078.2,1080.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1075.15,1077.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1084.47,1086.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1089.40,1090.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1093.2,1095.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1090.15,1092.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1099.51,1101.33 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1106.2,1106.25 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1111.2,1111.28 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1116.2,1116.27 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1101.33,1105.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1106.25,1110.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1111.28,1115.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1116.27,1120.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1124.44,1125.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1128.2,1130.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1125.15,1127.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1134.47,1136.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1139.40,1140.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1143.2,1145.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go:1140.15,1142.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/api_webhook.go:25.63,29.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/backend_types.go:280.13,282.2 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:33.69,37.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:46.32,46.33 0 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:54.66,56.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:59.84,61.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:64.44,67.33 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:70.2,71.51 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:75.2,75.107 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:79.2,79.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:84.2,84.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:67.33,69.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:71.51,74.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:75.107,78.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:79.22,83.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go:88.66,91.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_conversion.go:21.20,21.21 0 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_types.go:200.13,202.2 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:45.63,51.2 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:60.26,62.2 0 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:70.60,72.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:75.78,77.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:80.60,84.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:87.35,92.25 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:99.2,99.27 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:108.2,108.31 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:112.2,112.243 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:117.2,118.32 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:121.2,121.29 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:125.2,125.43 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:130.2,130.43 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:135.2,135.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:141.2,141.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:92.25,93.48 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:93.48,96.4 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:99.27,101.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:101.8,101.98 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:101.98,103.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:103.8,103.78 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:103.78,105.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:108.31,110.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:112.243,115.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:118.32,120.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:121.29,123.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:125.43,128.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:130.43,133.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:135.22,139.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:144.51,145.30 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:150.2,150.14 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:145.30,146.16 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:146.16,148.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:153.73,156.16 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:161.2,163.30 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:199.2,199.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:156.16,160.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:163.30,165.68 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:165.68,169.54 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:176.4,176.31 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:169.54,175.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:176.31,179.34 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:189.5,189.73 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:179.34,180.77 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:180.77,186.7 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:189.73,195.6 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:202.39,207.23 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:225.2,225.18 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:207.23,209.69 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:213.3,214.34 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:209.69,212.4 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:215.8,216.40 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:216.40,218.90 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:222.4,222.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:218.90,221.5 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:228.75,229.50 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:232.2,232.11 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:229.50,231.3 1 1 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:236.56,238.21 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:241.2,241.17 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go:238.21,240.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:30.39,36.2 5 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:39.32,40.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:43.2,45.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:40.15,42.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:49.48,50.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:53.2,53.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:50.34,52.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:57.47,61.21 4 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:61.21,64.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:64.22,66.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:71.40,72.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:75.2,77.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:72.15,74.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:81.52,82.34 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:85.2,85.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:82.34,84.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:89.47,91.26 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:98.2,98.23 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:105.2,105.29 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:91.26,94.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:94.22,96.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:98.23,101.22 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:101.22,103.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:105.29,109.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:113.40,114.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:117.2,119.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:114.15,116.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:123.51,126.2 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:129.44,130.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:133.2,135.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:130.15,132.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:139.65,141.30 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:145.2,145.22 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:141.30,144.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:145.22,149.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:153.58,154.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:157.2,159.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:154.15,156.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:163.51,165.29 2 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:165.29,169.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:173.44,174.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:177.2,179.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:174.15,176.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:183.49,185.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:188.42,189.15 1 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:192.2,194.12 3 0 -github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go:189.15,191.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:69.98,76.45 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:81.2,82.16 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:88.2,92.106 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:98.2,99.112 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:105.2,105.143 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:111.2,112.12 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:76.45,79.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:82.16,86.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:92.106,96.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:99.112,103.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:105.143,109.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:128.125,137.92 6 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:156.2,156.89 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:171.2,171.27 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:137.92,140.39 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:146.3,147.45 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:153.3,153.28 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:140.39,145.4 4 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:147.45,152.4 4 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:156.89,160.3 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:160.8,162.126 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:162.126,164.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:164.9,164.49 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:164.49,168.4 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:174.136,176.9 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:182.2,187.17 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:191.2,191.46 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:196.2,196.17 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:176.9,180.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:187.17,189.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:191.46,194.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:200.116,202.9 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:208.2,213.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:202.9,206.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:216.142,218.9 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:224.2,229.17 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:232.2,232.46 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:237.2,237.17 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:218.9,222.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:229.17,231.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:232.46,235.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:241.94,249.21 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:253.2,258.62 4 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:277.2,277.67 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:311.2,311.24 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:249.21,251.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:258.62,261.43 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:269.3,273.52 5 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:261.43,264.4 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:264.9,267.4 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:277.67,285.35 6 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:297.3,297.32 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:285.35,288.18 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:291.4,291.36 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:288.18,290.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:291.36,294.5 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:297.32,300.18 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:303.4,303.36 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:300.18,302.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:303.36,307.5 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:315.103,320.31 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:357.2,357.33 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:320.31,321.16 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:321.16,325.29 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:329.4,329.46 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:325.29,328.5 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:329.46,330.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:330.41,331.36 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:331.36,332.128 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:332.128,335.41 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:340.8,341.48 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:348.8,348.74 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:335.41,337.9 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:337.14,339.9 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:341.48,344.9 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:344.14,347.9 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:361.82,364.66 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:368.2,368.30 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:364.66,367.3 2 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:372.118,376.2 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:378.65,380.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:402.2,403.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:413.2,413.12 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:380.41,383.46 3 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:396.4,396.26 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:383.46,384.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:384.41,385.36 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:385.36,386.68 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:386.68,392.8 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:397.18,399.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:403.41,412.4 4 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:417.61,422.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:425.83,426.42 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:429.2,429.25 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:426.42,428.3 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:435.78,436.41 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:436.41,437.24 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:440.3,440.70 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:437.24,439.4 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:445.39,448.2 1 0 -github.com/wso2/apk/common-controller/internal/operator/controller/ratelimitpolicy_controller.go:451.96,455.2 1 0 diff --git a/common-controller/internal/cache/datastore.go b/common-controller/internal/cache/datastore.go index 250617ea5..528dfdd2d 100644 --- a/common-controller/internal/cache/datastore.go +++ b/common-controller/internal/cache/datastore.go @@ -21,7 +21,7 @@ import ( "sync" logger "github.com/sirupsen/logrus" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1" + dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/common-controller/internal/config/parser.go b/common-controller/internal/config/parser.go index 61c5c53f1..98a5af169 100644 --- a/common-controller/internal/config/parser.go +++ b/common-controller/internal/config/parser.go @@ -72,3 +72,14 @@ func ReadConfigs() *Config { }) return controllerConfig } + +// ClearLogConfigInstance removes the existing configuration. +// Then the log configuration can be re-initialized. +func ClearLogConfigInstance() { + pkgconf.ClearLogConfigInstance() +} + +// GetLogConfigPath returns the file location of the log-config path +func GetLogConfigPath() (string, error) { + return pkgconf.GetLogConfigPath() +} diff --git a/common-controller/internal/operator/Makefile b/common-controller/internal/operator/Makefile index 606039087..2f99a9acc 100644 --- a/common-controller/internal/operator/Makefile +++ b/common-controller/internal/operator/Makefile @@ -67,12 +67,12 @@ test: manifests generate fmt vet envtest ## Run tests. ##@ Build .PHONY: build -build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager cmd/main.go +build: generate fmt vet ## Build manager binary. + go build -o bin/manager operator.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. - go run ./cmd/main.go + go run ./operator.go # If you wish built the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. diff --git a/common-controller/internal/operator/PROJECT b/common-controller/internal/operator/PROJECT index 67793a4ef..aa5912bad 100644 --- a/common-controller/internal/operator/PROJECT +++ b/common-controller/internal/operator/PROJECT @@ -16,7 +16,7 @@ resources: domain: wso2.com group: dp kind: RateLimitPolicy - path: github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1 + path: github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1 version: v1alpha1 - api: crdVersion: v1 @@ -24,7 +24,7 @@ resources: domain: wso2.com group: dp kind: API - path: github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2 + path: github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha2 version: v1alpha2 webhooks: conversion: true @@ -37,9 +37,36 @@ resources: domain: wso2.com group: dp kind: API - path: github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1 + path: github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1 version: v1alpha1 webhooks: conversion: true webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: wso2.com + group: cp + kind: Application + path: github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2 + version: v1alpha2 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: wso2.com + group: cp + kind: Subscription + path: github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2 + version: v1alpha2 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: wso2.com + group: cp + kind: ApplicationMapping + path: github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2 + version: v1alpha2 version: "3" diff --git a/common-controller/internal/operator/api/cp/.gitKeep b/common-controller/internal/operator/api/cp/.gitKeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go b/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go deleted file mode 100644 index c36ab0a96..000000000 --- a/common-controller/internal/operator/api/dp/v1alpha2/zz_generated.deepcopy.go +++ /dev/null @@ -1,195 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* - * 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 controller-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *API) DeepCopyInto(out *API) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. -func (in *API) DeepCopy() *API { - if in == nil { - return nil - } - out := new(API) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *API) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIList) DeepCopyInto(out *APIList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]API, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIList. -func (in *APIList) DeepCopy() *APIList { - if in == nil { - return nil - } - out := new(APIList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *APIList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APISpec) DeepCopyInto(out *APISpec) { - *out = *in - if in.Production != nil { - in, out := &in.Production, &out.Production - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Sandbox != nil { - in, out := &in.Sandbox, &out.Sandbox - *out = make([]EnvConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.APIProperties != nil { - in, out := &in.APIProperties, &out.APIProperties - *out = make([]Property, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APISpec. -func (in *APISpec) DeepCopy() *APISpec { - if in == nil { - return nil - } - out := new(APISpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *APIStatus) DeepCopyInto(out *APIStatus) { - *out = *in - in.DeploymentStatus.DeepCopyInto(&out.DeploymentStatus) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIStatus. -func (in *APIStatus) DeepCopy() *APIStatus { - if in == nil { - return nil - } - out := new(APIStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { - *out = *in - if in.TransitionTime != nil { - in, out := &in.TransitionTime, &out.TransitionTime - *out = (*in).DeepCopy() - } - if in.Events != nil { - in, out := &in.Events, &out.Events - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatus. -func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { - if in == nil { - return nil - } - out := new(DeploymentStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *EnvConfig) DeepCopyInto(out *EnvConfig) { - *out = *in - if in.HTTPRouteRefs != nil { - in, out := &in.HTTPRouteRefs, &out.HTTPRouteRefs - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvConfig. -func (in *EnvConfig) DeepCopy() *EnvConfig { - if in == nil { - return nil - } - out := new(EnvConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Property) DeepCopyInto(out *Property) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Property. -func (in *Property) DeepCopy() *Property { - if in == nil { - return nil - } - out := new(Property) - in.DeepCopyInto(out) - return out -} diff --git a/adapter/internal/operator/apis/cp/v1alpha1/application_types.go b/common-controller/internal/operator/apis/cp/v1alpha2/application_types.go similarity index 67% rename from adapter/internal/operator/apis/cp/v1alpha1/application_types.go rename to common-controller/internal/operator/apis/cp/v1alpha2/application_types.go index 9c30f5da2..39ffbad41 100644 --- a/adapter/internal/operator/apis/cp/v1alpha1/application_types.go +++ b/common-controller/internal/operator/apis/cp/v1alpha2/application_types.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * 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. @@ -15,7 +15,7 @@ * */ -package v1alpha1 +package v1alpha2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -26,24 +26,28 @@ import ( // ApplicationSpec defines the desired state of Application type ApplicationSpec struct { - Name string `json:"name"` - Owner string `json:"owner"` - Policy string `json:"policy"` - Organization string `json:"organization"` - Attributes map[string]string `json:"attributes,omitempty"` - Keys []Key `json:"keys,omitempty"` + Name string `json:"name"` + Owner string `json:"owner"` + Attributes map[string]string `json:"attributes,omitempty"` + SecuritySchemes SecuritySchemes `json:"securitySchemes"` } -// Key defines the keys of Application -type Key struct { - Key string `json:"key"` - KeyManager string `json:"keyManager"` +// SecuritySchemes defines the supported security schemes +type SecuritySchemes struct { + // OAuth2 denotes the OAuth2 security scheme + OAuth2 *SecurityScheme `json:"oauth2,omitempty"` } -// SubscriptionRef defines a subscription of Application -type SubscriptionRef struct { - Name string `json:"name"` - Namespace string `json:"namespace"` +// SecurityScheme defines the details specific to a security scheme +type SecurityScheme struct { + Environments []Environment `json:"environments,omitempty"` +} + +// Environment defines the environment specific details related to the security scheme +type Environment struct { + EnvID string `json:"envId"` + AppID string `json:"appId"` + KeyType string `json:"keyType"` } // ApplicationStatus defines the observed state of Application @@ -52,7 +56,6 @@ type ApplicationStatus struct { // Important: Run "make" to regenerate code after modifying this file } -// +genclient //+kubebuilder:object:root=true //+kubebuilder:subresource:status diff --git a/common-controller/internal/operator/apis/cp/v1alpha2/applicationmapping_types.go b/common-controller/internal/operator/apis/cp/v1alpha2/applicationmapping_types.go new file mode 100644 index 000000000..b6b880da6 --- /dev/null +++ b/common-controller/internal/operator/apis/cp/v1alpha2/applicationmapping_types.go @@ -0,0 +1,62 @@ +/* + * 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// ApplicationMappingSpec defines the desired state of ApplicationMapping +type ApplicationMappingSpec struct { + ApplicationRef string `json:"applicationRef"` + SubscriptionRef string `json:"subscriptionRef"` +} + +// ApplicationMappingStatus defines the observed state of ApplicationMapping +type ApplicationMappingStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// ApplicationMapping is the Schema for the applicationmappings API +type ApplicationMapping struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ApplicationMappingSpec `json:"spec,omitempty"` + Status ApplicationMappingStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// ApplicationMappingList contains a list of ApplicationMapping +type ApplicationMappingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ApplicationMapping `json:"items"` +} + +func init() { + SchemeBuilder.Register(&ApplicationMapping{}, &ApplicationMappingList{}) +} diff --git a/adapter/internal/operator/apis/cp/v1alpha1/groupversion_info.go b/common-controller/internal/operator/apis/cp/v1alpha2/groupversion_info.go similarity index 91% rename from adapter/internal/operator/apis/cp/v1alpha1/groupversion_info.go rename to common-controller/internal/operator/apis/cp/v1alpha2/groupversion_info.go index 50e0d5775..bf97080de 100644 --- a/adapter/internal/operator/apis/cp/v1alpha1/groupversion_info.go +++ b/common-controller/internal/operator/apis/cp/v1alpha2/groupversion_info.go @@ -15,10 +15,10 @@ * */ -// Package v1alpha1 contains API Schema definitions for the cp v1alpha1 API group +// Package v1alpha2 contains API Schema definitions for the cp v1alpha2 API group // +kubebuilder:object:generate=true // +groupName=cp.wso2.com -package v1alpha1 +package v1alpha2 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -27,7 +27,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "cp.wso2.com", Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: "cp.wso2.com", Version: "v1alpha2"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/adapter/internal/operator/apis/cp/v1alpha1/subscription_types.go b/common-controller/internal/operator/apis/cp/v1alpha2/subscription_types.go similarity index 85% rename from adapter/internal/operator/apis/cp/v1alpha1/subscription_types.go rename to common-controller/internal/operator/apis/cp/v1alpha2/subscription_types.go index 0cf41b942..2f2f90578 100644 --- a/adapter/internal/operator/apis/cp/v1alpha1/subscription_types.go +++ b/common-controller/internal/operator/apis/cp/v1alpha2/subscription_types.go @@ -15,7 +15,7 @@ * */ -package v1alpha1 +package v1alpha2 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -26,14 +26,15 @@ import ( // SubscriptionSpec defines the desired state of Subscription type SubscriptionSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - APIRef string `json:"apiRef"` - ApplicationRef string `json:"applicationRef"` - PolicyID string `json:"policyId"` SubscriptionStatus string `json:"subscriptionStatus"` - Subscriber string `json:"subscriber"` Organization string `json:"organization"` + API API `json:"api"` +} + +// API defines the API associated with the subscription +type API struct { + Name string `json:"name"` + Version string `json:"version"` } // SubscriptionStatus defines the observed state of Subscription @@ -42,7 +43,6 @@ type SubscriptionStatus struct { // Important: Run "make" to regenerate code after modifying this file } -// +genclient //+kubebuilder:object:root=true //+kubebuilder:subresource:status diff --git a/adapter/internal/operator/apis/cp/v1alpha1/zz_generated.deepcopy.go b/common-controller/internal/operator/apis/cp/v1alpha2/zz_generated.deepcopy.go similarity index 61% rename from adapter/internal/operator/apis/cp/v1alpha1/zz_generated.deepcopy.go rename to common-controller/internal/operator/apis/cp/v1alpha2/zz_generated.deepcopy.go index 3fcc395b8..14dea1761 100644 --- a/adapter/internal/operator/apis/cp/v1alpha1/zz_generated.deepcopy.go +++ b/common-controller/internal/operator/apis/cp/v1alpha2/zz_generated.deepcopy.go @@ -20,12 +20,27 @@ // Code generated by controller-gen. DO NOT EDIT. -package v1alpha1 +package v1alpha2 import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *API) DeepCopyInto(out *API) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. +func (in *API) DeepCopy() *API { + if in == nil { + return nil + } + out := new(API) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Application) DeepCopyInto(out *Application) { *out = *in @@ -85,6 +100,95 @@ func (in *ApplicationList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationMapping) DeepCopyInto(out *ApplicationMapping) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMapping. +func (in *ApplicationMapping) DeepCopy() *ApplicationMapping { + if in == nil { + return nil + } + out := new(ApplicationMapping) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApplicationMapping) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationMappingList) DeepCopyInto(out *ApplicationMappingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ApplicationMapping, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMappingList. +func (in *ApplicationMappingList) DeepCopy() *ApplicationMappingList { + if in == nil { + return nil + } + out := new(ApplicationMappingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApplicationMappingList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationMappingSpec) DeepCopyInto(out *ApplicationMappingSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMappingSpec. +func (in *ApplicationMappingSpec) DeepCopy() *ApplicationMappingSpec { + if in == nil { + return nil + } + out := new(ApplicationMappingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationMappingStatus) DeepCopyInto(out *ApplicationMappingStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationMappingStatus. +func (in *ApplicationMappingStatus) DeepCopy() *ApplicationMappingStatus { + if in == nil { + return nil + } + out := new(ApplicationMappingStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) { *out = *in @@ -95,11 +199,7 @@ func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) { (*out)[key] = val } } - if in.Keys != nil { - in, out := &in.Keys, &out.Keys - *out = make([]Key, len(*in)) - copy(*out, *in) - } + in.SecuritySchemes.DeepCopyInto(&out.SecuritySchemes) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSpec. @@ -128,16 +228,56 @@ func (in *ApplicationStatus) DeepCopy() *ApplicationStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Key) DeepCopyInto(out *Key) { +func (in *Environment) DeepCopyInto(out *Environment) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Key. -func (in *Key) DeepCopy() *Key { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Environment. +func (in *Environment) DeepCopy() *Environment { if in == nil { return nil } - out := new(Key) + out := new(Environment) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecurityScheme) DeepCopyInto(out *SecurityScheme) { + *out = *in + if in.Environments != nil { + in, out := &in.Environments, &out.Environments + *out = make([]Environment, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityScheme. +func (in *SecurityScheme) DeepCopy() *SecurityScheme { + if in == nil { + return nil + } + out := new(SecurityScheme) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecuritySchemes) DeepCopyInto(out *SecuritySchemes) { + *out = *in + if in.OAuth2 != nil { + in, out := &in.OAuth2, &out.OAuth2 + *out = new(SecurityScheme) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecuritySchemes. +func (in *SecuritySchemes) DeepCopy() *SecuritySchemes { + if in == nil { + return nil + } + out := new(SecuritySchemes) in.DeepCopyInto(out) return out } @@ -201,24 +341,10 @@ func (in *SubscriptionList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SubscriptionRef) DeepCopyInto(out *SubscriptionRef) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionRef. -func (in *SubscriptionRef) DeepCopy() *SubscriptionRef { - if in == nil { - return nil - } - out := new(SubscriptionRef) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { *out = *in + out.API = in.API } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionSpec. diff --git a/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go b/common-controller/internal/operator/apis/dp/v1alpha1/api_conversion.go similarity index 97% rename from common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go rename to common-controller/internal/operator/apis/dp/v1alpha1/api_conversion.go index 3d794fc08..e10691e21 100644 --- a/common-controller/internal/operator/api/dp/v1alpha1/api_conversion.go +++ b/common-controller/internal/operator/apis/dp/v1alpha1/api_conversion.go @@ -18,7 +18,7 @@ package v1alpha1 import ( - "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2" + "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha2" "sigs.k8s.io/controller-runtime/pkg/conversion" ) diff --git a/common-controller/internal/operator/api/dp/v1alpha1/api_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/api_types.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/api_types.go rename to common-controller/internal/operator/apis/dp/v1alpha1/api_types.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/api_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/api_webhook.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/api_webhook.go rename to common-controller/internal/operator/apis/dp/v1alpha1/api_webhook.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_types.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/apipolicy_types.go rename to common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_types.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_webhook.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/apipolicy_webhook.go rename to common-controller/internal/operator/apis/dp/v1alpha1/apipolicy_webhook.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/backend_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/backend_types.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/backend_types.go rename to common-controller/internal/operator/apis/dp/v1alpha1/backend_types.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/backend_webhook.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/backend_webhook.go rename to common-controller/internal/operator/apis/dp/v1alpha1/backend_webhook.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_types.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/backendjwt_types.go rename to common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_types.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_webhook.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/backendjwt_webhook.go rename to common-controller/internal/operator/apis/dp/v1alpha1/backendjwt_webhook.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/custom_ratelimit_policy.go b/common-controller/internal/operator/apis/dp/v1alpha1/custom_ratelimit_policy.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/custom_ratelimit_policy.go rename to common-controller/internal/operator/apis/dp/v1alpha1/custom_ratelimit_policy.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/groupversion_info.go b/common-controller/internal/operator/apis/dp/v1alpha1/groupversion_info.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/groupversion_info.go rename to common-controller/internal/operator/apis/dp/v1alpha1/groupversion_info.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_types.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_types.go rename to common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_types.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_webhook.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/interceptorservice_webhook.go rename to common-controller/internal/operator/apis/dp/v1alpha1/interceptorservice_webhook.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_types.go b/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_types.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_types.go rename to common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_types.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_webhook.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/ratelimitpolicy_webhook.go rename to common-controller/internal/operator/apis/dp/v1alpha1/ratelimitpolicy_webhook.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/resolveRatelimit.go b/common-controller/internal/operator/apis/dp/v1alpha1/resolveRatelimit.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/resolveRatelimit.go rename to common-controller/internal/operator/apis/dp/v1alpha1/resolveRatelimit.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/webhook_suite_test.go b/common-controller/internal/operator/apis/dp/v1alpha1/webhook_suite_test.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha1/webhook_suite_test.go rename to common-controller/internal/operator/apis/dp/v1alpha1/webhook_suite_test.go diff --git a/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go b/common-controller/internal/operator/apis/dp/v1alpha1/zz_generated.deepcopy.go similarity index 99% rename from common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go rename to common-controller/internal/operator/apis/dp/v1alpha1/zz_generated.deepcopy.go index 9fc6c5768..b5fb3eaf3 100644 --- a/common-controller/internal/operator/api/dp/v1alpha1/zz_generated.deepcopy.go +++ b/common-controller/internal/operator/apis/dp/v1alpha1/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * 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. diff --git a/common-controller/internal/operator/api/dp/v1alpha2/api_conversion.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_conversion.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha2/api_conversion.go rename to common-controller/internal/operator/apis/dp/v1alpha2/api_conversion.go diff --git a/common-controller/internal/operator/api/dp/v1alpha2/api_types.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_types.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha2/api_types.go rename to common-controller/internal/operator/apis/dp/v1alpha2/api_types.go diff --git a/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook.go similarity index 99% rename from common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go rename to common-controller/internal/operator/apis/dp/v1alpha2/api_webhook.go index c2f297bbc..f2d92f642 100644 --- a/common-controller/internal/operator/api/dp/v1alpha2/api_webhook.go +++ b/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook.go @@ -26,7 +26,7 @@ import ( "github.com/wso2/apk/adapter/pkg/logging" "github.com/wso2/apk/common-controller/internal/config" "github.com/wso2/apk/common-controller/internal/loggers" - "github.com/wso2/apk/common-controller/internal/operator/utils" + "github.com/wso2/apk/common-controller/internal/utils" "golang.org/x/exp/slices" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" diff --git a/common-controller/internal/operator/api/dp/v1alpha2/api_webhook_test.go b/common-controller/internal/operator/apis/dp/v1alpha2/api_webhook_test.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha2/api_webhook_test.go rename to common-controller/internal/operator/apis/dp/v1alpha2/api_webhook_test.go diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_types.go b/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_types.go new file mode 100644 index 000000000..4bb4008a4 --- /dev/null +++ b/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_types.go @@ -0,0 +1,148 @@ +/* + * 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1alpha2" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// APIPolicySpec defines the desired state of APIPolicy +type APIPolicySpec struct { + Default *PolicySpec `json:"default,omitempty"` + Override *PolicySpec `json:"override,omitempty"` + TargetRef gwapiv1b1.PolicyTargetReference `json:"targetRef,omitempty"` +} + +// PolicySpec contains API policies +type PolicySpec struct { + // RequestInterceptors referenced to intercetor services to be applied + // to the request flow. + // + // +optional + // +nullable + // +kubebuilder:validation:MaxItems=1 + RequestInterceptors []InterceptorReference `json:"requestInterceptors,omitempty"` + + // ResponseInterceptors referenced to intercetor services to be applied + // to the response flow. + // + // +optional + // +nullable + // +kubebuilder:validation:MaxItems=1 + ResponseInterceptors []InterceptorReference `json:"responseInterceptors,omitempty"` + + // BackendJWTPolicy holds reference to backendJWT policy configurations + BackendJWTPolicy *BackendJWTToken `json:"backendJwtPolicy,omitempty"` + + // CORS policy to be applied to the API. + CORSPolicy *CORSPolicy `json:"cORSPolicy,omitempty"` + + // SubscriptionValidation denotes whether subscription validation is enabled for the API + // + // +kubebuilder:default:=false + // +optional + SubscriptionValidation bool `json:"subscriptionValidation,omitempty"` +} + +// BackendJWTToken holds backend JWT token information +type BackendJWTToken struct { + // Name holds the name of the BackendJWT resource. + Name string `json:"name,omitempty"` +} + +// CORSPolicy holds CORS policy information +type CORSPolicy struct { + // AllowCredentials indicates whether the request can include user credentials like + // cookies, HTTP authentication or client side SSL certificates. + // + // +optional + AccessControlAllowCredentials bool `json:"accessControlAllowCredentials,omitempty"` + + // AccessControlAllowHeaders indicates which headers can be used + // during the actual request. + // + // +optional + AccessControlAllowHeaders []string `json:"accessControlAllowHeaders,omitempty"` + + // AccessControlAllowMethods indicates which methods can be used + // during the actual request. + // + // +optional + AccessControlAllowMethods []string `json:"accessControlAllowMethods,omitempty"` + + // AccessControlAllowOrigins indicates which origins can be used + // during the actual request. + // + // +optional + AccessControlAllowOrigins []string `json:"accessControlAllowOrigins,omitempty"` + + // AccessControlExposeHeaders indicates which headers can be exposed + // as part of the response by listing their names. + // + // +optional + AccessControlExposeHeaders []string `json:"accessControlExposeHeaders,omitempty"` + + // AccessControlMaxAge indicates how long the results of a preflight request + // can be cached in a preflight result cache. + // + // +optional + AccessControlMaxAge *int `json:"accessControlMaxAge,omitempty"` +} + +// InterceptorReference holds InterceptorService reference using name and namespace +type InterceptorReference struct { + // Name is the referced CR's name of InterceptorService resource. + Name string `json:"name"` +} + +// APIPolicyStatus defines the observed state of APIPolicy +type APIPolicyStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +// +genclient +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:storageversion + +// APIPolicy is the Schema for the apipolicies API +type APIPolicy struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec APIPolicySpec `json:"spec,omitempty"` + Status APIPolicyStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// APIPolicyList contains a list of APIPolicy +type APIPolicyList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []APIPolicy `json:"items"` +} + +func init() { + SchemeBuilder.Register(&APIPolicy{}, &APIPolicyList{}) +} diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_webhook.go b/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_webhook.go new file mode 100644 index 000000000..997b29c8c --- /dev/null +++ b/common-controller/internal/operator/apis/dp/v1alpha2/apipolicy_webhook.go @@ -0,0 +1,91 @@ +/* + * 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 v1alpha2 + +import ( + constants "github.com/wso2/apk/common-controller/internal/operator/constant" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "sigs.k8s.io/gateway-api/apis/v1beta1" +) + +// SetupWebhookWithManager creates a new webhook builder for APIPolicy +func (r *APIPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! + +//+kubebuilder:webhook:path=/mutate-dp-wso2-com-v1alpha2-apipolicy,mutating=true,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apipolicies,verbs=create;update,versions=v1alpha2,name=mapipolicy.kb.io,admissionReviewVersions=v1 + +var _ webhook.Defaulter = &APIPolicy{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type +func (r *APIPolicy) Default() {} + +// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. +//+kubebuilder:webhook:path=/validate-dp-wso2-com-v1alpha2-apipolicy,mutating=false,failurePolicy=fail,sideEffects=None,groups=dp.wso2.com,resources=apipolicies,verbs=create;update,versions=v1alpha2,name=vapipolicy.kb.io,admissionReviewVersions=v1 + +var _ webhook.Validator = &APIPolicy{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +func (r *APIPolicy) ValidateCreate() (admission.Warnings, error) { + return nil, r.ValidatePolicy() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +func (r *APIPolicy) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + return nil, r.ValidatePolicy() +} + +// ValidatePolicy validates the APIPolicy +func (r *APIPolicy) ValidatePolicy() error { + var allErrs field.ErrorList + + if r.Spec.TargetRef.Name == "" { + allErrs = append(allErrs, field.Required(field.NewPath("spec").Child("targetRef").Child("name"), "Name is required")) + } + if !(r.Spec.TargetRef.Kind == constants.KindAPI || r.Spec.TargetRef.Kind == constants.KindResource || + r.Spec.TargetRef.Kind == constants.KindGateway) { + allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("kind"), r.Spec.TargetRef.Kind, + "Invalid Kind is provided")) + } + if r.Spec.TargetRef.Namespace != nil && r.Spec.TargetRef.Namespace != (*v1beta1.Namespace)(&r.Namespace) { + allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("targetRef").Child("namespace"), r.Spec.TargetRef.Namespace, + "namespace cross reference is not allowed")) + } + if len(allErrs) > 0 { + return apierrors.NewInvalid( + schema.GroupKind{Group: "dp.wso2.com", Kind: "APIPolicy"}, + r.Name, allErrs) + } + return nil +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +func (r *APIPolicy) ValidateDelete() (admission.Warnings, error) { + // TODO(user): fill in your validation logic upon object deletion. + return nil, nil +} diff --git a/common-controller/internal/operator/api/dp/v1alpha2/groupversion_info.go b/common-controller/internal/operator/apis/dp/v1alpha2/groupversion_info.go similarity index 100% rename from common-controller/internal/operator/api/dp/v1alpha2/groupversion_info.go rename to common-controller/internal/operator/apis/dp/v1alpha2/groupversion_info.go diff --git a/common-controller/internal/operator/api/dp/v1alpha2/webhook_suite_test.go b/common-controller/internal/operator/apis/dp/v1alpha2/webhook_suite_test.go similarity index 96% rename from common-controller/internal/operator/api/dp/v1alpha2/webhook_suite_test.go rename to common-controller/internal/operator/apis/dp/v1alpha2/webhook_suite_test.go index a06710c0c..a43cff45a 100644 --- a/common-controller/internal/operator/api/dp/v1alpha2/webhook_suite_test.go +++ b/common-controller/internal/operator/apis/dp/v1alpha2/webhook_suite_test.go @@ -29,7 +29,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - admissionv1 "k8s.io/api/admission/v1" + admissionv1beta1 "k8s.io/api/admission/v1beta1" //+kubebuilder:scaffold:imports "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" @@ -79,7 +79,7 @@ var _ = BeforeSuite(func() { err = AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) - err = admissionv1.AddToScheme(scheme) + err = admissionv1beta1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme @@ -100,7 +100,7 @@ var _ = BeforeSuite(func() { }) Expect(err).NotTo(HaveOccurred()) - err = (&API{}).SetupWebhookWithManager(mgr) + err = (&APIPolicy{}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:webhook diff --git a/common-controller/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go b/common-controller/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go new file mode 100644 index 000000000..4289c0ab5 --- /dev/null +++ b/common-controller/internal/operator/apis/dp/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,400 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* + * 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 controller-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *API) DeepCopyInto(out *API) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. +func (in *API) DeepCopy() *API { + if in == nil { + return nil + } + out := new(API) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *API) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIList) DeepCopyInto(out *APIList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]API, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIList. +func (in *APIList) DeepCopy() *APIList { + if in == nil { + return nil + } + out := new(APIList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicy) DeepCopyInto(out *APIPolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicy. +func (in *APIPolicy) DeepCopy() *APIPolicy { + if in == nil { + return nil + } + out := new(APIPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIPolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicyList) DeepCopyInto(out *APIPolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]APIPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyList. +func (in *APIPolicyList) DeepCopy() *APIPolicyList { + if in == nil { + return nil + } + out := new(APIPolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *APIPolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicySpec) DeepCopyInto(out *APIPolicySpec) { + *out = *in + if in.Default != nil { + in, out := &in.Default, &out.Default + *out = new(PolicySpec) + (*in).DeepCopyInto(*out) + } + if in.Override != nil { + in, out := &in.Override, &out.Override + *out = new(PolicySpec) + (*in).DeepCopyInto(*out) + } + in.TargetRef.DeepCopyInto(&out.TargetRef) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicySpec. +func (in *APIPolicySpec) DeepCopy() *APIPolicySpec { + if in == nil { + return nil + } + out := new(APIPolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIPolicyStatus) DeepCopyInto(out *APIPolicyStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIPolicyStatus. +func (in *APIPolicyStatus) DeepCopy() *APIPolicyStatus { + if in == nil { + return nil + } + out := new(APIPolicyStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APISpec) DeepCopyInto(out *APISpec) { + *out = *in + if in.Production != nil { + in, out := &in.Production, &out.Production + *out = make([]EnvConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Sandbox != nil { + in, out := &in.Sandbox, &out.Sandbox + *out = make([]EnvConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.APIProperties != nil { + in, out := &in.APIProperties, &out.APIProperties + *out = make([]Property, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APISpec. +func (in *APISpec) DeepCopy() *APISpec { + if in == nil { + return nil + } + out := new(APISpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIStatus) DeepCopyInto(out *APIStatus) { + *out = *in + in.DeploymentStatus.DeepCopyInto(&out.DeploymentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIStatus. +func (in *APIStatus) DeepCopy() *APIStatus { + if in == nil { + return nil + } + out := new(APIStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackendJWTToken) DeepCopyInto(out *BackendJWTToken) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendJWTToken. +func (in *BackendJWTToken) DeepCopy() *BackendJWTToken { + if in == nil { + return nil + } + out := new(BackendJWTToken) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CORSPolicy) DeepCopyInto(out *CORSPolicy) { + *out = *in + if in.AccessControlAllowHeaders != nil { + in, out := &in.AccessControlAllowHeaders, &out.AccessControlAllowHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlAllowMethods != nil { + in, out := &in.AccessControlAllowMethods, &out.AccessControlAllowMethods + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlAllowOrigins != nil { + in, out := &in.AccessControlAllowOrigins, &out.AccessControlAllowOrigins + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlExposeHeaders != nil { + in, out := &in.AccessControlExposeHeaders, &out.AccessControlExposeHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessControlMaxAge != nil { + in, out := &in.AccessControlMaxAge, &out.AccessControlMaxAge + *out = new(int) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CORSPolicy. +func (in *CORSPolicy) DeepCopy() *CORSPolicy { + if in == nil { + return nil + } + out := new(CORSPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { + *out = *in + if in.TransitionTime != nil { + in, out := &in.TransitionTime, &out.TransitionTime + *out = (*in).DeepCopy() + } + if in.Events != nil { + in, out := &in.Events, &out.Events + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatus. +func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { + if in == nil { + return nil + } + out := new(DeploymentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvConfig) DeepCopyInto(out *EnvConfig) { + *out = *in + if in.HTTPRouteRefs != nil { + in, out := &in.HTTPRouteRefs, &out.HTTPRouteRefs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvConfig. +func (in *EnvConfig) DeepCopy() *EnvConfig { + if in == nil { + return nil + } + out := new(EnvConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InterceptorReference) DeepCopyInto(out *InterceptorReference) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InterceptorReference. +func (in *InterceptorReference) DeepCopy() *InterceptorReference { + if in == nil { + return nil + } + out := new(InterceptorReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PolicySpec) DeepCopyInto(out *PolicySpec) { + *out = *in + if in.RequestInterceptors != nil { + in, out := &in.RequestInterceptors, &out.RequestInterceptors + *out = make([]InterceptorReference, len(*in)) + copy(*out, *in) + } + if in.ResponseInterceptors != nil { + in, out := &in.ResponseInterceptors, &out.ResponseInterceptors + *out = make([]InterceptorReference, len(*in)) + copy(*out, *in) + } + if in.BackendJWTPolicy != nil { + in, out := &in.BackendJWTPolicy, &out.BackendJWTPolicy + *out = new(BackendJWTToken) + **out = **in + } + if in.CORSPolicy != nil { + in, out := &in.CORSPolicy, &out.CORSPolicy + *out = new(CORSPolicy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicySpec. +func (in *PolicySpec) DeepCopy() *PolicySpec { + if in == nil { + return nil + } + out := new(PolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Property) DeepCopyInto(out *Property) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Property. +func (in *Property) DeepCopy() *Property { + if in == nil { + return nil + } + out := new(Property) + in.DeepCopyInto(out) + return out +} diff --git a/common-controller/internal/operator/config/crd/bases/cp.wso2.com_applicationmappings.yaml b/common-controller/internal/operator/config/crd/bases/cp.wso2.com_applicationmappings.yaml new file mode 100644 index 000000000..0d28116e6 --- /dev/null +++ b/common-controller/internal/operator/config/crd/bases/cp.wso2.com_applicationmappings.yaml @@ -0,0 +1,53 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: applicationmappings.cp.wso2.com +spec: + group: cp.wso2.com + names: + kind: ApplicationMapping + listKind: ApplicationMappingList + plural: applicationmappings + singular: applicationmapping + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: ApplicationMapping is the Schema for the applicationmappings + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ApplicationMappingSpec defines the desired state of ApplicationMapping + properties: + applicationRef: + type: string + subscriptionRef: + type: string + required: + - applicationRef + - subscriptionRef + type: object + status: + description: ApplicationMappingStatus defines the observed state of ApplicationMapping + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/common-controller/internal/operator/config/crd/bases/cp.wso2.com_applications.yaml b/common-controller/internal/operator/config/crd/bases/cp.wso2.com_applications.yaml new file mode 100644 index 000000000..49df1f41c --- /dev/null +++ b/common-controller/internal/operator/config/crd/bases/cp.wso2.com_applications.yaml @@ -0,0 +1,82 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: applications.cp.wso2.com +spec: + group: cp.wso2.com + names: + kind: Application + listKind: ApplicationList + plural: applications + singular: application + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: Application is the Schema for the applications API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ApplicationSpec defines the desired state of Application + properties: + attributes: + additionalProperties: + type: string + type: object + name: + type: string + owner: + type: string + securitySchemes: + description: SecuritySchemes defines the supported security schemes + properties: + oauth2: + description: OAuth2 denotes the OAuth2 security scheme + properties: + environments: + items: + description: Environment defines the environment specific + details related to the security scheme + properties: + appId: + type: string + envId: + type: string + keyType: + type: string + required: + - appId + - envId + - keyType + type: object + type: array + type: object + type: object + required: + - name + - owner + - securitySchemes + type: object + status: + description: ApplicationStatus defines the observed state of Application + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/common-controller/internal/operator/config/crd/bases/cp.wso2.com_subscriptions.yaml b/common-controller/internal/operator/config/crd/bases/cp.wso2.com_subscriptions.yaml new file mode 100644 index 000000000..172cb762c --- /dev/null +++ b/common-controller/internal/operator/config/crd/bases/cp.wso2.com_subscriptions.yaml @@ -0,0 +1,64 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: subscriptions.cp.wso2.com +spec: + group: cp.wso2.com + names: + kind: Subscription + listKind: SubscriptionList + plural: subscriptions + singular: subscription + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: Subscription is the Schema for the subscriptions API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: SubscriptionSpec defines the desired state of Subscription + properties: + api: + description: API defines the API associated with the subscription + properties: + name: + type: string + version: + type: string + required: + - name + - version + type: object + organization: + type: string + subscriptionStatus: + type: string + required: + - api + - organization + - subscriptionStatus + type: object + status: + description: SubscriptionStatus defines the observed state of Subscription + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml b/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml index d3fa66fef..6a3fc30b3 100644 --- a/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml +++ b/common-controller/internal/operator/config/crd/bases/dp.wso2.com_apipolicies.yaml @@ -247,6 +247,252 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - name: v1alpha2 + schema: + openAPIV3Schema: + description: APIPolicy is the Schema for the apipolicies API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: APIPolicySpec defines the desired state of APIPolicy + properties: + default: + description: PolicySpec contains API policies + properties: + backendJwtPolicy: + description: BackendJWTPolicy holds reference to backendJWT policy + configurations + properties: + name: + description: Name holds the name of the BackendJWT resource. + type: string + type: object + cORSPolicy: + description: CORS policy to be applied to the API. + properties: + accessControlAllowCredentials: + description: AllowCredentials indicates whether the request + can include user credentials like cookies, HTTP authentication + or client side SSL certificates. + type: boolean + accessControlAllowHeaders: + description: AccessControlAllowHeaders indicates which headers + can be used during the actual request. + items: + type: string + type: array + accessControlAllowMethods: + description: AccessControlAllowMethods indicates which methods + can be used during the actual request. + items: + type: string + type: array + accessControlAllowOrigins: + description: AccessControlAllowOrigins indicates which origins + can be used during the actual request. + items: + type: string + type: array + accessControlExposeHeaders: + description: AccessControlExposeHeaders indicates which headers + can be exposed as part of the response by listing their + names. + items: + type: string + type: array + accessControlMaxAge: + description: AccessControlMaxAge indicates how long the results + of a preflight request can be cached in a preflight result + cache. + type: integer + type: object + requestInterceptors: + description: RequestInterceptors referenced to intercetor services + to be applied to the request flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + responseInterceptors: + description: ResponseInterceptors referenced to intercetor services + to be applied to the response flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + subscriptionValidation: + default: false + description: SubscriptionValidation denotes whether subscription + validation is enabled for the API + type: boolean + type: object + override: + description: PolicySpec contains API policies + properties: + backendJwtPolicy: + description: BackendJWTPolicy holds reference to backendJWT policy + configurations + properties: + name: + description: Name holds the name of the BackendJWT resource. + type: string + type: object + cORSPolicy: + description: CORS policy to be applied to the API. + properties: + accessControlAllowCredentials: + description: AllowCredentials indicates whether the request + can include user credentials like cookies, HTTP authentication + or client side SSL certificates. + type: boolean + accessControlAllowHeaders: + description: AccessControlAllowHeaders indicates which headers + can be used during the actual request. + items: + type: string + type: array + accessControlAllowMethods: + description: AccessControlAllowMethods indicates which methods + can be used during the actual request. + items: + type: string + type: array + accessControlAllowOrigins: + description: AccessControlAllowOrigins indicates which origins + can be used during the actual request. + items: + type: string + type: array + accessControlExposeHeaders: + description: AccessControlExposeHeaders indicates which headers + can be exposed as part of the response by listing their + names. + items: + type: string + type: array + accessControlMaxAge: + description: AccessControlMaxAge indicates how long the results + of a preflight request can be cached in a preflight result + cache. + type: integer + type: object + requestInterceptors: + description: RequestInterceptors referenced to intercetor services + to be applied to the request flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + responseInterceptors: + description: ResponseInterceptors referenced to intercetor services + to be applied to the response flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + subscriptionValidation: + default: false + description: SubscriptionValidation denotes whether subscription + validation is enabled for the API + type: boolean + type: object + targetRef: + description: PolicyTargetReference identifies an API object to apply + policy to. This should be used as part of Policy resources that + can target Gateway API resources. For more information on how this + policy attachment model works, and a sample Policy resource, refer + to the policy attachment documentation for Gateway API. + properties: + group: + description: Group is the group of the target resource. + maxLength: 253 + pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + kind: + description: Kind is kind of the target resource. + maxLength: 63 + minLength: 1 + pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ + type: string + name: + description: Name is the name of the target resource. + maxLength: 253 + minLength: 1 + type: string + namespace: + description: Namespace is the namespace of the referent. When + unspecified, the local namespace is inferred. Even when policy + targets a resource in a different namespace, it MUST only apply + to traffic originating from the same namespace as the policy. + maxLength: 63 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + type: string + required: + - group + - kind + - name + type: object + type: object + status: + description: APIPolicyStatus defines the observed state of APIPolicy + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/common-controller/internal/operator/config/crd/kustomization.yaml b/common-controller/internal/operator/config/crd/kustomization.yaml index b274ccd2e..16ac3fc02 100644 --- a/common-controller/internal/operator/config/crd/kustomization.yaml +++ b/common-controller/internal/operator/config/crd/kustomization.yaml @@ -4,6 +4,9 @@ resources: - bases/dp.wso2.com_ratelimitpolicies.yaml - bases/dp.wso2.com_apis.yaml +- bases/cp.wso2.com_applications.yaml +- bases/cp.wso2.com_subscriptions.yaml +- bases/cp.wso2.com_applicationmappings.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: @@ -11,12 +14,18 @@ patches: # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_ratelimitpolicies.yaml #- path: patches/webhook_in_apis.yaml +#- patches/webhook_in_applications.yaml +#- patches/webhook_in_subscriptions.yaml +#- patches/webhook_in_applicationmappings.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- patches/cainjection_in_ratelimitpolicies.yaml #- path: patches/cainjection_in_apis.yaml +#- patches/cainjection_in_applications.yaml +#- patches/cainjection_in_subscriptions.yaml +#- patches/cainjection_in_applicationmappings.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/common-controller/internal/operator/config/crd/patches/cainjection_in_cp_applicationmappings.yaml b/common-controller/internal/operator/config/crd/patches/cainjection_in_cp_applicationmappings.yaml new file mode 100644 index 000000000..795a64a05 --- /dev/null +++ b/common-controller/internal/operator/config/crd/patches/cainjection_in_cp_applicationmappings.yaml @@ -0,0 +1,7 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: applicationmappings.cp.wso2.com diff --git a/adapter/internal/operator/config/crd/patches/cainjection_in_cp_applications.yaml b/common-controller/internal/operator/config/crd/patches/cainjection_in_cp_applications.yaml similarity index 71% rename from adapter/internal/operator/config/crd/patches/cainjection_in_cp_applications.yaml rename to common-controller/internal/operator/config/crd/patches/cainjection_in_cp_applications.yaml index 624972871..08bb54afc 100644 --- a/adapter/internal/operator/config/crd/patches/cainjection_in_cp_applications.yaml +++ b/common-controller/internal/operator/config/crd/patches/cainjection_in_cp_applications.yaml @@ -3,5 +3,5 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) name: applications.cp.wso2.com diff --git a/adapter/internal/operator/config/crd/patches/cainjection_in_cp_subscriptions.yaml b/common-controller/internal/operator/config/crd/patches/cainjection_in_cp_subscriptions.yaml similarity index 71% rename from adapter/internal/operator/config/crd/patches/cainjection_in_cp_subscriptions.yaml rename to common-controller/internal/operator/config/crd/patches/cainjection_in_cp_subscriptions.yaml index d69e35bc7..fb858b6c8 100644 --- a/adapter/internal/operator/config/crd/patches/cainjection_in_cp_subscriptions.yaml +++ b/common-controller/internal/operator/config/crd/patches/cainjection_in_cp_subscriptions.yaml @@ -3,5 +3,5 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) name: subscriptions.cp.wso2.com diff --git a/common-controller/internal/operator/config/crd/patches/webhook_in_cp_applicationmappings.yaml b/common-controller/internal/operator/config/crd/patches/webhook_in_cp_applicationmappings.yaml new file mode 100644 index 000000000..dba460e7a --- /dev/null +++ b/common-controller/internal/operator/config/crd/patches/webhook_in_cp_applicationmappings.yaml @@ -0,0 +1,16 @@ +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: applicationmappings.cp.wso2.com +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1 diff --git a/adapter/internal/operator/config/crd/patches/webhook_in_cp_applications.yaml b/common-controller/internal/operator/config/crd/patches/webhook_in_cp_applications.yaml similarity index 100% rename from adapter/internal/operator/config/crd/patches/webhook_in_cp_applications.yaml rename to common-controller/internal/operator/config/crd/patches/webhook_in_cp_applications.yaml diff --git a/adapter/internal/operator/config/crd/patches/webhook_in_cp_subscriptions.yaml b/common-controller/internal/operator/config/crd/patches/webhook_in_cp_subscriptions.yaml similarity index 100% rename from adapter/internal/operator/config/crd/patches/webhook_in_cp_subscriptions.yaml rename to common-controller/internal/operator/config/crd/patches/webhook_in_cp_subscriptions.yaml diff --git a/common-controller/internal/operator/config/rbac/cp_application_editor_role.yaml b/common-controller/internal/operator/config/rbac/cp_application_editor_role.yaml new file mode 100644 index 000000000..4e696df94 --- /dev/null +++ b/common-controller/internal/operator/config/rbac/cp_application_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit applications. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: application-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: operator + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + name: application-editor-role +rules: +- apiGroups: + - cp.wso2.com + resources: + - applications + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - cp.wso2.com + resources: + - applications/status + verbs: + - get diff --git a/common-controller/internal/operator/config/rbac/cp_application_viewer_role.yaml b/common-controller/internal/operator/config/rbac/cp_application_viewer_role.yaml new file mode 100644 index 000000000..679756c93 --- /dev/null +++ b/common-controller/internal/operator/config/rbac/cp_application_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view applications. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: application-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: operator + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + name: application-viewer-role +rules: +- apiGroups: + - cp.wso2.com + resources: + - applications + verbs: + - get + - list + - watch +- apiGroups: + - cp.wso2.com + resources: + - applications/status + verbs: + - get diff --git a/common-controller/internal/operator/config/rbac/cp_applicationmapping_editor_role.yaml b/common-controller/internal/operator/config/rbac/cp_applicationmapping_editor_role.yaml new file mode 100644 index 000000000..c5da7085c --- /dev/null +++ b/common-controller/internal/operator/config/rbac/cp_applicationmapping_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit applicationmappings. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: applicationmapping-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: operator + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + name: applicationmapping-editor-role +rules: +- apiGroups: + - cp.wso2.com + resources: + - applicationmappings + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - cp.wso2.com + resources: + - applicationmappings/status + verbs: + - get diff --git a/common-controller/internal/operator/config/rbac/cp_applicationmapping_viewer_role.yaml b/common-controller/internal/operator/config/rbac/cp_applicationmapping_viewer_role.yaml new file mode 100644 index 000000000..9ed75b5b6 --- /dev/null +++ b/common-controller/internal/operator/config/rbac/cp_applicationmapping_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view applicationmappings. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: applicationmapping-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: operator + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + name: applicationmapping-viewer-role +rules: +- apiGroups: + - cp.wso2.com + resources: + - applicationmappings + verbs: + - get + - list + - watch +- apiGroups: + - cp.wso2.com + resources: + - applicationmappings/status + verbs: + - get diff --git a/common-controller/internal/operator/config/rbac/cp_subscription_editor_role.yaml b/common-controller/internal/operator/config/rbac/cp_subscription_editor_role.yaml new file mode 100644 index 000000000..5edd27911 --- /dev/null +++ b/common-controller/internal/operator/config/rbac/cp_subscription_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit subscriptions. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: subscription-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: operator + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + name: subscription-editor-role +rules: +- apiGroups: + - cp.wso2.com + resources: + - subscriptions + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - cp.wso2.com + resources: + - subscriptions/status + verbs: + - get diff --git a/common-controller/internal/operator/config/rbac/cp_subscription_viewer_role.yaml b/common-controller/internal/operator/config/rbac/cp_subscription_viewer_role.yaml new file mode 100644 index 000000000..93dfacbe5 --- /dev/null +++ b/common-controller/internal/operator/config/rbac/cp_subscription_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view subscriptions. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: subscription-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: operator + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + name: subscription-viewer-role +rules: +- apiGroups: + - cp.wso2.com + resources: + - subscriptions + verbs: + - get + - list + - watch +- apiGroups: + - cp.wso2.com + resources: + - subscriptions/status + verbs: + - get diff --git a/common-controller/internal/operator/config/rbac/role.yaml b/common-controller/internal/operator/config/rbac/role.yaml index 742b5cba7..ca4e4315e 100644 --- a/common-controller/internal/operator/config/rbac/role.yaml +++ b/common-controller/internal/operator/config/rbac/role.yaml @@ -4,6 +4,84 @@ kind: ClusterRole metadata: name: manager-role rules: +- apiGroups: + - cp.wso2.com + resources: + - applicationmappings + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - cp.wso2.com + resources: + - applicationmappings/finalizers + verbs: + - update +- apiGroups: + - cp.wso2.com + resources: + - applicationmappings/status + verbs: + - get + - patch + - update +- apiGroups: + - cp.wso2.com + resources: + - applications + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - cp.wso2.com + resources: + - applications/finalizers + verbs: + - update +- apiGroups: + - cp.wso2.com + resources: + - applications/status + verbs: + - get + - patch + - update +- apiGroups: + - cp.wso2.com + resources: + - subscriptions + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - cp.wso2.com + resources: + - subscriptions/finalizers + verbs: + - update +- apiGroups: + - cp.wso2.com + resources: + - subscriptions/status + verbs: + - get + - patch + - update - apiGroups: - dp.wso2.com resources: diff --git a/common-controller/internal/operator/config/samples/cp_v1alpha2_application.yaml b/common-controller/internal/operator/config/samples/cp_v1alpha2_application.yaml new file mode 100644 index 000000000..c8d45fce6 --- /dev/null +++ b/common-controller/internal/operator/config/samples/cp_v1alpha2_application.yaml @@ -0,0 +1,22 @@ +apiVersion: cp.wso2.com/v1alpha2 +kind: Application +metadata: + labels: + app.kubernetes.io/name: application + app.kubernetes.io/instance: application-sample + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: operator + name: application-sample +spec: + name: app1 + owner: admin + attributes: + attb1: value1 + attb2: value2 + securitySchemes: + oauth2: + environments: + - envId: dev + appId: 45f1c5c8-a92e-11ed-afa1-0242ac120002 # OAuth2 consumer key + keyType: PRODUCTION diff --git a/common-controller/internal/operator/config/samples/cp_v1alpha2_applicationmapping.yaml b/common-controller/internal/operator/config/samples/cp_v1alpha2_applicationmapping.yaml new file mode 100644 index 000000000..306257be0 --- /dev/null +++ b/common-controller/internal/operator/config/samples/cp_v1alpha2_applicationmapping.yaml @@ -0,0 +1,13 @@ +apiVersion: cp.wso2.com/v1alpha2 +kind: ApplicationMapping +metadata: + labels: + app.kubernetes.io/name: applicationmapping + app.kubernetes.io/instance: applicationmapping-sample + app.kubernetes.io/part-of: operator + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: operator + name: applicationmapping-sample +spec: + applicationRef: application-sample + subscriptionRef: subscription-sample diff --git a/adapter/internal/operator/config/samples/cp_v1alpha1_subscription.yaml b/common-controller/internal/operator/config/samples/cp_v1alpha2_subscription.yaml similarity index 56% rename from adapter/internal/operator/config/samples/cp_v1alpha1_subscription.yaml rename to common-controller/internal/operator/config/samples/cp_v1alpha2_subscription.yaml index d13d8a636..43bf8ad1f 100644 --- a/adapter/internal/operator/config/samples/cp_v1alpha1_subscription.yaml +++ b/common-controller/internal/operator/config/samples/cp_v1alpha2_subscription.yaml @@ -1,12 +1,16 @@ -apiVersion: cp.wso2.com/v1alpha1 +apiVersion: cp.wso2.com/v1alpha2 kind: Subscription metadata: labels: app.kubernetes.io/name: subscription app.kubernetes.io/instance: subscription-sample app.kubernetes.io/part-of: operator - app.kuberentes.io/managed-by: kustomize + app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: operator name: subscription-sample spec: - # TODO(user): Add fields here + subscriptionStatus: ACTIVE + organization: carbon.super + api: + name: AppSubTestAPI + version: ^1.*|^v1$ diff --git a/common-controller/internal/operator/config/webhook/manifests.yaml b/common-controller/internal/operator/config/webhook/manifests.yaml index f131a3420..c7026f4c8 100644 --- a/common-controller/internal/operator/config/webhook/manifests.yaml +++ b/common-controller/internal/operator/config/webhook/manifests.yaml @@ -24,6 +24,26 @@ webhooks: resources: - apis sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-dp-wso2-com-v1alpha2-apipolicy + failurePolicy: Fail + name: mapipolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha2 + operations: + - CREATE + - UPDATE + resources: + - apipolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: @@ -150,6 +170,26 @@ webhooks: resources: - apis sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-dp-wso2-com-v1alpha2-apipolicy + failurePolicy: Fail + name: vapipolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha2 + operations: + - CREATE + - UPDATE + resources: + - apipolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/common-controller/internal/operator/constant/constant.go b/common-controller/internal/operator/constant/constant.go index 5521ded7c..cb2e18985 100644 --- a/common-controller/internal/operator/constant/constant.go +++ b/common-controller/internal/operator/constant/constant.go @@ -19,7 +19,10 @@ package constants // Controller related constants const ( - RatelimitController string = "RatelimitController" + RatelimitController string = "RatelimitController" + ApplicationController string = "ApplicationController" + SubscriptionController string = "SubscriptionController" + ApplicationMappingController string = "ApplicationMappingController" ) // API events related constants @@ -63,3 +66,8 @@ const ( GlobalRequestInterceptorClusterName = "request_interceptor_global_cluster" GlobalResponseInterceptorClusterName = "response_interceptor_global_cluster" ) + +// Application authentication types +const ( + OAuth2 = "OAuth2" +) diff --git a/adapter/internal/operator/controllers/cp/application_controller.go b/common-controller/internal/operator/controllers/cp/application_controller.go similarity index 74% rename from adapter/internal/operator/controllers/cp/application_controller.go rename to common-controller/internal/operator/controllers/cp/application_controller.go index e0ba582f7..78e717097 100644 --- a/adapter/internal/operator/controllers/cp/application_controller.go +++ b/common-controller/internal/operator/controllers/cp/application_controller.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * 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. @@ -21,9 +21,9 @@ import ( "context" "fmt" - "github.com/wso2/apk/adapter/internal/discovery/xds" - "github.com/wso2/apk/adapter/internal/loggers" "github.com/wso2/apk/adapter/pkg/logging" + "github.com/wso2/apk/common-controller/internal/loggers" + "github.com/wso2/apk/common-controller/internal/xds" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -35,10 +35,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - cpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1" - "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" + cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" + "github.com/wso2/apk/common-controller/internal/operator/constant" + "github.com/wso2/apk/common-controller/internal/utils" ) // ApplicationReconciler reconciles a Application object @@ -47,7 +47,7 @@ type ApplicationReconciler struct { Scheme *runtime.Scheme } -// NewApplicationController creates a new Application controller instance. +// NewApplicationController creates a new Application controller instance func NewApplicationController(mgr manager.Manager) error { r := &ApplicationReconciler{ client: mgr.GetClient(), @@ -58,7 +58,7 @@ func NewApplicationController(mgr manager.Manager) error { return err } - if err := c.Watch(source.Kind(mgr.GetCache(), &cpv1alpha1.Application{}), &handler.EnqueueRequestForObject{}, + if err := c.Watch(source.Kind(mgr.GetCache(), &cpv1alpha2.Application{}), &handler.EnqueueRequestForObject{}, predicate.NewPredicateFuncs(utils.FilterByNamespaces([]string{utils.GetOperatorPodNamespace()}))); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2607, logging.BLOCKER, "Error watching Application resources: %v", err.Error())) return err @@ -74,30 +74,29 @@ func NewApplicationController(mgr manager.Manager) error { // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. -// Modify the Reconcile function to compare the state specified by +// TODO(user): Modify the Reconcile function to compare the state specified by // the Application 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 +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile func (applicationReconciler *ApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { _ = log.FromContext(ctx) - - loggers.LoggerAPKOperator.Debugf("Reconciling application: %v", req.NamespacedName.String()) - applicationKey := req.NamespacedName - var applicationList = new(cpv1alpha1.ApplicationList) + var applicationList = new(cpv1alpha2.ApplicationList) + + loggers.LoggerAPKOperator.Debugf("Reconciling application: %v", applicationKey.String()) if err := applicationReconciler.client.List(ctx, applicationList); err != nil { return reconcile.Result{}, fmt.Errorf("failed to get applications %s/%s", applicationKey.Namespace, applicationKey.Name) } - sendUpdates(applicationList) + sendAppUpdates(applicationList) return ctrl.Result{}, nil } -func sendUpdates(applicationList *cpv1alpha1.ApplicationList) { +func sendAppUpdates(applicationList *cpv1alpha2.ApplicationList) { appList := marshalApplicationList(applicationList.Items) xds.UpdateEnforcerApplications(appList) @@ -105,13 +104,13 @@ func sendUpdates(applicationList *cpv1alpha1.ApplicationList) { xds.UpdateEnforcerApplicationKeyMappings(appKeyMappingList) } -func marshalApplicationList(applicationList []cpv1alpha1.Application) *subscription.ApplicationList { +func marshalApplicationList(applicationList []cpv1alpha2.Application) *subscription.ApplicationList { applications := []*subscription.Application{} for _, appInternal := range applicationList { app := &subscription.Application{ Uuid: appInternal.Name, Name: appInternal.Spec.Name, - Policy: appInternal.Spec.Policy, + Owner: appInternal.Spec.Owner, Attributes: appInternal.Spec.Attributes, } applications = append(applications, app) @@ -121,16 +120,21 @@ func marshalApplicationList(applicationList []cpv1alpha1.Application) *subscript } } -func marshalApplicationKeyMapping(applicationList []cpv1alpha1.Application) *subscription.ApplicationKeyMappingList { +func marshalApplicationKeyMapping(applicationList []cpv1alpha2.Application) *subscription.ApplicationKeyMappingList { applicationKeyMappings := []*subscription.ApplicationKeyMapping{} for _, appInternal := range applicationList { - for _, consumerKeyInternal := range appInternal.Spec.Keys { - consumerKey := &subscription.ApplicationKeyMapping{ - ConsumerKey: consumerKeyInternal.Key, - KeyManager: consumerKeyInternal.KeyManager, - ApplicationUUID: appInternal.Name, + var oauth2SecurityScheme = appInternal.Spec.SecuritySchemes.OAuth2 + if oauth2SecurityScheme != nil { + for _, env := range oauth2SecurityScheme.Environments { + appIdentifier := &subscription.ApplicationKeyMapping{ + ApplicationUUID: appInternal.Name, + SecurityScheme: constants.OAuth2, + ApplicationIdentifier: env.AppID, + KeyType: env.KeyType, + EnvID: env.EnvID, + } + applicationKeyMappings = append(applicationKeyMappings, appIdentifier) } - applicationKeyMappings = append(applicationKeyMappings, consumerKey) } } return &subscription.ApplicationKeyMappingList{ diff --git a/common-controller/internal/operator/controllers/cp/applicationmapping_controller.go b/common-controller/internal/operator/controllers/cp/applicationmapping_controller.go new file mode 100644 index 000000000..4569253e0 --- /dev/null +++ b/common-controller/internal/operator/controllers/cp/applicationmapping_controller.go @@ -0,0 +1,117 @@ +/* + * 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 cp + +import ( + "context" + "fmt" + + "github.com/wso2/apk/adapter/pkg/logging" + "github.com/wso2/apk/common-controller/internal/loggers" + "github.com/wso2/apk/common-controller/internal/xds" + "k8s.io/apimachinery/pkg/runtime" + 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" + "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" + + "github.com/wso2/apk/adapter/pkg/discovery/api/wso2/discovery/subscription" + cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" + "github.com/wso2/apk/common-controller/internal/operator/constant" + "github.com/wso2/apk/common-controller/internal/utils" +) + +// ApplicationMappingReconciler reconciles a ApplicationMapping object +type ApplicationMappingReconciler struct { + client client.Client + Scheme *runtime.Scheme +} + +// NewApplicationMappingController creates a new Application and Subscription mapping (i.e. ApplicationMapping) controller instance +func NewApplicationMappingController(mgr manager.Manager) error { + r := &ApplicationMappingReconciler{ + client: mgr.GetClient(), + } + c, err := controller.New(constants.ApplicationMappingController, mgr, controller.Options{Reconciler: r}) + if err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2610, logging.BLOCKER, "Error creating ApplicationMapping controller: %v", err.Error())) + return err + } + + if err := c.Watch(source.Kind(mgr.GetCache(), &cpv1alpha2.ApplicationMapping{}), &handler.EnqueueRequestForObject{}, + predicate.NewPredicateFuncs(utils.FilterByNamespaces([]string{utils.GetOperatorPodNamespace()}))); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2611, logging.BLOCKER, "Error watching ApplicationMapping resources: %v", err.Error())) + return err + } + + loggers.LoggerAPKOperator.Debug("ApplicationMapping Controller successfully started. Watching ApplicationMapping Objects...") + return nil +} + +//+kubebuilder:rbac:groups=cp.wso2.com,resources=applicationmappings,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=cp.wso2.com,resources=applicationmappings/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=cp.wso2.com,resources=applicationmappings/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 ApplicationMapping 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.14.4/pkg/reconcile +func (r *ApplicationMappingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + _ = log.FromContext(ctx) + applicationMappingKey := req.NamespacedName + var applicationMappingList = new(cpv1alpha2.ApplicationMappingList) + + loggers.LoggerAPKOperator.Debugf("Reconciling application mapping: %v", applicationMappingKey.String()) + if err := r.client.List(ctx, applicationMappingList); err != nil { + return reconcile.Result{}, fmt.Errorf("failed to get application mappings %s/%s", + applicationMappingKey.Namespace, applicationMappingKey.Name) + } + + sendUpdates(applicationMappingList) + return ctrl.Result{}, nil +} + +func sendUpdates(applicationMappingList *cpv1alpha2.ApplicationMappingList) { + appMappingList := marshalApplicationMappingList(applicationMappingList.Items) + xds.UpdateEnforcerApplicationMappings(appMappingList) +} + +func marshalApplicationMappingList(applicationMappingList []cpv1alpha2.ApplicationMapping) *subscription.ApplicationMappingList { + applicationMappings := []*subscription.ApplicationMapping{} + for _, appMappingInternal := range applicationMappingList { + appMapping := &subscription.ApplicationMapping{ + Uuid: appMappingInternal.Name, + ApplicationRef: appMappingInternal.Spec.ApplicationRef, + SubscriptionRef: appMappingInternal.Spec.SubscriptionRef, + } + applicationMappings = append(applicationMappings, appMapping) + } + return &subscription.ApplicationMappingList{ + List: applicationMappings, + } +} diff --git a/adapter/internal/operator/controllers/cp/subscription_controller.go b/common-controller/internal/operator/controllers/cp/subscription_controller.go similarity index 79% rename from adapter/internal/operator/controllers/cp/subscription_controller.go rename to common-controller/internal/operator/controllers/cp/subscription_controller.go index c6d1fe39e..0395c3cfd 100644 --- a/adapter/internal/operator/controllers/cp/subscription_controller.go +++ b/common-controller/internal/operator/controllers/cp/subscription_controller.go @@ -21,13 +21,12 @@ import ( "context" "fmt" - "github.com/wso2/apk/adapter/internal/discovery/xds" - "github.com/wso2/apk/adapter/internal/loggers" - cpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1" - "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" + 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/utils" + xds "github.com/wso2/apk/common-controller/internal/xds" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -38,6 +37,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" ) // SubscriptionReconciler reconciles a Subscription object @@ -57,7 +58,7 @@ func NewSubscriptionController(mgr manager.Manager) error { return err } - if err := c.Watch(source.Kind(mgr.GetCache(), &cpv1alpha1.Subscription{}), &handler.EnqueueRequestForObject{}, + if err := c.Watch(source.Kind(mgr.GetCache(), &cpv1alpha2.Subscription{}), &handler.EnqueueRequestForObject{}, predicate.NewPredicateFuncs(utils.FilterByNamespaces([]string{utils.GetOperatorPodNamespace()}))); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2609, logging.BLOCKER, "Error watching Subscription resources: %v", err.Error())) return err @@ -79,14 +80,14 @@ func NewSubscriptionController(mgr manager.Manager) error { // 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 +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile func (subscriptionReconciler *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { _ = log.FromContext(ctx) loggers.LoggerAPKOperator.Debugf("Reconciling subscription: %v", req.NamespacedName.String()) subscriptionKey := req.NamespacedName - var subscriptionList = new(cpv1alpha1.SubscriptionList) + var subscriptionList = new(cpv1alpha2.SubscriptionList) if err := subscriptionReconciler.client.List(ctx, subscriptionList); err != nil { return reconcile.Result{}, fmt.Errorf("failed to get subscriptions %s/%s", subscriptionKey.Namespace, subscriptionKey.Name) @@ -95,21 +96,25 @@ func (subscriptionReconciler *SubscriptionReconciler) Reconcile(ctx context.Cont return ctrl.Result{}, nil } -func sendSubUpdates(subscriptionsList *cpv1alpha1.SubscriptionList) { +func sendSubUpdates(subscriptionsList *cpv1alpha2.SubscriptionList) { subList := marshalSubscriptionList(subscriptionsList.Items) xds.UpdateEnforcerSubscriptions(subList) } -func marshalSubscriptionList(subscriptionList []cpv1alpha1.Subscription) *subscription.SubscriptionList { +func marshalSubscriptionList(subscriptionList []cpv1alpha2.Subscription) *subscription.SubscriptionList { subscriptions := []*subscription.Subscription{} for _, subInternal := range subscriptionList { + subscribedAPI := &subscription.SubscribedAPI{} sub := &subscription.Subscription{ - Uuid: string(subInternal.UID), - ApiRef: subInternal.Spec.APIRef, - PolicyId: subInternal.Spec.PolicyID, - SubStatus: subInternal.Spec.SubscriptionStatus, - ApplicationRef: subInternal.Spec.ApplicationRef, + Uuid: subInternal.Name, + SubStatus: subInternal.Spec.SubscriptionStatus, + Organization: subInternal.Spec.Organization, + } + if subInternal.Spec.API.Name != "" && subInternal.Spec.API.Version != "" { + subscribedAPI.Name = subInternal.Spec.API.Name + subscribedAPI.Version = subInternal.Spec.API.Version } + sub.SubscribedApi = subscribedAPI subscriptions = append(subscriptions, sub) } return &subscription.SubscriptionList{ diff --git a/adapter/internal/operator/controllers/cp/suite_test.go b/common-controller/internal/operator/controllers/cp/suite_test.go similarity index 91% rename from adapter/internal/operator/controllers/cp/suite_test.go rename to common-controller/internal/operator/controllers/cp/suite_test.go index 16323e1b9..767f73915 100644 --- a/adapter/internal/operator/controllers/cp/suite_test.go +++ b/common-controller/internal/operator/controllers/cp/suite_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * 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. @@ -31,7 +31,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - cpv1alpha1 "github.com/wso2/apk/adapter/internal/operator/apis/cp/v1alpha1" + cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" //+kubebuilder:scaffold:imports ) @@ -63,7 +63,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - err = cpv1alpha1.AddToScheme(scheme.Scheme) + err = cpv1alpha2.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme diff --git a/common-controller/internal/operator/controller/ratelimitpolicy_controller.go b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go similarity index 94% rename from common-controller/internal/operator/controller/ratelimitpolicy_controller.go rename to common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go index 9ab2f3dc3..e6e075a52 100644 --- a/common-controller/internal/operator/controller/ratelimitpolicy_controller.go +++ b/common-controller/internal/operator/controllers/dp/ratelimitpolicy_controller.go @@ -14,14 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package dp import ( "context" "fmt" logger "github.com/sirupsen/logrus" - "github.com/wso2/apk/common-controller/internal/operator/utils" k8error "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" @@ -40,14 +39,13 @@ import ( gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/wso2/apk/adapter/pkg/logging" - "github.com/wso2/apk/adapter/pkg/utils/envutils" - "github.com/wso2/apk/adapter/pkg/utils/stringutils" 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" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1" - dpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2" + dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha2" constants "github.com/wso2/apk/common-controller/internal/operator/constant" + "github.com/wso2/apk/common-controller/internal/utils" xds "github.com/wso2/apk/common-controller/internal/xds" ) @@ -86,7 +84,7 @@ func NewratelimitController(mgr manager.Manager, ratelimitStore *cache.Ratelimit } conf := config.ReadConfigs() - predicates := []predicate.Predicate{predicate.NewPredicateFuncs(FilterByNamespaces(conf.CommonController.Operator.Namespaces))} + predicates := []predicate.Predicate{predicate.NewPredicateFuncs(utils.FilterByNamespaces(conf.CommonController.Operator.Namespaces))} if err := c.Watch(source.Kind(mgr.GetCache(), &dpv1alpha2.API{}), handler.EnqueueRequestsFromMapFunc(ratelimitReconsiler.getRatelimitForAPI), predicates...); err != nil { @@ -429,24 +427,6 @@ func GetNamespace(namespace *gwapiv1b1.Namespace, defaultNamespace string) strin return defaultNamespace } -// FilterByNamespaces takes a list of namespaces and returns a filter function -// which return true if the input object is in the given namespaces list, -// and returns false otherwise -func FilterByNamespaces(namespaces []string) func(object client.Object) bool { - return func(object client.Object) bool { - if namespaces == nil { - return true - } - return stringutils.StringInSlice(object.GetNamespace(), namespaces) - } -} - -// GetOperatorPodNamespace returns the namesapce of the operator pod -func GetOperatorPodNamespace() string { - return envutils.GetEnv(constants.OperatorPodNamespace, - constants.OperatorPodNamespaceDefaultValue) -} - // SetupWithManager sets up the controller with the Manager. func (ratelimitReconsiler *RateLimitPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). diff --git a/common-controller/internal/operator/controller/suite_test.go b/common-controller/internal/operator/controllers/dp/suite_test.go similarity index 98% rename from common-controller/internal/operator/controller/suite_test.go rename to common-controller/internal/operator/controllers/dp/suite_test.go index cddbedb23..0738790e3 100644 --- a/common-controller/internal/operator/controller/suite_test.go +++ b/common-controller/internal/operator/controllers/dp/suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controller +package dp import ( "path/filepath" @@ -30,7 +30,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1" + dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" //+kubebuilder:scaffold:imports ) diff --git a/common-controller/internal/operator/operator.go b/common-controller/internal/operator/operator.go index f241cbfb6..b6e20627f 100644 --- a/common-controller/internal/operator/operator.go +++ b/common-controller/internal/operator/operator.go @@ -1,18 +1,19 @@ /* -Copyright 2023. - -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. -*/ + * 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 operator @@ -34,9 +35,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1" - dpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha2" - dpcontrollers "github.com/wso2/apk/common-controller/internal/operator/controller" + cpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/cp/v1alpha2" + dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" + dpv1alpha2 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha2" + cpcontrollers "github.com/wso2/apk/common-controller/internal/operator/controllers/cp" + dpcontrollers "github.com/wso2/apk/common-controller/internal/operator/controllers/dp" //+kubebuilder:scaffold:imports ) @@ -50,6 +53,8 @@ func init() { utilruntime.Must(gwapiv1b1.AddToScheme(scheme)) utilruntime.Must(dpv1alpha1.AddToScheme(scheme)) utilruntime.Must(dpv1alpha2.AddToScheme(scheme)) + utilruntime.Must(cpv1alpha2.AddToScheme(scheme)) + utilruntime.Must(cpv1alpha2.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -110,7 +115,7 @@ func InitOperator() { "Unable to create webhook for Ratelimit, error: %v", err)) } - if err = (&dpv1alpha1.APIPolicy{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&dpv1alpha2.APIPolicy{}).SetupWebhookWithManager(mgr); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2638, logging.MAJOR, "Unable to create webhook for APIPolicy, error: %v", err)) } @@ -128,6 +133,18 @@ func InitOperator() { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3114, logging.MAJOR, "Error creating JWT Issuer controller, error: %v", err)) } + if err := cpcontrollers.NewApplicationController(mgr); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3115, logging.MAJOR, + "Error creating Application controller, error: %v", err)) + } + if err := cpcontrollers.NewSubscriptionController(mgr); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3116, logging.MAJOR, + "Error creating Subscription controller, error: %v", err)) + } + if err := cpcontrollers.NewApplicationMappingController(mgr); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error3117, logging.MAJOR, + "Error creating Application Mapping controller, error: %v", err)) + } //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { diff --git a/common-controller/internal/utils/utils.go b/common-controller/internal/utils/utils.go index 8ae213310..0faf82fde 100644 --- a/common-controller/internal/utils/utils.go +++ b/common-controller/internal/utils/utils.go @@ -22,6 +22,11 @@ import ( "sync" discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" + constants "github.com/wso2/apk/common-controller/internal/operator/constant" + "github.com/wso2/apk/adapter/pkg/utils/envutils" + "github.com/wso2/apk/adapter/pkg/utils/stringutils" + k8client "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/wso2/apk/common-controller/internal/config" ) const nodeIDArrayMaxLength int = 20 @@ -93,3 +98,30 @@ func GetNodeIdentifier(request *discovery.DiscoveryRequest) string { } return nodeIdentifier } + +// FilterByNamespaces takes a list of namespaces and returns a filter function +// which return true if the input object is in the given namespaces list, +// and returns false otherwise +func FilterByNamespaces(namespaces []string) func(object k8client.Object) bool { + return func(object k8client.Object) bool { + if namespaces == nil { + return true + } + return stringutils.StringInSlice(object.GetNamespace(), namespaces) + } +} + +// GetOperatorPodNamespace returns the namesapce of the operator pod +func GetOperatorPodNamespace() string { + return envutils.GetEnv(constants.OperatorPodNamespace, + constants.OperatorPodNamespaceDefaultValue) +} + +// GetEnvironment takes the environment of the API. If the value is empty, +// it will return the default environment that is set in the config of the common controller. +func GetEnvironment(environment string) string { + if environment != "" { + return environment + } + return config.ReadConfigs().CommonController.Environment +} diff --git a/common-controller/internal/xds/common/utils.go b/common-controller/internal/xds/common/utils.go new file mode 100644 index 000000000..d8742ff3f --- /dev/null +++ b/common-controller/internal/xds/common/utils.go @@ -0,0 +1,94 @@ +/* + * 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 common includes the common functions shared between enforcer and router callbacks. +package common + +import ( + "sync" + + discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" +) + +const nodeIDArrayMaxLength int = 20 +const instanceIdentifierKey string = "instanceIdentifier" + +// NodeQueue struct is used to keep track of the nodes connected via the XDS. +type NodeQueue struct { + lock *sync.Mutex + queue []string +} + +// CheckEntryAndSwapToEnd function does the following. Recently accessed entry is removed last. +// Array should have a maximum length. If the the provided nodeId may or may not be within the array. +// +// 1. If the array's maximum length is not reached after adding the new element and the element is not inside the array, +// append the element to the end. +// 2. If the array is at maximum length and element is not within the array, the new entry should be appended to the end +// and the 0th element should be removed. +// 3. If the array is at the maximum length and element is inside the array, the new element should be appended and the already +// existing entry should be removed from the position. +// Returns the modified array and true if the entry is a new addition. +func (nodeQueue *NodeQueue) checkEntryAndMoveToEnd(nodeID string) (isNewAddition bool) { + matchedIndex := -1 + arraySize := len(nodeQueue.queue) + for index := arraySize - 1; index >= 0; index-- { + entry := nodeQueue.queue[index] + if entry == nodeID { + matchedIndex = index + break + } + } + + if matchedIndex == nodeIDArrayMaxLength-1 { + return false + } else if matchedIndex > 0 { + nodeQueue.queue = append(nodeQueue.queue[0:matchedIndex], nodeQueue.queue[matchedIndex+1:]...) + nodeQueue.queue = append(nodeQueue.queue, nodeID) + return false + } + if arraySize >= nodeIDArrayMaxLength { + nodeQueue.queue = nodeQueue.queue[1:] + } + nodeQueue.queue = append(nodeQueue.queue, nodeID) + return true +} + +// GenerateNodeQueue creates an instance of nodeQueue with a mutex and a string array assigned. +func GenerateNodeQueue() *NodeQueue { + return &NodeQueue{ + lock: &sync.Mutex{}, + queue: []string{}, + } +} + +// IsNewNode returns true if the provided nodeID does not exist in the nodeQueue +func (nodeQueue *NodeQueue) IsNewNode(nodeIdentifier string) bool { + nodeQueue.lock.Lock() + defer nodeQueue.lock.Unlock() + return nodeQueue.checkEntryAndMoveToEnd(nodeIdentifier) +} + +// GetNodeIdentifier constructs the nodeIdentifier from discovery request's node property, label: +func GetNodeIdentifier(request *discovery.DiscoveryRequest) string { + metadataMap := request.Node.Metadata.AsMap() + nodeIdentifier := request.Node.Id + if identifierVal, ok := metadataMap[instanceIdentifierKey]; ok { + nodeIdentifier = request.Node.Id + ":" + identifierVal.(string) + } + return nodeIdentifier +} diff --git a/common-controller/internal/xds/common/utils_test.go b/common-controller/internal/xds/common/utils_test.go new file mode 100644 index 000000000..17eca060b --- /dev/null +++ b/common-controller/internal/xds/common/utils_test.go @@ -0,0 +1,75 @@ +/* + * 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 common + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCheckEntryAndSwapToEnd(t *testing.T) { + entry := "node-40" + nodeQueue := GenerateNodeQueue() + nodeQueue.queue = generateNodeArray(5) + isNewAddition := nodeQueue.IsNewNode(entry) + assert.Equal(t, 6, len(nodeQueue.queue), "array length mismatch") + assert.Equal(t, "node-40", nodeQueue.queue[5], "array element mismatch") + assert.True(t, isNewAddition, "isNewAddition flag is not correct.") + + entry = "node-2" + nodeQueue.queue = generateNodeArray(5) + isNewAddition = nodeQueue.IsNewNode(entry) + assert.Equal(t, 5, len(nodeQueue.queue), "array length mismatch") + assert.Equal(t, "node-2", nodeQueue.queue[4], "array element mismatch") + assert.Equal(t, "node-3", nodeQueue.queue[2], "array element mismatch") + assert.False(t, isNewAddition, "isNewAddition flag is not correct.") + + entry = "node-19" + nodeQueue.queue = generateNodeArray(20) + isNewAddition = nodeQueue.IsNewNode(entry) + assert.Equal(t, 20, len(nodeQueue.queue), "array length mismatch") + assert.Equal(t, "node-19", nodeQueue.queue[19], "array element mismatch") + assert.False(t, isNewAddition, "isNewAddition flag is not correct.") + + nodeQueue.queue = generateNodeArray(20) + entry = "node-40" + isNewAddition = nodeQueue.IsNewNode(entry) + assert.Equal(t, 20, len(nodeQueue.queue), "array length mismatch") + assert.Equal(t, "node-40", nodeQueue.queue[19], "array element mismatch") + assert.Equal(t, "node-1", nodeQueue.queue[0], "array element mismatch") + assert.True(t, isNewAddition, "isNewAddition flag is not correct.") + + nodeQueue.queue = generateNodeArray(20) + entry = "node-10" + isNewAddition = nodeQueue.IsNewNode(entry) + assert.Equal(t, 20, len(nodeQueue.queue), "array length mismatch") + assert.Equal(t, "node-10", nodeQueue.queue[19], "array element mismatch") + assert.Equal(t, "node-11", nodeQueue.queue[10], "array element mismatch") + assert.Equal(t, "node-9", nodeQueue.queue[9], "array element mismatch") + assert.False(t, isNewAddition, "isNewAddition flag is not correct.") +} + +func generateNodeArray(length int) []string { + array := []string{} + for i := 0; i < length; i++ { + array = append(array, fmt.Sprintf("node-%d", i)) + } + return array +} diff --git a/common-controller/internal/xds/enforcercallbacks/enforcer_callbacks.go b/common-controller/internal/xds/enforcercallbacks/enforcer_callbacks.go new file mode 100644 index 000000000..27d3525ba --- /dev/null +++ b/common-controller/internal/xds/enforcercallbacks/enforcer_callbacks.go @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2021, 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 enforcercallbacks + +import ( + "context" + + core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" + discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" + "github.com/wso2/apk/common-controller/internal/xds/common" + logger "github.com/wso2/apk/common-controller/internal/loggers" + logging "github.com/wso2/apk/adapter/pkg/logging" +) + +var nodeQueueInstance *common.NodeQueue + +func init() { + nodeQueueInstance = common.GenerateNodeQueue() +} + +// Callbacks is used to debug the xds server related communication. +type Callbacks struct { +} + +// Report logs the fetches and requests. +func (cb *Callbacks) Report() {} + +// OnStreamOpen prints debug logs +func (cb *Callbacks) OnStreamOpen(_ context.Context, id int64, typ string) error { + logger.LoggerEnforcerXdsCallbacks.Debugf("stream %d open for %s\n", id, typ) + return nil +} + +// OnStreamClosed prints debug logs +func (cb *Callbacks) OnStreamClosed(id int64, node *core.Node) { + logger.LoggerEnforcerXdsCallbacks.Debugf("stream %d closed\n", id) +} + +// OnStreamRequest prints debug logs +func (cb *Callbacks) OnStreamRequest(id int64, request *discovery.DiscoveryRequest) error { + nodeIdentifier := common.GetNodeIdentifier(request) + if nodeQueueInstance.IsNewNode(nodeIdentifier) { + logger.LoggerEnforcerXdsCallbacks.Infof("stream request on stream id: %d, from node: %s, version: %s", + id, nodeIdentifier, request.VersionInfo) + } + logger.LoggerEnforcerXdsCallbacks.Debugf("stream request on stream id: %d, from node: %s, version: %s, for type: %s", + id, nodeIdentifier, request.GetVersionInfo(), request.GetTypeUrl()) + if request.ErrorDetail != nil { + logger.LoggerEnforcerXdsCallbacks.ErrorC(logging.PrintError(logging.Error1400, logging.CRITICAL, "Stream request for type %s on stream id: %d Error: %s", request.GetTypeUrl(), id, request.ErrorDetail.Message)) + } + // TODO: (VirajSalaka) Remove the commented logic once the fallback is implemented. + // requestEventChannel := xds.GetRequestEventChannel() + // if resource.APIType == request.GetTypeUrl() { + // requestEvent := xds.NewRequestEvent() + // if request.ErrorDetail != nil { + // logger.LoggerEnforcerXdsCallbacks.Errorf("stream request on stream id: %d Error: %s", id, request.ErrorDetail.Message) + // requestEvent.IsError = true + // } + // requestEvent.Node = request.GetNode().GetId() + // requestEvent.Version = request.VersionInfo + // requestEventChannel <- requestEvent + // } + return nil +} + +// OnStreamResponse prints debug logs +func (cb *Callbacks) OnStreamResponse(context context.Context, id int64, request *discovery.DiscoveryRequest, + response *discovery.DiscoveryResponse) { + nodeIdentifier := common.GetNodeIdentifier(request) + logger.LoggerEnforcerXdsCallbacks.Debugf("stream response on stream id: %d node: %s for type: %s version: %s", + id, nodeIdentifier, request.GetTypeUrl(), response.GetVersionInfo()) +} + +// OnFetchRequest prints debug logs +func (cb *Callbacks) OnFetchRequest(_ context.Context, req *discovery.DiscoveryRequest) error { + nodeIdentifier := common.GetNodeIdentifier(req) + logger.LoggerEnforcerXdsCallbacks.Debugf("fetch request from node: %s, version: %s, for type: %s", nodeIdentifier, + req.VersionInfo, req.TypeUrl) + return nil +} + +// OnFetchResponse prints debug logs +func (cb *Callbacks) OnFetchResponse(req *discovery.DiscoveryRequest, res *discovery.DiscoveryResponse) { + nodeIdentifier := common.GetNodeIdentifier(req) + logger.LoggerEnforcerXdsCallbacks.Debugf("fetch response to node: %s, version: %s, for type: %s", nodeIdentifier, + req.VersionInfo, res.TypeUrl) +} + +// OnDeltaStreamOpen is unused. +func (cb *Callbacks) OnDeltaStreamOpen(_ context.Context, id int64, typ string) error { + return nil +} + +// OnDeltaStreamClosed is unused. +func (cb *Callbacks) OnDeltaStreamClosed(id int64, node *core.Node) { +} + +// OnStreamDeltaResponse is unused. +func (cb *Callbacks) OnStreamDeltaResponse(id int64, req *discovery.DeltaDiscoveryRequest, res *discovery.DeltaDiscoveryResponse) { +} + +// OnStreamDeltaRequest is unused. +func (cb *Callbacks) OnStreamDeltaRequest(id int64, req *discovery.DeltaDiscoveryRequest) error { + return nil +} diff --git a/common-controller/internal/xds/ratelimiter_cache.go b/common-controller/internal/xds/ratelimiter_cache.go index b9193f6ec..a540cbc16 100644 --- a/common-controller/internal/xds/ratelimiter_cache.go +++ b/common-controller/internal/xds/ratelimiter_cache.go @@ -30,7 +30,7 @@ import ( logger "github.com/sirupsen/logrus" "github.com/wso2/apk/adapter/pkg/logging" "github.com/wso2/apk/common-controller/internal/loggers" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1" + dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" constants "github.com/wso2/apk/common-controller/internal/operator/constant" ) diff --git a/common-controller/internal/xds/routercallbacks/router_callbacks.go b/common-controller/internal/xds/routercallbacks/router_callbacks.go new file mode 100644 index 000000000..c47a5f75e --- /dev/null +++ b/common-controller/internal/xds/routercallbacks/router_callbacks.go @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2022, 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 routercallbacks + +import ( + "context" + + core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" + discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" + "github.com/wso2/apk/common-controller/internal/xds/common" + logger "github.com/wso2/apk/common-controller/internal/loggers" + logging "github.com/wso2/apk/adapter/pkg/logging" +) + +var nodeQueueInstance *common.NodeQueue + +func init() { + nodeQueueInstance = common.GenerateNodeQueue() +} + +// Callbacks is used to debug the xds server related communication. +type Callbacks struct { +} + +// Report logs the fetches and requests. +func (cb *Callbacks) Report() {} + +// OnStreamOpen prints debug logs +func (cb *Callbacks) OnStreamOpen(_ context.Context, id int64, typ string) error { + logger.LoggerRouterXdsCallbacks.Debugf("stream %d open for %s\n", id, typ) + return nil +} + +// OnStreamClosed prints debug logs +func (cb *Callbacks) OnStreamClosed(id int64, node *core.Node) { + logger.LoggerRouterXdsCallbacks.Debugf("stream %d closed\n", id) +} + +// OnStreamRequest prints debug logs +func (cb *Callbacks) OnStreamRequest(id int64, request *discovery.DiscoveryRequest) error { + nodeIdentifier := common.GetNodeIdentifier(request) + if nodeQueueInstance.IsNewNode(nodeIdentifier) { + logger.LoggerRouterXdsCallbacks.Infof("stream request on stream id: %d, from node: %s, version: %s", + id, nodeIdentifier, request.VersionInfo) + } + logger.LoggerRouterXdsCallbacks.Debugf("stream request on stream id: %d, from node: %s, version: %s, for type: %s", + id, nodeIdentifier, request.VersionInfo, request.TypeUrl) + if request.ErrorDetail != nil { + logger.LoggerRouterXdsCallbacks.ErrorC(logging.PrintError(logging.Error1401, logging.CRITICAL, "Stream request for type %s on stream id: %d, from node: %s, Error: %s", request.GetTypeUrl(), id, nodeIdentifier, request.ErrorDetail.Message)) + } + return nil +} + +// OnStreamResponse prints debug logs +func (cb *Callbacks) OnStreamResponse(context context.Context, id int64, request *discovery.DiscoveryRequest, + response *discovery.DiscoveryResponse) { + nodeIdentifier := common.GetNodeIdentifier(request) + logger.LoggerRouterXdsCallbacks.Debugf("stream response on stream id: %d, to node: %s, version: %s, for type: %v", id, + nodeIdentifier, response.VersionInfo, response.TypeUrl) +} + +// OnFetchRequest prints debug logs +func (cb *Callbacks) OnFetchRequest(_ context.Context, req *discovery.DiscoveryRequest) error { + logger.LoggerRouterXdsCallbacks.Debugf("fetch request from node %s, version: %s, for type %s", common.GetNodeIdentifier(req), + req.VersionInfo, req.TypeUrl) + return nil +} + +// OnFetchResponse prints debug logs +func (cb *Callbacks) OnFetchResponse(req *discovery.DiscoveryRequest, res *discovery.DiscoveryResponse) { + logger.LoggerRouterXdsCallbacks.Debugf("fetch response to node: %s, version: %s, for type %s", common.GetNodeIdentifier(req), + req.VersionInfo, res.TypeUrl) +} + +// OnDeltaStreamOpen is unused. +func (cb *Callbacks) OnDeltaStreamOpen(_ context.Context, id int64, typ string) error { + return nil +} + +// OnDeltaStreamClosed is unused. +func (cb *Callbacks) OnDeltaStreamClosed(id int64, node *core.Node) { +} + +// OnStreamDeltaResponse is unused. +func (cb *Callbacks) OnStreamDeltaResponse(id int64, req *discovery.DeltaDiscoveryRequest, res *discovery.DeltaDiscoveryResponse) { +} + +// OnStreamDeltaRequest is unused. +func (cb *Callbacks) OnStreamDeltaRequest(id int64, req *discovery.DeltaDiscoveryRequest) error { + return nil +} diff --git a/common-controller/internal/xds/server.go b/common-controller/internal/xds/server.go index 1f105aa25..9bd0ac587 100644 --- a/common-controller/internal/xds/server.go +++ b/common-controller/internal/xds/server.go @@ -18,18 +18,95 @@ package xds import ( + "context" + crand "crypto/rand" "fmt" "math/big" + "math/rand" + "sync" + "time" + clusterv3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3" corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" + listenerv3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" + routev3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" + "github.com/envoyproxy/go-control-plane/pkg/cache/types" envoy_cachev3 "github.com/envoyproxy/go-control-plane/pkg/cache/v3" - dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/api/dp/v1alpha1" + + "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" + "github.com/wso2/apk/adapter/pkg/logging" + "github.com/wso2/apk/common-controller/internal/loggers" + dpv1alpha1 "github.com/wso2/apk/common-controller/internal/operator/apis/dp/v1alpha1" +) + +// EnvoyInternalAPI struct use to hold envoy resources and adapter internal resources +type EnvoyInternalAPI struct { + // commonControllerInternalAPI model.commonControllerInternalAPI + envoyLabels []string + routes []*routev3.Route + clusters []*clusterv3.Cluster + endpointAddresses []*corev3.Address + enforcerAPI types.Resource +} + +// EnvoyGatewayConfig struct use to hold envoy gateway resources +type EnvoyGatewayConfig struct { + listener *listenerv3.Listener + routeConfig *routev3.RouteConfiguration + clusters []*clusterv3.Cluster + endpoints []*corev3.Address + // customRateLimitPolicies []*model.CustomRateLimitPolicy +} + +// EnforcerInternalAPI struct use to hold enforcer resources +type EnforcerInternalAPI struct { + configs []types.Resource + subscriptions []types.Resource + applications []types.Resource + applicationKeyMappings []types.Resource + applicationMappings []types.Resource +} + +var ( + // TODO: (VirajSalaka) Remove Unused mutexes. + 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 + + orgAPIMap map[string]map[string]*EnvoyInternalAPI // organizationID -> Vhost:API_UUID -> EnvoyInternalAPI struct map + + orgIDvHostBasepathMap map[string]map[string]string // organizationID -> Vhost:basepath -> Vhost:API_UUID + orgIDAPIvHostsMap map[string]map[string][]string // organizationID -> UUID -> prod/sand -> Envoy Vhost Array map + + // Envoy Label as map key + gatewayLabelConfigMap map[string]*EnvoyGatewayConfig // GW-Label -> EnvoyGatewayConfig struct map + + // Listener as map key + listenerToRouteArrayMap map[string][]*routev3.Route // Listener -> Routes map + + // Common Enforcer Label as map key + // TODO(amali) This doesn't have a usage yet. It will be used to handle multiple enforcer labels in future. + enforcerLabelMap map[string]*EnforcerInternalAPI // Enforcer Label -> EnforcerInternalAPI struct map + + // KeyManagerList to store data + KeyManagerList = make([]eventhubTypes.KeyManager, 0) + isReady = false ) const ( maxRandomInt int = 999999999 grpcMaxConcurrentStreams = 1000000 apiKeyFieldSeparator string = ":" + commonEnforcerLabel string = "commonEnforcerLabel" ) func maxRandomBigInt() *big.Int { @@ -49,6 +126,27 @@ func (IDHash) ID(node *corev3.Node) string { 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) + orgIDAPIvHostsMap = make(map[string]map[string][]string) // organizationID -> UUID-prod/sand -> Envoy Vhost Array map + orgIDvHostBasepathMap = make(map[string]map[string]string) + + enforcerLabelMap = make(map[string]*EnforcerInternalAPI) + //TODO(amali) currently subscriptions, configs, applications, applicationPolicies, subscriptionPolicies, + // applicationKeyMappings, keyManagerConfigList, revokedTokens are supported with the hard coded label for Enforcer + enforcerLabelMap[commonEnforcerLabel] = &EnforcerInternalAPI{} + rand.Seed(time.Now().UnixNano()) + // go watchEnforcerResponse() +} + // GetRateLimiterCache returns xds server cache for rate limiter service. func GetRateLimiterCache() envoy_cachev3.SnapshotCache { return rlsPolicyCache.xdsCache @@ -117,3 +215,109 @@ func UpdateRateLimiterPolicies(label string) { func SetEmptySnapshotupdate(lable string) bool { return rlsPolicyCache.SetEmptySnapshot(lable) } + +// GetXdsCache returns xds server cache. +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 +} + +// UpdateEnforcerApplications sets new update to the enforcer's Applications +func UpdateEnforcerApplications(applications *subscription.ApplicationList) { + loggers.LoggerXds.Debug("Updating Enforcer Application Cache") + label := commonEnforcerLabel + applicationList := append(enforcerLabelMap[label].applications, applications) + version, _ := crand.Int(crand.Reader, maxRandomBigInt()) + snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ + wso2_resource.ApplicationListType: applicationList, + }) + snap.Consistent() + errSetSnap := enforcerApplicationCache.SetSnapshot(context.Background(), label, snap) + if errSetSnap != nil { + loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1414, logging.MAJOR, "Error while setting the snapshot : %v", errSetSnap.Error())) + } + enforcerLabelMap[label].applications = applicationList + loggers.LoggerXds.Infof("New Application cache update for the label: " + label + " version: " + fmt.Sprint(version)) +} + +// UpdateEnforcerApplicationKeyMappings sets new update to the enforcer's Application Key Mappings +func UpdateEnforcerApplicationKeyMappings(applicationKeyMappings *subscription.ApplicationKeyMappingList) { + loggers.LoggerXds.Debug("Updating Application Key Mapping Cache") + label := commonEnforcerLabel + applicationKeyMappingList := append(enforcerLabelMap[label].applicationKeyMappings, applicationKeyMappings) + version, _ := crand.Int(crand.Reader, maxRandomBigInt()) + snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ + wso2_resource.ApplicationKeyMappingListType: applicationKeyMappingList, + }) + snap.Consistent() + errSetSnap := enforcerApplicationKeyMappingCache.SetSnapshot(context.Background(), label, snap) + if errSetSnap != nil { + loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1414, logging.MAJOR, "Error while setting the snapshot : %v", errSetSnap.Error())) + } + enforcerLabelMap[label].applicationKeyMappings = applicationKeyMappingList + loggers.LoggerXds.Infof("New Application Key Mapping cache update for the label: " + label + " version: " + fmt.Sprint(version)) +} + +// UpdateEnforcerSubscriptions sets new update to the enforcer's Subscriptions +func UpdateEnforcerSubscriptions(subscriptions *subscription.SubscriptionList) { + //TODO: (Dinusha) check this hardcoded value + loggers.LoggerXds.Debug("Updating Enforcer Subscription Cache") + label := commonEnforcerLabel + subscriptionList := append(enforcerLabelMap[label].subscriptions, subscriptions) + + // TODO: (VirajSalaka) Decide if a map is required to keep version (just to avoid having the same version) + version, _ := crand.Int(crand.Reader, maxRandomBigInt()) + snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ + wso2_resource.SubscriptionListType: subscriptionList, + }) + snap.Consistent() + + errSetSnap := enforcerSubscriptionCache.SetSnapshot(context.Background(), label, snap) + if errSetSnap != nil { + loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1414, logging.MAJOR, "Error while setting the snapshot : %v", errSetSnap.Error())) + } + enforcerLabelMap[label].subscriptions = subscriptionList + loggers.LoggerXds.Infof("New Subscription cache update for the label: " + label + " version: " + fmt.Sprint(version)) +} + +// UpdateEnforcerApplicationMappings sets new update to the enforcer's Application Mappings +func UpdateEnforcerApplicationMappings(applicationMappings *subscription.ApplicationMappingList) { + loggers.LoggerXds.Debug("Updating Application Mapping Cache") + label := commonEnforcerLabel + applicationMappingList := append(enforcerLabelMap[label].applicationMappings, applicationMappings) + version, _ := crand.Int(crand.Reader, maxRandomBigInt()) + snap, _ := wso2_cache.NewSnapshot(fmt.Sprint(version), map[wso2_resource.Type][]types.Resource{ + wso2_resource.ApplicationMappingListType: applicationMappingList, + }) + snap.Consistent() + errSetSnap := enforcerApplicationMappingCache.SetSnapshot(context.Background(), label, snap) + if errSetSnap != nil { + loggers.LoggerXds.ErrorC(logging.PrintError(logging.Error1414, logging.MAJOR, "Error while setting the snapshot : %v", errSetSnap.Error())) + } + enforcerLabelMap[label].applicationMappings = applicationMappingList + loggers.LoggerXds.Infof("New Application Mapping cache update for the label: " + label + " version: " + fmt.Sprint(version)) +} diff --git a/common-controller/revive.toml b/common-controller/revive.toml index d52be3ca3..0096b4de7 100644 --- a/common-controller/revive.toml +++ b/common-controller/revive.toml @@ -8,7 +8,7 @@ warningCode = 0 [rule.context-as-argument] [rule.context-keys-type] [rule.dot-imports] -exclude = ["internal/operator/api/dp/v1alpha1/webhook_suite_test.go", "internal/operator/controller/suite_test.go", "internal/operator/api/dp/v1alpha2/webhook_suite_test.go"] +exclude = ["internal/operator/apis/dp/v1alpha1/webhook_suite_test.go", "internal/operator/apis/dp/v1alpha2/webhook_suite_test.go", "internal/operator/controllers/cp/suite_test.go", "internal/operator/controllers/dp/suite_test.go"] [rule.error-return] [rule.error-strings] [rule.error-naming] diff --git a/gateway/enforcer/Dockerfile b/gateway/enforcer/Dockerfile index 88a9c9fa8..406e8cf1c 100644 --- a/gateway/enforcer/Dockerfile +++ b/gateway/enforcer/Dockerfile @@ -81,6 +81,9 @@ ENV TRUSTED_CA_CERTS_PATH=/home/wso2/security/truststore ENV ADAPTER_HOST_NAME=adapter ENV ADAPTER_HOST=adapter ENV ADAPTER_XDS_PORT=18000 +ENV COMMON_CONTROLLER_HOST_NAME=common-controller +ENV COMMON_CONTROLLER_HOST=common-controller +ENV COMMON_CONTROLLER_XDS_PORT=18002 ENV ENFORCER_LABEL="default" ENV XDS_MAX_MSG_SIZE=4194304 ENV XDS_MAX_RETRIES=3 diff --git a/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/APIConfig.java b/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/APIConfig.java index 789b51481..31248f44e 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/APIConfig.java +++ b/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/APIConfig.java @@ -54,6 +54,7 @@ public class APIConfig { private boolean systemAPI; private byte[] apiDefinition; private String environment; + private boolean subscriptionValidation; /** * getApiType returns the API type. This could be one of the following. * HTTP, WS, WEBHOOK @@ -232,6 +233,14 @@ public byte[] getApiDefinition() { return apiDefinition; } + /** + * Returns the subscription validation status. + * @return true if subscription validation is enabled. + */ + public boolean isSubscriptionValidation() { + return subscriptionValidation; + } + public JWTConfigurationDto getJwtConfigurationDto() { return jwtConfigurationDto; } @@ -270,6 +279,7 @@ public static class Builder { private GraphQLSchemaDTO graphQLSchemaDTO; private boolean systemAPI; private byte[] apiDefinition; + private boolean subscriptionValidation; private JWTConfigurationDto jwtConfigurationDto; private String environment; public Builder(String name) { @@ -374,14 +384,22 @@ public Builder jwtConfigurationDto(JWTConfigurationDto jwtConfigurationDto) { this.jwtConfigurationDto = jwtConfigurationDto; return this; } + public Builder apiDefinition(byte[] apiDefinition) { this.apiDefinition = apiDefinition; return this; } + public Builder environment(String environment) { this.environment = environment; return this; } + + public Builder subscriptionValidation(boolean subscriptionValidation) { + this.subscriptionValidation = subscriptionValidation; + return this; + } + public APIConfig build() { APIConfig apiConfig = new APIConfig(); apiConfig.name = this.name; @@ -407,6 +425,7 @@ public APIConfig build() { apiConfig.jwtConfigurationDto = this.jwtConfigurationDto; apiConfig.apiDefinition = this.apiDefinition; apiConfig.environment = this.environment; + apiConfig.subscriptionValidation = this.subscriptionValidation; return apiConfig; } } diff --git a/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/AuthenticationContext.java b/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/AuthenticationContext.java index 067fcfeb0..9870bdd11 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/AuthenticationContext.java +++ b/gateway/enforcer/org.wso2.apk.enforcer.commons/src/main/java/org/wso2/apk/enforcer/commons/model/AuthenticationContext.java @@ -37,7 +37,7 @@ public class AuthenticationContext { private String subscriber; private List throttlingDataList; private int spikeArrestLimit; - private String subscriberTenantDomain; + private String subscriberOrganization; private String spikeArrestUnit; private boolean stopOnQuotaReach; private String apiPublisher; @@ -56,7 +56,7 @@ public AuthenticationContext() { this.consumerKey = UNKNOWN_VALUE; this.spikeArrestUnit = ""; this.subscriber = UNKNOWN_VALUE; - this.subscriberTenantDomain = UNKNOWN_VALUE; + this.subscriberOrganization = UNKNOWN_VALUE; } public List getThrottlingDataList() { @@ -227,12 +227,12 @@ public void setSpikeArrestLimit(int spikeArrestLimit) { * * @return Subscriber Tenant Domain */ - public String getSubscriberTenantDomain() { - return subscriberTenantDomain; + public String getSubscriberOrganization() { + return subscriberOrganization; } - public void setSubscriberTenantDomain(String subscriberTenantDomain) { - this.subscriberTenantDomain = subscriberTenantDomain; + public void setSubscriberOrganization(String subscriberOrganization) { + this.subscriberOrganization = subscriberOrganization; } /** diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsUtils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsUtils.java index 849b2265f..8e94f9f1c 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsUtils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsUtils.java @@ -48,7 +48,7 @@ public static String setDefaultIfNull(String value) { } public static String getAPIProvider(String uuid) { - API api = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore().getApiByContextAndVersion(uuid); + API api = SubscriptionDataHolder.getInstance().getSubscriptionDataStore().getApiByContextAndVersion(uuid); if (api == null) { return AnalyticsConstants.DEFAULT_FOR_UNASSIGNED; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/RestAPI.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/RestAPI.java index aaf33ad06..d40ddb7cb 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/RestAPI.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/api/RestAPI.java @@ -145,7 +145,8 @@ public String init(Api api) { .disableScopes(api.getDisableScopes()).trustStore(trustStore).organizationId(api.getOrganizationId()) .mtlsCertificateTiers(mtlsCertificateTiers).mutualSSL(mutualSSL).systemAPI(api.getSystemAPI()) .applicationSecurity(applicationSecurity).jwtConfigurationDto(jwtConfigurationDto) - .apiDefinition(apiDefinition).environment(api.getEnvironment()).build(); + .apiDefinition(apiDefinition).environment(api.getEnvironment()) + .subscriptionValidation(api.getSubscriptionValidation()).build(); initFilters(); return basePath; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnvVarConfig.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnvVarConfig.java index 85b4c2ead..1a3ac0877 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnvVarConfig.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/EnvVarConfig.java @@ -28,12 +28,15 @@ public class EnvVarConfig { private static final String TRUSTED_CA_CERTS_PATH = "TRUSTED_CA_CERTS_PATH"; private static final String TRUST_DEFAULT_CERTS = "TRUST_DEFAULT_CERTS"; private static final String ADAPTER_HOST_NAME = "ADAPTER_HOST_NAME"; + private static final String COMMON_CONTROLLER_HOST_NAME = "COMMON_CONTROLLER_HOST_NAME"; private static final String ENFORCER_PRIVATE_KEY_PATH = "ENFORCER_PRIVATE_KEY_PATH"; private static final String ENFORCER_PUBLIC_CERT_PATH = "ENFORCER_PUBLIC_CERT_PATH"; private static final String OPA_CLIENT_PRIVATE_KEY_PATH = "OPA_CLIENT_PRIVATE_KEY_PATH"; private static final String OPA_CLIENT_PUBLIC_CERT_PATH = "OPA_CLIENT_PUBLIC_CERT_PATH"; private static final String ADAPTER_HOST = "ADAPTER_HOST"; private static final String ADAPTER_XDS_PORT = "ADAPTER_XDS_PORT"; + private static final String COMMON_CONTROLLER_HOST = "COMMON_CONTROLLER_HOST"; + private static final String COMMON_CONTROLLER_XDS_PORT = "COMMON_CONTROLLER_XDS_PORT"; private static final String ENFORCER_LABEL = "ENFORCER_LABEL"; private static final String ENFORCER_REGION_ID = "ENFORCER_REGION"; public static final String XDS_MAX_MSG_SIZE = "XDS_MAX_MSG_SIZE"; @@ -56,11 +59,14 @@ public class EnvVarConfig { private static final String DEFAULT_TRUSTED_CA_CERTS_PATH = "/home/wso2/security/truststore"; private static final String DEFAULT_TRUST_DEFAULT_CERTS = "true"; private static final String DEFAULT_ADAPTER_HOST_NAME = "adapter"; + private static final String DEFAULT_COMMON_CONTROLLER_HOST_NAME = "common-controller"; private static final String DEFAULT_ENFORCER_PRIVATE_KEY_PATH = "/home/wso2/security/keystore/mg.key"; private static final String DEFAULT_ENFORCER_PUBLIC_CERT_PATH = "/home/wso2/security/keystore/mg.pem"; private static final String DEFAULT_ENFORCER_REGION_ID = "UNKNOWN"; private static final String DEFAULT_ADAPTER_HOST = "adapter"; private static final String DEFAULT_ADAPTER_XDS_PORT = "18000"; + private static final String DEFAULT_COMMON_CONTROLLER_HOST = "common-controller"; + private static final String DEFAULT_COMMON_CONTROLLER_XDS_PORT = "18002"; private static final String DEFAULT_ENFORCER_LABEL = "enforcer"; public static final String DEFAULT_XDS_MAX_MSG_SIZE = "4194304"; public static final String DEFAULT_XDS_MAX_RETRIES = Integer.toString(Constants.MAX_XDS_RETRIES); @@ -84,9 +90,12 @@ public class EnvVarConfig { private final String opaClientPrivateKeyPath; private final String opaClientPublicKeyPath; private final String adapterHost; + private final String commonControllerHost; private final String enforcerLabel; private final String adapterXdsPort; - private final String adapterHostName; + private final String commonControllerXdsPort; + private final String adapterHostname; + private final String commonControllerHostname; // TODO: (VirajSalaka) Enforcer ID should be picked from router once envoy 1.18.0 is released and microgateway // is updated. private final String enforcerRegionId; @@ -120,8 +129,13 @@ private EnvVarConfig() { DEFAULT_ENFORCER_PUBLIC_CERT_PATH); enforcerLabel = retrieveEnvVarOrDefault(ENFORCER_LABEL, DEFAULT_ENFORCER_LABEL); adapterHost = retrieveEnvVarOrDefault(ADAPTER_HOST, DEFAULT_ADAPTER_HOST); - adapterHostName = retrieveEnvVarOrDefault(ADAPTER_HOST_NAME, DEFAULT_ADAPTER_HOST_NAME); + adapterHostname = retrieveEnvVarOrDefault(ADAPTER_HOST_NAME, DEFAULT_ADAPTER_HOST_NAME); adapterXdsPort = retrieveEnvVarOrDefault(ADAPTER_XDS_PORT, DEFAULT_ADAPTER_XDS_PORT); + commonControllerHost = retrieveEnvVarOrDefault(COMMON_CONTROLLER_HOST, DEFAULT_COMMON_CONTROLLER_HOST); + commonControllerHostname = retrieveEnvVarOrDefault(COMMON_CONTROLLER_HOST_NAME, + DEFAULT_COMMON_CONTROLLER_HOST_NAME); + commonControllerXdsPort = retrieveEnvVarOrDefault(COMMON_CONTROLLER_XDS_PORT, + DEFAULT_COMMON_CONTROLLER_XDS_PORT); xdsMaxMsgSize = retrieveEnvVarOrDefault(XDS_MAX_MSG_SIZE, DEFAULT_XDS_MAX_MSG_SIZE); enforcerRegionId = retrieveEnvVarOrDefault(ENFORCER_REGION_ID, DEFAULT_ENFORCER_REGION_ID); xdsMaxRetries = retrieveEnvVarOrDefault(XDS_MAX_RETRIES, DEFAULT_XDS_MAX_RETRIES); @@ -206,6 +220,10 @@ public String getAdapterHost() { return adapterHost; } + public String getCommonControllerHost() { + return commonControllerHost; + } + public String getEnforcerLabel() { return enforcerLabel; } @@ -214,8 +232,16 @@ public String getAdapterXdsPort() { return adapterXdsPort; } - public String getAdapterHostName() { - return adapterHostName; + public String getCommonControllerXdsPort() { + return commonControllerXdsPort; + } + + public String getAdapterHostname() { + return adapterHostname; + } + + public String getCommonControllerHostname() { + return commonControllerHostname; } public String getXdsMaxMsgSize() { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java index c33ab464f..978bfb18b 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APIConstants.java @@ -49,7 +49,7 @@ public class APIConstants { public static final String DEFAULT_ENVIRONMENT_NAME = "Default"; public static final String AUTHORIZATION_HEADER_BASIC = "Basic"; - public static final String API_SECURITY_OAUTH2 = "oauth2"; + public static final String API_SECURITY_OAUTH2 = "OAuth2"; public static final String API_SECURITY_BASIC_AUTH = "basic_auth"; public static final String SWAGGER_API_KEY_AUTH_TYPE_NAME = "apiKey"; public static final String SWAGGER_API_KEY_IN_HEADER = "Header"; @@ -129,6 +129,7 @@ public static class SubscriptionStatus { public static final String PROD_ONLY_BLOCKED = "PROD_ONLY_BLOCKED"; public static final String ON_HOLD = "ON_HOLD"; public static final String REJECTED = "REJECTED"; + public static final String INACTIVE = "INACTIVE"; private SubscriptionStatus() { @@ -154,8 +155,6 @@ public static class JwtTokenConstants { public static final String APPLICATION_NAME = "name"; public static final String APPLICATION_TIER = "tier"; public static final String APPLICATION_OWNER = "owner"; - public static final String KEY_TYPE = "keytype"; - public static final String CONSUMER_KEY = "consumerKey"; public static final String SUBSCRIPTION_TIER = "subscriptionTier"; public static final String SUBSCRIBER_TENANT_DOMAIN = "subscriberTenantDomain"; public static final String TIER_INFO = "tierInfo"; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APISecurityConstants.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APISecurityConstants.java index 9e734d6ad..21c83570d 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APISecurityConstants.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/APISecurityConstants.java @@ -58,7 +58,7 @@ public class APISecurityConstants { public static final String API_SUBSCRIPTION_BLOCKED_DESCRIPTION = "API Subscription is blocked"; public static final int API_AUTH_FORBIDDEN = 900908; - public static final String API_AUTH_FORBIDDEN_MESSAGE = "Resource forbidden "; + public static final String API_AUTH_FORBIDDEN_MESSAGE = "Resource forbidden"; public static final int SUBSCRIPTION_INACTIVE = 900909; public static final String SUBSCRIPTION_INACTIVE_MESSAGE = "The subscription to the API is inactive"; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/Constants.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/Constants.java index a79f31108..989f18101 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/Constants.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/constants/Constants.java @@ -38,6 +38,8 @@ public class Constants { "type.googleapis.com/wso2.discovery.subscription.SubscriptionPolicyList"; public static final String APPLICATION_KEY_MAPPING_LIST_TYPE_URL = "type.googleapis.com/wso2.discovery.subscription.ApplicationKeyMappingList"; + public static final String APPLICATION_MAPPING_LIST_TYPE_URL = + "type.googleapis.com/wso2.discovery.subscription.ApplicationMappingList"; public static final String KEY_MANAGER_TYPE_URL = "type.googleapis.com/wso2.discovery.keymgt.KeyManagerConfig"; public static final String REVOKED_TOKEN_TYPE_URL = diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiDiscoveryClient.java index d78d1c528..27c7a6907 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiDiscoveryClient.java @@ -50,6 +50,7 @@ public class ApiDiscoveryClient implements Runnable { private static ApiDiscoveryClient instance; private final APIFactory apiFactory; private final String host; + private final String hostname; private final int port; private ManagedChannel channel; private ApiDiscoveryServiceGrpc.ApiDiscoveryServiceStub stub; @@ -76,8 +77,9 @@ public class ApiDiscoveryClient implements Runnable { */ private final Node node; - private ApiDiscoveryClient(String host, int port) { + private ApiDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.apiFactory = APIFactory.getInstance(); this.node = XDSCommonUtils.generateXDSNode(ConfigHolder.getInstance().getEnvVarConfig().getEnforcerLabel()); @@ -97,7 +99,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = ApiDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopAPIDiscoveryScheduling(); @@ -107,8 +109,9 @@ private void initConnection() { public static ApiDiscoveryClient getInstance() { if (instance == null) { String adsHost = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHost(); + String adsHostname = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHostname(); int adsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getAdapterXdsPort()); - instance = new ApiDiscoveryClient(adsHost, adsPort); + instance = new ApiDiscoveryClient(adsHost, adsHostname, adsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiListDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiListDiscoveryClient.java index daf0785b7..c2f220abc 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiListDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApiListDiscoveryClient.java @@ -53,6 +53,7 @@ public class ApiListDiscoveryClient implements Runnable { private StreamObserver reqObserver; private final SubscriptionDataStoreImpl subscriptionDataStore; private final String host; + private final String hostname; private final int port; /** @@ -78,8 +79,9 @@ public class ApiListDiscoveryClient implements Runnable { */ private final Node node; - private ApiListDiscoveryClient(String host, int port) { + private ApiListDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); initConnection(); @@ -99,7 +101,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = ApiListDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopAPIListDiscoveryScheduling(); @@ -109,8 +111,9 @@ private void initConnection() { public static ApiListDiscoveryClient 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 ApiListDiscoveryClient(sdsHost, sdsPort); + instance = new ApiListDiscoveryClient(sdsHost, sdsHostname, sdsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationDiscoveryClient.java index d0b75d73e..c119742ca 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationDiscoveryClient.java @@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit; /** - * Client to communicate with Application discovery service at the adapter. + * Client to communicate with Application discovery service at the common-controller. */ public class ApplicationDiscoveryClient implements Runnable { private static final Logger logger = LogManager.getLogger(ApplicationDiscoveryClient.class); @@ -54,6 +54,7 @@ public class ApplicationDiscoveryClient implements Runnable { private StreamObserver reqObserver; private final SubscriptionDataStoreImpl subscriptionDataStore; private final String host; + private final String hostname; private final int port; /** @@ -79,8 +80,9 @@ public class ApplicationDiscoveryClient implements Runnable { */ private final Node node; - private ApplicationDiscoveryClient(String host, int port) { + private ApplicationDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); initConnection(); @@ -100,7 +102,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = ApplicationDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopApplicationDiscoveryScheduling(); @@ -109,9 +111,10 @@ private void initConnection() { public static ApplicationDiscoveryClient getInstance() { if (instance == null) { - String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHost(); - int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getAdapterXdsPort()); - instance = new ApplicationDiscoveryClient(sdsHost, sdsPort); + String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHost(); + String sdsHostname = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHostname(); + int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerXdsPort()); + instance = new ApplicationDiscoveryClient(sdsHost, sdsHostname, sdsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java index 80ce3fa81..b7215f337 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java @@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit; /** - * Client to communicate with Application Key Mapping discovery service at the adapter. + * Client to communicate with Application Key Mapping discovery service at the common-controller. */ public class ApplicationKeyMappingDiscoveryClient implements Runnable { private static final Logger logger = LogManager.getLogger(ApplicationKeyMappingDiscoveryClient.class); @@ -54,6 +54,7 @@ public class ApplicationKeyMappingDiscoveryClient implements Runnable { private StreamObserver reqObserver; private final SubscriptionDataStoreImpl subscriptionDataStore; private final String host; + private final String hostname; private final int port; /** @@ -79,8 +80,9 @@ public class ApplicationKeyMappingDiscoveryClient implements Runnable { */ private final Node node; - private ApplicationKeyMappingDiscoveryClient(String host, int port) { + private ApplicationKeyMappingDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); initConnection(); @@ -100,7 +102,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = ApplicationKeyMappingDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopApplicationKeyMappingDiscoveryScheduling(); @@ -109,9 +111,10 @@ private void initConnection() { public static ApplicationKeyMappingDiscoveryClient getInstance() { if (instance == null) { - String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHost(); - int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getAdapterXdsPort()); - instance = new ApplicationKeyMappingDiscoveryClient(sdsHost, sdsPort); + String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHost(); + String sdsHostname = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHostname(); + int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerXdsPort()); + instance = new ApplicationKeyMappingDiscoveryClient(sdsHost, sdsHostname, sdsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationMappingDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationMappingDiscoveryClient.java new file mode 100644 index 000000000..18df15e92 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationMappingDiscoveryClient.java @@ -0,0 +1,204 @@ +/* + * 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.discovery.service.subscription.ApplicationMappingDiscoveryServiceGrpc; +import org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping; +import org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList; +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.subscription.SubscriptionDataStoreImpl; +import org.wso2.apk.enforcer.util.GRPCUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * Client to communicate with Application Mapping discovery service at the common-controller. + */ +public class ApplicationMappingDiscoveryClient implements Runnable { + private static final Logger logger = LogManager.getLogger(ApplicationMappingDiscoveryClient.class); + private static ApplicationMappingDiscoveryClient instance; + private ManagedChannel channel; + private ApplicationMappingDiscoveryServiceGrpc.ApplicationMappingDiscoveryServiceStub stub; + private StreamObserver reqObserver; + private final SubscriptionDataStoreImpl subscriptionDataStore; + 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 ApplicationMappingDiscoveryClient(String host, String hostname, int port) { + this.host = host; + this.hostname = hostname; + this.port = port; + this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); + 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("Application mapping discovery channel shutdown wait was interrupted", e); + } + } while (!channel.isShutdown()); + } + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); + this.stub = ApplicationMappingDiscoveryServiceGrpc.newStub(channel); + } else if (channel.getState(true) == ConnectivityState.READY) { + XdsSchedulerManager.getInstance().stopApplicationMappingDiscoveryScheduling(); + } + } + + public static ApplicationMappingDiscoveryClient getInstance() { + if (instance == null) { + String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHost(); + String sdsHostname = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHostname(); + int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerXdsPort()); + instance = new ApplicationMappingDiscoveryClient(sdsHost, sdsHostname, sdsPort); + } + return instance; + } + + public void run() { + initConnection(); + watchApplicationMappings(); + } + + public void watchApplicationMappings() { + // TODO: (Praminda) implement a deadline with retries + reqObserver = stub.streamApplicationMappings(new StreamObserver() { + @Override + public void onNext(DiscoveryResponse response) { + logger.info("Application Mapping event received with version : " + response.getVersionInfo()); + logger.debug("Received Application Mapping discovery response " + response); + XdsSchedulerManager.getInstance().stopApplicationMappingDiscoveryScheduling(); + latestReceived = response; + try { + List applicationMappingList = new ArrayList<>(); + for (Any res : response.getResourcesList()) { + applicationMappingList.addAll(res.unpack(ApplicationMappingList.class).getListList()); + } + subscriptionDataStore.addApplicationMappings(applicationMappingList); + logger.info("Number of application mappings received : " + applicationMappingList.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 Application Mappings discovery", throwable); + XdsSchedulerManager.getInstance().startApplicationMappingDiscoveryScheduling(); + nack(throwable); + } + + @Override + public void onCompleted() { + logger.info("Completed receiving Application Mapping data"); + } + }); + + try { + DiscoveryRequest req = DiscoveryRequest.newBuilder() + .setNode(node) + .setVersionInfo(latestACKed.getVersionInfo()) + .setTypeUrl(Constants.APPLICATION_MAPPING_LIST_TYPE_URL).build(); + reqObserver.onNext(req); + logger.debug("Sent Discovery request for type url: " + Constants.APPLICATION_MAPPING_LIST_TYPE_URL); + + } catch (Exception e) { + logger.error("Unexpected error occurred in Application Mapping 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.APPLICATION_MAPPING_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.APPLICATION_MAPPING_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/ApplicationPolicyDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationPolicyDiscoveryClient.java index b87a5b748..1a63aa033 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationPolicyDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ApplicationPolicyDiscoveryClient.java @@ -54,6 +54,7 @@ public class ApplicationPolicyDiscoveryClient implements Runnable { private StreamObserver reqObserver; private final SubscriptionDataStoreImpl subscriptionDataStore; private final String host; + private final String hostname; private final int port; /** @@ -79,8 +80,9 @@ public class ApplicationPolicyDiscoveryClient implements Runnable { */ private final Node node; - private ApplicationPolicyDiscoveryClient(String host, int port) { + private ApplicationPolicyDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); initConnection(); @@ -100,7 +102,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = ApplicationPolicyDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopApplicationPolicyDiscoveryScheduling(); @@ -110,8 +112,9 @@ private void initConnection() { public static ApplicationPolicyDiscoveryClient 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 ApplicationPolicyDiscoveryClient(sdsHost, sdsPort); + instance = new ApplicationPolicyDiscoveryClient(sdsHost, sdsHostname, sdsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ConfigDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ConfigDiscoveryClient.java index cf4008ff4..638567e6a 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ConfigDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/ConfigDiscoveryClient.java @@ -46,6 +46,7 @@ public class ConfigDiscoveryClient implements Runnable { private static final Logger log = LogManager.getLogger(ConfigDiscoveryClient.class); private static ConfigDiscoveryClient instance; private final String host; + private final String hostname; private final int port; private final CountDownLatch latch; private ConfigDiscoveryServiceGrpc.ConfigDiscoveryServiceBlockingStub blockingStub; @@ -55,8 +56,9 @@ public class ConfigDiscoveryClient implements Runnable { */ private final Node node; - private ConfigDiscoveryClient(String host, int port, CountDownLatch latch) { + private ConfigDiscoveryClient(String host, String hostname, int port, CountDownLatch latch) { this.host = host; + this.hostname = hostname; this.port = port; this.latch = latch; this.node = XDSCommonUtils.generateXDSNode(AdapterConstants.COMMON_ENFORCER_LABEL); @@ -73,8 +75,9 @@ private ConfigDiscoveryClient(String host, int port, CountDownLatch latch) { public static ConfigDiscoveryClient init(@NotNull CountDownLatch latch) { if (instance == null) { String adsHost = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHost(); + String adsHostname = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHostname(); int adsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getAdapterXdsPort()); - instance = new ConfigDiscoveryClient(adsHost, adsPort, latch); + instance = new ConfigDiscoveryClient(adsHost, adsHostname, adsPort, latch); } return instance; } @@ -105,7 +108,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(log, host, port); + this.channel = GRPCUtils.createSecuredChannel(log, host, port, hostname); this.blockingStub = ConfigDiscoveryServiceGrpc.newBlockingStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopConfigDiscoveryScheduling(); 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 index 397806629..83476aaee 100644 --- 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 @@ -55,6 +55,7 @@ public class JWTIssuerDiscoveryClient implements Runnable { private StreamObserver reqObserver; private final SubscriptionDataStoreImpl subscriptionDataStore; private final String host; + private final String hostname; private final int port; /** @@ -80,8 +81,9 @@ public class JWTIssuerDiscoveryClient implements Runnable { */ private final Node node; - private JWTIssuerDiscoveryClient(String host, int port) { + private JWTIssuerDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); initConnection(); @@ -101,7 +103,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = JWTIssuerDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopJWTIssuerDiscoveryScheduling(); @@ -111,8 +113,9 @@ private void initConnection() { 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, sdsPort); + instance = new JWTIssuerDiscoveryClient(sdsHost,sdsHostname, sdsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/RevokedTokenDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/RevokedTokenDiscoveryClient.java index 212416971..93c5b026d 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/RevokedTokenDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/RevokedTokenDiscoveryClient.java @@ -56,6 +56,7 @@ public class RevokedTokenDiscoveryClient implements Runnable { private StreamObserver reqObserver; private static final Logger log = LogManager.getLogger(RevokedTokenDiscoveryClient.class); private final String host; + private final String hostname; private final int port; /** * This is a reference to the latest received response from the ADS. @@ -79,8 +80,9 @@ public class RevokedTokenDiscoveryClient implements Runnable { */ private final Node node; - private RevokedTokenDiscoveryClient(String host, int port) { + private RevokedTokenDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.revokedJWTDataHolder = RevokedJWTDataHolder.getInstance(); initConnection(); @@ -103,7 +105,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(log, host, port); + this.channel = GRPCUtils.createSecuredChannel(log, host, port, hostname); this.stub = RevokedTokenDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopRevokedTokenDiscoveryScheduling(); @@ -113,8 +115,9 @@ private void initConnection() { public static RevokedTokenDiscoveryClient getInstance() { if (instance == null) { String adsHost = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHost(); + String adsHostname = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHostname(); int adsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getAdapterXdsPort()); - instance = new RevokedTokenDiscoveryClient(adsHost, adsPort); + instance = new RevokedTokenDiscoveryClient(adsHost, adsHostname, adsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionDiscoveryClient.java index 3a37a9b4c..61c317b63 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionDiscoveryClient.java @@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit; /** - * Client to communicate with Subscription discovery service at the adapter. + * Client to communicate with Subscription discovery service at the common-controller. */ public class SubscriptionDiscoveryClient implements Runnable { private static final Logger logger = LogManager.getLogger(SubscriptionDiscoveryClient.class); @@ -54,6 +54,7 @@ public class SubscriptionDiscoveryClient implements Runnable { private StreamObserver reqObserver; private final SubscriptionDataStoreImpl subscriptionDataStore; private final String host; + private final String hostname; private final int port; /** @@ -78,8 +79,9 @@ public class SubscriptionDiscoveryClient implements Runnable { */ private final Node node; - private SubscriptionDiscoveryClient(String host, int port) { + private SubscriptionDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); initConnection(); @@ -99,7 +101,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = SubscriptionDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopSubscriptionDiscoveryScheduling(); @@ -108,9 +110,10 @@ private void initConnection() { public static SubscriptionDiscoveryClient getInstance() { if (instance == null) { - String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getAdapterHost(); - int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getAdapterXdsPort()); - instance = new SubscriptionDiscoveryClient(sdsHost, sdsPort); + String sdsHost = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHost(); + String sdsHostname = ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerHostname(); + int sdsPort = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getCommonControllerXdsPort()); + instance = new SubscriptionDiscoveryClient(sdsHost, sdsHostname, sdsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java index 28582770d..3498b9c36 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java @@ -54,6 +54,7 @@ public class SubscriptionPolicyDiscoveryClient implements Runnable { private StreamObserver reqObserver; private final SubscriptionDataStoreImpl subscriptionDataStore; private final String host; + private final String hostname; private final int port; /** @@ -78,8 +79,9 @@ public class SubscriptionPolicyDiscoveryClient implements Runnable { */ private final Node node; - private SubscriptionPolicyDiscoveryClient(String host, int port) { + private SubscriptionPolicyDiscoveryClient(String host, String hostname, int port) { this.host = host; + this.hostname = hostname; this.port = port; this.subscriptionDataStore = SubscriptionDataStoreImpl.getInstance(); initConnection(); @@ -99,7 +101,7 @@ private void initConnection() { } } while (!channel.isShutdown()); } - this.channel = GRPCUtils.createSecuredChannel(logger, host, port); + this.channel = GRPCUtils.createSecuredChannel(logger, host, port, hostname); this.stub = SubscriptionPolicyDiscoveryServiceGrpc.newStub(channel); } else if (channel.getState(true) == ConnectivityState.READY) { XdsSchedulerManager.getInstance().stopSubscriptionPolicyDiscoveryScheduling(); @@ -109,8 +111,9 @@ private void initConnection() { public static SubscriptionPolicyDiscoveryClient 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 SubscriptionPolicyDiscoveryClient(sdsHost, sdsPort); + instance = new SubscriptionPolicyDiscoveryClient(sdsHost, sdsHostname, sdsPort); } return instance; } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java index 51b7d871a..13e45af13 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/Api.java @@ -196,6 +196,11 @@ private Api( environment_ = s; break; } + case 224: { + + subscriptionValidation_ = input.readBool(); + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -876,6 +881,17 @@ public java.lang.String getEnvironment() { } } + public static final int SUBSCRIPTIONVALIDATION_FIELD_NUMBER = 28; + private boolean subscriptionValidation_; + /** + * bool subscriptionValidation = 28; + * @return The subscriptionValidation. + */ + @java.lang.Override + public boolean getSubscriptionValidation() { + return subscriptionValidation_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -950,6 +966,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getEnvironmentBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 27, environment_); } + if (subscriptionValidation_ != false) { + output.writeBool(28, subscriptionValidation_); + } unknownFields.writeTo(output); } @@ -1027,6 +1046,10 @@ public int getSerializedSize() { if (!getEnvironmentBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(27, environment_); } + if (subscriptionValidation_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(28, subscriptionValidation_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1085,6 +1108,8 @@ public boolean equals(final java.lang.Object obj) { .equals(other.getApiDefinitionFile())) return false; if (!getEnvironment() .equals(other.getEnvironment())) return false; + if (getSubscriptionValidation() + != other.getSubscriptionValidation()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -1146,6 +1171,9 @@ public int hashCode() { hash = (53 * hash) + getApiDefinitionFile().hashCode(); hash = (37 * hash) + ENVIRONMENT_FIELD_NUMBER; hash = (53 * hash) + getEnvironment().hashCode(); + hash = (37 * hash) + SUBSCRIPTIONVALIDATION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getSubscriptionValidation()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1337,6 +1365,8 @@ public Builder clear() { environment_ = ""; + subscriptionValidation_ = false; + return this; } @@ -1404,6 +1434,7 @@ public org.wso2.apk.enforcer.discovery.api.Api buildPartial() { } result.apiDefinitionFile_ = apiDefinitionFile_; result.environment_ = environment_; + result.subscriptionValidation_ = subscriptionValidation_; onBuilt(); return result; } @@ -1570,6 +1601,9 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.api.Api other) { environment_ = other.environment_; onChanged(); } + if (other.getSubscriptionValidation() != false) { + setSubscriptionValidation(other.getSubscriptionValidation()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -3355,6 +3389,37 @@ public Builder setEnvironmentBytes( onChanged(); return this; } + + private boolean subscriptionValidation_ ; + /** + * bool subscriptionValidation = 28; + * @return The subscriptionValidation. + */ + @java.lang.Override + public boolean getSubscriptionValidation() { + return subscriptionValidation_; + } + /** + * bool subscriptionValidation = 28; + * @param value The subscriptionValidation to set. + * @return This builder for chaining. + */ + public Builder setSubscriptionValidation(boolean value) { + + subscriptionValidation_ = value; + onChanged(); + return this; + } + /** + * bool subscriptionValidation = 28; + * @return This builder for chaining. + */ + public Builder clearSubscriptionValidation() { + + subscriptionValidation_ = false; + onChanged(); + return this; + } @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/api/ApiOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiOrBuilder.java index 9656c6f27..2eb44452c 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiOrBuilder.java @@ -268,4 +268,10 @@ org.wso2.apk.enforcer.discovery.api.CertificateOrBuilder getClientCertificatesOr */ com.google.protobuf.ByteString getEnvironmentBytes(); + + /** + * bool subscriptionValidation = 28; + * @return The subscriptionValidation. + */ + boolean getSubscriptionValidation(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java index 485076d63..d3deec7d7 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/api/ApiProto.java @@ -32,7 +32,7 @@ public static void registerAllExtensions( "covery.api\032!wso2/discovery/api/Resource." + "proto\032$wso2/discovery/api/Certificate.pr" + "oto\032,wso2/discovery/api/BackendJWTTokenI" + - "nfo.proto\"\223\004\n\003Api\022\n\n\002id\030\001 \001(\t\022\r\n\005title\030\002" + + "nfo.proto\"\263\004\n\003Api\022\n\n\002id\030\001 \001(\t\022\r\n\005title\030\002" + " \001(\t\022\017\n\007version\030\003 \001(\t\022\017\n\007apiType\030\004 \001(\t\022\036" + "\n\026disableAuthentications\030\005 \001(\010\022\025\n\rdisabl" + "eScopes\030\006 \001(\010\022\017\n\007envType\030\007 \001(\t\022/\n\tresour" + @@ -45,10 +45,11 @@ public static void registerAllExtensions( "\030\020 \001(\010\022\021\n\tsystemAPI\030\030 \001(\010\022D\n\023backendJWTT" + "okenInfo\030\031 \001(\0132\'.wso2.discovery.api.Back" + "endJWTTokenInfo\022\031\n\021apiDefinitionFile\030\032 \001" + - "(\014\022\023\n\013environment\030\033 \001(\tBp\n#org.wso2.apk." + - "enforcer.discovery.apiB\010ApiProtoP\001Z=gith" + - "ub.com/envoyproxy/go-control-plane/wso2/" + - "discovery/api;apib\006proto3" + "(\014\022\023\n\013environment\030\033 \001(\t\022\036\n\026subscriptionV" + + "alidation\030\034 \001(\010Bp\n#org.wso2.apk.enforcer" + + ".discovery.apiB\010ApiProtoP\001Z=github.com/e" + + "nvoyproxy/go-control-plane/wso2/discover" + + "y/api;apib\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -62,7 +63,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_api_Api_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_api_Api_descriptor, - new java.lang.String[] { "Id", "Title", "Version", "ApiType", "DisableAuthentications", "DisableScopes", "EnvType", "Resources", "BasePath", "Tier", "ApiLifeCycleState", "Vhost", "OrganizationId", "ClientCertificates", "MutualSSL", "ApplicationSecurity", "SystemAPI", "BackendJWTTokenInfo", "ApiDefinitionFile", "Environment", }); + new java.lang.String[] { "Id", "Title", "Version", "ApiType", "DisableAuthentications", "DisableScopes", "EnvType", "Resources", "BasePath", "Tier", "ApiLifeCycleState", "Vhost", "OrganizationId", "ClientCertificates", "MutualSSL", "ApplicationSecurity", "SystemAPI", "BackendJWTTokenInfo", "ApiDefinitionFile", "Environment", "SubscriptionValidation", }); org.wso2.apk.enforcer.discovery.api.ResourceProto.getDescriptor(); org.wso2.apk.enforcer.discovery.api.CertificateProto.getDescriptor(); org.wso2.apk.enforcer.discovery.api.BackendJWTTokenInfoProto.getDescriptor(); 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 795dcdd59..a23c03879 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 @@ -23,6 +23,7 @@ import org.wso2.apk.enforcer.discovery.ApiListDiscoveryClient; import org.wso2.apk.enforcer.discovery.ApplicationDiscoveryClient; import org.wso2.apk.enforcer.discovery.ApplicationKeyMappingDiscoveryClient; +import org.wso2.apk.enforcer.discovery.ApplicationMappingDiscoveryClient; import org.wso2.apk.enforcer.discovery.ApplicationPolicyDiscoveryClient; import org.wso2.apk.enforcer.discovery.ConfigDiscoveryClient; import org.wso2.apk.enforcer.discovery.JWTIssuerDiscoveryClient; @@ -48,6 +49,7 @@ public class XdsSchedulerManager { private ScheduledFuture jwtIssuerDiscoveryScheduledFuture; private ScheduledFuture applicationKeyMappingDiscoveryScheduledFuture; + private ScheduledFuture applicationMappingDiscoveryScheduledFuture; private ScheduledFuture keyManagerDiscoveryScheduledFuture; private ScheduledFuture revokedTokenDiscoveryScheduledFuture; private ScheduledFuture subscriptionDiscoveryScheduledFuture; @@ -208,4 +210,19 @@ public synchronized void stopSubscriptionPolicyDiscoveryScheduling() { subscriptionPolicyDiscoveryScheduledFuture.cancel(false); } } + + public synchronized void startApplicationMappingDiscoveryScheduling() { + if (applicationMappingDiscoveryScheduledFuture == null || applicationMappingDiscoveryScheduledFuture.isDone()) { + applicationMappingDiscoveryScheduledFuture = discoveryClientScheduler + .scheduleWithFixedDelay(ApplicationMappingDiscoveryClient.getInstance(), 1, retryPeriod, + TimeUnit.SECONDS); + } + } + + public synchronized void stopApplicationMappingDiscoveryScheduling() { + if (applicationMappingDiscoveryScheduledFuture != null && !applicationMappingDiscoveryScheduledFuture + .isDone()) { + applicationMappingDiscoveryScheduledFuture.cancel(false); + } + } } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/AppMappingDSProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/AppMappingDSProto.java new file mode 100644 index 000000000..d3f33884d --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/AppMappingDSProto.java @@ -0,0 +1,48 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/service/subscription/app_mapping_ds.proto + +package org.wso2.apk.enforcer.discovery.service.subscription; + +public final class AppMappingDSProto { + private AppMappingDSProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n8wso2/discovery/service/subscription/ap" + + "p_mapping_ds.proto\022\036discovery.service.su" + + "bscription\032*envoy/service/discovery/v3/d" + + "iscovery.proto2\244\001\n\"ApplicationMappingDis" + + "coveryService\022~\n\031StreamApplicationMappin" + + "gs\022,.envoy.service.discovery.v3.Discover" + + "yRequest\032-.envoy.service.discovery.v3.Di" + + "scoveryResponse\"\000(\0010\001B\232\001\n4org.wso2.apk.e" + + "nforcer.discovery.service.subscriptionB\021" + + "AppMappingDSProtoP\001ZJgithub.com/envoypro" + + "xy/go-control-plane/wso2/discovery/servi" + + "ce/subscription\210\001\001b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + io.envoyproxy.envoy.service.discovery.v3.DiscoveryProto.getDescriptor(), + }); + io.envoyproxy.envoy.service.discovery.v3.DiscoveryProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/ApplicationMappingDiscoveryService.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/ApplicationMappingDiscoveryService.java new file mode 100644 index 000000000..c68493ec9 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/ApplicationMappingDiscoveryService.java @@ -0,0 +1,241 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/service/subscription/app_mapping_ds.proto + +package org.wso2.apk.enforcer.discovery.service.subscription; + +/** + *
+ * [#protodoc-title: AppMappingDS]
+ * 
+ * + * Protobuf service {@code discovery.service.subscription.ApplicationMappingDiscoveryService} + */ +public abstract class ApplicationMappingDiscoveryService + implements com.google.protobuf.Service { + protected ApplicationMappingDiscoveryService() {} + + public interface Interface { + /** + * rpc StreamApplicationMappings(stream .envoy.service.discovery.v3.DiscoveryRequest) returns (stream .envoy.service.discovery.v3.DiscoveryResponse); + */ + public abstract void streamApplicationMappings( + com.google.protobuf.RpcController controller, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest request, + com.google.protobuf.RpcCallback done); + + } + + public static com.google.protobuf.Service newReflectiveService( + final Interface impl) { + return new ApplicationMappingDiscoveryService() { + @java.lang.Override + public void streamApplicationMappings( + com.google.protobuf.RpcController controller, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest request, + com.google.protobuf.RpcCallback done) { + impl.streamApplicationMappings(controller, request, done); + } + + }; + } + + public static com.google.protobuf.BlockingService + newReflectiveBlockingService(final BlockingInterface impl) { + return new com.google.protobuf.BlockingService() { + public final com.google.protobuf.Descriptors.ServiceDescriptor + getDescriptorForType() { + return getDescriptor(); + } + + public final com.google.protobuf.Message callBlockingMethod( + com.google.protobuf.Descriptors.MethodDescriptor method, + com.google.protobuf.RpcController controller, + com.google.protobuf.Message request) + throws com.google.protobuf.ServiceException { + if (method.getService() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "Service.callBlockingMethod() given method descriptor for " + + "wrong service type."); + } + switch(method.getIndex()) { + case 0: + return impl.streamApplicationMappings(controller, (io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest)request); + default: + throw new java.lang.AssertionError("Can't get here."); + } + } + + public final com.google.protobuf.Message + getRequestPrototype( + com.google.protobuf.Descriptors.MethodDescriptor method) { + if (method.getService() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "Service.getRequestPrototype() given method " + + "descriptor for wrong service type."); + } + switch(method.getIndex()) { + case 0: + return io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest.getDefaultInstance(); + default: + throw new java.lang.AssertionError("Can't get here."); + } + } + + public final com.google.protobuf.Message + getResponsePrototype( + com.google.protobuf.Descriptors.MethodDescriptor method) { + if (method.getService() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "Service.getResponsePrototype() given method " + + "descriptor for wrong service type."); + } + switch(method.getIndex()) { + case 0: + return io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.getDefaultInstance(); + default: + throw new java.lang.AssertionError("Can't get here."); + } + } + + }; + } + + /** + * rpc StreamApplicationMappings(stream .envoy.service.discovery.v3.DiscoveryRequest) returns (stream .envoy.service.discovery.v3.DiscoveryResponse); + */ + public abstract void streamApplicationMappings( + com.google.protobuf.RpcController controller, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest request, + com.google.protobuf.RpcCallback done); + + public static final + com.google.protobuf.Descriptors.ServiceDescriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.service.subscription.AppMappingDSProto.getDescriptor().getServices().get(0); + } + public final com.google.protobuf.Descriptors.ServiceDescriptor + getDescriptorForType() { + return getDescriptor(); + } + + public final void callMethod( + com.google.protobuf.Descriptors.MethodDescriptor method, + com.google.protobuf.RpcController controller, + com.google.protobuf.Message request, + com.google.protobuf.RpcCallback< + com.google.protobuf.Message> done) { + if (method.getService() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "Service.callMethod() given method descriptor for wrong " + + "service type."); + } + switch(method.getIndex()) { + case 0: + this.streamApplicationMappings(controller, (io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest)request, + com.google.protobuf.RpcUtil.specializeCallback( + done)); + return; + default: + throw new java.lang.AssertionError("Can't get here."); + } + } + + public final com.google.protobuf.Message + getRequestPrototype( + com.google.protobuf.Descriptors.MethodDescriptor method) { + if (method.getService() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "Service.getRequestPrototype() given method " + + "descriptor for wrong service type."); + } + switch(method.getIndex()) { + case 0: + return io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest.getDefaultInstance(); + default: + throw new java.lang.AssertionError("Can't get here."); + } + } + + public final com.google.protobuf.Message + getResponsePrototype( + com.google.protobuf.Descriptors.MethodDescriptor method) { + if (method.getService() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "Service.getResponsePrototype() given method " + + "descriptor for wrong service type."); + } + switch(method.getIndex()) { + case 0: + return io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.getDefaultInstance(); + default: + throw new java.lang.AssertionError("Can't get here."); + } + } + + public static Stub newStub( + com.google.protobuf.RpcChannel channel) { + return new Stub(channel); + } + + public static final class Stub extends org.wso2.apk.enforcer.discovery.service.subscription.ApplicationMappingDiscoveryService implements Interface { + private Stub(com.google.protobuf.RpcChannel channel) { + this.channel = channel; + } + + private final com.google.protobuf.RpcChannel channel; + + public com.google.protobuf.RpcChannel getChannel() { + return channel; + } + + public void streamApplicationMappings( + com.google.protobuf.RpcController controller, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest request, + com.google.protobuf.RpcCallback done) { + channel.callMethod( + getDescriptor().getMethods().get(0), + controller, + request, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.getDefaultInstance(), + com.google.protobuf.RpcUtil.generalizeCallback( + done, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.class, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.getDefaultInstance())); + } + } + + public static BlockingInterface newBlockingStub( + com.google.protobuf.BlockingRpcChannel channel) { + return new BlockingStub(channel); + } + + public interface BlockingInterface { + public io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse streamApplicationMappings( + com.google.protobuf.RpcController controller, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest request) + throws com.google.protobuf.ServiceException; + } + + private static final class BlockingStub implements BlockingInterface { + private BlockingStub(com.google.protobuf.BlockingRpcChannel channel) { + this.channel = channel; + } + + private final com.google.protobuf.BlockingRpcChannel channel; + + public io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse streamApplicationMappings( + com.google.protobuf.RpcController controller, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest request) + throws com.google.protobuf.ServiceException { + return (io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse) channel.callBlockingMethod( + getDescriptor().getMethods().get(0), + controller, + request, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.getDefaultInstance()); + } + + } + + // @@protoc_insertion_point(class_scope:discovery.service.subscription.ApplicationMappingDiscoveryService) +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/ApplicationMappingDiscoveryServiceGrpc.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/ApplicationMappingDiscoveryServiceGrpc.java new file mode 100644 index 000000000..8e973639c --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/service/subscription/ApplicationMappingDiscoveryServiceGrpc.java @@ -0,0 +1,287 @@ +package org.wso2.apk.enforcer.discovery.service.subscription; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + *
+ * [#protodoc-title: AppMappingDS]
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: wso2/discovery/service/subscription/app_mapping_ds.proto") +public final class ApplicationMappingDiscoveryServiceGrpc { + + private ApplicationMappingDiscoveryServiceGrpc() {} + + public static final String SERVICE_NAME = "discovery.service.subscription.ApplicationMappingDiscoveryService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getStreamApplicationMappingsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "StreamApplicationMappings", + requestType = io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest.class, + responseType = io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + public static io.grpc.MethodDescriptor getStreamApplicationMappingsMethod() { + io.grpc.MethodDescriptor getStreamApplicationMappingsMethod; + if ((getStreamApplicationMappingsMethod = ApplicationMappingDiscoveryServiceGrpc.getStreamApplicationMappingsMethod) == null) { + synchronized (ApplicationMappingDiscoveryServiceGrpc.class) { + if ((getStreamApplicationMappingsMethod = ApplicationMappingDiscoveryServiceGrpc.getStreamApplicationMappingsMethod) == null) { + ApplicationMappingDiscoveryServiceGrpc.getStreamApplicationMappingsMethod = getStreamApplicationMappingsMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "StreamApplicationMappings")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse.getDefaultInstance())) + .setSchemaDescriptor(new ApplicationMappingDiscoveryServiceMethodDescriptorSupplier("StreamApplicationMappings")) + .build(); + } + } + } + return getStreamApplicationMappingsMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static ApplicationMappingDiscoveryServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ApplicationMappingDiscoveryServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ApplicationMappingDiscoveryServiceStub(channel, callOptions); + } + }; + return ApplicationMappingDiscoveryServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static ApplicationMappingDiscoveryServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ApplicationMappingDiscoveryServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ApplicationMappingDiscoveryServiceBlockingStub(channel, callOptions); + } + }; + return ApplicationMappingDiscoveryServiceBlockingStub.newStub(factory, channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static ApplicationMappingDiscoveryServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public ApplicationMappingDiscoveryServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ApplicationMappingDiscoveryServiceFutureStub(channel, callOptions); + } + }; + return ApplicationMappingDiscoveryServiceFutureStub.newStub(factory, channel); + } + + /** + *
+   * [#protodoc-title: AppMappingDS]
+   * 
+ */ + public static abstract class ApplicationMappingDiscoveryServiceImplBase implements io.grpc.BindableService { + + /** + */ + public io.grpc.stub.StreamObserver streamApplicationMappings( + io.grpc.stub.StreamObserver responseObserver) { + return asyncUnimplementedStreamingCall(getStreamApplicationMappingsMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getStreamApplicationMappingsMethod(), + asyncBidiStreamingCall( + new MethodHandlers< + io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest, + io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse>( + this, METHODID_STREAM_APPLICATION_MAPPINGS))) + .build(); + } + } + + /** + *
+   * [#protodoc-title: AppMappingDS]
+   * 
+ */ + public static final class ApplicationMappingDiscoveryServiceStub extends io.grpc.stub.AbstractAsyncStub { + private ApplicationMappingDiscoveryServiceStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ApplicationMappingDiscoveryServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ApplicationMappingDiscoveryServiceStub(channel, callOptions); + } + + /** + */ + public io.grpc.stub.StreamObserver streamApplicationMappings( + io.grpc.stub.StreamObserver responseObserver) { + return asyncBidiStreamingCall( + getChannel().newCall(getStreamApplicationMappingsMethod(), getCallOptions()), responseObserver); + } + } + + /** + *
+   * [#protodoc-title: AppMappingDS]
+   * 
+ */ + public static final class ApplicationMappingDiscoveryServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { + private ApplicationMappingDiscoveryServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ApplicationMappingDiscoveryServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ApplicationMappingDiscoveryServiceBlockingStub(channel, callOptions); + } + } + + /** + *
+   * [#protodoc-title: AppMappingDS]
+   * 
+ */ + public static final class ApplicationMappingDiscoveryServiceFutureStub extends io.grpc.stub.AbstractFutureStub { + private ApplicationMappingDiscoveryServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ApplicationMappingDiscoveryServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new ApplicationMappingDiscoveryServiceFutureStub(channel, callOptions); + } + } + + private static final int METHODID_STREAM_APPLICATION_MAPPINGS = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final ApplicationMappingDiscoveryServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(ApplicationMappingDiscoveryServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_STREAM_APPLICATION_MAPPINGS: + return (io.grpc.stub.StreamObserver) serviceImpl.streamApplicationMappings( + (io.grpc.stub.StreamObserver) responseObserver); + default: + throw new AssertionError(); + } + } + } + + private static abstract class ApplicationMappingDiscoveryServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + ApplicationMappingDiscoveryServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return org.wso2.apk.enforcer.discovery.service.subscription.AppMappingDSProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("ApplicationMappingDiscoveryService"); + } + } + + private static final class ApplicationMappingDiscoveryServiceFileDescriptorSupplier + extends ApplicationMappingDiscoveryServiceBaseDescriptorSupplier { + ApplicationMappingDiscoveryServiceFileDescriptorSupplier() {} + } + + private static final class ApplicationMappingDiscoveryServiceMethodDescriptorSupplier + extends ApplicationMappingDiscoveryServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + ApplicationMappingDiscoveryServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (ApplicationMappingDiscoveryServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new ApplicationMappingDiscoveryServiceFileDescriptorSupplier()) + .addMethod(getStreamApplicationMappingsMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/APIOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/APIOrBuilder.java new file mode 100644 index 000000000..23721994a --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/APIOrBuilder.java @@ -0,0 +1,46 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/subscription.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface APIOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.API) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + * @return The name. + */ + java.lang.String getName(); + /** + * string name = 1; + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * repeated string versions = 2; + * @return A list containing the versions. + */ + java.util.List + getVersionsList(); + /** + * repeated string versions = 2; + * @return The count of versions. + */ + int getVersionsCount(); + /** + * repeated string versions = 2; + * @param index The index of the element to return. + * @return The versions at the given index. + */ + java.lang.String getVersions(int index); + /** + * repeated string versions = 2; + * @param index The index of the value to return. + * @return The bytes of the versions at the given index. + */ + com.google.protobuf.ByteString + getVersionsBytes(int index); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Application.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Application.java index fb845723d..907e16b6f 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Application.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Application.java @@ -20,14 +20,9 @@ private Application(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } private Application() { - eventId_ = ""; - name_ = ""; uuid_ = ""; + name_ = ""; owner_ = ""; - policy_ = ""; - keys_ = java.util.Collections.emptyList(); - organization_ = ""; - timeStamp_ = ""; } @java.lang.Override @@ -64,7 +59,7 @@ private Application( case 10: { java.lang.String s = input.readStringRequireUtf8(); - eventId_ = s; + uuid_ = s; break; } case 18: { @@ -76,22 +71,10 @@ private Application( case 26: { java.lang.String s = input.readStringRequireUtf8(); - uuid_ = s; - break; - } - case 34: { - java.lang.String s = input.readStringRequireUtf8(); - owner_ = s; break; } - case 42: { - java.lang.String s = input.readStringRequireUtf8(); - - policy_ = s; - break; - } - case 50: { + case 34: { if (!((mutable_bitField0_ & 0x00000001) != 0)) { attributes_ = com.google.protobuf.MapField.newMapField( AttributesDefaultEntryHolder.defaultEntry); @@ -104,27 +87,6 @@ private Application( attributes__.getKey(), attributes__.getValue()); break; } - case 58: { - if (!((mutable_bitField0_ & 0x00000002) != 0)) { - keys_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - keys_.add( - input.readMessage(org.wso2.apk.enforcer.discovery.subscription.Application.Key.parser(), extensionRegistry)); - break; - } - case 66: { - java.lang.String s = input.readStringRequireUtf8(); - - organization_ = s; - break; - } - case 74: { - java.lang.String s = input.readStringRequireUtf8(); - - timeStamp_ = s; - break; - } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -140,9 +102,6 @@ private Application( throw new com.google.protobuf.InvalidProtocolBufferException( e).setUnfinishedMessage(this); } finally { - if (((mutable_bitField0_ & 0x00000002) != 0)) { - keys_ = java.util.Collections.unmodifiableList(keys_); - } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -157,7 +116,7 @@ private Application( protected com.google.protobuf.MapField internalGetMapField( int number) { switch (number) { - case 6: + case 4: return internalGetAttributes(); default: throw new RuntimeException( @@ -172,756 +131,38 @@ protected com.google.protobuf.MapField internalGetMapField( org.wso2.apk.enforcer.discovery.subscription.Application.class, org.wso2.apk.enforcer.discovery.subscription.Application.Builder.class); } - public interface KeyOrBuilder extends - // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.Application.Key) - com.google.protobuf.MessageOrBuilder { - - /** - * string key = 1; - * @return The key. - */ - java.lang.String getKey(); - /** - * string key = 1; - * @return The bytes for key. - */ - com.google.protobuf.ByteString - getKeyBytes(); - - /** - * string keyManager = 2; - * @return The keyManager. - */ - java.lang.String getKeyManager(); - /** - * string keyManager = 2; - * @return The bytes for keyManager. - */ - com.google.protobuf.ByteString - getKeyManagerBytes(); - } - /** - * Protobuf type {@code wso2.discovery.subscription.Application.Key} - */ - public static final class Key extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.Application.Key) - KeyOrBuilder { - private static final long serialVersionUID = 0L; - // Use Key.newBuilder() to construct. - private Key(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Key() { - key_ = ""; - keyManager_ = ""; - } - - @java.lang.Override - @SuppressWarnings({"unused"}) - protected java.lang.Object newInstance( - UnusedPrivateParameter unused) { - return new Key(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Key( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - 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(); - - key_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - keyManager_ = 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 { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Application_Key_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Application_Key_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.wso2.apk.enforcer.discovery.subscription.Application.Key.class, org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder.class); - } - - public static final int KEY_FIELD_NUMBER = 1; - private volatile java.lang.Object key_; - /** - * string key = 1; - * @return The key. - */ - @java.lang.Override - public java.lang.String getKey() { - java.lang.Object ref = key_; - 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(); - key_ = s; - return s; - } - } - /** - * string key = 1; - * @return The bytes for key. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int KEYMANAGER_FIELD_NUMBER = 2; - private volatile java.lang.Object keyManager_; - /** - * string keyManager = 2; - * @return The keyManager. - */ - @java.lang.Override - public java.lang.String getKeyManager() { - java.lang.Object ref = keyManager_; - 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(); - keyManager_ = s; - return s; - } - } - /** - * string keyManager = 2; - * @return The bytes for keyManager. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getKeyManagerBytes() { - java.lang.Object ref = keyManager_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - keyManager_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - 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 (!getKeyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); - } - if (!getKeyManagerBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, keyManager_); - } - unknownFields.writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getKeyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); - } - if (!getKeyManagerBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, keyManager_); - } - 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.Application.Key)) { - return super.equals(obj); - } - org.wso2.apk.enforcer.discovery.subscription.Application.Key other = (org.wso2.apk.enforcer.discovery.subscription.Application.Key) obj; - - if (!getKey() - .equals(other.getKey())) return false; - if (!getKeyManager() - .equals(other.getKeyManager())) 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) + KEY_FIELD_NUMBER; - hash = (53 * hash) + getKey().hashCode(); - hash = (37 * hash) + KEYMANAGER_FIELD_NUMBER; - hash = (53 * hash) + getKeyManager().hashCode(); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static org.wso2.apk.enforcer.discovery.subscription.Application.Key parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.wso2.apk.enforcer.discovery.subscription.Application.Key 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.Application.Key parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.wso2.apk.enforcer.discovery.subscription.Application.Key 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.Application.Key parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static org.wso2.apk.enforcer.discovery.subscription.Application.Key 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.Application.Key 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.Application.Key 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.Application.Key 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.Application.Key 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.Application.Key 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.Application.Key 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.Application.Key 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; - } - /** - * Protobuf type {@code wso2.discovery.subscription.Application.Key} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.Application.Key) - org.wso2.apk.enforcer.discovery.subscription.Application.KeyOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Application_Key_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Application_Key_fieldAccessorTable - .ensureFieldAccessorsInitialized( - org.wso2.apk.enforcer.discovery.subscription.Application.Key.class, org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder.class); - } - - // Construct using org.wso2.apk.enforcer.discovery.subscription.Application.Key.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(); - key_ = ""; - - keyManager_ = ""; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Application_Key_descriptor; - } - - @java.lang.Override - public org.wso2.apk.enforcer.discovery.subscription.Application.Key getDefaultInstanceForType() { - return org.wso2.apk.enforcer.discovery.subscription.Application.Key.getDefaultInstance(); - } - - @java.lang.Override - public org.wso2.apk.enforcer.discovery.subscription.Application.Key build() { - org.wso2.apk.enforcer.discovery.subscription.Application.Key result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public org.wso2.apk.enforcer.discovery.subscription.Application.Key buildPartial() { - org.wso2.apk.enforcer.discovery.subscription.Application.Key result = new org.wso2.apk.enforcer.discovery.subscription.Application.Key(this); - result.key_ = key_; - result.keyManager_ = keyManager_; - 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.Application.Key) { - return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.Application.Key)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.Application.Key other) { - if (other == org.wso2.apk.enforcer.discovery.subscription.Application.Key.getDefaultInstance()) return this; - if (!other.getKey().isEmpty()) { - key_ = other.key_; - onChanged(); - } - if (!other.getKeyManager().isEmpty()) { - keyManager_ = other.keyManager_; - 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.Application.Key parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.Application.Key) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private java.lang.Object key_ = ""; - /** - * string key = 1; - * @return The key. - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - key_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string key = 1; - * @return The bytes for key. - */ - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string key = 1; - * @param value The key to set. - * @return This builder for chaining. - */ - public Builder setKey( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - key_ = value; - onChanged(); - return this; - } - /** - * string key = 1; - * @return This builder for chaining. - */ - public Builder clearKey() { - - key_ = getDefaultInstance().getKey(); - onChanged(); - return this; - } - /** - * string key = 1; - * @param value The bytes for key to set. - * @return This builder for chaining. - */ - public Builder setKeyBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - key_ = value; - onChanged(); - return this; - } - - private java.lang.Object keyManager_ = ""; - /** - * string keyManager = 2; - * @return The keyManager. - */ - public java.lang.String getKeyManager() { - java.lang.Object ref = keyManager_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - keyManager_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string keyManager = 2; - * @return The bytes for keyManager. - */ - public com.google.protobuf.ByteString - getKeyManagerBytes() { - java.lang.Object ref = keyManager_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - keyManager_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string keyManager = 2; - * @param value The keyManager to set. - * @return This builder for chaining. - */ - public Builder setKeyManager( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - keyManager_ = value; - onChanged(); - return this; - } - /** - * string keyManager = 2; - * @return This builder for chaining. - */ - public Builder clearKeyManager() { - - keyManager_ = getDefaultInstance().getKeyManager(); - onChanged(); - return this; - } - /** - * string keyManager = 2; - * @param value The bytes for keyManager to set. - * @return This builder for chaining. - */ - public Builder setKeyManagerBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - keyManager_ = 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.Application.Key) - } - - // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.Application.Key) - private static final org.wso2.apk.enforcer.discovery.subscription.Application.Key DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.Application.Key(); - } - - public static org.wso2.apk.enforcer.discovery.subscription.Application.Key getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public Key parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Key(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.Application.Key getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public static final int EVENTID_FIELD_NUMBER = 1; - private volatile java.lang.Object eventId_; + public static final int UUID_FIELD_NUMBER = 1; + private volatile java.lang.Object uuid_; /** - * string eventId = 1; - * @return The eventId. + * string uuid = 1; + * @return The uuid. */ @java.lang.Override - public java.lang.String getEventId() { - java.lang.Object ref = eventId_; + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; 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; + uuid_ = s; return s; } } /** - * string eventId = 1; - * @return The bytes for eventId. + * string uuid = 1; + * @return The bytes for uuid. */ @java.lang.Override public com.google.protobuf.ByteString - getEventIdBytes() { - java.lang.Object ref = eventId_; + getUuidBytes() { + java.lang.Object ref = uuid_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - eventId_ = b; + uuid_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; @@ -966,48 +207,10 @@ public java.lang.String getName() { } } - public static final int UUID_FIELD_NUMBER = 3; - private volatile java.lang.Object uuid_; - /** - * string uuid = 3; - * @return The uuid. - */ - @java.lang.Override - public java.lang.String getUuid() { - java.lang.Object ref = uuid_; - 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(); - uuid_ = s; - return s; - } - } - /** - * string uuid = 3; - * @return The bytes for uuid. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getUuidBytes() { - java.lang.Object ref = uuid_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - uuid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int OWNER_FIELD_NUMBER = 4; + public static final int OWNER_FIELD_NUMBER = 3; private volatile java.lang.Object owner_; /** - * string owner = 4; + * string owner = 3; * @return The owner. */ @java.lang.Override @@ -1024,7 +227,7 @@ public java.lang.String getOwner() { } } /** - * string owner = 4; + * string owner = 3; * @return The bytes for owner. */ @java.lang.Override @@ -1042,45 +245,7 @@ public java.lang.String getOwner() { } } - public static final int POLICY_FIELD_NUMBER = 5; - private volatile java.lang.Object policy_; - /** - * string policy = 5; - * @return The policy. - */ - @java.lang.Override - public java.lang.String getPolicy() { - java.lang.Object ref = policy_; - 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(); - policy_ = s; - return s; - } - } - /** - * string policy = 5; - * @return The bytes for policy. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getPolicyBytes() { - java.lang.Object ref = policy_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - policy_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ATTRIBUTES_FIELD_NUMBER = 6; + public static final int ATTRIBUTES_FIELD_NUMBER = 4; private static final class AttributesDefaultEntryHolder { static final com.google.protobuf.MapEntry< java.lang.String, java.lang.String> defaultEntry = @@ -1107,174 +272,58 @@ public int getAttributesCount() { return internalGetAttributes().getMap().size(); } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ @java.lang.Override public boolean containsAttributes( java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetAttributes().getMap().containsKey(key); - } - /** - * Use {@link #getAttributesMap()} instead. - */ - @java.lang.Override - @java.lang.Deprecated - public java.util.Map getAttributes() { - return getAttributesMap(); - } - /** - * map<string, string> attributes = 6; - */ - @java.lang.Override - - public java.util.Map getAttributesMap() { - return internalGetAttributes().getMap(); - } - /** - * map<string, string> attributes = 6; - */ - @java.lang.Override - - public java.lang.String getAttributesOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetAttributes().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, string> attributes = 6; - */ - @java.lang.Override - - public java.lang.String getAttributesOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetAttributes().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public static final int KEYS_FIELD_NUMBER = 7; - private java.util.List keys_; - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - @java.lang.Override - public java.util.List getKeysList() { - return keys_; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - @java.lang.Override - public java.util.List - getKeysOrBuilderList() { - return keys_; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - @java.lang.Override - public int getKeysCount() { - return keys_.size(); - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - @java.lang.Override - public org.wso2.apk.enforcer.discovery.subscription.Application.Key getKeys(int index) { - return keys_.get(index); - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - @java.lang.Override - public org.wso2.apk.enforcer.discovery.subscription.Application.KeyOrBuilder getKeysOrBuilder( - int index) { - return keys_.get(index); - } - - public static final int ORGANIZATION_FIELD_NUMBER = 8; - private volatile java.lang.Object organization_; - /** - * string organization = 8; - * @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; - } + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAttributes().getMap().containsKey(key); } /** - * string organization = 8; - * @return The bytes for organization. + * Use {@link #getAttributesMap()} instead. */ @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; - } + @java.lang.Deprecated + public java.util.Map getAttributes() { + return getAttributesMap(); } + /** + * map<string, string> attributes = 4; + */ + @java.lang.Override - public static final int TIMESTAMP_FIELD_NUMBER = 9; - private volatile java.lang.Object timeStamp_; + public java.util.Map getAttributesMap() { + return internalGetAttributes().getMap(); + } /** - * string timeStamp = 9; - * @return The timeStamp. + * map<string, string> attributes = 4; */ @java.lang.Override - public java.lang.String getTimeStamp() { - java.lang.Object ref = timeStamp_; - 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(); - timeStamp_ = s; - return s; - } + + public java.lang.String getAttributesOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAttributes().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; } /** - * string timeStamp = 9; - * @return The bytes for timeStamp. + * map<string, string> attributes = 4; */ @java.lang.Override - public com.google.protobuf.ByteString - getTimeStampBytes() { - java.lang.Object ref = timeStamp_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - timeStamp_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; + + public java.lang.String getAttributesOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAttributes().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); } + return map.get(key); } private byte memoizedIsInitialized = -1; @@ -1291,36 +340,21 @@ public final boolean isInitialized() { @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 (!getUuidBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, uuid_); } if (!getNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); } - if (!getUuidBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, uuid_); - } if (!getOwnerBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, owner_); - } - if (!getPolicyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, policy_); + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, owner_); } com.google.protobuf.GeneratedMessageV3 .serializeStringMapTo( output, internalGetAttributes(), AttributesDefaultEntryHolder.defaultEntry, - 6); - for (int i = 0; i < keys_.size(); i++) { - output.writeMessage(7, keys_.get(i)); - } - if (!getOrganizationBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, organization_); - } - if (!getTimeStampBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 9, timeStamp_); - } + 4); unknownFields.writeTo(output); } @@ -1330,20 +364,14 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!getEventIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, eventId_); + if (!getUuidBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, uuid_); } if (!getNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); } - if (!getUuidBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, uuid_); - } if (!getOwnerBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, owner_); - } - if (!getPolicyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, policy_); + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, owner_); } for (java.util.Map.Entry entry : internalGetAttributes().getMap().entrySet()) { @@ -1353,17 +381,7 @@ public int getSerializedSize() { .setValue(entry.getValue()) .build(); size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, attributes__); - } - for (int i = 0; i < keys_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, keys_.get(i)); - } - if (!getOrganizationBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, organization_); - } - if (!getTimeStampBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, timeStamp_); + .computeMessageSize(4, attributes__); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -1380,24 +398,14 @@ public boolean equals(final java.lang.Object obj) { } org.wso2.apk.enforcer.discovery.subscription.Application other = (org.wso2.apk.enforcer.discovery.subscription.Application) obj; - if (!getEventId() - .equals(other.getEventId())) return false; - if (!getName() - .equals(other.getName())) return false; if (!getUuid() .equals(other.getUuid())) return false; + if (!getName() + .equals(other.getName())) return false; if (!getOwner() .equals(other.getOwner())) return false; - if (!getPolicy() - .equals(other.getPolicy())) return false; if (!internalGetAttributes().equals( other.internalGetAttributes())) return false; - if (!getKeysList() - .equals(other.getKeysList())) return false; - if (!getOrganization() - .equals(other.getOrganization())) return false; - if (!getTimeStamp() - .equals(other.getTimeStamp())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -1409,28 +417,16 @@ public int hashCode() { } 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) + UUID_FIELD_NUMBER; hash = (53 * hash) + getUuid().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + OWNER_FIELD_NUMBER; hash = (53 * hash) + getOwner().hashCode(); - hash = (37 * hash) + POLICY_FIELD_NUMBER; - hash = (53 * hash) + getPolicy().hashCode(); if (!internalGetAttributes().getMap().isEmpty()) { hash = (37 * hash) + ATTRIBUTES_FIELD_NUMBER; hash = (53 * hash) + internalGetAttributes().hashCode(); } - if (getKeysCount() > 0) { - hash = (37 * hash) + KEYS_FIELD_NUMBER; - hash = (53 * hash) + getKeysList().hashCode(); - } - hash = (37 * hash) + ORGANIZATION_FIELD_NUMBER; - hash = (53 * hash) + getOrganization().hashCode(); - hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; - hash = (53 * hash) + getTimeStamp().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1546,7 +542,7 @@ public static final class Builder extends protected com.google.protobuf.MapField internalGetMapField( int number) { switch (number) { - case 6: + case 4: return internalGetAttributes(); default: throw new RuntimeException( @@ -1557,7 +553,7 @@ protected com.google.protobuf.MapField internalGetMapField( protected com.google.protobuf.MapField internalGetMutableMapField( int number) { switch (number) { - case 6: + case 4: return internalGetMutableAttributes(); default: throw new RuntimeException( @@ -1585,33 +581,18 @@ private Builder( private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3 .alwaysUseFieldBuilders) { - getKeysFieldBuilder(); } } @java.lang.Override public Builder clear() { super.clear(); - eventId_ = ""; + uuid_ = ""; name_ = ""; - uuid_ = ""; - owner_ = ""; - policy_ = ""; - internalGetMutableAttributes().clear(); - if (keysBuilder_ == null) { - keys_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - } else { - keysBuilder_.clear(); - } - organization_ = ""; - - timeStamp_ = ""; - return this; } @@ -1639,24 +620,11 @@ public org.wso2.apk.enforcer.discovery.subscription.Application build() { public org.wso2.apk.enforcer.discovery.subscription.Application buildPartial() { org.wso2.apk.enforcer.discovery.subscription.Application result = new org.wso2.apk.enforcer.discovery.subscription.Application(this); int from_bitField0_ = bitField0_; - result.eventId_ = eventId_; - result.name_ = name_; result.uuid_ = uuid_; + result.name_ = name_; result.owner_ = owner_; - result.policy_ = policy_; result.attributes_ = internalGetAttributes(); result.attributes_.makeImmutable(); - if (keysBuilder_ == null) { - if (((bitField0_ & 0x00000002) != 0)) { - keys_ = java.util.Collections.unmodifiableList(keys_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.keys_ = keys_; - } else { - result.keys_ = keysBuilder_.build(); - } - result.organization_ = organization_; - result.timeStamp_ = timeStamp_; onBuilt(); return result; } @@ -1705,62 +673,20 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.Application other) { if (other == org.wso2.apk.enforcer.discovery.subscription.Application.getDefaultInstance()) return this; - if (!other.getEventId().isEmpty()) { - eventId_ = other.eventId_; + if (!other.getUuid().isEmpty()) { + uuid_ = other.uuid_; onChanged(); } if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } - if (!other.getUuid().isEmpty()) { - uuid_ = other.uuid_; - onChanged(); - } if (!other.getOwner().isEmpty()) { owner_ = other.owner_; onChanged(); } - if (!other.getPolicy().isEmpty()) { - policy_ = other.policy_; - onChanged(); - } internalGetMutableAttributes().mergeFrom( other.internalGetAttributes()); - if (keysBuilder_ == null) { - if (!other.keys_.isEmpty()) { - if (keys_.isEmpty()) { - keys_ = other.keys_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureKeysIsMutable(); - keys_.addAll(other.keys_); - } - onChanged(); - } - } else { - if (!other.keys_.isEmpty()) { - if (keysBuilder_.isEmpty()) { - keysBuilder_.dispose(); - keysBuilder_ = null; - keys_ = other.keys_; - bitField0_ = (bitField0_ & ~0x00000002); - keysBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getKeysFieldBuilder() : null; - } else { - keysBuilder_.addAllMessages(other.keys_); - } - } - } - if (!other.getOrganization().isEmpty()) { - organization_ = other.organization_; - onChanged(); - } - if (!other.getTimeStamp().isEmpty()) { - timeStamp_ = other.timeStamp_; - onChanged(); - } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1791,161 +717,9 @@ public Builder mergeFrom( } 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 uuid_ = ""; /** - * string uuid = 3; + * string uuid = 1; * @return The uuid. */ public java.lang.String getUuid() { @@ -1961,7 +735,7 @@ public java.lang.String getUuid() { } } /** - * string uuid = 3; + * string uuid = 1; * @return The bytes for uuid. */ public com.google.protobuf.ByteString @@ -1978,7 +752,7 @@ public java.lang.String getUuid() { } } /** - * string uuid = 3; + * string uuid = 1; * @param value The uuid to set. * @return This builder for chaining. */ @@ -1993,7 +767,7 @@ public Builder setUuid( return this; } /** - * string uuid = 3; + * string uuid = 1; * @return This builder for chaining. */ public Builder clearUuid() { @@ -2003,7 +777,7 @@ public Builder clearUuid() { return this; } /** - * string uuid = 3; + * string uuid = 1; * @param value The bytes for uuid to set. * @return This builder for chaining. */ @@ -2019,154 +793,154 @@ public Builder setUuidBytes( return this; } - private java.lang.Object owner_ = ""; + private java.lang.Object name_ = ""; /** - * string owner = 4; - * @return The owner. + * string name = 2; + * @return The name. */ - public java.lang.String getOwner() { - java.lang.Object ref = owner_; + 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(); - owner_ = s; + name_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string owner = 4; - * @return The bytes for owner. + * string name = 2; + * @return The bytes for name. */ - public com.google.protobuf.ByteString - getOwnerBytes() { - java.lang.Object ref = owner_; + 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); - owner_ = b; + name_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string owner = 4; - * @param value The owner to set. + * string name = 2; + * @param value The name to set. * @return This builder for chaining. */ - public Builder setOwner( + public Builder setName( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - owner_ = value; + name_ = value; onChanged(); return this; } /** - * string owner = 4; + * string name = 2; * @return This builder for chaining. */ - public Builder clearOwner() { + public Builder clearName() { - owner_ = getDefaultInstance().getOwner(); + name_ = getDefaultInstance().getName(); onChanged(); return this; } /** - * string owner = 4; - * @param value The bytes for owner to set. + * string name = 2; + * @param value The bytes for name to set. * @return This builder for chaining. */ - public Builder setOwnerBytes( + public Builder setNameBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - owner_ = value; + name_ = value; onChanged(); return this; } - private java.lang.Object policy_ = ""; + private java.lang.Object owner_ = ""; /** - * string policy = 5; - * @return The policy. + * string owner = 3; + * @return The owner. */ - public java.lang.String getPolicy() { - java.lang.Object ref = policy_; + public java.lang.String getOwner() { + java.lang.Object ref = owner_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - policy_ = s; + owner_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string policy = 5; - * @return The bytes for policy. + * string owner = 3; + * @return The bytes for owner. */ public com.google.protobuf.ByteString - getPolicyBytes() { - java.lang.Object ref = policy_; + getOwnerBytes() { + java.lang.Object ref = owner_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - policy_ = b; + owner_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string policy = 5; - * @param value The policy to set. + * string owner = 3; + * @param value The owner to set. * @return This builder for chaining. */ - public Builder setPolicy( + public Builder setOwner( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - policy_ = value; + owner_ = value; onChanged(); return this; } /** - * string policy = 5; + * string owner = 3; * @return This builder for chaining. */ - public Builder clearPolicy() { + public Builder clearOwner() { - policy_ = getDefaultInstance().getPolicy(); + owner_ = getDefaultInstance().getOwner(); onChanged(); return this; } /** - * string policy = 5; - * @param value The bytes for policy to set. + * string owner = 3; + * @param value The bytes for owner to set. * @return This builder for chaining. */ - public Builder setPolicyBytes( + public Builder setOwnerBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - policy_ = value; + owner_ = value; onChanged(); return this; } @@ -2198,7 +972,7 @@ public int getAttributesCount() { return internalGetAttributes().getMap().size(); } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ @java.lang.Override @@ -2216,7 +990,7 @@ public java.util.Map getAttributes() { return getAttributesMap(); } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ @java.lang.Override @@ -2224,7 +998,7 @@ public java.util.Map getAttributesMap() { return internalGetAttributes().getMap(); } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ @java.lang.Override @@ -2237,7 +1011,7 @@ public java.lang.String getAttributesOrDefault( return map.containsKey(key) ? map.get(key) : defaultValue; } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ @java.lang.Override @@ -2258,7 +1032,7 @@ public Builder clearAttributes() { return this; } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ public Builder removeAttributes( @@ -2277,7 +1051,7 @@ public Builder removeAttributes( return internalGetMutableAttributes().getMutableMap(); } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ public Builder putAttributes( java.lang.String key, @@ -2289,7 +1063,7 @@ public Builder putAttributes( return this; } /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ public Builder putAllAttributes( @@ -2298,398 +1072,6 @@ public Builder putAllAttributes( .putAll(values); return this; } - - private java.util.List keys_ = - java.util.Collections.emptyList(); - private void ensureKeysIsMutable() { - if (!((bitField0_ & 0x00000002) != 0)) { - keys_ = new java.util.ArrayList(keys_); - bitField0_ |= 0x00000002; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - org.wso2.apk.enforcer.discovery.subscription.Application.Key, org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder, org.wso2.apk.enforcer.discovery.subscription.Application.KeyOrBuilder> keysBuilder_; - - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public java.util.List getKeysList() { - if (keysBuilder_ == null) { - return java.util.Collections.unmodifiableList(keys_); - } else { - return keysBuilder_.getMessageList(); - } - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public int getKeysCount() { - if (keysBuilder_ == null) { - return keys_.size(); - } else { - return keysBuilder_.getCount(); - } - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public org.wso2.apk.enforcer.discovery.subscription.Application.Key getKeys(int index) { - if (keysBuilder_ == null) { - return keys_.get(index); - } else { - return keysBuilder_.getMessage(index); - } - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder setKeys( - int index, org.wso2.apk.enforcer.discovery.subscription.Application.Key value) { - if (keysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureKeysIsMutable(); - keys_.set(index, value); - onChanged(); - } else { - keysBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder setKeys( - int index, org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder builderForValue) { - if (keysBuilder_ == null) { - ensureKeysIsMutable(); - keys_.set(index, builderForValue.build()); - onChanged(); - } else { - keysBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder addKeys(org.wso2.apk.enforcer.discovery.subscription.Application.Key value) { - if (keysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureKeysIsMutable(); - keys_.add(value); - onChanged(); - } else { - keysBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder addKeys( - int index, org.wso2.apk.enforcer.discovery.subscription.Application.Key value) { - if (keysBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureKeysIsMutable(); - keys_.add(index, value); - onChanged(); - } else { - keysBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder addKeys( - org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder builderForValue) { - if (keysBuilder_ == null) { - ensureKeysIsMutable(); - keys_.add(builderForValue.build()); - onChanged(); - } else { - keysBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder addKeys( - int index, org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder builderForValue) { - if (keysBuilder_ == null) { - ensureKeysIsMutable(); - keys_.add(index, builderForValue.build()); - onChanged(); - } else { - keysBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder addAllKeys( - java.lang.Iterable values) { - if (keysBuilder_ == null) { - ensureKeysIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, keys_); - onChanged(); - } else { - keysBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder clearKeys() { - if (keysBuilder_ == null) { - keys_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - } else { - keysBuilder_.clear(); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public Builder removeKeys(int index) { - if (keysBuilder_ == null) { - ensureKeysIsMutable(); - keys_.remove(index); - onChanged(); - } else { - keysBuilder_.remove(index); - } - return this; - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder getKeysBuilder( - int index) { - return getKeysFieldBuilder().getBuilder(index); - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public org.wso2.apk.enforcer.discovery.subscription.Application.KeyOrBuilder getKeysOrBuilder( - int index) { - if (keysBuilder_ == null) { - return keys_.get(index); } else { - return keysBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public java.util.List - getKeysOrBuilderList() { - if (keysBuilder_ != null) { - return keysBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(keys_); - } - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder addKeysBuilder() { - return getKeysFieldBuilder().addBuilder( - org.wso2.apk.enforcer.discovery.subscription.Application.Key.getDefaultInstance()); - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder addKeysBuilder( - int index) { - return getKeysFieldBuilder().addBuilder( - index, org.wso2.apk.enforcer.discovery.subscription.Application.Key.getDefaultInstance()); - } - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - public java.util.List - getKeysBuilderList() { - return getKeysFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilderV3< - org.wso2.apk.enforcer.discovery.subscription.Application.Key, org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder, org.wso2.apk.enforcer.discovery.subscription.Application.KeyOrBuilder> - getKeysFieldBuilder() { - if (keysBuilder_ == null) { - keysBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - org.wso2.apk.enforcer.discovery.subscription.Application.Key, org.wso2.apk.enforcer.discovery.subscription.Application.Key.Builder, org.wso2.apk.enforcer.discovery.subscription.Application.KeyOrBuilder>( - keys_, - ((bitField0_ & 0x00000002) != 0), - getParentForChildren(), - isClean()); - keys_ = null; - } - return keysBuilder_; - } - - private java.lang.Object organization_ = ""; - /** - * string organization = 8; - * @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 = 8; - * @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 = 8; - * @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 = 8; - * @return This builder for chaining. - */ - public Builder clearOrganization() { - - organization_ = getDefaultInstance().getOrganization(); - onChanged(); - return this; - } - /** - * string organization = 8; - * @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 timeStamp_ = ""; - /** - * string timeStamp = 9; - * @return The timeStamp. - */ - public java.lang.String getTimeStamp() { - java.lang.Object ref = timeStamp_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - timeStamp_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string timeStamp = 9; - * @return The bytes for timeStamp. - */ - public com.google.protobuf.ByteString - getTimeStampBytes() { - java.lang.Object ref = timeStamp_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - timeStamp_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string timeStamp = 9; - * @param value The timeStamp to set. - * @return This builder for chaining. - */ - public Builder setTimeStamp( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - timeStamp_ = value; - onChanged(); - return this; - } - /** - * string timeStamp = 9; - * @return This builder for chaining. - */ - public Builder clearTimeStamp() { - - timeStamp_ = getDefaultInstance().getTimeStamp(); - onChanged(); - return this; - } - /** - * string timeStamp = 9; - * @param value The bytes for timeStamp to set. - * @return This builder for chaining. - */ - public Builder setTimeStampBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - timeStamp_ = value; - onChanged(); - return this; - } @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/ApplicationKeyMapping.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMapping.java index f8d6568d5..1cc9000a2 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMapping.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMapping.java @@ -20,11 +20,11 @@ private ApplicationKeyMapping(com.google.protobuf.GeneratedMessageV3.Builder super(builder); } private ApplicationKeyMapping() { - consumerKey_ = ""; - keyType_ = ""; - keyManager_ = ""; - tenantDomain_ = ""; applicationUUID_ = ""; + securityScheme_ = ""; + applicationIdentifier_ = ""; + keyType_ = ""; + envID_ = ""; } @java.lang.Override @@ -60,48 +60,38 @@ private ApplicationKeyMapping( case 10: { java.lang.String s = input.readStringRequireUtf8(); - consumerKey_ = s; + applicationUUID_ = s; break; } case 18: { java.lang.String s = input.readStringRequireUtf8(); - keyType_ = s; + securityScheme_ = s; break; } case 26: { java.lang.String s = input.readStringRequireUtf8(); - keyManager_ = s; + applicationIdentifier_ = s; break; } - case 32: { - - applicationId_ = input.readInt32(); - break; - } - case 40: { + case 34: { + java.lang.String s = input.readStringRequireUtf8(); - tenantId_ = input.readInt32(); + keyType_ = s; break; } - case 50: { + case 42: { java.lang.String s = input.readStringRequireUtf8(); - tenantDomain_ = s; + envID_ = s; break; } - case 56: { + case 48: { timestamp_ = input.readInt64(); break; } - case 66: { - java.lang.String s = input.readStringRequireUtf8(); - - applicationUUID_ = s; - break; - } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -134,229 +124,207 @@ private ApplicationKeyMapping( org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping.class, org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping.Builder.class); } - public static final int CONSUMERKEY_FIELD_NUMBER = 1; - private volatile java.lang.Object consumerKey_; + public static final int APPLICATIONUUID_FIELD_NUMBER = 1; + private volatile java.lang.Object applicationUUID_; /** - * string consumerKey = 1; - * @return The consumerKey. + * string applicationUUID = 1; + * @return The applicationUUID. */ @java.lang.Override - public java.lang.String getConsumerKey() { - java.lang.Object ref = consumerKey_; + public java.lang.String getApplicationUUID() { + java.lang.Object ref = applicationUUID_; 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(); - consumerKey_ = s; + applicationUUID_ = s; return s; } } /** - * string consumerKey = 1; - * @return The bytes for consumerKey. + * string applicationUUID = 1; + * @return The bytes for applicationUUID. */ @java.lang.Override public com.google.protobuf.ByteString - getConsumerKeyBytes() { - java.lang.Object ref = consumerKey_; + getApplicationUUIDBytes() { + java.lang.Object ref = applicationUUID_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - consumerKey_ = b; + applicationUUID_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } - public static final int KEYTYPE_FIELD_NUMBER = 2; - private volatile java.lang.Object keyType_; + public static final int SECURITYSCHEME_FIELD_NUMBER = 2; + private volatile java.lang.Object securityScheme_; /** - * string keyType = 2; - * @return The keyType. + * string securityScheme = 2; + * @return The securityScheme. */ @java.lang.Override - public java.lang.String getKeyType() { - java.lang.Object ref = keyType_; + public java.lang.String getSecurityScheme() { + java.lang.Object ref = securityScheme_; 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(); - keyType_ = s; + securityScheme_ = s; return s; } } /** - * string keyType = 2; - * @return The bytes for keyType. + * string securityScheme = 2; + * @return The bytes for securityScheme. */ @java.lang.Override public com.google.protobuf.ByteString - getKeyTypeBytes() { - java.lang.Object ref = keyType_; + getSecuritySchemeBytes() { + java.lang.Object ref = securityScheme_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - keyType_ = b; + securityScheme_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } - public static final int KEYMANAGER_FIELD_NUMBER = 3; - private volatile java.lang.Object keyManager_; + public static final int APPLICATIONIDENTIFIER_FIELD_NUMBER = 3; + private volatile java.lang.Object applicationIdentifier_; /** - * string keyManager = 3; - * @return The keyManager. + * string applicationIdentifier = 3; + * @return The applicationIdentifier. */ @java.lang.Override - public java.lang.String getKeyManager() { - java.lang.Object ref = keyManager_; + public java.lang.String getApplicationIdentifier() { + java.lang.Object ref = applicationIdentifier_; 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(); - keyManager_ = s; + applicationIdentifier_ = s; return s; } } /** - * string keyManager = 3; - * @return The bytes for keyManager. + * string applicationIdentifier = 3; + * @return The bytes for applicationIdentifier. */ @java.lang.Override public com.google.protobuf.ByteString - getKeyManagerBytes() { - java.lang.Object ref = keyManager_; + getApplicationIdentifierBytes() { + java.lang.Object ref = applicationIdentifier_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - keyManager_ = b; + applicationIdentifier_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } - public static final int APPLICATIONID_FIELD_NUMBER = 4; - private int applicationId_; - /** - * int32 applicationId = 4; - * @return The applicationId. - */ - @java.lang.Override - public int getApplicationId() { - return applicationId_; - } - - public static final int TENANTID_FIELD_NUMBER = 5; - private int tenantId_; - /** - * int32 tenantId = 5; - * @return The tenantId. - */ - @java.lang.Override - public int getTenantId() { - return tenantId_; - } - - public static final int TENANTDOMAIN_FIELD_NUMBER = 6; - private volatile java.lang.Object tenantDomain_; + public static final int KEYTYPE_FIELD_NUMBER = 4; + private volatile java.lang.Object keyType_; /** - * string tenantDomain = 6; - * @return The tenantDomain. + * string keyType = 4; + * @return The keyType. */ @java.lang.Override - public java.lang.String getTenantDomain() { - java.lang.Object ref = tenantDomain_; + public java.lang.String getKeyType() { + java.lang.Object ref = keyType_; 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(); - tenantDomain_ = s; + keyType_ = s; return s; } } /** - * string tenantDomain = 6; - * @return The bytes for tenantDomain. + * string keyType = 4; + * @return The bytes for keyType. */ @java.lang.Override public com.google.protobuf.ByteString - getTenantDomainBytes() { - java.lang.Object ref = tenantDomain_; + getKeyTypeBytes() { + java.lang.Object ref = keyType_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - tenantDomain_ = b; + keyType_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } - public static final int TIMESTAMP_FIELD_NUMBER = 7; - private long timestamp_; + public static final int ENVID_FIELD_NUMBER = 5; + private volatile java.lang.Object envID_; /** - * int64 timestamp = 7; - * @return The timestamp. + * string envID = 5; + * @return The envID. */ @java.lang.Override - public long getTimestamp() { - return timestamp_; - } - - public static final int APPLICATIONUUID_FIELD_NUMBER = 8; - private volatile java.lang.Object applicationUUID_; - /** - * string applicationUUID = 8; - * @return The applicationUUID. - */ - @java.lang.Override - public java.lang.String getApplicationUUID() { - java.lang.Object ref = applicationUUID_; + public java.lang.String getEnvID() { + java.lang.Object ref = envID_; 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(); - applicationUUID_ = s; + envID_ = s; return s; } } /** - * string applicationUUID = 8; - * @return The bytes for applicationUUID. + * string envID = 5; + * @return The bytes for envID. */ @java.lang.Override public com.google.protobuf.ByteString - getApplicationUUIDBytes() { - java.lang.Object ref = applicationUUID_; + getEnvIDBytes() { + java.lang.Object ref = envID_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - applicationUUID_ = b; + envID_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } + public static final int TIMESTAMP_FIELD_NUMBER = 6; + private long timestamp_; + /** + * int64 timestamp = 6; + * @return The timestamp. + */ + @java.lang.Override + public long getTimestamp() { + return timestamp_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -371,29 +339,23 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!getConsumerKeyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, consumerKey_); - } - if (!getKeyTypeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, keyType_); + if (!getApplicationUUIDBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, applicationUUID_); } - if (!getKeyManagerBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, keyManager_); + if (!getSecuritySchemeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, securityScheme_); } - if (applicationId_ != 0) { - output.writeInt32(4, applicationId_); + if (!getApplicationIdentifierBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, applicationIdentifier_); } - if (tenantId_ != 0) { - output.writeInt32(5, tenantId_); + if (!getKeyTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, keyType_); } - if (!getTenantDomainBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, tenantDomain_); + if (!getEnvIDBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, envID_); } if (timestamp_ != 0L) { - output.writeInt64(7, timestamp_); - } - if (!getApplicationUUIDBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, applicationUUID_); + output.writeInt64(6, timestamp_); } unknownFields.writeTo(output); } @@ -404,32 +366,24 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!getConsumerKeyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, consumerKey_); - } - if (!getKeyTypeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, keyType_); + if (!getApplicationUUIDBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, applicationUUID_); } - if (!getKeyManagerBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, keyManager_); + if (!getSecuritySchemeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, securityScheme_); } - if (applicationId_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(4, applicationId_); + if (!getApplicationIdentifierBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, applicationIdentifier_); } - if (tenantId_ != 0) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(5, tenantId_); + if (!getKeyTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, keyType_); } - if (!getTenantDomainBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, tenantDomain_); + if (!getEnvIDBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, envID_); } if (timestamp_ != 0L) { size += com.google.protobuf.CodedOutputStream - .computeInt64Size(7, timestamp_); - } - if (!getApplicationUUIDBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, applicationUUID_); + .computeInt64Size(6, timestamp_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -446,22 +400,18 @@ public boolean equals(final java.lang.Object obj) { } org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping other = (org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping) obj; - if (!getConsumerKey() - .equals(other.getConsumerKey())) return false; + if (!getApplicationUUID() + .equals(other.getApplicationUUID())) return false; + if (!getSecurityScheme() + .equals(other.getSecurityScheme())) return false; + if (!getApplicationIdentifier() + .equals(other.getApplicationIdentifier())) return false; if (!getKeyType() .equals(other.getKeyType())) return false; - if (!getKeyManager() - .equals(other.getKeyManager())) return false; - if (getApplicationId() - != other.getApplicationId()) return false; - if (getTenantId() - != other.getTenantId()) return false; - if (!getTenantDomain() - .equals(other.getTenantDomain())) return false; + if (!getEnvID() + .equals(other.getEnvID())) return false; if (getTimestamp() != other.getTimestamp()) return false; - if (!getApplicationUUID() - .equals(other.getApplicationUUID())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -473,23 +423,19 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + CONSUMERKEY_FIELD_NUMBER; - hash = (53 * hash) + getConsumerKey().hashCode(); + hash = (37 * hash) + APPLICATIONUUID_FIELD_NUMBER; + hash = (53 * hash) + getApplicationUUID().hashCode(); + hash = (37 * hash) + SECURITYSCHEME_FIELD_NUMBER; + hash = (53 * hash) + getSecurityScheme().hashCode(); + hash = (37 * hash) + APPLICATIONIDENTIFIER_FIELD_NUMBER; + hash = (53 * hash) + getApplicationIdentifier().hashCode(); hash = (37 * hash) + KEYTYPE_FIELD_NUMBER; hash = (53 * hash) + getKeyType().hashCode(); - hash = (37 * hash) + KEYMANAGER_FIELD_NUMBER; - hash = (53 * hash) + getKeyManager().hashCode(); - hash = (37 * hash) + APPLICATIONID_FIELD_NUMBER; - hash = (53 * hash) + getApplicationId(); - hash = (37 * hash) + TENANTID_FIELD_NUMBER; - hash = (53 * hash) + getTenantId(); - hash = (37 * hash) + TENANTDOMAIN_FIELD_NUMBER; - hash = (53 * hash) + getTenantDomain().hashCode(); + hash = (37 * hash) + ENVID_FIELD_NUMBER; + hash = (53 * hash) + getEnvID().hashCode(); hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getTimestamp()); - hash = (37 * hash) + APPLICATIONUUID_FIELD_NUMBER; - hash = (53 * hash) + getApplicationUUID().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -627,22 +573,18 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - consumerKey_ = ""; - - keyType_ = ""; + applicationUUID_ = ""; - keyManager_ = ""; + securityScheme_ = ""; - applicationId_ = 0; + applicationIdentifier_ = ""; - tenantId_ = 0; + keyType_ = ""; - tenantDomain_ = ""; + envID_ = ""; timestamp_ = 0L; - applicationUUID_ = ""; - return this; } @@ -669,14 +611,12 @@ public org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping build( @java.lang.Override public org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping buildPartial() { org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping result = new org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping(this); - result.consumerKey_ = consumerKey_; + result.applicationUUID_ = applicationUUID_; + result.securityScheme_ = securityScheme_; + result.applicationIdentifier_ = applicationIdentifier_; result.keyType_ = keyType_; - result.keyManager_ = keyManager_; - result.applicationId_ = applicationId_; - result.tenantId_ = tenantId_; - result.tenantDomain_ = tenantDomain_; + result.envID_ = envID_; result.timestamp_ = timestamp_; - result.applicationUUID_ = applicationUUID_; onBuilt(); return result; } @@ -725,35 +665,29 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping other) { if (other == org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping.getDefaultInstance()) return this; - if (!other.getConsumerKey().isEmpty()) { - consumerKey_ = other.consumerKey_; + if (!other.getApplicationUUID().isEmpty()) { + applicationUUID_ = other.applicationUUID_; onChanged(); } - if (!other.getKeyType().isEmpty()) { - keyType_ = other.keyType_; + if (!other.getSecurityScheme().isEmpty()) { + securityScheme_ = other.securityScheme_; onChanged(); } - if (!other.getKeyManager().isEmpty()) { - keyManager_ = other.keyManager_; + if (!other.getApplicationIdentifier().isEmpty()) { + applicationIdentifier_ = other.applicationIdentifier_; onChanged(); } - if (other.getApplicationId() != 0) { - setApplicationId(other.getApplicationId()); - } - if (other.getTenantId() != 0) { - setTenantId(other.getTenantId()); + if (!other.getKeyType().isEmpty()) { + keyType_ = other.keyType_; + onChanged(); } - if (!other.getTenantDomain().isEmpty()) { - tenantDomain_ = other.tenantDomain_; + if (!other.getEnvID().isEmpty()) { + envID_ = other.envID_; onChanged(); } if (other.getTimestamp() != 0L) { setTimestamp(other.getTimestamp()); } - if (!other.getApplicationUUID().isEmpty()) { - applicationUUID_ = other.applicationUUID_; - onChanged(); - } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -783,375 +717,389 @@ public Builder mergeFrom( return this; } - private java.lang.Object consumerKey_ = ""; + private java.lang.Object applicationUUID_ = ""; /** - * string consumerKey = 1; - * @return The consumerKey. + * string applicationUUID = 1; + * @return The applicationUUID. */ - public java.lang.String getConsumerKey() { - java.lang.Object ref = consumerKey_; + public java.lang.String getApplicationUUID() { + java.lang.Object ref = applicationUUID_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - consumerKey_ = s; + applicationUUID_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string consumerKey = 1; - * @return The bytes for consumerKey. + * string applicationUUID = 1; + * @return The bytes for applicationUUID. */ public com.google.protobuf.ByteString - getConsumerKeyBytes() { - java.lang.Object ref = consumerKey_; + getApplicationUUIDBytes() { + java.lang.Object ref = applicationUUID_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - consumerKey_ = b; + applicationUUID_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string consumerKey = 1; - * @param value The consumerKey to set. + * string applicationUUID = 1; + * @param value The applicationUUID to set. * @return This builder for chaining. */ - public Builder setConsumerKey( + public Builder setApplicationUUID( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - consumerKey_ = value; + applicationUUID_ = value; onChanged(); return this; } /** - * string consumerKey = 1; + * string applicationUUID = 1; * @return This builder for chaining. */ - public Builder clearConsumerKey() { + public Builder clearApplicationUUID() { - consumerKey_ = getDefaultInstance().getConsumerKey(); + applicationUUID_ = getDefaultInstance().getApplicationUUID(); onChanged(); return this; } /** - * string consumerKey = 1; - * @param value The bytes for consumerKey to set. + * string applicationUUID = 1; + * @param value The bytes for applicationUUID to set. * @return This builder for chaining. */ - public Builder setConsumerKeyBytes( + public Builder setApplicationUUIDBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - consumerKey_ = value; + applicationUUID_ = value; onChanged(); return this; } - private java.lang.Object keyType_ = ""; + private java.lang.Object securityScheme_ = ""; /** - * string keyType = 2; - * @return The keyType. + * string securityScheme = 2; + * @return The securityScheme. */ - public java.lang.String getKeyType() { - java.lang.Object ref = keyType_; + public java.lang.String getSecurityScheme() { + java.lang.Object ref = securityScheme_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - keyType_ = s; + securityScheme_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string keyType = 2; - * @return The bytes for keyType. + * string securityScheme = 2; + * @return The bytes for securityScheme. */ public com.google.protobuf.ByteString - getKeyTypeBytes() { - java.lang.Object ref = keyType_; + getSecuritySchemeBytes() { + java.lang.Object ref = securityScheme_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - keyType_ = b; + securityScheme_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string keyType = 2; - * @param value The keyType to set. + * string securityScheme = 2; + * @param value The securityScheme to set. * @return This builder for chaining. */ - public Builder setKeyType( + public Builder setSecurityScheme( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - keyType_ = value; + securityScheme_ = value; onChanged(); return this; } /** - * string keyType = 2; + * string securityScheme = 2; * @return This builder for chaining. */ - public Builder clearKeyType() { + public Builder clearSecurityScheme() { - keyType_ = getDefaultInstance().getKeyType(); + securityScheme_ = getDefaultInstance().getSecurityScheme(); onChanged(); return this; } /** - * string keyType = 2; - * @param value The bytes for keyType to set. + * string securityScheme = 2; + * @param value The bytes for securityScheme to set. * @return This builder for chaining. */ - public Builder setKeyTypeBytes( + public Builder setSecuritySchemeBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - keyType_ = value; + securityScheme_ = value; onChanged(); return this; } - private java.lang.Object keyManager_ = ""; + private java.lang.Object applicationIdentifier_ = ""; /** - * string keyManager = 3; - * @return The keyManager. + * string applicationIdentifier = 3; + * @return The applicationIdentifier. */ - public java.lang.String getKeyManager() { - java.lang.Object ref = keyManager_; + public java.lang.String getApplicationIdentifier() { + java.lang.Object ref = applicationIdentifier_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - keyManager_ = s; + applicationIdentifier_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string keyManager = 3; - * @return The bytes for keyManager. + * string applicationIdentifier = 3; + * @return The bytes for applicationIdentifier. */ public com.google.protobuf.ByteString - getKeyManagerBytes() { - java.lang.Object ref = keyManager_; + getApplicationIdentifierBytes() { + java.lang.Object ref = applicationIdentifier_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - keyManager_ = b; + applicationIdentifier_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string keyManager = 3; - * @param value The keyManager to set. + * string applicationIdentifier = 3; + * @param value The applicationIdentifier to set. * @return This builder for chaining. */ - public Builder setKeyManager( + public Builder setApplicationIdentifier( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - keyManager_ = value; + applicationIdentifier_ = value; onChanged(); return this; } /** - * string keyManager = 3; + * string applicationIdentifier = 3; * @return This builder for chaining. */ - public Builder clearKeyManager() { + public Builder clearApplicationIdentifier() { - keyManager_ = getDefaultInstance().getKeyManager(); + applicationIdentifier_ = getDefaultInstance().getApplicationIdentifier(); onChanged(); return this; } /** - * string keyManager = 3; - * @param value The bytes for keyManager to set. + * string applicationIdentifier = 3; + * @param value The bytes for applicationIdentifier to set. * @return This builder for chaining. */ - public Builder setKeyManagerBytes( + public Builder setApplicationIdentifierBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - keyManager_ = value; + applicationIdentifier_ = value; onChanged(); return this; } - private int applicationId_ ; + private java.lang.Object keyType_ = ""; /** - * int32 applicationId = 4; - * @return The applicationId. + * string keyType = 4; + * @return The keyType. */ - @java.lang.Override - public int getApplicationId() { - return applicationId_; + public java.lang.String getKeyType() { + java.lang.Object ref = keyType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + keyType_ = s; + return s; + } else { + return (java.lang.String) ref; + } } /** - * int32 applicationId = 4; - * @param value The applicationId to set. - * @return This builder for chaining. + * string keyType = 4; + * @return The bytes for keyType. */ - public Builder setApplicationId(int value) { - - applicationId_ = value; - onChanged(); - return this; + public com.google.protobuf.ByteString + getKeyTypeBytes() { + java.lang.Object ref = keyType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + keyType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } /** - * int32 applicationId = 4; + * string keyType = 4; + * @param value The keyType to set. * @return This builder for chaining. */ - public Builder clearApplicationId() { - - applicationId_ = 0; + public Builder setKeyType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + keyType_ = value; onChanged(); return this; } - - private int tenantId_ ; /** - * int32 tenantId = 5; - * @return The tenantId. - */ - @java.lang.Override - public int getTenantId() { - return tenantId_; - } - /** - * int32 tenantId = 5; - * @param value The tenantId to set. + * string keyType = 4; * @return This builder for chaining. */ - public Builder setTenantId(int value) { + public Builder clearKeyType() { - tenantId_ = value; + keyType_ = getDefaultInstance().getKeyType(); onChanged(); return this; } /** - * int32 tenantId = 5; + * string keyType = 4; + * @param value The bytes for keyType to set. * @return This builder for chaining. */ - public Builder clearTenantId() { + public Builder setKeyTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); - tenantId_ = 0; + keyType_ = value; onChanged(); return this; } - private java.lang.Object tenantDomain_ = ""; + private java.lang.Object envID_ = ""; /** - * string tenantDomain = 6; - * @return The tenantDomain. + * string envID = 5; + * @return The envID. */ - public java.lang.String getTenantDomain() { - java.lang.Object ref = tenantDomain_; + public java.lang.String getEnvID() { + java.lang.Object ref = envID_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - tenantDomain_ = s; + envID_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string tenantDomain = 6; - * @return The bytes for tenantDomain. + * string envID = 5; + * @return The bytes for envID. */ public com.google.protobuf.ByteString - getTenantDomainBytes() { - java.lang.Object ref = tenantDomain_; + getEnvIDBytes() { + java.lang.Object ref = envID_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - tenantDomain_ = b; + envID_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string tenantDomain = 6; - * @param value The tenantDomain to set. + * string envID = 5; + * @param value The envID to set. * @return This builder for chaining. */ - public Builder setTenantDomain( + public Builder setEnvID( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - tenantDomain_ = value; + envID_ = value; onChanged(); return this; } /** - * string tenantDomain = 6; + * string envID = 5; * @return This builder for chaining. */ - public Builder clearTenantDomain() { + public Builder clearEnvID() { - tenantDomain_ = getDefaultInstance().getTenantDomain(); + envID_ = getDefaultInstance().getEnvID(); onChanged(); return this; } /** - * string tenantDomain = 6; - * @param value The bytes for tenantDomain to set. + * string envID = 5; + * @param value The bytes for envID to set. * @return This builder for chaining. */ - public Builder setTenantDomainBytes( + public Builder setEnvIDBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - tenantDomain_ = value; + envID_ = value; onChanged(); return this; } private long timestamp_ ; /** - * int64 timestamp = 7; + * int64 timestamp = 6; * @return The timestamp. */ @java.lang.Override @@ -1159,7 +1107,7 @@ public long getTimestamp() { return timestamp_; } /** - * int64 timestamp = 7; + * int64 timestamp = 6; * @param value The timestamp to set. * @return This builder for chaining. */ @@ -1170,7 +1118,7 @@ public Builder setTimestamp(long value) { return this; } /** - * int64 timestamp = 7; + * int64 timestamp = 6; * @return This builder for chaining. */ public Builder clearTimestamp() { @@ -1179,82 +1127,6 @@ public Builder clearTimestamp() { onChanged(); return this; } - - private java.lang.Object applicationUUID_ = ""; - /** - * string applicationUUID = 8; - * @return The applicationUUID. - */ - public java.lang.String getApplicationUUID() { - java.lang.Object ref = applicationUUID_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - applicationUUID_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string applicationUUID = 8; - * @return The bytes for applicationUUID. - */ - public com.google.protobuf.ByteString - getApplicationUUIDBytes() { - java.lang.Object ref = applicationUUID_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - applicationUUID_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string applicationUUID = 8; - * @param value The applicationUUID to set. - * @return This builder for chaining. - */ - public Builder setApplicationUUID( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - applicationUUID_ = value; - onChanged(); - return this; - } - /** - * string applicationUUID = 8; - * @return This builder for chaining. - */ - public Builder clearApplicationUUID() { - - applicationUUID_ = getDefaultInstance().getApplicationUUID(); - onChanged(); - return this; - } - /** - * string applicationUUID = 8; - * @param value The bytes for applicationUUID to set. - * @return This builder for chaining. - */ - public Builder setApplicationUUIDBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - applicationUUID_ = value; - onChanged(); - return this; - } @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/ApplicationKeyMappingOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingOrBuilder.java index f9da898d4..9f9d38302 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingOrBuilder.java @@ -8,80 +8,68 @@ public interface ApplicationKeyMappingOrBuilder extends com.google.protobuf.MessageOrBuilder { /** - * string consumerKey = 1; - * @return The consumerKey. + * string applicationUUID = 1; + * @return The applicationUUID. */ - java.lang.String getConsumerKey(); + java.lang.String getApplicationUUID(); /** - * string consumerKey = 1; - * @return The bytes for consumerKey. + * string applicationUUID = 1; + * @return The bytes for applicationUUID. */ com.google.protobuf.ByteString - getConsumerKeyBytes(); + getApplicationUUIDBytes(); /** - * string keyType = 2; - * @return The keyType. + * string securityScheme = 2; + * @return The securityScheme. */ - java.lang.String getKeyType(); + java.lang.String getSecurityScheme(); /** - * string keyType = 2; - * @return The bytes for keyType. + * string securityScheme = 2; + * @return The bytes for securityScheme. */ com.google.protobuf.ByteString - getKeyTypeBytes(); + getSecuritySchemeBytes(); /** - * string keyManager = 3; - * @return The keyManager. + * string applicationIdentifier = 3; + * @return The applicationIdentifier. */ - java.lang.String getKeyManager(); + java.lang.String getApplicationIdentifier(); /** - * string keyManager = 3; - * @return The bytes for keyManager. + * string applicationIdentifier = 3; + * @return The bytes for applicationIdentifier. */ com.google.protobuf.ByteString - getKeyManagerBytes(); + getApplicationIdentifierBytes(); /** - * int32 applicationId = 4; - * @return The applicationId. + * string keyType = 4; + * @return The keyType. */ - int getApplicationId(); - + java.lang.String getKeyType(); /** - * int32 tenantId = 5; - * @return The tenantId. + * string keyType = 4; + * @return The bytes for keyType. */ - int getTenantId(); + com.google.protobuf.ByteString + getKeyTypeBytes(); /** - * string tenantDomain = 6; - * @return The tenantDomain. + * string envID = 5; + * @return The envID. */ - java.lang.String getTenantDomain(); + java.lang.String getEnvID(); /** - * string tenantDomain = 6; - * @return The bytes for tenantDomain. + * string envID = 5; + * @return The bytes for envID. */ com.google.protobuf.ByteString - getTenantDomainBytes(); + getEnvIDBytes(); /** - * int64 timestamp = 7; + * int64 timestamp = 6; * @return The timestamp. */ long getTimestamp(); - - /** - * string applicationUUID = 8; - * @return The applicationUUID. - */ - java.lang.String getApplicationUUID(); - /** - * string applicationUUID = 8; - * @return The bytes for applicationUUID. - */ - com.google.protobuf.ByteString - getApplicationUUIDBytes(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingProto.java index 112373254..712e3f083 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationKeyMappingProto.java @@ -30,16 +30,15 @@ public static void registerAllExtensions( java.lang.String[] descriptorData = { "\n9wso2/discovery/subscription/applicatio" + "n_key_mapping.proto\022\033wso2.discovery.subs" + - "cription\"\274\001\n\025ApplicationKeyMapping\022\023\n\013co" + - "nsumerKey\030\001 \001(\t\022\017\n\007keyType\030\002 \001(\t\022\022\n\nkeyM" + - "anager\030\003 \001(\t\022\025\n\rapplicationId\030\004 \001(\005\022\020\n\010t" + - "enantId\030\005 \001(\005\022\024\n\014tenantDomain\030\006 \001(\t\022\021\n\tt" + - "imestamp\030\007 \001(\003\022\027\n\017applicationUUID\030\010 \001(\tB" + - "\235\001\n,org.wso2.apk.enforcer.discovery.subs" + - "criptionB\032ApplicationKeyMappingProtoP\001ZO" + - "github.com/envoyproxy/go-control-plane/w" + - "so2/discovery/subscription;subscriptionb" + - "\006proto3" + "cription\"\232\001\n\025ApplicationKeyMapping\022\027\n\017ap" + + "plicationUUID\030\001 \001(\t\022\026\n\016securityScheme\030\002 " + + "\001(\t\022\035\n\025applicationIdentifier\030\003 \001(\t\022\017\n\007ke" + + "yType\030\004 \001(\t\022\r\n\005envID\030\005 \001(\t\022\021\n\ttimestamp\030" + + "\006 \001(\003B\235\001\n,org.wso2.apk.enforcer.discover" + + "y.subscriptionB\032ApplicationKeyMappingPro" + + "toP\001ZOgithub.com/envoyproxy/go-control-p" + + "lane/wso2/discovery/subscription;subscri" + + "ptionb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -50,7 +49,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_subscription_ApplicationKeyMapping_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_subscription_ApplicationKeyMapping_descriptor, - new java.lang.String[] { "ConsumerKey", "KeyType", "KeyManager", "ApplicationId", "TenantId", "TenantDomain", "Timestamp", "ApplicationUUID", }); + new java.lang.String[] { "ApplicationUUID", "SecurityScheme", "ApplicationIdentifier", "KeyType", "EnvID", "Timestamp", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMapping.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMapping.java new file mode 100644 index 000000000..5cf0522e1 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMapping.java @@ -0,0 +1,841 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/applicationmapping.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +/** + *
+ * ApplicationMapping data model
+ * 
+ * + * Protobuf type {@code wso2.discovery.subscription.ApplicationMapping} + */ +public final class ApplicationMapping extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.ApplicationMapping) + ApplicationMappingOrBuilder { +private static final long serialVersionUID = 0L; + // Use ApplicationMapping.newBuilder() to construct. + private ApplicationMapping(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ApplicationMapping() { + uuid_ = ""; + applicationRef_ = ""; + subscriptionRef_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ApplicationMapping(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ApplicationMapping( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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(); + + uuid_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + applicationRef_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + subscriptionRef_ = 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 { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.internal_static_wso2_discovery_subscription_ApplicationMapping_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.internal_static_wso2_discovery_subscription_ApplicationMapping_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.class, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder.class); + } + + public static final int UUID_FIELD_NUMBER = 1; + private volatile java.lang.Object uuid_; + /** + * string uuid = 1; + * @return The uuid. + */ + @java.lang.Override + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + 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(); + uuid_ = s; + return s; + } + } + /** + * string uuid = 1; + * @return The bytes for uuid. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int APPLICATIONREF_FIELD_NUMBER = 2; + private volatile java.lang.Object applicationRef_; + /** + * string applicationRef = 2; + * @return The applicationRef. + */ + @java.lang.Override + public java.lang.String getApplicationRef() { + java.lang.Object ref = applicationRef_; + 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(); + applicationRef_ = s; + return s; + } + } + /** + * string applicationRef = 2; + * @return The bytes for applicationRef. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getApplicationRefBytes() { + java.lang.Object ref = applicationRef_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + applicationRef_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SUBSCRIPTIONREF_FIELD_NUMBER = 3; + private volatile java.lang.Object subscriptionRef_; + /** + * string subscriptionRef = 3; + * @return The subscriptionRef. + */ + @java.lang.Override + public java.lang.String getSubscriptionRef() { + java.lang.Object ref = subscriptionRef_; + 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(); + subscriptionRef_ = s; + return s; + } + } + /** + * string subscriptionRef = 3; + * @return The bytes for subscriptionRef. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSubscriptionRefBytes() { + java.lang.Object ref = subscriptionRef_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscriptionRef_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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 (!getUuidBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, uuid_); + } + if (!getApplicationRefBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, applicationRef_); + } + if (!getSubscriptionRefBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, subscriptionRef_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getUuidBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, uuid_); + } + if (!getApplicationRefBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, applicationRef_); + } + if (!getSubscriptionRefBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, subscriptionRef_); + } + 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.ApplicationMapping)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping other = (org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping) obj; + + if (!getUuid() + .equals(other.getUuid())) return false; + if (!getApplicationRef() + .equals(other.getApplicationRef())) return false; + if (!getSubscriptionRef() + .equals(other.getSubscriptionRef())) 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) + UUID_FIELD_NUMBER; + hash = (53 * hash) + getUuid().hashCode(); + hash = (37 * hash) + APPLICATIONREF_FIELD_NUMBER; + hash = (53 * hash) + getApplicationRef().hashCode(); + hash = (37 * hash) + SUBSCRIPTIONREF_FIELD_NUMBER; + hash = (53 * hash) + getSubscriptionRef().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping 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.ApplicationMapping parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping 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.ApplicationMapping parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping 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.ApplicationMapping 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.ApplicationMapping 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.ApplicationMapping 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.ApplicationMapping 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.ApplicationMapping 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.ApplicationMapping 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.ApplicationMapping 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; + } + /** + *
+   * ApplicationMapping data model
+   * 
+ * + * Protobuf type {@code wso2.discovery.subscription.ApplicationMapping} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.ApplicationMapping) + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.internal_static_wso2_discovery_subscription_ApplicationMapping_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.internal_static_wso2_discovery_subscription_ApplicationMapping_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.class, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.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(); + uuid_ = ""; + + applicationRef_ = ""; + + subscriptionRef_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.internal_static_wso2_discovery_subscription_ApplicationMapping_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping build() { + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping result = new org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping(this); + result.uuid_ = uuid_; + result.applicationRef_ = applicationRef_; + result.subscriptionRef_ = subscriptionRef_; + 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.ApplicationMapping) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.getDefaultInstance()) return this; + if (!other.getUuid().isEmpty()) { + uuid_ = other.uuid_; + onChanged(); + } + if (!other.getApplicationRef().isEmpty()) { + applicationRef_ = other.applicationRef_; + onChanged(); + } + if (!other.getSubscriptionRef().isEmpty()) { + subscriptionRef_ = other.subscriptionRef_; + 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.ApplicationMapping parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object uuid_ = ""; + /** + * string uuid = 1; + * @return The uuid. + */ + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uuid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string uuid = 1; + * @return The bytes for uuid. + */ + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string uuid = 1; + * @param value The uuid to set. + * @return This builder for chaining. + */ + public Builder setUuid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + uuid_ = value; + onChanged(); + return this; + } + /** + * string uuid = 1; + * @return This builder for chaining. + */ + public Builder clearUuid() { + + uuid_ = getDefaultInstance().getUuid(); + onChanged(); + return this; + } + /** + * string uuid = 1; + * @param value The bytes for uuid to set. + * @return This builder for chaining. + */ + public Builder setUuidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + uuid_ = value; + onChanged(); + return this; + } + + private java.lang.Object applicationRef_ = ""; + /** + * string applicationRef = 2; + * @return The applicationRef. + */ + public java.lang.String getApplicationRef() { + java.lang.Object ref = applicationRef_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + applicationRef_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string applicationRef = 2; + * @return The bytes for applicationRef. + */ + public com.google.protobuf.ByteString + getApplicationRefBytes() { + java.lang.Object ref = applicationRef_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + applicationRef_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string applicationRef = 2; + * @param value The applicationRef to set. + * @return This builder for chaining. + */ + public Builder setApplicationRef( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + applicationRef_ = value; + onChanged(); + return this; + } + /** + * string applicationRef = 2; + * @return This builder for chaining. + */ + public Builder clearApplicationRef() { + + applicationRef_ = getDefaultInstance().getApplicationRef(); + onChanged(); + return this; + } + /** + * string applicationRef = 2; + * @param value The bytes for applicationRef to set. + * @return This builder for chaining. + */ + public Builder setApplicationRefBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + applicationRef_ = value; + onChanged(); + return this; + } + + private java.lang.Object subscriptionRef_ = ""; + /** + * string subscriptionRef = 3; + * @return The subscriptionRef. + */ + public java.lang.String getSubscriptionRef() { + java.lang.Object ref = subscriptionRef_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + subscriptionRef_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string subscriptionRef = 3; + * @return The bytes for subscriptionRef. + */ + public com.google.protobuf.ByteString + getSubscriptionRefBytes() { + java.lang.Object ref = subscriptionRef_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + subscriptionRef_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string subscriptionRef = 3; + * @param value The subscriptionRef to set. + * @return This builder for chaining. + */ + public Builder setSubscriptionRef( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + subscriptionRef_ = value; + onChanged(); + return this; + } + /** + * string subscriptionRef = 3; + * @return This builder for chaining. + */ + public Builder clearSubscriptionRef() { + + subscriptionRef_ = getDefaultInstance().getSubscriptionRef(); + onChanged(); + return this; + } + /** + * string subscriptionRef = 3; + * @param value The bytes for subscriptionRef to set. + * @return This builder for chaining. + */ + public Builder setSubscriptionRefBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + subscriptionRef_ = 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.ApplicationMapping) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.ApplicationMapping) + private static final org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ApplicationMapping parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ApplicationMapping(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.ApplicationMapping getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingList.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingList.java new file mode 100644 index 000000000..de67b9d94 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingList.java @@ -0,0 +1,778 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/applicationmapping_list.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +/** + *
+ * ApplicationMappingList data model
+ * 
+ * + * Protobuf type {@code wso2.discovery.subscription.ApplicationMappingList} + */ +public final class ApplicationMappingList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.ApplicationMappingList) + ApplicationMappingListOrBuilder { +private static final long serialVersionUID = 0L; + // Use ApplicationMappingList.newBuilder() to construct. + private ApplicationMappingList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ApplicationMappingList() { + list_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new ApplicationMappingList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ApplicationMappingList( + 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 18: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + list_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + list_.add( + input.readMessage(org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.parser(), extensionRegistry)); + 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_ & 0x00000001) != 0)) { + list_ = java.util.Collections.unmodifiableList(list_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingListProto.internal_static_wso2_discovery_subscription_ApplicationMappingList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingListProto.internal_static_wso2_discovery_subscription_ApplicationMappingList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList.class, org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList.Builder.class); + } + + public static final int LIST_FIELD_NUMBER = 2; + private java.util.List list_; + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + @java.lang.Override + public java.util.List getListList() { + return list_; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + @java.lang.Override + public java.util.List + getListOrBuilderList() { + return list_; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + @java.lang.Override + public int getListCount() { + return list_.size(); + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping getList(int index) { + return list_.get(index); + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingOrBuilder getListOrBuilder( + int index) { + return list_.get(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 { + for (int i = 0; i < list_.size(); i++) { + output.writeMessage(2, list_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < list_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, list_.get(i)); + } + 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.ApplicationMappingList)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList other = (org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList) obj; + + if (!getListList() + .equals(other.getListList())) 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(); + if (getListCount() > 0) { + hash = (37 * hash) + LIST_FIELD_NUMBER; + hash = (53 * hash) + getListList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList 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.ApplicationMappingList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList 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.ApplicationMappingList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList 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.ApplicationMappingList 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.ApplicationMappingList 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.ApplicationMappingList 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.ApplicationMappingList 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.ApplicationMappingList 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.ApplicationMappingList 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.ApplicationMappingList 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; + } + /** + *
+   * ApplicationMappingList data model
+   * 
+ * + * Protobuf type {@code wso2.discovery.subscription.ApplicationMappingList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.ApplicationMappingList) + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingListProto.internal_static_wso2_discovery_subscription_ApplicationMappingList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingListProto.internal_static_wso2_discovery_subscription_ApplicationMappingList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList.class, org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getListFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (listBuilder_ == null) { + list_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + listBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingListProto.internal_static_wso2_discovery_subscription_ApplicationMappingList_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList build() { + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList result = new org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList(this); + int from_bitField0_ = bitField0_; + if (listBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + list_ = java.util.Collections.unmodifiableList(list_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.list_ = list_; + } else { + result.list_ = listBuilder_.build(); + } + 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.ApplicationMappingList) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList.getDefaultInstance()) return this; + if (listBuilder_ == null) { + if (!other.list_.isEmpty()) { + if (list_.isEmpty()) { + list_ = other.list_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureListIsMutable(); + list_.addAll(other.list_); + } + onChanged(); + } + } else { + if (!other.list_.isEmpty()) { + if (listBuilder_.isEmpty()) { + listBuilder_.dispose(); + listBuilder_ = null; + list_ = other.list_; + bitField0_ = (bitField0_ & ~0x00000001); + listBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getListFieldBuilder() : null; + } else { + listBuilder_.addAllMessages(other.list_); + } + } + } + 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.ApplicationMappingList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List list_ = + java.util.Collections.emptyList(); + private void ensureListIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + list_ = new java.util.ArrayList(list_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder, org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingOrBuilder> listBuilder_; + + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public java.util.List getListList() { + if (listBuilder_ == null) { + return java.util.Collections.unmodifiableList(list_); + } else { + return listBuilder_.getMessageList(); + } + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public int getListCount() { + if (listBuilder_ == null) { + return list_.size(); + } else { + return listBuilder_.getCount(); + } + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping getList(int index) { + if (listBuilder_ == null) { + return list_.get(index); + } else { + return listBuilder_.getMessage(index); + } + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder setList( + int index, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping value) { + if (listBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureListIsMutable(); + list_.set(index, value); + onChanged(); + } else { + listBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder setList( + int index, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder builderForValue) { + if (listBuilder_ == null) { + ensureListIsMutable(); + list_.set(index, builderForValue.build()); + onChanged(); + } else { + listBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder addList(org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping value) { + if (listBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureListIsMutable(); + list_.add(value); + onChanged(); + } else { + listBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder addList( + int index, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping value) { + if (listBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureListIsMutable(); + list_.add(index, value); + onChanged(); + } else { + listBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder addList( + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder builderForValue) { + if (listBuilder_ == null) { + ensureListIsMutable(); + list_.add(builderForValue.build()); + onChanged(); + } else { + listBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder addList( + int index, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder builderForValue) { + if (listBuilder_ == null) { + ensureListIsMutable(); + list_.add(index, builderForValue.build()); + onChanged(); + } else { + listBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder addAllList( + java.lang.Iterable values) { + if (listBuilder_ == null) { + ensureListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, list_); + onChanged(); + } else { + listBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder clearList() { + if (listBuilder_ == null) { + list_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + listBuilder_.clear(); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public Builder removeList(int index) { + if (listBuilder_ == null) { + ensureListIsMutable(); + list_.remove(index); + onChanged(); + } else { + listBuilder_.remove(index); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder getListBuilder( + int index) { + return getListFieldBuilder().getBuilder(index); + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingOrBuilder getListOrBuilder( + int index) { + if (listBuilder_ == null) { + return list_.get(index); } else { + return listBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public java.util.List + getListOrBuilderList() { + if (listBuilder_ != null) { + return listBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(list_); + } + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder addListBuilder() { + return getListFieldBuilder().addBuilder( + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder addListBuilder( + int index) { + return getListFieldBuilder().addBuilder( + index, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + public java.util.List + getListBuilderList() { + return getListFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder, org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingOrBuilder> + getListFieldBuilder() { + if (listBuilder_ == null) { + listBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping, org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping.Builder, org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingOrBuilder>( + list_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + list_ = null; + } + return listBuilder_; + } + @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.ApplicationMappingList) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.ApplicationMappingList) + private static final org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ApplicationMappingList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ApplicationMappingList(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.ApplicationMappingList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingListOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingListOrBuilder.java new file mode 100644 index 000000000..2aed5e587 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingListOrBuilder.java @@ -0,0 +1,33 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/applicationmapping_list.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface ApplicationMappingListOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.ApplicationMappingList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + java.util.List + getListList(); + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping getList(int index); + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + int getListCount(); + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + java.util.List + getListOrBuilderList(); + /** + * repeated .wso2.discovery.subscription.ApplicationMapping list = 2; + */ + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingOrBuilder getListOrBuilder( + int index); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingListProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingListProto.java new file mode 100644 index 000000000..9e3e5715a --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingListProto.java @@ -0,0 +1,57 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/applicationmapping_list.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public final class ApplicationMappingListProto { + private ApplicationMappingListProto() {} + 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_ApplicationMappingList_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_ApplicationMappingList_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n9wso2/discovery/subscription/applicatio" + + "nmapping_list.proto\022\033wso2.discovery.subs" + + "cription\0324wso2/discovery/subscription/ap" + + "plicationmapping.proto\"W\n\026ApplicationMap" + + "pingList\022=\n\004list\030\002 \003(\0132/.wso2.discovery." + + "subscription.ApplicationMappingB\236\001\n,org." + + "wso2.apk.enforcer.discovery.subscription" + + "B\033ApplicationMappingListProtoP\001ZOgithub." + + "com/envoyproxy/go-control-plane/wso2/dis" + + "covery/subscription;subscriptionb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.getDescriptor(), + }); + internal_static_wso2_discovery_subscription_ApplicationMappingList_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_wso2_discovery_subscription_ApplicationMappingList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_ApplicationMappingList_descriptor, + new java.lang.String[] { "List", }); + org.wso2.apk.enforcer.discovery.subscription.ApplicationMappingProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingOrBuilder.java new file mode 100644 index 000000000..429a38bfd --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingOrBuilder.java @@ -0,0 +1,45 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/applicationmapping.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface ApplicationMappingOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.ApplicationMapping) + com.google.protobuf.MessageOrBuilder { + + /** + * string uuid = 1; + * @return The uuid. + */ + java.lang.String getUuid(); + /** + * string uuid = 1; + * @return The bytes for uuid. + */ + com.google.protobuf.ByteString + getUuidBytes(); + + /** + * string applicationRef = 2; + * @return The applicationRef. + */ + java.lang.String getApplicationRef(); + /** + * string applicationRef = 2; + * @return The bytes for applicationRef. + */ + com.google.protobuf.ByteString + getApplicationRefBytes(); + + /** + * string subscriptionRef = 3; + * @return The subscriptionRef. + */ + java.lang.String getSubscriptionRef(); + /** + * string subscriptionRef = 3; + * @return The bytes for subscriptionRef. + */ + com.google.protobuf.ByteString + getSubscriptionRefBytes(); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingProto.java new file mode 100644 index 000000000..acf005fed --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationMappingProto.java @@ -0,0 +1,54 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/applicationmapping.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public final class ApplicationMappingProto { + private ApplicationMappingProto() {} + 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_ApplicationMapping_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_ApplicationMapping_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n4wso2/discovery/subscription/applicatio" + + "nmapping.proto\022\033wso2.discovery.subscript" + + "ion\"S\n\022ApplicationMapping\022\014\n\004uuid\030\001 \001(\t\022" + + "\026\n\016applicationRef\030\002 \001(\t\022\027\n\017subscriptionR" + + "ef\030\003 \001(\tB\232\001\n,org.wso2.apk.enforcer.disco" + + "very.subscriptionB\027ApplicationMappingPro" + + "toP\001ZOgithub.com/envoyproxy/go-control-p" + + "lane/wso2/discovery/subscription;subscri" + + "ptionb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_wso2_discovery_subscription_ApplicationMapping_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_wso2_discovery_subscription_ApplicationMapping_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_ApplicationMapping_descriptor, + new java.lang.String[] { "Uuid", "ApplicationRef", "SubscriptionRef", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationOrBuilder.java index 5defddb89..df686382a 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationOrBuilder.java @@ -8,16 +8,16 @@ public interface ApplicationOrBuilder extends com.google.protobuf.MessageOrBuilder { /** - * string eventId = 1; - * @return The eventId. + * string uuid = 1; + * @return The uuid. */ - java.lang.String getEventId(); + java.lang.String getUuid(); /** - * string eventId = 1; - * @return The bytes for eventId. + * string uuid = 1; + * @return The bytes for uuid. */ com.google.protobuf.ByteString - getEventIdBytes(); + getUuidBytes(); /** * string name = 2; @@ -32,47 +32,23 @@ public interface ApplicationOrBuilder extends getNameBytes(); /** - * string uuid = 3; - * @return The uuid. - */ - java.lang.String getUuid(); - /** - * string uuid = 3; - * @return The bytes for uuid. - */ - com.google.protobuf.ByteString - getUuidBytes(); - - /** - * string owner = 4; + * string owner = 3; * @return The owner. */ java.lang.String getOwner(); /** - * string owner = 4; + * string owner = 3; * @return The bytes for owner. */ com.google.protobuf.ByteString getOwnerBytes(); /** - * string policy = 5; - * @return The policy. - */ - java.lang.String getPolicy(); - /** - * string policy = 5; - * @return The bytes for policy. - */ - com.google.protobuf.ByteString - getPolicyBytes(); - - /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ int getAttributesCount(); /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ boolean containsAttributes( java.lang.String key); @@ -83,69 +59,21 @@ boolean containsAttributes( java.util.Map getAttributes(); /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ java.util.Map getAttributesMap(); /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ java.lang.String getAttributesOrDefault( java.lang.String key, java.lang.String defaultValue); /** - * map<string, string> attributes = 6; + * map<string, string> attributes = 4; */ java.lang.String getAttributesOrThrow( java.lang.String key); - - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - java.util.List - getKeysList(); - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - org.wso2.apk.enforcer.discovery.subscription.Application.Key getKeys(int index); - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - int getKeysCount(); - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - java.util.List - getKeysOrBuilderList(); - /** - * repeated .wso2.discovery.subscription.Application.Key keys = 7; - */ - org.wso2.apk.enforcer.discovery.subscription.Application.KeyOrBuilder getKeysOrBuilder( - int index); - - /** - * string organization = 8; - * @return The organization. - */ - java.lang.String getOrganization(); - /** - * string organization = 8; - * @return The bytes for organization. - */ - com.google.protobuf.ByteString - getOrganizationBytes(); - - /** - * string timeStamp = 9; - * @return The timeStamp. - */ - java.lang.String getTimeStamp(); - /** - * string timeStamp = 9; - * @return The bytes for timeStamp. - */ - com.google.protobuf.ByteString - getTimeStampBytes(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationProto.java index 9a2797e48..d4b5b129c 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/ApplicationProto.java @@ -25,10 +25,20 @@ public static void registerAllExtensions( com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_wso2_discovery_subscription_Application_AttributesEntry_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor - internal_static_wso2_discovery_subscription_Application_Key_descriptor; + internal_static_wso2_discovery_subscription_SecuritySchemes_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_wso2_discovery_subscription_Application_Key_fieldAccessorTable; + internal_static_wso2_discovery_subscription_SecuritySchemes_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_subscription_OAuth2_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_OAuth2_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_subscription_Environment_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_Environment_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -39,20 +49,22 @@ public static void registerAllExtensions( static { java.lang.String[] descriptorData = { "\n-wso2/discovery/subscription/applicatio" + - "n.proto\022\033wso2.discovery.subscription\"\347\002\n" + - "\013Application\022\017\n\007eventId\030\001 \001(\t\022\014\n\004name\030\002 " + - "\001(\t\022\014\n\004uuid\030\003 \001(\t\022\r\n\005owner\030\004 \001(\t\022\016\n\006poli" + - "cy\030\005 \001(\t\022L\n\nattributes\030\006 \003(\01328.wso2.disc" + - "overy.subscription.Application.Attribute" + - "sEntry\022:\n\004keys\030\007 \003(\0132,.wso2.discovery.su" + - "bscription.Application.Key\022\024\n\014organizati" + - "on\030\010 \001(\t\022\021\n\ttimeStamp\030\t \001(\t\0321\n\017Attribute" + - "sEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\032&" + - "\n\003Key\022\013\n\003key\030\001 \001(\t\022\022\n\nkeyManager\030\002 \001(\tB\223" + - "\001\n,org.wso2.apk.enforcer.discovery.subsc" + - "riptionB\020ApplicationProtoP\001ZOgithub.com/" + - "envoyproxy/go-control-plane/wso2/discove" + - "ry/subscription;subscriptionb\006proto3" + "n.proto\022\033wso2.discovery.subscription\"\271\001\n" + + "\013Application\022\014\n\004uuid\030\001 \001(\t\022\014\n\004name\030\002 \001(\t" + + "\022\r\n\005owner\030\003 \001(\t\022L\n\nattributes\030\004 \003(\01328.ws" + + "o2.discovery.subscription.Application.At" + + "tributesEntry\0321\n\017AttributesEntry\022\013\n\003key\030" + + "\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"F\n\017SecuritySche" + + "mes\0223\n\006oAuth2\030\001 \001(\0132#.wso2.discovery.sub" + + "scription.OAuth2\"H\n\006OAuth2\022>\n\014environmen" + + "ts\030\001 \003(\0132(.wso2.discovery.subscription.E" + + "nvironment\"L\n\013Environment\022\r\n\005envID\030\001 \001(\t" + + "\022\035\n\025applicationIdentifier\030\002 \001(\t\022\017\n\007keyTy" + + "pe\030\003 \001(\tB\223\001\n,org.wso2.apk.enforcer.disco" + + "very.subscriptionB\020ApplicationProtoP\001ZOg" + + "ithub.com/envoyproxy/go-control-plane/ws" + + "o2/discovery/subscription;subscriptionb\006" + + "proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -63,19 +75,31 @@ public static void registerAllExtensions( internal_static_wso2_discovery_subscription_Application_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_subscription_Application_descriptor, - new java.lang.String[] { "EventId", "Name", "Uuid", "Owner", "Policy", "Attributes", "Keys", "Organization", "TimeStamp", }); + new java.lang.String[] { "Uuid", "Name", "Owner", "Attributes", }); internal_static_wso2_discovery_subscription_Application_AttributesEntry_descriptor = internal_static_wso2_discovery_subscription_Application_descriptor.getNestedTypes().get(0); internal_static_wso2_discovery_subscription_Application_AttributesEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_subscription_Application_AttributesEntry_descriptor, new java.lang.String[] { "Key", "Value", }); - internal_static_wso2_discovery_subscription_Application_Key_descriptor = - internal_static_wso2_discovery_subscription_Application_descriptor.getNestedTypes().get(1); - internal_static_wso2_discovery_subscription_Application_Key_fieldAccessorTable = new + internal_static_wso2_discovery_subscription_SecuritySchemes_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_wso2_discovery_subscription_SecuritySchemes_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_SecuritySchemes_descriptor, + new java.lang.String[] { "OAuth2", }); + internal_static_wso2_discovery_subscription_OAuth2_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_wso2_discovery_subscription_OAuth2_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_OAuth2_descriptor, + new java.lang.String[] { "Environments", }); + internal_static_wso2_discovery_subscription_Environment_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_wso2_discovery_subscription_Environment_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_wso2_discovery_subscription_Application_Key_descriptor, - new java.lang.String[] { "Key", "KeyManager", }); + internal_static_wso2_discovery_subscription_Environment_descriptor, + new java.lang.String[] { "EnvID", "ApplicationIdentifier", "KeyType", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/AuthenticationOptionOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/AuthenticationOptionOrBuilder.java new file mode 100644 index 000000000..4e8065e1c --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/AuthenticationOptionOrBuilder.java @@ -0,0 +1,57 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/application.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface AuthenticationOptionOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.AuthenticationOption) + com.google.protobuf.MessageOrBuilder { + + /** + * string type = 1; + * @return The type. + */ + java.lang.String getType(); + /** + * string type = 1; + * @return The bytes for type. + */ + com.google.protobuf.ByteString + getTypeBytes(); + + /** + *
+   * MTLS mTLS = 3;
+   * BasicAuth basicAuth = 4;
+   * APIKey apiKey = 5;
+   * IPRange IPRange = 6;
+   * 
+ * + * .wso2.discovery.subscription.OAuth2 oAuth2 = 2; + * @return Whether the oAuth2 field is set. + */ + boolean hasOAuth2(); + /** + *
+   * MTLS mTLS = 3;
+   * BasicAuth basicAuth = 4;
+   * APIKey apiKey = 5;
+   * IPRange IPRange = 6;
+   * 
+ * + * .wso2.discovery.subscription.OAuth2 oAuth2 = 2; + * @return The oAuth2. + */ + org.wso2.apk.enforcer.discovery.subscription.OAuth2 getOAuth2(); + /** + *
+   * MTLS mTLS = 3;
+   * BasicAuth basicAuth = 4;
+   * APIKey apiKey = 5;
+   * IPRange IPRange = 6;
+   * 
+ * + * .wso2.discovery.subscription.OAuth2 oAuth2 = 2; + */ + org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder getOAuth2OrBuilder(); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Environment.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Environment.java new file mode 100644 index 000000000..d2774073f --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Environment.java @@ -0,0 +1,833 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/application.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +/** + * Protobuf type {@code wso2.discovery.subscription.Environment} + */ +public final class Environment extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.Environment) + EnvironmentOrBuilder { +private static final long serialVersionUID = 0L; + // Use Environment.newBuilder() to construct. + private Environment(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Environment() { + envID_ = ""; + applicationIdentifier_ = ""; + keyType_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Environment(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Environment( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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(); + + envID_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + applicationIdentifier_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + keyType_ = 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 { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Environment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Environment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.Environment.class, org.wso2.apk.enforcer.discovery.subscription.Environment.Builder.class); + } + + public static final int ENVID_FIELD_NUMBER = 1; + private volatile java.lang.Object envID_; + /** + * string envID = 1; + * @return The envID. + */ + @java.lang.Override + public java.lang.String getEnvID() { + java.lang.Object ref = envID_; + 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(); + envID_ = s; + return s; + } + } + /** + * string envID = 1; + * @return The bytes for envID. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getEnvIDBytes() { + java.lang.Object ref = envID_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + envID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int APPLICATIONIDENTIFIER_FIELD_NUMBER = 2; + private volatile java.lang.Object applicationIdentifier_; + /** + * string applicationIdentifier = 2; + * @return The applicationIdentifier. + */ + @java.lang.Override + public java.lang.String getApplicationIdentifier() { + java.lang.Object ref = applicationIdentifier_; + 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(); + applicationIdentifier_ = s; + return s; + } + } + /** + * string applicationIdentifier = 2; + * @return The bytes for applicationIdentifier. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getApplicationIdentifierBytes() { + java.lang.Object ref = applicationIdentifier_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + applicationIdentifier_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int KEYTYPE_FIELD_NUMBER = 3; + private volatile java.lang.Object keyType_; + /** + * string keyType = 3; + * @return The keyType. + */ + @java.lang.Override + public java.lang.String getKeyType() { + java.lang.Object ref = keyType_; + 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(); + keyType_ = s; + return s; + } + } + /** + * string keyType = 3; + * @return The bytes for keyType. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getKeyTypeBytes() { + java.lang.Object ref = keyType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + keyType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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 (!getEnvIDBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, envID_); + } + if (!getApplicationIdentifierBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, applicationIdentifier_); + } + if (!getKeyTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, keyType_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getEnvIDBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, envID_); + } + if (!getApplicationIdentifierBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, applicationIdentifier_); + } + if (!getKeyTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, keyType_); + } + 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.Environment)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.Environment other = (org.wso2.apk.enforcer.discovery.subscription.Environment) obj; + + if (!getEnvID() + .equals(other.getEnvID())) return false; + if (!getApplicationIdentifier() + .equals(other.getApplicationIdentifier())) return false; + if (!getKeyType() + .equals(other.getKeyType())) 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) + ENVID_FIELD_NUMBER; + hash = (53 * hash) + getEnvID().hashCode(); + hash = (37 * hash) + APPLICATIONIDENTIFIER_FIELD_NUMBER; + hash = (53 * hash) + getApplicationIdentifier().hashCode(); + hash = (37 * hash) + KEYTYPE_FIELD_NUMBER; + hash = (53 * hash) + getKeyType().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.apk.enforcer.discovery.subscription.Environment parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.Environment 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.Environment parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.Environment 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.Environment parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.Environment 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.Environment 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.Environment 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.Environment 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.Environment 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.Environment 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.Environment 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.Environment 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; + } + /** + * Protobuf type {@code wso2.discovery.subscription.Environment} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.Environment) + org.wso2.apk.enforcer.discovery.subscription.EnvironmentOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Environment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Environment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.Environment.class, org.wso2.apk.enforcer.discovery.subscription.Environment.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.Environment.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(); + envID_ = ""; + + applicationIdentifier_ = ""; + + keyType_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_Environment_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.Environment getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.Environment.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.Environment build() { + org.wso2.apk.enforcer.discovery.subscription.Environment result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.Environment buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.Environment result = new org.wso2.apk.enforcer.discovery.subscription.Environment(this); + result.envID_ = envID_; + result.applicationIdentifier_ = applicationIdentifier_; + result.keyType_ = keyType_; + 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.Environment) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.Environment)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.Environment other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.Environment.getDefaultInstance()) return this; + if (!other.getEnvID().isEmpty()) { + envID_ = other.envID_; + onChanged(); + } + if (!other.getApplicationIdentifier().isEmpty()) { + applicationIdentifier_ = other.applicationIdentifier_; + onChanged(); + } + if (!other.getKeyType().isEmpty()) { + keyType_ = other.keyType_; + 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.Environment parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.Environment) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object envID_ = ""; + /** + * string envID = 1; + * @return The envID. + */ + public java.lang.String getEnvID() { + java.lang.Object ref = envID_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + envID_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string envID = 1; + * @return The bytes for envID. + */ + public com.google.protobuf.ByteString + getEnvIDBytes() { + java.lang.Object ref = envID_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + envID_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string envID = 1; + * @param value The envID to set. + * @return This builder for chaining. + */ + public Builder setEnvID( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + envID_ = value; + onChanged(); + return this; + } + /** + * string envID = 1; + * @return This builder for chaining. + */ + public Builder clearEnvID() { + + envID_ = getDefaultInstance().getEnvID(); + onChanged(); + return this; + } + /** + * string envID = 1; + * @param value The bytes for envID to set. + * @return This builder for chaining. + */ + public Builder setEnvIDBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + envID_ = value; + onChanged(); + return this; + } + + private java.lang.Object applicationIdentifier_ = ""; + /** + * string applicationIdentifier = 2; + * @return The applicationIdentifier. + */ + public java.lang.String getApplicationIdentifier() { + java.lang.Object ref = applicationIdentifier_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + applicationIdentifier_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string applicationIdentifier = 2; + * @return The bytes for applicationIdentifier. + */ + public com.google.protobuf.ByteString + getApplicationIdentifierBytes() { + java.lang.Object ref = applicationIdentifier_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + applicationIdentifier_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string applicationIdentifier = 2; + * @param value The applicationIdentifier to set. + * @return This builder for chaining. + */ + public Builder setApplicationIdentifier( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + applicationIdentifier_ = value; + onChanged(); + return this; + } + /** + * string applicationIdentifier = 2; + * @return This builder for chaining. + */ + public Builder clearApplicationIdentifier() { + + applicationIdentifier_ = getDefaultInstance().getApplicationIdentifier(); + onChanged(); + return this; + } + /** + * string applicationIdentifier = 2; + * @param value The bytes for applicationIdentifier to set. + * @return This builder for chaining. + */ + public Builder setApplicationIdentifierBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + applicationIdentifier_ = value; + onChanged(); + return this; + } + + private java.lang.Object keyType_ = ""; + /** + * string keyType = 3; + * @return The keyType. + */ + public java.lang.String getKeyType() { + java.lang.Object ref = keyType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + keyType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string keyType = 3; + * @return The bytes for keyType. + */ + public com.google.protobuf.ByteString + getKeyTypeBytes() { + java.lang.Object ref = keyType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + keyType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string keyType = 3; + * @param value The keyType to set. + * @return This builder for chaining. + */ + public Builder setKeyType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + keyType_ = value; + onChanged(); + return this; + } + /** + * string keyType = 3; + * @return This builder for chaining. + */ + public Builder clearKeyType() { + + keyType_ = getDefaultInstance().getKeyType(); + onChanged(); + return this; + } + /** + * string keyType = 3; + * @param value The bytes for keyType to set. + * @return This builder for chaining. + */ + public Builder setKeyTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + keyType_ = 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.Environment) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.Environment) + private static final org.wso2.apk.enforcer.discovery.subscription.Environment DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.Environment(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.Environment getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Environment parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Environment(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.Environment getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EnvironmentOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EnvironmentOrBuilder.java new file mode 100644 index 000000000..97f621f50 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/EnvironmentOrBuilder.java @@ -0,0 +1,45 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/application.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface EnvironmentOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.Environment) + com.google.protobuf.MessageOrBuilder { + + /** + * string envID = 1; + * @return The envID. + */ + java.lang.String getEnvID(); + /** + * string envID = 1; + * @return The bytes for envID. + */ + com.google.protobuf.ByteString + getEnvIDBytes(); + + /** + * string applicationIdentifier = 2; + * @return The applicationIdentifier. + */ + java.lang.String getApplicationIdentifier(); + /** + * string applicationIdentifier = 2; + * @return The bytes for applicationIdentifier. + */ + com.google.protobuf.ByteString + getApplicationIdentifierBytes(); + + /** + * string keyType = 3; + * @return The keyType. + */ + java.lang.String getKeyType(); + /** + * string keyType = 3; + * @return The bytes for keyType. + */ + com.google.protobuf.ByteString + getKeyTypeBytes(); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/OAuth2.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/OAuth2.java new file mode 100644 index 000000000..5e40ba2b2 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/OAuth2.java @@ -0,0 +1,770 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/application.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +/** + * Protobuf type {@code wso2.discovery.subscription.OAuth2} + */ +public final class OAuth2 extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.OAuth2) + OAuth2OrBuilder { +private static final long serialVersionUID = 0L; + // Use OAuth2.newBuilder() to construct. + private OAuth2(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private OAuth2() { + environments_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new OAuth2(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private OAuth2( + 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: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + environments_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + environments_.add( + input.readMessage(org.wso2.apk.enforcer.discovery.subscription.Environment.parser(), extensionRegistry)); + 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_ & 0x00000001) != 0)) { + environments_ = java.util.Collections.unmodifiableList(environments_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_OAuth2_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_OAuth2_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.OAuth2.class, org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder.class); + } + + public static final int ENVIRONMENTS_FIELD_NUMBER = 1; + private java.util.List environments_; + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + @java.lang.Override + public java.util.List getEnvironmentsList() { + return environments_; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + @java.lang.Override + public java.util.List + getEnvironmentsOrBuilderList() { + return environments_; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + @java.lang.Override + public int getEnvironmentsCount() { + return environments_.size(); + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.Environment getEnvironments(int index) { + return environments_.get(index); + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.EnvironmentOrBuilder getEnvironmentsOrBuilder( + int index) { + return environments_.get(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 { + for (int i = 0; i < environments_.size(); i++) { + output.writeMessage(1, environments_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < environments_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, environments_.get(i)); + } + 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.OAuth2)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.OAuth2 other = (org.wso2.apk.enforcer.discovery.subscription.OAuth2) obj; + + 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(); + 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.OAuth2 parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.OAuth2 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.OAuth2 parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.OAuth2 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.OAuth2 parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.OAuth2 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.OAuth2 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.OAuth2 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.OAuth2 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.OAuth2 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.OAuth2 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.OAuth2 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.OAuth2 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; + } + /** + * Protobuf type {@code wso2.discovery.subscription.OAuth2} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.OAuth2) + org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_OAuth2_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_OAuth2_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.OAuth2.class, org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.OAuth2.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getEnvironmentsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (environmentsBuilder_ == null) { + environments_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + environmentsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_OAuth2_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.OAuth2 getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.OAuth2.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.OAuth2 build() { + org.wso2.apk.enforcer.discovery.subscription.OAuth2 result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.OAuth2 buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.OAuth2 result = new org.wso2.apk.enforcer.discovery.subscription.OAuth2(this); + int from_bitField0_ = bitField0_; + if (environmentsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + environments_ = java.util.Collections.unmodifiableList(environments_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.environments_ = environments_; + } else { + result.environments_ = environmentsBuilder_.build(); + } + 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.OAuth2) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.OAuth2)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.OAuth2 other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.OAuth2.getDefaultInstance()) return this; + if (environmentsBuilder_ == null) { + if (!other.environments_.isEmpty()) { + if (environments_.isEmpty()) { + environments_ = other.environments_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureEnvironmentsIsMutable(); + environments_.addAll(other.environments_); + } + onChanged(); + } + } else { + if (!other.environments_.isEmpty()) { + if (environmentsBuilder_.isEmpty()) { + environmentsBuilder_.dispose(); + environmentsBuilder_ = null; + environments_ = other.environments_; + bitField0_ = (bitField0_ & ~0x00000001); + environmentsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getEnvironmentsFieldBuilder() : null; + } else { + environmentsBuilder_.addAllMessages(other.environments_); + } + } + } + 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.OAuth2 parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.OAuth2) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List environments_ = + java.util.Collections.emptyList(); + private void ensureEnvironmentsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + environments_ = new java.util.ArrayList(environments_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.Environment, org.wso2.apk.enforcer.discovery.subscription.Environment.Builder, org.wso2.apk.enforcer.discovery.subscription.EnvironmentOrBuilder> environmentsBuilder_; + + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public java.util.List getEnvironmentsList() { + if (environmentsBuilder_ == null) { + return java.util.Collections.unmodifiableList(environments_); + } else { + return environmentsBuilder_.getMessageList(); + } + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public int getEnvironmentsCount() { + if (environmentsBuilder_ == null) { + return environments_.size(); + } else { + return environmentsBuilder_.getCount(); + } + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public org.wso2.apk.enforcer.discovery.subscription.Environment getEnvironments(int index) { + if (environmentsBuilder_ == null) { + return environments_.get(index); + } else { + return environmentsBuilder_.getMessage(index); + } + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder setEnvironments( + int index, org.wso2.apk.enforcer.discovery.subscription.Environment value) { + if (environmentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvironmentsIsMutable(); + environments_.set(index, value); + onChanged(); + } else { + environmentsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder setEnvironments( + int index, org.wso2.apk.enforcer.discovery.subscription.Environment.Builder builderForValue) { + if (environmentsBuilder_ == null) { + ensureEnvironmentsIsMutable(); + environments_.set(index, builderForValue.build()); + onChanged(); + } else { + environmentsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder addEnvironments(org.wso2.apk.enforcer.discovery.subscription.Environment value) { + if (environmentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvironmentsIsMutable(); + environments_.add(value); + onChanged(); + } else { + environmentsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder addEnvironments( + int index, org.wso2.apk.enforcer.discovery.subscription.Environment value) { + if (environmentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvironmentsIsMutable(); + environments_.add(index, value); + onChanged(); + } else { + environmentsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder addEnvironments( + org.wso2.apk.enforcer.discovery.subscription.Environment.Builder builderForValue) { + if (environmentsBuilder_ == null) { + ensureEnvironmentsIsMutable(); + environments_.add(builderForValue.build()); + onChanged(); + } else { + environmentsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder addEnvironments( + int index, org.wso2.apk.enforcer.discovery.subscription.Environment.Builder builderForValue) { + if (environmentsBuilder_ == null) { + ensureEnvironmentsIsMutable(); + environments_.add(index, builderForValue.build()); + onChanged(); + } else { + environmentsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder addAllEnvironments( + java.lang.Iterable values) { + if (environmentsBuilder_ == null) { + ensureEnvironmentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, environments_); + onChanged(); + } else { + environmentsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder clearEnvironments() { + if (environmentsBuilder_ == null) { + environments_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + environmentsBuilder_.clear(); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public Builder removeEnvironments(int index) { + if (environmentsBuilder_ == null) { + ensureEnvironmentsIsMutable(); + environments_.remove(index); + onChanged(); + } else { + environmentsBuilder_.remove(index); + } + return this; + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public org.wso2.apk.enforcer.discovery.subscription.Environment.Builder getEnvironmentsBuilder( + int index) { + return getEnvironmentsFieldBuilder().getBuilder(index); + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public org.wso2.apk.enforcer.discovery.subscription.EnvironmentOrBuilder getEnvironmentsOrBuilder( + int index) { + if (environmentsBuilder_ == null) { + return environments_.get(index); } else { + return environmentsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public java.util.List + getEnvironmentsOrBuilderList() { + if (environmentsBuilder_ != null) { + return environmentsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(environments_); + } + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public org.wso2.apk.enforcer.discovery.subscription.Environment.Builder addEnvironmentsBuilder() { + return getEnvironmentsFieldBuilder().addBuilder( + org.wso2.apk.enforcer.discovery.subscription.Environment.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public org.wso2.apk.enforcer.discovery.subscription.Environment.Builder addEnvironmentsBuilder( + int index) { + return getEnvironmentsFieldBuilder().addBuilder( + index, org.wso2.apk.enforcer.discovery.subscription.Environment.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + public java.util.List + getEnvironmentsBuilderList() { + return getEnvironmentsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.Environment, org.wso2.apk.enforcer.discovery.subscription.Environment.Builder, org.wso2.apk.enforcer.discovery.subscription.EnvironmentOrBuilder> + getEnvironmentsFieldBuilder() { + if (environmentsBuilder_ == null) { + environmentsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.Environment, org.wso2.apk.enforcer.discovery.subscription.Environment.Builder, org.wso2.apk.enforcer.discovery.subscription.EnvironmentOrBuilder>( + environments_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + environments_ = null; + } + return environmentsBuilder_; + } + @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.OAuth2) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.OAuth2) + private static final org.wso2.apk.enforcer.discovery.subscription.OAuth2 DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.OAuth2(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.OAuth2 getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public OAuth2 parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new OAuth2(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.OAuth2 getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/OAuth2OrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/OAuth2OrBuilder.java new file mode 100644 index 000000000..186f562e2 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/OAuth2OrBuilder.java @@ -0,0 +1,33 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/application.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface OAuth2OrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.OAuth2) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + java.util.List + getEnvironmentsList(); + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + org.wso2.apk.enforcer.discovery.subscription.Environment getEnvironments(int index); + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + int getEnvironmentsCount(); + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + java.util.List + getEnvironmentsOrBuilderList(); + /** + * repeated .wso2.discovery.subscription.Environment environments = 1; + */ + org.wso2.apk.enforcer.discovery.subscription.EnvironmentOrBuilder getEnvironmentsOrBuilder( + int index); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SecuritySchemes.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SecuritySchemes.java new file mode 100644 index 000000000..6653eb815 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SecuritySchemes.java @@ -0,0 +1,607 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/application.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +/** + * Protobuf type {@code wso2.discovery.subscription.SecuritySchemes} + */ +public final class SecuritySchemes extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.SecuritySchemes) + SecuritySchemesOrBuilder { +private static final long serialVersionUID = 0L; + // Use SecuritySchemes.newBuilder() to construct. + private SecuritySchemes(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SecuritySchemes() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SecuritySchemes(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SecuritySchemes( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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: { + org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder subBuilder = null; + if (oAuth2_ != null) { + subBuilder = oAuth2_.toBuilder(); + } + oAuth2_ = input.readMessage(org.wso2.apk.enforcer.discovery.subscription.OAuth2.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(oAuth2_); + oAuth2_ = subBuilder.buildPartial(); + } + + 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 { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_SecuritySchemes_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_SecuritySchemes_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes.class, org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes.Builder.class); + } + + public static final int OAUTH2_FIELD_NUMBER = 1; + private org.wso2.apk.enforcer.discovery.subscription.OAuth2 oAuth2_; + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + * @return Whether the oAuth2 field is set. + */ + @java.lang.Override + public boolean hasOAuth2() { + return oAuth2_ != null; + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + * @return The oAuth2. + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.OAuth2 getOAuth2() { + return oAuth2_ == null ? org.wso2.apk.enforcer.discovery.subscription.OAuth2.getDefaultInstance() : oAuth2_; + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder getOAuth2OrBuilder() { + return getOAuth2(); + } + + 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 (oAuth2_ != null) { + output.writeMessage(1, getOAuth2()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (oAuth2_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getOAuth2()); + } + 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.SecuritySchemes)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes other = (org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes) obj; + + if (hasOAuth2() != other.hasOAuth2()) return false; + if (hasOAuth2()) { + if (!getOAuth2() + .equals(other.getOAuth2())) 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(); + if (hasOAuth2()) { + hash = (37 * hash) + OAUTH2_FIELD_NUMBER; + hash = (53 * hash) + getOAuth2().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes 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.SecuritySchemes parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes 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.SecuritySchemes parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes 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.SecuritySchemes 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.SecuritySchemes 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.SecuritySchemes 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.SecuritySchemes 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.SecuritySchemes 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.SecuritySchemes 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.SecuritySchemes 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; + } + /** + * Protobuf type {@code wso2.discovery.subscription.SecuritySchemes} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.SecuritySchemes) + org.wso2.apk.enforcer.discovery.subscription.SecuritySchemesOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_SecuritySchemes_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_SecuritySchemes_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes.class, org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes.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(); + if (oAuth2Builder_ == null) { + oAuth2_ = null; + } else { + oAuth2_ = null; + oAuth2Builder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.apk.enforcer.discovery.subscription.ApplicationProto.internal_static_wso2_discovery_subscription_SecuritySchemes_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes build() { + org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes result = new org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes(this); + if (oAuth2Builder_ == null) { + result.oAuth2_ = oAuth2_; + } else { + result.oAuth2_ = oAuth2Builder_.build(); + } + 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.SecuritySchemes) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes.getDefaultInstance()) return this; + if (other.hasOAuth2()) { + mergeOAuth2(other.getOAuth2()); + } + 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.SecuritySchemes parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private org.wso2.apk.enforcer.discovery.subscription.OAuth2 oAuth2_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.OAuth2, org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder, org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder> oAuth2Builder_; + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + * @return Whether the oAuth2 field is set. + */ + public boolean hasOAuth2() { + return oAuth2Builder_ != null || oAuth2_ != null; + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + * @return The oAuth2. + */ + public org.wso2.apk.enforcer.discovery.subscription.OAuth2 getOAuth2() { + if (oAuth2Builder_ == null) { + return oAuth2_ == null ? org.wso2.apk.enforcer.discovery.subscription.OAuth2.getDefaultInstance() : oAuth2_; + } else { + return oAuth2Builder_.getMessage(); + } + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + public Builder setOAuth2(org.wso2.apk.enforcer.discovery.subscription.OAuth2 value) { + if (oAuth2Builder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + oAuth2_ = value; + onChanged(); + } else { + oAuth2Builder_.setMessage(value); + } + + return this; + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + public Builder setOAuth2( + org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder builderForValue) { + if (oAuth2Builder_ == null) { + oAuth2_ = builderForValue.build(); + onChanged(); + } else { + oAuth2Builder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + public Builder mergeOAuth2(org.wso2.apk.enforcer.discovery.subscription.OAuth2 value) { + if (oAuth2Builder_ == null) { + if (oAuth2_ != null) { + oAuth2_ = + org.wso2.apk.enforcer.discovery.subscription.OAuth2.newBuilder(oAuth2_).mergeFrom(value).buildPartial(); + } else { + oAuth2_ = value; + } + onChanged(); + } else { + oAuth2Builder_.mergeFrom(value); + } + + return this; + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + public Builder clearOAuth2() { + if (oAuth2Builder_ == null) { + oAuth2_ = null; + onChanged(); + } else { + oAuth2_ = null; + oAuth2Builder_ = null; + } + + return this; + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + public org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder getOAuth2Builder() { + + onChanged(); + return getOAuth2FieldBuilder().getBuilder(); + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + public org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder getOAuth2OrBuilder() { + if (oAuth2Builder_ != null) { + return oAuth2Builder_.getMessageOrBuilder(); + } else { + return oAuth2_ == null ? + org.wso2.apk.enforcer.discovery.subscription.OAuth2.getDefaultInstance() : oAuth2_; + } + } + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.OAuth2, org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder, org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder> + getOAuth2FieldBuilder() { + if (oAuth2Builder_ == null) { + oAuth2Builder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.OAuth2, org.wso2.apk.enforcer.discovery.subscription.OAuth2.Builder, org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder>( + getOAuth2(), + getParentForChildren(), + isClean()); + oAuth2_ = null; + } + return oAuth2Builder_; + } + @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.SecuritySchemes) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.SecuritySchemes) + private static final org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.SecuritySchemes getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SecuritySchemes parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SecuritySchemes(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.SecuritySchemes getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SecuritySchemesOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SecuritySchemesOrBuilder.java new file mode 100644 index 000000000..2c568b7ce --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SecuritySchemesOrBuilder.java @@ -0,0 +1,24 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/application.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface SecuritySchemesOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.SecuritySchemes) + com.google.protobuf.MessageOrBuilder { + + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + * @return Whether the oAuth2 field is set. + */ + boolean hasOAuth2(); + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + * @return The oAuth2. + */ + org.wso2.apk.enforcer.discovery.subscription.OAuth2 getOAuth2(); + /** + * .wso2.discovery.subscription.OAuth2 oAuth2 = 1; + */ + org.wso2.apk.enforcer.discovery.subscription.OAuth2OrBuilder getOAuth2OrBuilder(); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPI.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPI.java new file mode 100644 index 000000000..9b2274d4b --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPI.java @@ -0,0 +1,695 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/subscription.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +/** + * Protobuf type {@code wso2.discovery.subscription.SubscribedAPI} + */ +public final class SubscribedAPI extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.SubscribedAPI) + SubscribedAPIOrBuilder { +private static final long serialVersionUID = 0L; + // Use SubscribedAPI.newBuilder() to construct. + private SubscribedAPI(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SubscribedAPI() { + name_ = ""; + version_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SubscribedAPI(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SubscribedAPI( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + 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(); + + name_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + version_ = 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 { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPI_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.class, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * string name = 1; + * @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 = 1; + * @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 VERSION_FIELD_NUMBER = 2; + private volatile java.lang.Object version_; + /** + * string version = 2; + * @return The version. + */ + @java.lang.Override + public java.lang.String getVersion() { + java.lang.Object ref = version_; + 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(); + version_ = s; + return s; + } + } + /** + * string version = 2; + * @return The bytes for version. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getVersionBytes() { + java.lang.Object ref = version_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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 (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (!getVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, version_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (!getVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, version_); + } + 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.SubscribedAPI)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI other = (org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI) obj; + + if (!getName() + .equals(other.getName())) return false; + if (!getVersion() + .equals(other.getVersion())) 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) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI 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.SubscribedAPI parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI 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.SubscribedAPI parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI 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.SubscribedAPI 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.SubscribedAPI 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.SubscribedAPI 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.SubscribedAPI 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.SubscribedAPI 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.SubscribedAPI 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.SubscribedAPI 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; + } + /** + * Protobuf type {@code wso2.discovery.subscription.SubscribedAPI} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.SubscribedAPI) + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPI_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.class, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.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(); + name_ = ""; + + version_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI build() { + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI result = new org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI(this); + result.name_ = name_; + result.version_ = version_; + 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.SubscribedAPI) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getVersion().isEmpty()) { + version_ = other.version_; + 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.SubscribedAPI parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 1; + * @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 = 1; + * @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 = 1; + * @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 = 1; + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 1; + * @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 version_ = ""; + /** + * string version = 2; + * @return The version. + */ + public java.lang.String getVersion() { + java.lang.Object ref = version_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + version_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string version = 2; + * @return The bytes for version. + */ + public com.google.protobuf.ByteString + getVersionBytes() { + java.lang.Object ref = version_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string version = 2; + * @param value The version to set. + * @return This builder for chaining. + */ + public Builder setVersion( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + version_ = value; + onChanged(); + return this; + } + /** + * string version = 2; + * @return This builder for chaining. + */ + public Builder clearVersion() { + + version_ = getDefaultInstance().getVersion(); + onChanged(); + return this; + } + /** + * string version = 2; + * @param value The bytes for version to set. + * @return This builder for chaining. + */ + public Builder setVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + version_ = 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.SubscribedAPI) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.SubscribedAPI) + private static final org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SubscribedAPI parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SubscribedAPI(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.SubscribedAPI getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIOrBuilder.java new file mode 100644 index 000000000..2d67f4095 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIOrBuilder.java @@ -0,0 +1,33 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/subscription/subscription.proto + +package org.wso2.apk.enforcer.discovery.subscription; + +public interface SubscribedAPIOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.SubscribedAPI) + com.google.protobuf.MessageOrBuilder { + + /** + * string name = 1; + * @return The name. + */ + java.lang.String getName(); + /** + * string name = 1; + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * string version = 2; + * @return The version. + */ + java.lang.String getVersion(); + /** + * string version = 2; + * @return The bytes for version. + */ + com.google.protobuf.ByteString + getVersionBytes(); +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Subscription.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Subscription.java index 1533d2198..8afbfaa96 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Subscription.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Subscription.java @@ -20,14 +20,8 @@ private Subscription(com.google.protobuf.GeneratedMessageV3.Builder builder) super(builder); } private Subscription() { - eventId_ = ""; - applicationRef_ = ""; - apiRef_ = ""; - policyId_ = ""; subStatus_ = ""; - subscriber_ = ""; uuid_ = ""; - timeStamp_ = ""; organization_ = ""; } @@ -64,55 +58,32 @@ private Subscription( case 10: { java.lang.String s = input.readStringRequireUtf8(); - eventId_ = s; + subStatus_ = s; break; } case 18: { java.lang.String s = input.readStringRequireUtf8(); - applicationRef_ = s; + uuid_ = s; break; } case 26: { java.lang.String s = input.readStringRequireUtf8(); - apiRef_ = s; + organization_ = s; break; } case 34: { - java.lang.String s = input.readStringRequireUtf8(); - - policyId_ = s; - break; - } - case 42: { - java.lang.String s = input.readStringRequireUtf8(); - - subStatus_ = s; - break; - } - case 50: { - java.lang.String s = input.readStringRequireUtf8(); - - subscriber_ = s; - break; - } - case 58: { - java.lang.String s = input.readStringRequireUtf8(); - - uuid_ = s; - break; - } - case 66: { - java.lang.String s = input.readStringRequireUtf8(); - - timeStamp_ = s; - break; - } - case 74: { - java.lang.String s = input.readStringRequireUtf8(); + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder subBuilder = null; + if (subscribedApi_ != null) { + subBuilder = subscribedApi_.toBuilder(); + } + subscribedApi_ = input.readMessage(org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(subscribedApi_); + subscribedApi_ = subBuilder.buildPartial(); + } - organization_ = s; break; } default: { @@ -147,162 +118,10 @@ private Subscription( org.wso2.apk.enforcer.discovery.subscription.Subscription.class, org.wso2.apk.enforcer.discovery.subscription.Subscription.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 APPLICATIONREF_FIELD_NUMBER = 2; - private volatile java.lang.Object applicationRef_; - /** - * string applicationRef = 2; - * @return The applicationRef. - */ - @java.lang.Override - public java.lang.String getApplicationRef() { - java.lang.Object ref = applicationRef_; - 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(); - applicationRef_ = s; - return s; - } - } - /** - * string applicationRef = 2; - * @return The bytes for applicationRef. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getApplicationRefBytes() { - java.lang.Object ref = applicationRef_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - applicationRef_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int APIREF_FIELD_NUMBER = 3; - private volatile java.lang.Object apiRef_; - /** - * string apiRef = 3; - * @return The apiRef. - */ - @java.lang.Override - public java.lang.String getApiRef() { - java.lang.Object ref = apiRef_; - 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(); - apiRef_ = s; - return s; - } - } - /** - * string apiRef = 3; - * @return The bytes for apiRef. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getApiRefBytes() { - java.lang.Object ref = apiRef_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - apiRef_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int POLICYID_FIELD_NUMBER = 4; - private volatile java.lang.Object policyId_; - /** - * string policyId = 4; - * @return The policyId. - */ - @java.lang.Override - public java.lang.String getPolicyId() { - java.lang.Object ref = policyId_; - 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(); - policyId_ = s; - return s; - } - } - /** - * string policyId = 4; - * @return The bytes for policyId. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getPolicyIdBytes() { - java.lang.Object ref = policyId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - policyId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SUBSTATUS_FIELD_NUMBER = 5; + public static final int SUBSTATUS_FIELD_NUMBER = 1; private volatile java.lang.Object subStatus_; /** - * string subStatus = 5; + * string subStatus = 1; * @return The subStatus. */ @java.lang.Override @@ -319,7 +138,7 @@ public java.lang.String getSubStatus() { } } /** - * string subStatus = 5; + * string subStatus = 1; * @return The bytes for subStatus. */ @java.lang.Override @@ -337,48 +156,10 @@ public java.lang.String getSubStatus() { } } - public static final int SUBSCRIBER_FIELD_NUMBER = 6; - private volatile java.lang.Object subscriber_; - /** - * string subscriber = 6; - * @return The subscriber. - */ - @java.lang.Override - public java.lang.String getSubscriber() { - java.lang.Object ref = subscriber_; - 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(); - subscriber_ = s; - return s; - } - } - /** - * string subscriber = 6; - * @return The bytes for subscriber. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getSubscriberBytes() { - java.lang.Object ref = subscriber_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscriber_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int UUID_FIELD_NUMBER = 7; + public static final int UUID_FIELD_NUMBER = 2; private volatile java.lang.Object uuid_; /** - * string uuid = 7; + * string uuid = 2; * @return The uuid. */ @java.lang.Override @@ -395,7 +176,7 @@ public java.lang.String getUuid() { } } /** - * string uuid = 7; + * string uuid = 2; * @return The bytes for uuid. */ @java.lang.Override @@ -413,48 +194,10 @@ public java.lang.String getUuid() { } } - public static final int TIMESTAMP_FIELD_NUMBER = 8; - private volatile java.lang.Object timeStamp_; - /** - * string timeStamp = 8; - * @return The timeStamp. - */ - @java.lang.Override - public java.lang.String getTimeStamp() { - java.lang.Object ref = timeStamp_; - 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(); - timeStamp_ = s; - return s; - } - } - /** - * string timeStamp = 8; - * @return The bytes for timeStamp. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getTimeStampBytes() { - java.lang.Object ref = timeStamp_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - timeStamp_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int ORGANIZATION_FIELD_NUMBER = 9; + public static final int ORGANIZATION_FIELD_NUMBER = 3; private volatile java.lang.Object organization_; /** - * string organization = 9; + * string organization = 3; * @return The organization. */ @java.lang.Override @@ -471,7 +214,7 @@ public java.lang.String getOrganization() { } } /** - * string organization = 9; + * string organization = 3; * @return The bytes for organization. */ @java.lang.Override @@ -489,6 +232,32 @@ public java.lang.String getOrganization() { } } + public static final int SUBSCRIBEDAPI_FIELD_NUMBER = 4; + private org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI subscribedApi_; + /** + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + * @return Whether the subscribedApi field is set. + */ + @java.lang.Override + public boolean hasSubscribedApi() { + return subscribedApi_ != null; + } + /** + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + * @return The subscribedApi. + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI getSubscribedApi() { + return subscribedApi_ == null ? org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.getDefaultInstance() : subscribedApi_; + } + /** + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + */ + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder getSubscribedApiOrBuilder() { + return getSubscribedApi(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -503,32 +272,17 @@ public final boolean isInitialized() { @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 (!getApplicationRefBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, applicationRef_); - } - if (!getApiRefBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, apiRef_); - } - if (!getPolicyIdBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, policyId_); - } if (!getSubStatusBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, subStatus_); - } - if (!getSubscriberBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, subscriber_); + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, subStatus_); } if (!getUuidBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 7, uuid_); - } - if (!getTimeStampBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, timeStamp_); + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, uuid_); } if (!getOrganizationBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 9, organization_); + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, organization_); + } + if (subscribedApi_ != null) { + output.writeMessage(4, getSubscribedApi()); } unknownFields.writeTo(output); } @@ -539,32 +293,18 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!getEventIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, eventId_); - } - if (!getApplicationRefBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, applicationRef_); - } - if (!getApiRefBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, apiRef_); - } - if (!getPolicyIdBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, policyId_); - } if (!getSubStatusBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, subStatus_); - } - if (!getSubscriberBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, subscriber_); + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, subStatus_); } if (!getUuidBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, uuid_); - } - if (!getTimeStampBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, timeStamp_); + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, uuid_); } if (!getOrganizationBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, organization_); + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, organization_); + } + if (subscribedApi_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getSubscribedApi()); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -581,24 +321,17 @@ public boolean equals(final java.lang.Object obj) { } org.wso2.apk.enforcer.discovery.subscription.Subscription other = (org.wso2.apk.enforcer.discovery.subscription.Subscription) obj; - if (!getEventId() - .equals(other.getEventId())) return false; - if (!getApplicationRef() - .equals(other.getApplicationRef())) return false; - if (!getApiRef() - .equals(other.getApiRef())) return false; - if (!getPolicyId() - .equals(other.getPolicyId())) return false; if (!getSubStatus() .equals(other.getSubStatus())) return false; - if (!getSubscriber() - .equals(other.getSubscriber())) return false; if (!getUuid() .equals(other.getUuid())) return false; - if (!getTimeStamp() - .equals(other.getTimeStamp())) return false; if (!getOrganization() .equals(other.getOrganization())) return false; + if (hasSubscribedApi() != other.hasSubscribedApi()) return false; + if (hasSubscribedApi()) { + if (!getSubscribedApi() + .equals(other.getSubscribedApi())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -610,24 +343,16 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + EVENTID_FIELD_NUMBER; - hash = (53 * hash) + getEventId().hashCode(); - hash = (37 * hash) + APPLICATIONREF_FIELD_NUMBER; - hash = (53 * hash) + getApplicationRef().hashCode(); - hash = (37 * hash) + APIREF_FIELD_NUMBER; - hash = (53 * hash) + getApiRef().hashCode(); - hash = (37 * hash) + POLICYID_FIELD_NUMBER; - hash = (53 * hash) + getPolicyId().hashCode(); hash = (37 * hash) + SUBSTATUS_FIELD_NUMBER; hash = (53 * hash) + getSubStatus().hashCode(); - hash = (37 * hash) + SUBSCRIBER_FIELD_NUMBER; - hash = (53 * hash) + getSubscriber().hashCode(); hash = (37 * hash) + UUID_FIELD_NUMBER; hash = (53 * hash) + getUuid().hashCode(); - hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; - hash = (53 * hash) + getTimeStamp().hashCode(); hash = (37 * hash) + ORGANIZATION_FIELD_NUMBER; hash = (53 * hash) + getOrganization().hashCode(); + if (hasSubscribedApi()) { + hash = (37 * hash) + SUBSCRIBEDAPI_FIELD_NUMBER; + hash = (53 * hash) + getSubscribedApi().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -765,24 +490,18 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - eventId_ = ""; - - applicationRef_ = ""; - - apiRef_ = ""; - - policyId_ = ""; - subStatus_ = ""; - subscriber_ = ""; - uuid_ = ""; - timeStamp_ = ""; - organization_ = ""; + if (subscribedApiBuilder_ == null) { + subscribedApi_ = null; + } else { + subscribedApi_ = null; + subscribedApiBuilder_ = null; + } return this; } @@ -809,15 +528,14 @@ public org.wso2.apk.enforcer.discovery.subscription.Subscription build() { @java.lang.Override public org.wso2.apk.enforcer.discovery.subscription.Subscription buildPartial() { org.wso2.apk.enforcer.discovery.subscription.Subscription result = new org.wso2.apk.enforcer.discovery.subscription.Subscription(this); - result.eventId_ = eventId_; - result.applicationRef_ = applicationRef_; - result.apiRef_ = apiRef_; - result.policyId_ = policyId_; result.subStatus_ = subStatus_; - result.subscriber_ = subscriber_; result.uuid_ = uuid_; - result.timeStamp_ = timeStamp_; result.organization_ = organization_; + if (subscribedApiBuilder_ == null) { + result.subscribedApi_ = subscribedApi_; + } else { + result.subscribedApi_ = subscribedApiBuilder_.build(); + } onBuilt(); return result; } @@ -866,42 +584,21 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.Subscription other) { if (other == org.wso2.apk.enforcer.discovery.subscription.Subscription.getDefaultInstance()) return this; - if (!other.getEventId().isEmpty()) { - eventId_ = other.eventId_; - onChanged(); - } - if (!other.getApplicationRef().isEmpty()) { - applicationRef_ = other.applicationRef_; - onChanged(); - } - if (!other.getApiRef().isEmpty()) { - apiRef_ = other.apiRef_; - onChanged(); - } - if (!other.getPolicyId().isEmpty()) { - policyId_ = other.policyId_; - onChanged(); - } if (!other.getSubStatus().isEmpty()) { subStatus_ = other.subStatus_; onChanged(); } - if (!other.getSubscriber().isEmpty()) { - subscriber_ = other.subscriber_; - onChanged(); - } if (!other.getUuid().isEmpty()) { uuid_ = other.uuid_; onChanged(); } - if (!other.getTimeStamp().isEmpty()) { - timeStamp_ = other.timeStamp_; - onChanged(); - } if (!other.getOrganization().isEmpty()) { organization_ = other.organization_; onChanged(); } + if (other.hasSubscribedApi()) { + mergeSubscribedApi(other.getSubscribedApi()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -931,688 +628,351 @@ public Builder mergeFrom( return this; } - private java.lang.Object eventId_ = ""; + private java.lang.Object subStatus_ = ""; /** - * string eventId = 1; - * @return The eventId. + * string subStatus = 1; + * @return The subStatus. */ - public java.lang.String getEventId() { - java.lang.Object ref = eventId_; + public java.lang.String getSubStatus() { + java.lang.Object ref = subStatus_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - eventId_ = s; + subStatus_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string eventId = 1; - * @return The bytes for eventId. + * string subStatus = 1; + * @return The bytes for subStatus. */ public com.google.protobuf.ByteString - getEventIdBytes() { - java.lang.Object ref = eventId_; + getSubStatusBytes() { + java.lang.Object ref = subStatus_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - eventId_ = b; + subStatus_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string eventId = 1; - * @param value The eventId to set. + * string subStatus = 1; + * @param value The subStatus to set. * @return This builder for chaining. */ - public Builder setEventId( + public Builder setSubStatus( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - eventId_ = value; + subStatus_ = value; onChanged(); return this; } /** - * string eventId = 1; + * string subStatus = 1; * @return This builder for chaining. */ - public Builder clearEventId() { + public Builder clearSubStatus() { - eventId_ = getDefaultInstance().getEventId(); + subStatus_ = getDefaultInstance().getSubStatus(); onChanged(); return this; } /** - * string eventId = 1; - * @param value The bytes for eventId to set. + * string subStatus = 1; + * @param value The bytes for subStatus to set. * @return This builder for chaining. */ - public Builder setEventIdBytes( + public Builder setSubStatusBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - eventId_ = value; + subStatus_ = value; onChanged(); return this; } - private java.lang.Object applicationRef_ = ""; + private java.lang.Object uuid_ = ""; /** - * string applicationRef = 2; - * @return The applicationRef. + * string uuid = 2; + * @return The uuid. */ - public java.lang.String getApplicationRef() { - java.lang.Object ref = applicationRef_; + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - applicationRef_ = s; + uuid_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string applicationRef = 2; - * @return The bytes for applicationRef. + * string uuid = 2; + * @return The bytes for uuid. */ public com.google.protobuf.ByteString - getApplicationRefBytes() { - java.lang.Object ref = applicationRef_; + getUuidBytes() { + java.lang.Object ref = uuid_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - applicationRef_ = b; + uuid_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string applicationRef = 2; - * @param value The applicationRef to set. + * string uuid = 2; + * @param value The uuid to set. * @return This builder for chaining. */ - public Builder setApplicationRef( + public Builder setUuid( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - applicationRef_ = value; + uuid_ = value; onChanged(); return this; } /** - * string applicationRef = 2; + * string uuid = 2; * @return This builder for chaining. */ - public Builder clearApplicationRef() { + public Builder clearUuid() { - applicationRef_ = getDefaultInstance().getApplicationRef(); + uuid_ = getDefaultInstance().getUuid(); onChanged(); return this; } /** - * string applicationRef = 2; - * @param value The bytes for applicationRef to set. + * string uuid = 2; + * @param value The bytes for uuid to set. * @return This builder for chaining. */ - public Builder setApplicationRefBytes( + public Builder setUuidBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - applicationRef_ = value; + uuid_ = value; onChanged(); return this; } - private java.lang.Object apiRef_ = ""; + private java.lang.Object organization_ = ""; /** - * string apiRef = 3; - * @return The apiRef. + * string organization = 3; + * @return The organization. */ - public java.lang.String getApiRef() { - java.lang.Object ref = apiRef_; + 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(); - apiRef_ = s; + organization_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string apiRef = 3; - * @return The bytes for apiRef. + * string organization = 3; + * @return The bytes for organization. */ public com.google.protobuf.ByteString - getApiRefBytes() { - java.lang.Object ref = apiRef_; + getOrganizationBytes() { + java.lang.Object ref = organization_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - apiRef_ = b; + organization_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string apiRef = 3; - * @param value The apiRef to set. + * string organization = 3; + * @param value The organization to set. * @return This builder for chaining. */ - public Builder setApiRef( + public Builder setOrganization( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - apiRef_ = value; + organization_ = value; onChanged(); return this; } /** - * string apiRef = 3; + * string organization = 3; * @return This builder for chaining. */ - public Builder clearApiRef() { + public Builder clearOrganization() { - apiRef_ = getDefaultInstance().getApiRef(); + organization_ = getDefaultInstance().getOrganization(); onChanged(); return this; } /** - * string apiRef = 3; - * @param value The bytes for apiRef to set. + * string organization = 3; + * @param value The bytes for organization to set. * @return This builder for chaining. */ - public Builder setApiRefBytes( + public Builder setOrganizationBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - apiRef_ = value; + organization_ = value; onChanged(); return this; } - private java.lang.Object policyId_ = ""; + private org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI subscribedApi_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder> subscribedApiBuilder_; /** - * string policyId = 4; - * @return The policyId. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + * @return Whether the subscribedApi field is set. */ - public java.lang.String getPolicyId() { - java.lang.Object ref = policyId_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - policyId_ = s; - return s; - } else { - return (java.lang.String) ref; - } + public boolean hasSubscribedApi() { + return subscribedApiBuilder_ != null || subscribedApi_ != null; } /** - * string policyId = 4; - * @return The bytes for policyId. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + * @return The subscribedApi. */ - public com.google.protobuf.ByteString - getPolicyIdBytes() { - java.lang.Object ref = policyId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - policyId_ = b; - return b; + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI getSubscribedApi() { + if (subscribedApiBuilder_ == null) { + return subscribedApi_ == null ? org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.getDefaultInstance() : subscribedApi_; } else { - return (com.google.protobuf.ByteString) ref; + return subscribedApiBuilder_.getMessage(); } } /** - * string policyId = 4; - * @param value The policyId to set. - * @return This builder for chaining. - */ - public Builder setPolicyId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - policyId_ = value; - onChanged(); - return this; - } - /** - * string policyId = 4; - * @return This builder for chaining. - */ - public Builder clearPolicyId() { - - policyId_ = getDefaultInstance().getPolicyId(); - onChanged(); - return this; - } - /** - * string policyId = 4; - * @param value The bytes for policyId to set. - * @return This builder for chaining. - */ - public Builder setPolicyIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - policyId_ = value; - onChanged(); - return this; - } - - private java.lang.Object subStatus_ = ""; - /** - * string subStatus = 5; - * @return The subStatus. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; */ - public java.lang.String getSubStatus() { - java.lang.Object ref = subStatus_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subStatus_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string subStatus = 5; - * @return The bytes for subStatus. - */ - public com.google.protobuf.ByteString - getSubStatusBytes() { - java.lang.Object ref = subStatus_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subStatus_ = b; - return b; + public Builder setSubscribedApi(org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI value) { + if (subscribedApiBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + subscribedApi_ = value; + onChanged(); } else { - return (com.google.protobuf.ByteString) ref; + subscribedApiBuilder_.setMessage(value); } - } - /** - * string subStatus = 5; - * @param value The subStatus to set. - * @return This builder for chaining. - */ - public Builder setSubStatus( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subStatus_ = value; - onChanged(); - return this; - } - /** - * string subStatus = 5; - * @return This builder for chaining. - */ - public Builder clearSubStatus() { - - subStatus_ = getDefaultInstance().getSubStatus(); - onChanged(); - return this; - } - /** - * string subStatus = 5; - * @param value The bytes for subStatus to set. - * @return This builder for chaining. - */ - public Builder setSubStatusBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subStatus_ = value; - onChanged(); - return this; - } - private java.lang.Object subscriber_ = ""; - /** - * string subscriber = 6; - * @return The subscriber. - */ - public java.lang.String getSubscriber() { - java.lang.Object ref = subscriber_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - subscriber_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string subscriber = 6; - * @return The bytes for subscriber. - */ - public com.google.protobuf.ByteString - getSubscriberBytes() { - java.lang.Object ref = subscriber_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - subscriber_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string subscriber = 6; - * @param value The subscriber to set. - * @return This builder for chaining. - */ - public Builder setSubscriber( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - subscriber_ = value; - onChanged(); - return this; - } - /** - * string subscriber = 6; - * @return This builder for chaining. - */ - public Builder clearSubscriber() { - - subscriber_ = getDefaultInstance().getSubscriber(); - onChanged(); return this; } /** - * string subscriber = 6; - * @param value The bytes for subscriber to set. - * @return This builder for chaining. - */ - public Builder setSubscriberBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - subscriber_ = value; - onChanged(); - return this; - } - - private java.lang.Object uuid_ = ""; - /** - * string uuid = 7; - * @return The uuid. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; */ - public java.lang.String getUuid() { - java.lang.Object ref = uuid_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - uuid_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string uuid = 7; - * @return The bytes for uuid. - */ - public com.google.protobuf.ByteString - getUuidBytes() { - java.lang.Object ref = uuid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - uuid_ = b; - return b; + public Builder setSubscribedApi( + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder builderForValue) { + if (subscribedApiBuilder_ == null) { + subscribedApi_ = builderForValue.build(); + onChanged(); } else { - return (com.google.protobuf.ByteString) ref; + subscribedApiBuilder_.setMessage(builderForValue.build()); } - } - /** - * string uuid = 7; - * @param value The uuid to set. - * @return This builder for chaining. - */ - public Builder setUuid( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - uuid_ = value; - onChanged(); - return this; - } - /** - * string uuid = 7; - * @return This builder for chaining. - */ - public Builder clearUuid() { - - uuid_ = getDefaultInstance().getUuid(); - onChanged(); - return this; - } - /** - * string uuid = 7; - * @param value The bytes for uuid to set. - * @return This builder for chaining. - */ - public Builder setUuidBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - uuid_ = value; - onChanged(); + return this; } - - private java.lang.Object timeStamp_ = ""; /** - * string timeStamp = 8; - * @return The timeStamp. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; */ - public java.lang.String getTimeStamp() { - java.lang.Object ref = timeStamp_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - timeStamp_ = s; - return s; + public Builder mergeSubscribedApi(org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI value) { + if (subscribedApiBuilder_ == null) { + if (subscribedApi_ != null) { + subscribedApi_ = + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.newBuilder(subscribedApi_).mergeFrom(value).buildPartial(); + } else { + subscribedApi_ = value; + } + onChanged(); } else { - return (java.lang.String) ref; + subscribedApiBuilder_.mergeFrom(value); } + + return this; } /** - * string timeStamp = 8; - * @return The bytes for timeStamp. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; */ - public com.google.protobuf.ByteString - getTimeStampBytes() { - java.lang.Object ref = timeStamp_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - timeStamp_ = b; - return b; + public Builder clearSubscribedApi() { + if (subscribedApiBuilder_ == null) { + subscribedApi_ = null; + onChanged(); } else { - return (com.google.protobuf.ByteString) ref; + subscribedApi_ = null; + subscribedApiBuilder_ = null; } - } - /** - * string timeStamp = 8; - * @param value The timeStamp to set. - * @return This builder for chaining. - */ - public Builder setTimeStamp( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - timeStamp_ = value; - onChanged(); - return this; - } - /** - * string timeStamp = 8; - * @return This builder for chaining. - */ - public Builder clearTimeStamp() { - - timeStamp_ = getDefaultInstance().getTimeStamp(); - onChanged(); + return this; } /** - * string timeStamp = 8; - * @param value The bytes for timeStamp to set. - * @return This builder for chaining. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; */ - public Builder setTimeStampBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder getSubscribedApiBuilder() { - timeStamp_ = value; onChanged(); - return this; + return getSubscribedApiFieldBuilder().getBuilder(); } - - private java.lang.Object organization_ = ""; /** - * string organization = 9; - * @return The organization. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; */ - 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; + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder getSubscribedApiOrBuilder() { + if (subscribedApiBuilder_ != null) { + return subscribedApiBuilder_.getMessageOrBuilder(); } else { - return (java.lang.String) ref; + return subscribedApi_ == null ? + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.getDefaultInstance() : subscribedApi_; } } /** - * string organization = 9; - * @return The bytes for organization. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; */ - 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; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder> + getSubscribedApiFieldBuilder() { + if (subscribedApiBuilder_ == null) { + subscribedApiBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder>( + getSubscribedApi(), + getParentForChildren(), + isClean()); + subscribedApi_ = null; } - } - /** - * string organization = 9; - * @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 = 9; - * @return This builder for chaining. - */ - public Builder clearOrganization() { - - organization_ = getDefaultInstance().getOrganization(); - onChanged(); - return this; - } - /** - * string organization = 9; - * @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; + return subscribedApiBuilder_; } @java.lang.Override public final Builder setUnknownFields( diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionOrBuilder.java index 671c603fe..514093ba9 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionOrBuilder.java @@ -8,110 +8,53 @@ public interface SubscriptionOrBuilder extends 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 applicationRef = 2; - * @return The applicationRef. - */ - java.lang.String getApplicationRef(); - /** - * string applicationRef = 2; - * @return The bytes for applicationRef. - */ - com.google.protobuf.ByteString - getApplicationRefBytes(); - - /** - * string apiRef = 3; - * @return The apiRef. - */ - java.lang.String getApiRef(); - /** - * string apiRef = 3; - * @return The bytes for apiRef. - */ - com.google.protobuf.ByteString - getApiRefBytes(); - - /** - * string policyId = 4; - * @return The policyId. - */ - java.lang.String getPolicyId(); - /** - * string policyId = 4; - * @return The bytes for policyId. - */ - com.google.protobuf.ByteString - getPolicyIdBytes(); - - /** - * string subStatus = 5; + * string subStatus = 1; * @return The subStatus. */ java.lang.String getSubStatus(); /** - * string subStatus = 5; + * string subStatus = 1; * @return The bytes for subStatus. */ com.google.protobuf.ByteString getSubStatusBytes(); /** - * string subscriber = 6; - * @return The subscriber. - */ - java.lang.String getSubscriber(); - /** - * string subscriber = 6; - * @return The bytes for subscriber. - */ - com.google.protobuf.ByteString - getSubscriberBytes(); - - /** - * string uuid = 7; + * string uuid = 2; * @return The uuid. */ java.lang.String getUuid(); /** - * string uuid = 7; + * string uuid = 2; * @return The bytes for uuid. */ com.google.protobuf.ByteString getUuidBytes(); /** - * string timeStamp = 8; - * @return The timeStamp. + * string organization = 3; + * @return The organization. */ - java.lang.String getTimeStamp(); + java.lang.String getOrganization(); /** - * string timeStamp = 8; - * @return The bytes for timeStamp. + * string organization = 3; + * @return The bytes for organization. */ com.google.protobuf.ByteString - getTimeStampBytes(); + getOrganizationBytes(); /** - * string organization = 9; - * @return The organization. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + * @return Whether the subscribedApi field is set. */ - java.lang.String getOrganization(); + boolean hasSubscribedApi(); /** - * string organization = 9; - * @return The bytes for organization. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + * @return The subscribedApi. */ - com.google.protobuf.ByteString - getOrganizationBytes(); + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI getSubscribedApi(); + /** + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 4; + */ + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder getSubscribedApiOrBuilder(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionProto.java index a31bfb5fa..5bd30b302 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscriptionProto.java @@ -19,6 +19,11 @@ public static void registerAllExtensions( static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_wso2_discovery_subscription_Subscription_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_subscription_SubscribedAPI_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -29,16 +34,16 @@ public static void registerAllExtensions( static { java.lang.String[] descriptorData = { "\n.wso2/discovery/subscription/subscripti" + - "on.proto\022\033wso2.discovery.subscription\"\267\001" + - "\n\014Subscription\022\017\n\007eventId\030\001 \001(\t\022\026\n\016appli" + - "cationRef\030\002 \001(\t\022\016\n\006apiRef\030\003 \001(\t\022\020\n\010polic" + - "yId\030\004 \001(\t\022\021\n\tsubStatus\030\005 \001(\t\022\022\n\nsubscrib" + - "er\030\006 \001(\t\022\014\n\004uuid\030\007 \001(\t\022\021\n\ttimeStamp\030\010 \001(" + - "\t\022\024\n\014organization\030\t \001(\tB\224\001\n,org.wso2.apk" + - ".enforcer.discovery.subscriptionB\021Subscr" + - "iptionProtoP\001ZOgithub.com/envoyproxy/go-" + - "control-plane/wso2/discovery/subscriptio" + - "n;subscriptionb\006proto3" + "on.proto\022\033wso2.discovery.subscription\"\210\001" + + "\n\014Subscription\022\021\n\tsubStatus\030\001 \001(\t\022\014\n\004uui" + + "d\030\002 \001(\t\022\024\n\014organization\030\003 \001(\t\022A\n\rsubscri" + + "bedApi\030\004 \001(\0132*.wso2.discovery.subscripti" + + "on.SubscribedAPI\".\n\rSubscribedAPI\022\014\n\004nam" + + "e\030\001 \001(\t\022\017\n\007version\030\002 \001(\tB\224\001\n,org.wso2.ap" + + "k.enforcer.discovery.subscriptionB\021Subsc" + + "riptionProtoP\001ZOgithub.com/envoyproxy/go" + + "-control-plane/wso2/discovery/subscripti" + + "on;subscriptionb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -49,7 +54,13 @@ public static void registerAllExtensions( internal_static_wso2_discovery_subscription_Subscription_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_subscription_Subscription_descriptor, - new java.lang.String[] { "EventId", "ApplicationRef", "ApiRef", "PolicyId", "SubStatus", "Subscriber", "Uuid", "TimeStamp", "Organization", }); + new java.lang.String[] { "SubStatus", "Uuid", "Organization", "SubscribedApi", }); + internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_wso2_discovery_subscription_SubscribedAPI_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor, + new java.lang.String[] { "Name", "Version", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/dto/APIKeyValidationInfoDTO.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/dto/APIKeyValidationInfoDTO.java index eeab20c2a..f9fe0dfd2 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/dto/APIKeyValidationInfoDTO.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/dto/APIKeyValidationInfoDTO.java @@ -42,19 +42,14 @@ public class APIKeyValidationInfoDTO implements Serializable { private String userType; private String endUserToken; private String endUserName; - private int applicationId; private String applicationName; - private String applicationTier; //use this to pass key validation status private int validationStatus; private long validityPeriod; private long issuedTime; private List authorizedDomains; - //Following throttle data list can be use to hold throttle data and api level throttle key - //should be its first element. - private List throttlingDataList; private int spikeArrestLimit; - private String subscriberTenantDomain; + private String subscriberOrganization; private String spikeArrestUnit; private boolean stopOnQuotaReach; //keeps productId of product for which the key was validated, if key was validated for an api this will be null @@ -65,17 +60,11 @@ public class APIKeyValidationInfoDTO implements Serializable { private int graphQLMaxComplexity; private String apiVersion; private String apiUUID; + private String apiName; + private String apiContext; private String applicationUUID; private Map appAttributes; - public List getThrottlingDataList() { - return throttlingDataList; - } - - public void setThrottlingDataList(List throttlingDataList) { - this.throttlingDataList = throttlingDataList; - } - public boolean isContentAware() { return contentAware; } @@ -86,11 +75,10 @@ public void setContentAware(boolean contentAware) { private Set scopes; - private String apiName; - private String consumerKey; private String apiPublisher; + private String securityScheme; public boolean isAuthorized() { return authorized; @@ -140,14 +128,6 @@ public void setEndUserName(String endUserName) { this.endUserName = endUserName; } - public int getApplicationId() { - return applicationId; - } - - public void setApplicationId(int applicationId) { - this.applicationId = applicationId; - } - public String getApplicationName() { return applicationName; } @@ -156,14 +136,6 @@ public void setApplicationName(String applicationName) { this.applicationName = applicationName; } - public String getApplicationTier() { - return applicationTier; - } - - public void setApplicationTier(String applicationTier) { - this.applicationTier = applicationTier; - } - public int getValidationStatus() { return validationStatus; } @@ -212,6 +184,14 @@ public void setApiName(String apiName) { this.apiName = apiName; } + public String getApiContext() { + return apiContext; + } + + public void setApiContext(String apiContext) { + this.apiContext = apiContext; + } + public String getConsumerKey() { return consumerKey; } @@ -228,6 +208,14 @@ public void setApiPublisher(String apiPublisher) { this.apiPublisher = apiPublisher; } + public String getSecurityScheme() { + return securityScheme; + } + + public void setSecurityScheme(String securityScheme) { + this.securityScheme = securityScheme; + } + public Set getScopes() { return scopes; } @@ -246,21 +234,21 @@ public String toString() { append(" , userType:").append(userType). append(" , endUserToken:").append(endUserToken). append(" , endUserName:").append(endUserName). - append(" , applicationId:").append(applicationId). append(" , applicationName:").append(applicationName). - append(" , applicationTier:").append(applicationTier). append(" , validationStatus:").append(validationStatus). append(" , validityPeriod:").append(validityPeriod). append(" , issuedTime:").append(issuedTime). append(" , apiName:").append(apiName). + append(" , apiContext:").append(apiContext). append(" , consumerKey:").append(consumerKey). append(" , spikeArrestLimit:").append(spikeArrestLimit). append(" , spikeArrestUnit:").append(spikeArrestUnit). - append(" , subscriberTenantDomain:").append(subscriberTenantDomain). + append(" , subscriberOrganization:").append(subscriberOrganization). append(" , stopOnQuotaReach:").append(stopOnQuotaReach). append(" , productName:").append(productName). append(" , productProvider:").append(productProvider). append(" , apiPublisher:").append(apiPublisher). + append(" , securityScheme:").append(securityScheme). append(" , graphQLMaxDepth:").append(graphQLMaxDepth). append(" , graphQLMaxComplexity:").append(graphQLMaxComplexity); @@ -311,12 +299,12 @@ public void setStopOnQuotaReach(boolean stopOnQuotaReach) { this.stopOnQuotaReach = stopOnQuotaReach; } - public String getSubscriberTenantDomain() { - return subscriberTenantDomain; + public String getSubscriberOrganization() { + return subscriberOrganization; } - public void setSubscriberTenantDomain(String subscriberTenantDomain) { - this.subscriberTenantDomain = subscriberTenantDomain; + public void setSubscriberOrganization(String subscriberOrganization) { + this.subscriberOrganization = subscriberOrganization; } public void setProductName(String productName) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Application.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Application.java index 5c145b3e6..030d301c2 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Application.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Application.java @@ -20,8 +20,6 @@ import org.wso2.apk.enforcer.common.CacheableEntity; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -30,25 +28,19 @@ */ public class Application implements CacheableEntity { - private Integer id = null; private String uuid; private String name = null; - private Integer subId = null; - private String subName = null; - private String policy = null; - private String tokenType = null; - private String tenantDomain = null; - private List groupIds = new ArrayList<>(); + private String owner = null; private Map attributes = new ConcurrentHashMap<>(); - public Integer getId() { + public String getUUID() { - return id; + return uuid; } - public void setId(Integer id) { + public void setUUID(String uuid) { - this.id = id; + this.uuid = uuid; } public String getName() { @@ -61,54 +53,14 @@ public void setName(String name) { this.name = name; } - public Integer getSubId() { - - return subId; - } - - public void setSubId(Integer subId) { - - this.subId = subId; - } - - public String getPolicy() { - - return policy; - } - - public void setPolicy(String policy) { + public String getOwner() { - this.policy = policy; + return owner; } - public String getTokenType() { + public void setOwner(String owner) { - return tokenType; - } - - public void setTokenType(String tokenType) { - - this.tokenType = tokenType; - } - - public String getCacheKey() { - - return uuid; - } - - public List getGroupIds() { - - return groupIds; - } - - public void addGroupId(String groupId) { - - this.groupIds.add(groupId); - } - - public void removeGroupId(String groupId) { - - this.groupIds.remove(groupId); + this.owner = owner; } public Map getAttributes() { @@ -126,39 +78,17 @@ public void removeAttribute(String key) { this.attributes.remove(key); } - public String getSubName() { - - return subName; - } - - public void setSubName(String subName) { - - this.subName = subName; - } - - public void setUUID(String uuid) { - - this.uuid = uuid; - } - - public String getTenantDomain() { - return tenantDomain; - } + public String getCacheKey() { - public void setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; + return uuid; } @Override public String toString() { - return "Application [id=" + id + ", name=" + name + ", subId=" + subId + ", policy=" + policy + ", tokenType=" - + tokenType + ", groupIds=" + groupIds + ", tenantDomain=" + tenantDomain + ", attributes=" + attributes + + return "Application [uuid=" + uuid + ", name=" + name + ", owner=" + owner + ", attributes=" + attributes + "]"; } - public String getUUID() { - - return uuid; - } } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMapping.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMapping.java index 2bf815b5b..aadc9f92e 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMapping.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMapping.java @@ -23,88 +23,67 @@ /** * Entity for keeping mapping between Application and Consumer key. */ -public class ApplicationKeyMapping implements CacheableEntity { +public class ApplicationKeyMapping implements CacheableEntity { - private String consumerKey; - private String keyType; - private String keyManager; - private String wfState; private String applicationUUID; - private int applicationId; - - public String getConsumerKey() { + private String securityScheme; + private String applicationIdentifier; + private String keyType; + private String envId; - return consumerKey; + public String getApplicationUUID() { + return applicationUUID; } - public void setConsumerKey(String consumerKey) { - - this.consumerKey = consumerKey; + public void setApplicationUUID(String applicationUUID) { + this.applicationUUID = applicationUUID; } - public String getKeyType() { - - return keyType; + public String getSecurityScheme() { + return securityScheme; } - public void setKeyType(String keyType) { - - this.keyType = keyType; + public void setSecurityScheme(String securityScheme) { + this.securityScheme = securityScheme; } - public String getWfState() { - - return wfState; + public String getApplicationIdentifier() { + return applicationIdentifier; } - public void setWfState(String wfState) { - - this.wfState = wfState; + public void setApplicationIdentifier(String applicationIdentifier) { + this.applicationIdentifier = applicationIdentifier; } - public int getApplicationId() { - - return applicationId; + public String getKeyType() { + return keyType; } - public void setApplicationId(int applicationId) { - - this.applicationId = applicationId; + public void setKeyType(String keyType) { + this.keyType = keyType; } - @Override - public ApplicationKeyMappingCacheKey getCacheKey() { - return new ApplicationKeyMappingCacheKey(getConsumerKey(), getKeyManager()); + public String getEnvId() { + return envId; } - public String getKeyManager() { - - return keyManager; + public void setEnvId(String envId) { + this.envId = envId; } - public void setKeyManager(String keyManager) { - - this.keyManager = keyManager; + @Override + public String getCacheKey() { + return securityScheme + CacheableEntity.DELEM_PERIOD + applicationIdentifier; } @Override public String toString() { - return "ApplicationKeyMapping{" + - "consumerKey='" + consumerKey + '\'' + + "applicationUUID='" + applicationUUID + '\'' + + ", securityScheme='" + securityScheme + '\'' + + ", applicationIdentifier='" + applicationIdentifier + '\'' + ", keyType='" + keyType + '\'' + - ", keyManager='" + keyManager + '\'' + - ", wfState='" + wfState + '\'' + - ", applicationId=" + applicationId + + ", envId='" + envId + '\'' + '}'; } - - public String getApplicationUUID() { - return applicationUUID; - } - - public void setApplicationUUID(String applicationUUID) { - this.applicationUUID = applicationUUID; - } } - diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMappingCacheKey.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMappingCacheKey.java deleted file mode 100644 index 48c06f830..000000000 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMappingCacheKey.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.models; - -import java.util.Objects; - -/** - * Cache Key For Application KeyMapping Entries. - */ -public class ApplicationKeyMappingCacheKey { - - private String consumerKey; - private String keyManager; - - public ApplicationKeyMappingCacheKey(String consumerKey, String keyManager) { - this.consumerKey = consumerKey; - this.keyManager = keyManager; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ApplicationKeyMappingCacheKey that = (ApplicationKeyMappingCacheKey) o; - return Objects.equals(consumerKey, that.consumerKey) && - Objects.equals(keyManager, that.keyManager); - } - - @Override - public int hashCode() { - return Objects.hash(consumerKey, keyManager); - } - - @Override - public String toString() { - - return "ApplicationKeyMappingCacheKey{" + - "consumerKey='" + consumerKey + '\'' + - ", keyManager='" + keyManager + '\'' + - '}'; - } -} - diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationMapping.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationMapping.java new file mode 100644 index 000000000..ade548e22 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationMapping.java @@ -0,0 +1,71 @@ +/* + * 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.models; + +import org.wso2.apk.enforcer.common.CacheableEntity; + +/** + * Entity for keeping mapping between Application and Subscription. + */ +public class ApplicationMapping implements CacheableEntity { + + private String uuid = null; + private String applicationRef = null; + private String subscriptionRef = null; + + public String getUuid() { + + return uuid; + } + + public void setUuid(String uuid) { + + this.uuid = uuid; + } + + public String getApplicationRef() { + + return applicationRef; + } + + public void setApplicationRef(String applicationRef) { + + this.applicationRef = applicationRef; + } + + public String getSubscriptionRef() { + + return subscriptionRef; + } + + public void setSubscriptionRef(String subscriptionRef) { + + this.subscriptionRef = subscriptionRef; + } + + public String getCacheKey() { + return uuid; + } + + @Override + public String toString() { + return "ApplicationMapping [uuid=" + uuid + ", applicationRef=" + applicationRef + ", subscriptionRef=" + + subscriptionRef + "]"; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationMappingList.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationMappingList.java new file mode 100644 index 000000000..e3abcd6fa --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationMappingList.java @@ -0,0 +1,51 @@ +/* + * 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.models; + +import java.util.ArrayList; +import java.util.List; + +/** + * Holds details about list of application and subscription mappings. + */ +public class ApplicationMappingList { + + private Integer count = null; + private List list = new ArrayList<>(); + + public Integer getCount() { + + return count; + } + + public void setCount(Integer count) { + + this.count = count; + } + + public List getList() { + + return list; + } + + public void setList(List list) { + + this.list = list; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/SubscribedAPI.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/SubscribedAPI.java new file mode 100644 index 000000000..ba5282a7a --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/SubscribedAPI.java @@ -0,0 +1,47 @@ +/* + * 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.models; + +import java.util.ArrayList; +import java.util.List; + +/** + * Model class for Subscription related API details + */ +public class SubscribedAPI { + + private String name = null; + private String version = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Subscription.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Subscription.java index d3a2d6580..34fa8c73e 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Subscription.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/Subscription.java @@ -19,7 +19,6 @@ package org.wso2.apk.enforcer.models; import org.wso2.apk.enforcer.common.CacheableEntity; -import org.wso2.apk.enforcer.subscription.SubscriptionDataStoreUtil; /** * Entity for representing a SubscriptionDTO in APIM. @@ -27,10 +26,9 @@ public class Subscription implements CacheableEntity { private String subscriptionId = null; - private String policyId = null; - private String apiUUID = null; - private String appUUID = null; - private String subscriptionState = null; + private String subscriptionStatus = null; + private String organization = null; + private SubscribedAPI subscribedApi = null; private long timeStamp; public String getSubscriptionId() { @@ -43,30 +41,34 @@ public void setSubscriptionId(String subscriptionId) { this.subscriptionId = subscriptionId; } - public String getPolicyId() { + public String getSubscriptionStatus() { - return policyId; + return subscriptionStatus; } - public void setPolicyId(String policyId) { + public void setSubscriptionStatus(String subscriptionStatus) { - this.policyId = policyId; + this.subscriptionStatus = subscriptionStatus; } - public String getSubscriptionState() { + public String getOrganization() { - return subscriptionState; + return organization; } - public void setSubscriptionState(String subscriptionState) { + public void setOrganization(String organization) { - this.subscriptionState = subscriptionState; + this.organization = organization; } - @Override - public String getCacheKey() { + public SubscribedAPI getSubscribedApi() { + + return subscribedApi; + } + + public void setSubscribedApi(SubscribedAPI subscribedApi) { - return SubscriptionDataStoreUtil.getSubscriptionCacheKey(getAppUUID(), getApiUUID()); + this.subscribedApi = subscribedApi; } public long getTimeStamp() { @@ -79,33 +81,21 @@ public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } + @Override + public String getCacheKey() { + + return subscriptionId; + } + @Override public String toString() { return "Subscription{" + "subscriptionId='" + subscriptionId + '\'' + - ", policyId='" + policyId + '\'' + - ", apiId=" + apiUUID + - ", appId=" + appUUID + - ", subscriptionState='" + subscriptionState + '\'' + + ", subscriptionStatus='" + subscriptionStatus + '\'' + + ", organization='" + organization + '\'' + + ", subscribedApi=" + subscribedApi + ", timeStamp=" + timeStamp + '}'; } - - public String getApiUUID() { - return apiUUID; - } - - public void setApiUUID(String apiUUID) { - this.apiUUID = apiUUID; - } - - public String getAppUUID() { - return appUUID; - } - - public void setAppUUID(String appUUID) { - this.appUUID = appUUID; - } } - diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/KeyValidator.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/KeyValidator.java index bd3bbe10a..fb5ad9306 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/KeyValidator.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/KeyValidator.java @@ -29,24 +29,19 @@ import org.wso2.apk.enforcer.commons.model.ResourceConfig; import org.wso2.apk.enforcer.constants.APIConstants; import org.wso2.apk.enforcer.constants.APISecurityConstants; -import org.wso2.apk.enforcer.constants.GeneralErrorCodeConstants; import org.wso2.apk.enforcer.dto.APIKeyValidationInfoDTO; import org.wso2.apk.enforcer.models.API; -import org.wso2.apk.enforcer.models.ApiPolicy; import org.wso2.apk.enforcer.models.Application; import org.wso2.apk.enforcer.models.ApplicationKeyMapping; -import org.wso2.apk.enforcer.models.ApplicationPolicy; +import org.wso2.apk.enforcer.models.ApplicationMapping; import org.wso2.apk.enforcer.models.Subscription; -import org.wso2.apk.enforcer.models.SubscriptionPolicy; -import org.wso2.apk.enforcer.models.URLMapping; import org.wso2.apk.enforcer.subscription.SubscriptionDataHolder; import org.wso2.apk.enforcer.subscription.SubscriptionDataStore; -import org.wso2.apk.enforcer.util.FilterUtils; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Does the subscription and scope validation. @@ -115,74 +110,89 @@ public static boolean validateScopes(TokenValidationContext validationContext) t } /** - * Validate subscriptions for access tokens. + * Validate subscriptions for access tokens by utilizing the consumer key. * - * @param uuid uuid of the API - * @param apiContext API context, used for logging purposes and to extract the tenant domain - * @param apiVersion API version, used for logging purposes - * @param consumerKey consumer key related to the token - * @param keyManager key manager related to the token - * @return validation information about the request + * @param validationInfo Token validation related details. This will be populated based on the available data during + * the subscription validation. + * @throws APISecurityException throws if subscription validation fails. */ - public static APIKeyValidationInfoDTO validateSubscription(String uuid, String apiContext, String apiVersion, - String consumerKey, String envType, String keyManager) { + public static void validateSubscriptionUsingConsumerKey(APIKeyValidationInfoDTO validationInfo) + throws APISecurityException { + API api; + Application app; + Subscription sub; + ApplicationKeyMapping keyMapping; + ApplicationMapping appMapping; + String apiName = validationInfo.getApiName(); + String apiContext = validationInfo.getApiContext(); + String apiVersion = validationInfo.getApiVersion(); + String consumerKey = validationInfo.getConsumerKey(); + String securityScheme = validationInfo.getSecurityScheme(); + String keyType = validationInfo.getType(); + log.debug("Before validating subscriptions"); - log.debug("Validation Info : { uuid : {}, context : {}, version : {}, consumerKey : {} }", - uuid, apiContext, apiVersion, consumerKey); - String apiTenantDomain = FilterUtils.getTenantDomainFromRequestURL(apiContext); - if (apiTenantDomain == null) { - apiTenantDomain = APIConstants.SUPER_TENANT_DOMAIN_NAME; - } + log.debug("Validation Info : { name : {}, context : {}, version : {}, consumerKey : {} }", + apiName, apiContext, apiVersion, consumerKey); - API api = null; - ApplicationKeyMapping key = null; - Application app = null; - Subscription sub = null; + SubscriptionDataStore datastore = SubscriptionDataHolder.getInstance().getSubscriptionDataStore(); - SubscriptionDataStore datastore = SubscriptionDataHolder.getInstance() - .getTenantSubscriptionStore(apiTenantDomain); - //TODO add a check to see whether datastore is initialized an load data using rest api if it is not loaded - // TODO: (VirajSalaka) Handle the scenario where the event is dropped. if (datastore != null) { - api = datastore.getApiByContextAndVersion(uuid); + api = datastore.getMatchingAPI(apiContext, apiVersion); if (api != null) { - // TODO: (Sampath) Handle the scenario when App keys are generated properly and sent -// key = datastore.getKeyMappingByKeyAndKeyManager(consumerKey, keyManager); -// if (key != null) { - app = datastore.getApplicationById(key.getApplicationUUID()); - if (app != null) { - sub = datastore.getSubscriptionById(app.getUUID(), api.getApiUUID()); - if (sub != null) { - log.debug("All information is retrieved from the inmemory data store."); + // Get application key mapping using the consumer key, key type and security scheme + keyMapping = datastore.getMatchingApplicationKeyMapping(consumerKey, keyType, securityScheme); + + if (keyMapping != null) { + // Get application and application mapping using application UUID + String applicationUUID = keyMapping.getApplicationUUID(); + app = datastore.getMatchingApplication(applicationUUID); + appMapping = datastore.getMatchingApplicationMapping(applicationUUID); + + if (appMapping != null && app != null) { + // Get subscription using the subscription UUID + String subscriptionUUID = appMapping.getSubscriptionRef(); + sub = datastore.getMatchingSubscription(subscriptionUUID); + + // Validate subscription + if (sub != null) { + validate(validationInfo, api, app, sub); + if (!validationInfo.isAuthorized() && validationInfo.getValidationStatus() == 0) { + // Scenario where validation failed and message is not set + validationInfo.setValidationStatus( + APIConstants.KeyValidationStatus.API_AUTH_RESOURCE_FORBIDDEN); + } + log.debug("After validating subscriptions"); + return; + } else { + log.error( + "Valid subscription not found for access token. " + + "application: {}, app_UUID: {}, API name: {}, API context: {} API version : {}", + app.getName(), app.getUUID(), apiName, apiContext, apiVersion); + } } else { - log.info( - "Valid subscription not found for oauth access token. " + - "application: {} app_UUID: {} API_name: {} API_UUID : {}", - app.getName(), app.getUUID(), api.getApiName(), api.getApiUUID()); + log.error( + "Valid application and / or application mapping not found for application uuid : " + applicationUUID); } } else { - log.info("Application not found in the data store for uuid " + key.getApplicationUUID()); + log.error( + "Valid application key mapping not found in the data store for access token. " + + "Application identifier: {}, key type : {}, security scheme : {}", + consumerKey, keyType, securityScheme); } -// } else { -// log.info("Application key mapping not found in the data store for id consumerKey " + consumerKey); -// } } else { - log.info("API not found in the data store for API UUID :" + uuid); + log.error("API not found for API context : {} and API version : {}", apiContext, apiVersion); } } else { - log.error("Subscription data store is null for tenant domain " + apiTenantDomain); - } - - APIKeyValidationInfoDTO infoDTO = new APIKeyValidationInfoDTO(); - if (api != null && app != null && sub != null) { - validate(infoDTO, datastore, api, envType, app, sub); - } - if (!infoDTO.isAuthorized() && infoDTO.getValidationStatus() == 0) { - //Scenario where validation failed and message is not set - infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.API_AUTH_RESOURCE_FORBIDDEN); + log.error("Subscription data store is null"); + throw new APISecurityException(APIConstants.StatusCodes.UNAUTHENTICATED.getCode(), + APISecurityConstants.API_AUTH_GENERAL_ERROR, + APISecurityConstants.API_AUTH_GENERAL_ERROR_MESSAGE); } - log.debug("After validating subscriptions"); - return infoDTO; + // If the execution reaches this point, it means that the subscription validation has failed. + log.error("User is NOT authorized to access the API. Subscription validation failed for consumer key : " + + consumerKey); + throw new APISecurityException(APIConstants.StatusCodes.UNAUTHORIZED.getCode(), + APISecurityConstants.API_AUTH_FORBIDDEN, APISecurityConstants.API_AUTH_FORBIDDEN_MESSAGE); } /** @@ -194,19 +204,14 @@ public static APIKeyValidationInfoDTO validateSubscription(String uuid, String a * @return validation information about the request */ public static APIKeyValidationInfoDTO validateSubscription(String apiUuid, String apiContext, - JWTClaimsSet payload, String envType) { + JWTClaimsSet payload) { log.debug("Before validating subscriptions with API key. API_uuid: {}, context: {}", apiUuid, apiContext); - String apiTenantDomain = FilterUtils.getTenantDomainFromRequestURL(apiContext); - if (apiTenantDomain == null) { - apiTenantDomain = APIConstants.SUPER_TENANT_DOMAIN_NAME; - } API api = null; Application app = null; Subscription sub = null; - SubscriptionDataStore datastore = SubscriptionDataHolder.getInstance() - .getTenantSubscriptionStore(apiTenantDomain); + SubscriptionDataStore datastore = SubscriptionDataHolder.getInstance().getSubscriptionDataStore(); //TODO add a check to see whether datastore is initialized an load data using rest api if it is not loaded // TODO: (VirajSalaka) Handle the scenario where the event is dropped. if (datastore != null) { @@ -236,12 +241,12 @@ public static APIKeyValidationInfoDTO validateSubscription(String apiUuid, Strin log.info("API not found in the data store for API UUID :" + apiUuid); } } else { - log.error("Subscription data store is null for tenant domain " + apiTenantDomain); + log.error("Subscription data store is null"); } APIKeyValidationInfoDTO infoDTO = new APIKeyValidationInfoDTO(); if (api != null && app != null && sub != null) { - validate(infoDTO, datastore, api, envType, app, sub); + validate(infoDTO, api, app, sub); } if (!infoDTO.isAuthorized() && infoDTO.getValidationStatus() == 0) { //Scenario where validation failed and message is not set @@ -251,76 +256,60 @@ public static APIKeyValidationInfoDTO validateSubscription(String apiUuid, Strin return infoDTO; } - private static void validate(APIKeyValidationInfoDTO infoDTO, SubscriptionDataStore datastore, - API api, String keyType, Application app, Subscription sub) { - String subscriptionStatus = sub.getSubscriptionState(); - if (APIConstants.SubscriptionStatus.BLOCKED.equals(subscriptionStatus)) { - infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.API_BLOCKED); - infoDTO.setAuthorized(false); - return; - } else if (APIConstants.SubscriptionStatus.ON_HOLD.equals(subscriptionStatus) - || APIConstants.SubscriptionStatus.REJECTED.equals(subscriptionStatus)) { + private static void validate(APIKeyValidationInfoDTO infoDTO, API api, Application app, Subscription sub) { + + // Validate subscription status + String subscriptionStatus = sub.getSubscriptionStatus(); + if (APIConstants.SubscriptionStatus.INACTIVE.equals(subscriptionStatus)) { infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.SUBSCRIPTION_INACTIVE); infoDTO.setAuthorized(false); return; - } else if (APIConstants.SubscriptionStatus.PROD_ONLY_BLOCKED.equals(subscriptionStatus) - && !APIConstants.API_KEY_TYPE_SANDBOX.equals(keyType)) { - infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.API_BLOCKED); - infoDTO.setType(keyType); + } +// if (APIConstants.SubscriptionStatus.BLOCKED.equals(subscriptionStatus)) { +// infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.API_BLOCKED); +// infoDTO.setAuthorized(false); +// return; +// } else if (APIConstants.SubscriptionStatus.ON_HOLD.equals(subscriptionStatus) +// || APIConstants.SubscriptionStatus.REJECTED.equals(subscriptionStatus)) { +// infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.SUBSCRIPTION_INACTIVE); +// infoDTO.setAuthorized(false); +// return; +// } else if (APIConstants.SubscriptionStatus.PROD_ONLY_BLOCKED.equals(subscriptionStatus) +// && !APIConstants.API_KEY_TYPE_SANDBOX.equals(keyType)) { +// infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.API_BLOCKED); +// infoDTO.setType(keyType); +// infoDTO.setAuthorized(false); +// return; +// } else if (APIConstants.LifecycleStatus.BLOCKED.equals(api.getLcState())) { +// infoDTO.setValidationStatus(GeneralErrorCodeConstants.API_BLOCKED_CODE); +// infoDTO.setAuthorized(false); +// return; +// } + + // Validate API details embedded within the subscription + // Validate API name + if (!infoDTO.getApiName().equals(sub.getSubscribedApi().getName())) { infoDTO.setAuthorized(false); return; - } else if (APIConstants.LifecycleStatus.BLOCKED.equals(api.getLcState())) { - infoDTO.setValidationStatus(GeneralErrorCodeConstants.API_BLOCKED_CODE); + } + // Validate API version + String versionRegex = sub.getSubscribedApi().getVersion(); + String versionToMatch = infoDTO.getApiVersion(); + Pattern pattern = Pattern.compile(versionRegex); + Matcher matcher = pattern.matcher(versionToMatch); + if (!matcher.matches()) { infoDTO.setAuthorized(false); return; } - infoDTO.setTier(sub.getPolicyId()); - infoDTO.setSubscriber(app.getSubName()); - //infoDTO.setApplicationId(app.getId()); + infoDTO.setApplicationUUID(app.getUUID()); + infoDTO.setSubscriber(app.getOwner()); infoDTO.setApiName(api.getApiName()); infoDTO.setApiVersion(api.getApiVersion()); infoDTO.setApiPublisher(api.getApiProvider()); infoDTO.setApplicationName(app.getName()); - infoDTO.setApplicationTier(app.getPolicy()); infoDTO.setAppAttributes(app.getAttributes()); infoDTO.setApiUUID(api.getApiUUID()); - infoDTO.setType(keyType); - infoDTO.setSubscriberTenantDomain(app.getTenantDomain()); - - // Todo: (Sampath) This must be implemented as a part rate plans implementation. -// ApplicationPolicy appPolicy = datastore.getApplicationPolicyByName(app.getPolicy()); -// SubscriptionPolicy subPolicy = datastore.getSubscriptionPolicyByName(sub.getPolicyId()); -// ApiPolicy apiPolicy = datastore.getApiPolicyByName(api.getApiTier()); -// boolean isContentAware = appPolicy.isContentAware() || subPolicy.isContentAware() || -// (apiPolicy != null && apiPolicy.isContentAware()); -// infoDTO.setContentAware(isContentAware); -// int spikeArrest = 0; -// String apiLevelThrottlingKey = "api_level_throttling_key"; -// -// if (subPolicy.getRateLimitCount() > 0) { -// spikeArrest = subPolicy.getRateLimitCount(); -// } -// -// String spikeArrestUnit = null; -// -// if (subPolicy.getRateLimitTimeUnit() != null) { -// spikeArrestUnit = subPolicy.getRateLimitTimeUnit(); -// } -// boolean stopOnQuotaReach = subPolicy.isStopOnQuotaReach(); -// int graphQLMaxDepth = Math.max(subPolicy.getGraphQLMaxDepth(), 0); -// int graphQLMaxComplexity = Math.max(subPolicy.getGraphQLMaxComplexity(), 0); -// List list = new ArrayList<>(); -// list.add(apiLevelThrottlingKey); -// infoDTO.setSpikeArrestLimit(spikeArrest); -// infoDTO.setSpikeArrestUnit(spikeArrestUnit); -// infoDTO.setStopOnQuotaReach(stopOnQuotaReach); -// infoDTO.setGraphQLMaxDepth(graphQLMaxDepth); -// infoDTO.setGraphQLMaxComplexity(graphQLMaxComplexity); -// // We also need to set throttling data list associated with given API. This need to have -// // policy id and -// // condition id list for all throttling tiers associated with this API. -// infoDTO.setThrottlingDataList(list); infoDTO.setAuthorized(true); } } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/APIKeyAuthenticator.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/APIKeyAuthenticator.java index 45fc78fcb..431bb7a4b 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/APIKeyAuthenticator.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/APIKeyAuthenticator.java @@ -209,7 +209,7 @@ private AuthenticationContext processAPIKey(RequestContext requestContext, Strin APIKeyValidationInfoDTO validationInfoDto; log.debug("Validating subscription for API Key against subscription store." + " context: {} version: {}", apiContext, apiVersion); - validationInfoDto = KeyValidator.validateSubscription(apiUuid, apiContext, payload, envType); + validationInfoDto = KeyValidator.validateSubscription(apiUuid, apiContext, payload); if (!requestContext.getMatchedAPI().isSystemAPI()) { log.debug("Validating subscription for API Key using JWT claims against invoked API info." + " context: {} version: {}", apiContext, apiVersion); @@ -218,7 +218,7 @@ private AuthenticationContext processAPIKey(RequestContext requestContext, Strin log.debug("Creating API Key info DTO for unknown API and Application." + " context: {} version: {}", apiContext, apiVersion); validationInfoDto = new APIKeyValidationInfoDTO(); - JWTUtils.updateApplicationNameForSubscriptionDisabledKM(validationInfoDto, + JWTUtils.updateApplicationNameForSubscriptionDisabledFlow(validationInfoDto, APIConstants.KeyManager.APIM_APIKEY_ISSUER); validationInfoDto.setAuthorized(true); } @@ -312,7 +312,6 @@ private APIKeyValidationInfoDTO getAPIKeyValidationDTO(RequestContext requestCon if (app != null) { validationInfoDTO.setApplicationUUID(app.getAsString(APIConstants.JwtTokenConstants.APPLICATION_UUID)); validationInfoDTO.setApplicationName(app.getAsString(APIConstants.JwtTokenConstants.APPLICATION_NAME)); - validationInfoDTO.setApplicationTier(app.getAsString(APIConstants.JwtTokenConstants.APPLICATION_TIER)); //validationInfoDTO.setSubscriber(app.getAsString(APIConstants.JwtTokenConstants.APPLICATION_OWNER)); } @@ -347,7 +346,7 @@ private APIKeyValidationInfoDTO getAPIKeyValidationDTO(RequestContext requestCon validationInfoDTO.setApiPublisher(subPublisher); } if (subTenant != null) { - validationInfoDTO.setSubscriberTenantDomain(subTenant); + validationInfoDTO.setSubscriberOrganization(subTenant); } log.debug("APIKeyValidationInfoDTO populated for API: {}, version: {}.", name, version); diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/InternalAPIKeyAuthenticator.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/InternalAPIKeyAuthenticator.java index 9a7a9fda0..78c33ae5c 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/InternalAPIKeyAuthenticator.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/InternalAPIKeyAuthenticator.java @@ -229,11 +229,9 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws api = validateAPISubscription(apiContext, apiVersion, payload, splitToken, false); if (api != null) { - String context = requestContext.getMatchedAPI().getBasePath(); String uuid = requestContext.getMatchedAPI().getUuid(); - String apiTenantDomain = FilterUtils.getTenantDomainFromRequestURL(context); SubscriptionDataStore datastore = SubscriptionDataHolder.getInstance() - .getTenantSubscriptionStore(apiTenantDomain); + .getSubscriptionDataStore(); API subscriptionDataStoreAPI = datastore.getApiByContextAndVersion(uuid); if (subscriptionDataStoreAPI != null && APIConstants.LifecycleStatus.BLOCKED diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/JWTAuthenticator.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/JWTAuthenticator.java index aed6ab9f8..46f110e0e 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/JWTAuthenticator.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/security/jwt/JWTAuthenticator.java @@ -21,14 +21,11 @@ import com.nimbusds.jwt.SignedJWT; import com.nimbusds.jwt.util.DateUtils; import io.opentelemetry.context.Scope; -import net.minidev.json.JSONArray; -import net.minidev.json.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.ThreadContext; import org.wso2.apk.enforcer.common.CacheProviderUtil; -import org.wso2.apk.enforcer.commons.constants.GraphQLConstants; import org.wso2.apk.enforcer.commons.dto.ClaimValueDTO; import org.wso2.apk.enforcer.commons.dto.JWTConfigurationDto; import org.wso2.apk.enforcer.commons.dto.JWTInfoDto; @@ -42,7 +39,6 @@ import org.wso2.apk.enforcer.commons.model.ResourceConfig; import org.wso2.apk.enforcer.constants.APIConstants; import org.wso2.apk.enforcer.constants.APISecurityConstants; -import org.wso2.apk.enforcer.constants.GeneralErrorCodeConstants; import org.wso2.apk.enforcer.dto.APIKeyValidationInfoDTO; import org.wso2.apk.enforcer.security.Authenticator; import org.wso2.apk.enforcer.security.KeyValidator; @@ -50,7 +46,7 @@ import org.wso2.apk.enforcer.security.jwt.validator.JWTConstants; import org.wso2.apk.enforcer.security.jwt.validator.JWTValidator; import org.wso2.apk.enforcer.security.jwt.validator.RevokedJWTDataHolder; -import org.wso2.apk.enforcer.subscription.SubscriptionDataStoreImpl; +import org.wso2.apk.enforcer.subscription.SubscriptionDataHolder; import org.wso2.apk.enforcer.server.RevokedTokenRedisClient; import org.wso2.apk.enforcer.tracing.TracingConstants; import org.wso2.apk.enforcer.tracing.TracingSpan; @@ -137,7 +133,6 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws String version = requestContext.getMatchedAPI().getVersion(); String organization = requestContext.getMatchedAPI().getOrganizationId(); String environment = requestContext.getMatchedAPI().getEnvironment(); - context = context + "/" + version; JWTValidationInfo validationInfo = getJwtValidationInfo(jwtToken, organization, environment); @@ -160,8 +155,7 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws APIKeyValidationInfoDTO apiKeyValidationInfoDTO = new APIKeyValidationInfoDTO(); Scope validateSubscriptionSpanScope = null; try { - // TODO(TharinduD) revisit when subscription validation is enabled - if (false) { + if (requestContext.getMatchedAPI().isSubscriptionValidation()) { if (Utils.tracingEnabled()) { validateSubscriptionSpan = Utils.startSpan(TracingConstants.SUBSCRIPTION_VALIDATION_SPAN, tracer); @@ -169,56 +163,28 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws Utils.setTag(validateSubscriptionSpan, APIConstants.LOG_TRACE_ID, ThreadContext.get(APIConstants.LOG_TRACE_ID)); } - // if the token is self contained, validation subscription from `subscribedApis` claim - JSONObject api = validateSubscriptionFromClaim(name, version, - validationInfo.getJwtClaimsSet(), splitToken, envType - , apiKeyValidationInfoDTO); - if (api == null) { - if (log.isDebugEnabled()) { - log.debug("Begin subscription validation via Key Manager: " + validationInfo.getKeyManager()); - } - apiKeyValidationInfoDTO = validateSubscriptionUsingKeyManager(requestContext, - validationInfo); - - if (log.isDebugEnabled()) { - log.debug("Subscription validation via Key Manager. Status: " + apiKeyValidationInfoDTO.isAuthorized()); - } - if (!apiKeyValidationInfoDTO.isAuthorized()) { - if (GeneralErrorCodeConstants.API_BLOCKED_CODE == apiKeyValidationInfoDTO.getValidationStatus()) { - FilterUtils.setErrorToContext(requestContext, - GeneralErrorCodeConstants.API_BLOCKED_CODE, - APIConstants.StatusCodes.SERVICE_UNAVAILABLE.getCode(), - GeneralErrorCodeConstants.API_BLOCKED_MESSAGE, - GeneralErrorCodeConstants.API_BLOCKED_DESCRIPTION); - throw new APISecurityException(APIConstants.StatusCodes.SERVICE_UNAVAILABLE.getCode(), apiKeyValidationInfoDTO.getValidationStatus(), GeneralErrorCodeConstants.API_BLOCKED_MESSAGE); - } else if (APISecurityConstants.API_SUBSCRIPTION_BLOCKED == apiKeyValidationInfoDTO.getValidationStatus()) { - FilterUtils.setErrorToContext(requestContext, - APISecurityConstants.API_SUBSCRIPTION_BLOCKED, - APIConstants.StatusCodes.UNAUTHENTICATED.getCode(), - APISecurityConstants.API_SUBSCRIPTION_BLOCKED_MESSAGE, - APISecurityConstants.API_SUBSCRIPTION_BLOCKED_DESCRIPTION); - throw new APISecurityException(APIConstants.StatusCodes.UNAUTHENTICATED.getCode(), apiKeyValidationInfoDTO.getValidationStatus(), APISecurityConstants.API_SUBSCRIPTION_BLOCKED_MESSAGE); - } - throw new APISecurityException(APIConstants.StatusCodes.UNAUTHORIZED.getCode(), - apiKeyValidationInfoDTO.getValidationStatus(), "User is NOT authorized to" + - " access the Resource. " + "API Subscription validation failed."); - } else { - /* GraphQL Query Analysis Information */ - if (APIConstants.ApiType.GRAPHQL.equals(requestContext.getMatchedAPI().getApiType())) { - requestContext.getProperties().put(GraphQLConstants.MAXIMUM_QUERY_DEPTH, - apiKeyValidationInfoDTO.getGraphQLMaxDepth()); - requestContext.getProperties().put(GraphQLConstants.MAXIMUM_QUERY_COMPLEXITY, - apiKeyValidationInfoDTO.getGraphQLMaxComplexity()); - } - } + + // Get consumer key from the JWT token claim set + String consumerKey = validationInfo.getConsumerKey(); + + // Subscription validation using consumer key + if (consumerKey != null) { + validateSubscriptionUsingConsumerKey(apiKeyValidationInfoDTO, name, version, context, + consumerKey, envType, APIConstants.API_SECURITY_OAUTH2, organization, + splitToken); + } else { + log.error("Error while extracting consumer key from token"); + throw new APISecurityException(APIConstants.StatusCodes.UNAUTHENTICATED.getCode(), + APISecurityConstants.API_AUTH_INVALID_CREDENTIALS, + "Invalid JWT token. Error while extracting consumer key from token"); } } else { // In this case, the application related properties are populated so that analytics // could provide much better insights. // Since application notion becomes less meaningful with subscription validation disabled, // the application name would be populated under the convention "anon:" - JWTUtils.updateApplicationNameForSubscriptionDisabledKM(apiKeyValidationInfoDTO, - validationInfo.getKeyManager()); + JWTUtils.updateApplicationNameForSubscriptionDisabledFlow(apiKeyValidationInfoDTO, + APIConstants.KeyManager.DEFAULT_KEY_MANAGER); } } finally { if (Utils.tracingEnabled()) { @@ -352,114 +318,49 @@ private void validateScopes(String apiContext, String apiVersion, ArrayList applicationKeyMappingList); + /** + * Filter the API map according to the provided parameters + * + * @param context API Context + * @param version API Version + * @return Matching list of apis. + */ + API getMatchingAPI(String context, String version); + + /** + * Filter the applicationMapping map based on the provided application UUID. + * + * @param uuid Application UUID + * @return ApplicationMapping which match the given UUID + */ + ApplicationMapping getMatchingApplicationMapping(String uuid); + + /** + * Filter the application key mapping map based on provided parameters + * + * @param applicationIdentifier Application identifier + * @param keyType Key type, i.e. PRODUCTION or SANDBOX + * @param securityScheme Security scheme + * @return ApplicationKeyMapping which match the given parameters + */ + ApplicationKeyMapping getMatchingApplicationKeyMapping(String applicationIdentifier, String keyType, + String securityScheme); + + /** + * Filter the applications map based on the provided parameters. + * + * @param uuid UUID of the application + * @return Application which match the given UUID + */ + Application getMatchingApplication(String uuid); + + /** + * Filter the subscriptions map based on the provided parameters. + * + * @param uuid UUID of the subscription + * @return Subscription which matches the given UUID + */ + Subscription getMatchingSubscription(String uuid); + void addJWTIssuers(List jwtIssuers); /** 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 f74061775..42f1ba786 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 @@ -29,6 +29,7 @@ import org.wso2.apk.enforcer.discovery.ApiListDiscoveryClient; import org.wso2.apk.enforcer.discovery.ApplicationDiscoveryClient; import org.wso2.apk.enforcer.discovery.ApplicationKeyMappingDiscoveryClient; +import org.wso2.apk.enforcer.discovery.ApplicationMappingDiscoveryClient; import org.wso2.apk.enforcer.discovery.ApplicationPolicyDiscoveryClient; import org.wso2.apk.enforcer.discovery.JWTIssuerDiscoveryClient; import org.wso2.apk.enforcer.discovery.SubscriptionDiscoveryClient; @@ -40,8 +41,9 @@ import org.wso2.apk.enforcer.models.ApiPolicy; import org.wso2.apk.enforcer.models.Application; import org.wso2.apk.enforcer.models.ApplicationKeyMapping; -import org.wso2.apk.enforcer.models.ApplicationKeyMappingCacheKey; +import org.wso2.apk.enforcer.models.ApplicationMapping; import org.wso2.apk.enforcer.models.ApplicationPolicy; +import org.wso2.apk.enforcer.models.SubscribedAPI; import org.wso2.apk.enforcer.models.Subscription; import org.wso2.apk.enforcer.models.SubscriptionPolicy; import org.wso2.apk.enforcer.security.jwt.validator.JWTValidator; @@ -75,7 +77,8 @@ public enum PolicyType { public static final String DELEM_PERIOD = ":"; // Maps for keeping Subscription related details. - private Map applicationKeyMappingMap; + private Map applicationKeyMappingMap; + private Map applicationMappingMap; private Map applicationMap; private Map apiMap; private Map apiPolicyMap; @@ -103,6 +106,7 @@ public void initializeStore() { this.appPolicyMap = new ConcurrentHashMap<>(); this.apiPolicyMap = new ConcurrentHashMap<>(); this.subscriptionMap = new ConcurrentHashMap<>(); + this.applicationMappingMap = new ConcurrentHashMap<>(); this.jwtValidatorMap = new ConcurrentHashMap<>(); initializeLoadingTasks(); } @@ -133,6 +137,7 @@ private void initializeLoadingTasks() { ApplicationPolicyDiscoveryClient.getInstance().watchApplicationPolicies(); SubscriptionPolicyDiscoveryClient.getInstance().watchSubscriptionPolicies(); ApplicationKeyMappingDiscoveryClient.getInstance().watchApplicationKeyMappings(); + ApplicationMappingDiscoveryClient.getInstance().watchApplicationMappings(); JWTIssuerDiscoveryClient.getInstance().watchJWTIssuers(); } @@ -141,13 +146,16 @@ public void addSubscriptions(List newSubscriptionMap = new ConcurrentHashMap<>(); for (org.wso2.apk.enforcer.discovery.subscription.Subscription 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.setPolicyId(subscription.getPolicyId()); - newSubscription.setApiUUID(subscription.getApiRef()); - newSubscription.setAppUUID(subscription.getApplicationRef()); - newSubscription.setSubscriptionState(subscription.getSubStatus()); - // newSubscription.setTimeStamp(Long.parseLong(subscription.getTimeStamp())); + newSubscription.setSubscriptionStatus(subscription.getSubStatus()); + newSubscription.setOrganization(subscription.getOrganization()); + newSubscription.setSubscribedApi(subscribedAPI); +// newSubscription.setTimeStamp(Long.parseLong(subscription.getTimeStamp())); newSubscriptionMap.put(newSubscription.getCacheKey(), newSubscription); } @@ -164,10 +172,9 @@ public void addApplications(List applicationKeyMappingList) { - Map newApplicationKeyMappingMap = new ConcurrentHashMap<>(); + Map newApplicationKeyMappingMap = new ConcurrentHashMap<>(); for (org.wso2.apk.enforcer.discovery.subscription.ApplicationKeyMapping applicationKeyMapping : applicationKeyMappingList) { ApplicationKeyMapping mapping = new ApplicationKeyMapping(); - mapping.setApplicationId(applicationKeyMapping.getApplicationId()); mapping.setApplicationUUID(applicationKeyMapping.getApplicationUUID()); - mapping.setConsumerKey(applicationKeyMapping.getConsumerKey()); + mapping.setSecurityScheme(applicationKeyMapping.getSecurityScheme()); + mapping.setApplicationIdentifier(applicationKeyMapping.getApplicationIdentifier()); mapping.setKeyType(applicationKeyMapping.getKeyType()); - mapping.setKeyManager(applicationKeyMapping.getKeyManager()); - + mapping.setEnvId(applicationKeyMapping.getEnvID()); newApplicationKeyMappingMap.put(mapping.getCacheKey(), mapping); } if (log.isDebugEnabled()) { @@ -267,6 +273,106 @@ public void addApplicationKeyMappings( this.applicationKeyMappingMap = newApplicationKeyMappingMap; } + public void addApplicationMappings( + List applicationMappingList) { + + Map newApplicationMappingMap = new ConcurrentHashMap<>(); + + for (org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping applicationMapping : + applicationMappingList) { + ApplicationMapping appMapping = new ApplicationMapping(); + appMapping.setUuid(applicationMapping.getUuid()); + appMapping.setApplicationRef(applicationMapping.getApplicationRef()); + appMapping.setSubscriptionRef(applicationMapping.getSubscriptionRef()); + newApplicationMappingMap.put(appMapping.getCacheKey(), appMapping); + } + if (log.isDebugEnabled()) { + log.debug("Total Application Mappings in new cache: {}", newApplicationMappingMap.size()); + } + this.applicationMappingMap = newApplicationMappingMap; + } + + @Override + public API getMatchingAPI(String context, String version) { + + for (API api : apiMap.values()) { + if (StringUtils.isNotEmpty(context) && StringUtils.isNotEmpty(version)) { + if (api.getContext().equals(context) && api.getApiVersion().equals(version)) { + return api; + } + } + } + return null; + } + + @Override + public ApplicationKeyMapping getMatchingApplicationKeyMapping(String applicationIdentifier, String keyType, + String securityScheme) { + + for (ApplicationKeyMapping applicationKeyMapping : applicationKeyMappingMap.values()) { + boolean isApplicationIdentifierMatching = false; + boolean isSecuritySchemeMatching = false; + boolean isKeyTypeMatching = false; + + if (StringUtils.isNotEmpty(applicationIdentifier)) { + if (applicationKeyMapping.getApplicationIdentifier().equals(applicationIdentifier)) { + isApplicationIdentifierMatching = true; + } + } + if (StringUtils.isNotEmpty(securityScheme)) { + if (applicationKeyMapping.getSecurityScheme().equals(securityScheme)) { + isSecuritySchemeMatching = true; + } + } + if (StringUtils.isNotEmpty(keyType)) { + if (applicationKeyMapping.getKeyType().equals(keyType)) { + isKeyTypeMatching = true; + } + } + + if (isApplicationIdentifierMatching && isSecuritySchemeMatching && isKeyTypeMatching) { + return applicationKeyMapping; + } + } + return null; + } + + @Override + public ApplicationMapping getMatchingApplicationMapping(String uuid) { + for (ApplicationMapping applicationMapping : applicationMappingMap.values()) { + if (StringUtils.isNotEmpty(uuid)) { + if (applicationMapping.getApplicationRef().equals(uuid)) { + return applicationMapping; + } + } + } + return null; + } + + @Override + public Application getMatchingApplication(String uuid) { + for (Application application : applicationMap.values()) { + if (StringUtils.isNotEmpty(uuid)) { + if (application.getUUID().equals(uuid)) { + return application; + } + } + } + return null; + } + + @Override + public Subscription getMatchingSubscription(String uuid) { + for (Subscription subscription : subscriptionMap.values()) { + if (StringUtils.isNotEmpty(uuid)) { + if (subscription.getSubscriptionId().equals(uuid)) { + return subscription; + } + } + } + return null; + } + @Override public void addJWTIssuers(List jwtIssuers) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/FilterUtils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/FilterUtils.java index 3f3421964..14db15b6d 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/FilterUtils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/FilterUtils.java @@ -273,13 +273,11 @@ public static AuthenticationContext generateAuthenticationContext(RequestContext authContext.setUsername(jwtValidationInfo.getUser()); if (apiKeyValidationInfoDTO != null) { - authContext.setApplicationId(apiKeyValidationInfoDTO.getApplicationId()); authContext.setApplicationUUID(apiKeyValidationInfoDTO.getApplicationUUID()); authContext.setApplicationName(apiKeyValidationInfoDTO.getApplicationName()); - authContext.setApplicationTier(apiKeyValidationInfoDTO.getApplicationTier()); authContext.setSubscriber(apiKeyValidationInfoDTO.getSubscriber()); authContext.setTier(apiKeyValidationInfoDTO.getTier()); - authContext.setSubscriberTenantDomain(apiKeyValidationInfoDTO.getSubscriberTenantDomain()); + authContext.setSubscriberOrganization(apiKeyValidationInfoDTO.getSubscriberOrganization()); authContext.setApiPublisher(apiKeyValidationInfoDTO.getApiPublisher()); authContext.setStopOnQuotaReach(apiKeyValidationInfoDTO.isStopOnQuotaReach()); authContext.setSpikeArrestLimit(apiKeyValidationInfoDTO.getSpikeArrestLimit()); @@ -409,7 +407,6 @@ private static void constructJWTContent(JSONObject subscribedAPI, if (apiKeyValidationInfoDTO != null) { jwtInfoDto.setApplicationId(apiKeyValidationInfoDTO.getApplicationUUID()); jwtInfoDto.setApplicationName(apiKeyValidationInfoDTO.getApplicationName()); - jwtInfoDto.setApplicationTier(apiKeyValidationInfoDTO.getApplicationTier()); jwtInfoDto.setKeyType(apiKeyValidationInfoDTO.getType()); jwtInfoDto.setSubscriber(apiKeyValidationInfoDTO.getSubscriber()); jwtInfoDto.setSubscriptionTier(apiKeyValidationInfoDTO.getTier()); diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/GRPCUtils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/GRPCUtils.java index 82affafdc..373f3ed29 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/GRPCUtils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/GRPCUtils.java @@ -36,7 +36,7 @@ */ public class GRPCUtils { - public static ManagedChannel createSecuredChannel(Logger logger, String host, int port) { + public static ManagedChannel createSecuredChannel(Logger logger, String host, int port, String hostname) { File certFile = Paths.get(ConfigHolder.getInstance().getEnvVarConfig().getEnforcerPublicKeyPath()).toFile(); File keyFile = Paths.get(ConfigHolder.getInstance().getEnvVarConfig().getEnforcerPrivateKeyPath()).toFile(); SslContext sslContext = null; @@ -52,7 +52,7 @@ public static ManagedChannel createSecuredChannel(Logger logger, String host, in return NettyChannelBuilder.forAddress(host, port) .useTransportSecurity() .sslContext(sslContext) - .overrideAuthority(ConfigHolder.getInstance().getEnvVarConfig().getAdapterHostName()) + .overrideAuthority(hostname) .build(); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/JWTUtils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/JWTUtils.java index c9b26d8f9..ab12f5b2d 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/JWTUtils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/util/JWTUtils.java @@ -216,14 +216,12 @@ public static boolean isExpired(long exp) { * @param apiKeyValidationInfoDTO empty JWT info DTO to be populated with anonymous details * @param kmReference name of the token service */ - public static void updateApplicationNameForSubscriptionDisabledKM(APIKeyValidationInfoDTO apiKeyValidationInfoDTO - , String kmReference) { + public static void updateApplicationNameForSubscriptionDisabledFlow(APIKeyValidationInfoDTO apiKeyValidationInfoDTO, + String kmReference) { String applicationRef = APIConstants.ANONYMOUS_PREFIX + kmReference; apiKeyValidationInfoDTO.setApplicationName(applicationRef); - apiKeyValidationInfoDTO.setApplicationId(-1); apiKeyValidationInfoDTO.setApplicationUUID(UUID.nameUUIDFromBytes(applicationRef.getBytes(StandardCharsets.UTF_8)).toString()); - apiKeyValidationInfoDTO.setApplicationTier(APIConstants.UNLIMITED_TIER); } public static String getJWTTokenIdentifier(SignedJWTInfo signedJWTInfo) { diff --git a/helm-charts/crds/cp.wso2.com_applicationmappings.yaml b/helm-charts/crds/cp.wso2.com_applicationmappings.yaml new file mode 100644 index 000000000..0d28116e6 --- /dev/null +++ b/helm-charts/crds/cp.wso2.com_applicationmappings.yaml @@ -0,0 +1,53 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: applicationmappings.cp.wso2.com +spec: + group: cp.wso2.com + names: + kind: ApplicationMapping + listKind: ApplicationMappingList + plural: applicationmappings + singular: applicationmapping + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: ApplicationMapping is the Schema for the applicationmappings + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ApplicationMappingSpec defines the desired state of ApplicationMapping + properties: + applicationRef: + type: string + subscriptionRef: + type: string + required: + - applicationRef + - subscriptionRef + type: object + status: + description: ApplicationMappingStatus defines the observed state of ApplicationMapping + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/helm-charts/crds/cp.wso2.com_applications.yaml b/helm-charts/crds/cp.wso2.com_applications.yaml new file mode 100644 index 000000000..49df1f41c --- /dev/null +++ b/helm-charts/crds/cp.wso2.com_applications.yaml @@ -0,0 +1,82 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: applications.cp.wso2.com +spec: + group: cp.wso2.com + names: + kind: Application + listKind: ApplicationList + plural: applications + singular: application + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: Application is the Schema for the applications API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ApplicationSpec defines the desired state of Application + properties: + attributes: + additionalProperties: + type: string + type: object + name: + type: string + owner: + type: string + securitySchemes: + description: SecuritySchemes defines the supported security schemes + properties: + oauth2: + description: OAuth2 denotes the OAuth2 security scheme + properties: + environments: + items: + description: Environment defines the environment specific + details related to the security scheme + properties: + appId: + type: string + envId: + type: string + keyType: + type: string + required: + - appId + - envId + - keyType + type: object + type: array + type: object + type: object + required: + - name + - owner + - securitySchemes + type: object + status: + description: ApplicationStatus defines the observed state of Application + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/helm-charts/crds/cp.wso2.com_subscriptions.yaml b/helm-charts/crds/cp.wso2.com_subscriptions.yaml new file mode 100644 index 000000000..172cb762c --- /dev/null +++ b/helm-charts/crds/cp.wso2.com_subscriptions.yaml @@ -0,0 +1,64 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: subscriptions.cp.wso2.com +spec: + group: cp.wso2.com + names: + kind: Subscription + listKind: SubscriptionList + plural: subscriptions + singular: subscription + scope: Namespaced + versions: + - name: v1alpha2 + schema: + openAPIV3Schema: + description: Subscription is the Schema for the subscriptions API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: SubscriptionSpec defines the desired state of Subscription + properties: + api: + description: API defines the API associated with the subscription + properties: + name: + type: string + version: + type: string + required: + - name + - version + type: object + organization: + type: string + subscriptionStatus: + type: string + required: + - api + - organization + - subscriptionStatus + type: object + status: + description: SubscriptionStatus defines the observed state of Subscription + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/helm-charts/crds/dp.wso2.com_apipolicies.yaml b/helm-charts/crds/dp.wso2.com_apipolicies.yaml index 562864106..d05fe5fd6 100644 --- a/helm-charts/crds/dp.wso2.com_apipolicies.yaml +++ b/helm-charts/crds/dp.wso2.com_apipolicies.yaml @@ -248,6 +248,252 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - name: v1alpha2 + schema: + openAPIV3Schema: + description: APIPolicy is the Schema for the apipolicies API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: APIPolicySpec defines the desired state of APIPolicy + properties: + default: + description: PolicySpec contains API policies + properties: + backendJwtPolicy: + description: BackendJWTPolicy holds reference to backendJWT policy + configurations + properties: + name: + description: Name holds the name of the BackendJWT resource. + type: string + type: object + cORSPolicy: + description: CORS policy to be applied to the API. + properties: + accessControlAllowCredentials: + description: AllowCredentials indicates whether the request + can include user credentials like cookies, HTTP authentication + or client side SSL certificates. + type: boolean + accessControlAllowHeaders: + description: AccessControlAllowHeaders indicates which headers + can be used during the actual request. + items: + type: string + type: array + accessControlAllowMethods: + description: AccessControlAllowMethods indicates which methods + can be used during the actual request. + items: + type: string + type: array + accessControlAllowOrigins: + description: AccessControlAllowOrigins indicates which origins + can be used during the actual request. + items: + type: string + type: array + accessControlExposeHeaders: + description: AccessControlExposeHeaders indicates which headers + can be exposed as part of the response by listing their + names. + items: + type: string + type: array + accessControlMaxAge: + description: AccessControlMaxAge indicates how long the results + of a preflight request can be cached in a preflight result + cache. + type: integer + type: object + requestInterceptors: + description: RequestInterceptors referenced to intercetor services + to be applied to the request flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + responseInterceptors: + description: ResponseInterceptors referenced to intercetor services + to be applied to the response flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + subscriptionValidation: + default: false + description: SubscriptionValidation denotes whether subscription + validation is enabled for the API + type: boolean + type: object + override: + description: PolicySpec contains API policies + properties: + backendJwtPolicy: + description: BackendJWTPolicy holds reference to backendJWT policy + configurations + properties: + name: + description: Name holds the name of the BackendJWT resource. + type: string + type: object + cORSPolicy: + description: CORS policy to be applied to the API. + properties: + accessControlAllowCredentials: + description: AllowCredentials indicates whether the request + can include user credentials like cookies, HTTP authentication + or client side SSL certificates. + type: boolean + accessControlAllowHeaders: + description: AccessControlAllowHeaders indicates which headers + can be used during the actual request. + items: + type: string + type: array + accessControlAllowMethods: + description: AccessControlAllowMethods indicates which methods + can be used during the actual request. + items: + type: string + type: array + accessControlAllowOrigins: + description: AccessControlAllowOrigins indicates which origins + can be used during the actual request. + items: + type: string + type: array + accessControlExposeHeaders: + description: AccessControlExposeHeaders indicates which headers + can be exposed as part of the response by listing their + names. + items: + type: string + type: array + accessControlMaxAge: + description: AccessControlMaxAge indicates how long the results + of a preflight request can be cached in a preflight result + cache. + type: integer + type: object + requestInterceptors: + description: RequestInterceptors referenced to intercetor services + to be applied to the request flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + responseInterceptors: + description: ResponseInterceptors referenced to intercetor services + to be applied to the response flow. + items: + description: InterceptorReference holds InterceptorService reference + using name and namespace + properties: + name: + description: Name is the referced CR's name of InterceptorService + resource. + type: string + required: + - name + type: object + maxItems: 1 + nullable: true + type: array + subscriptionValidation: + default: false + description: SubscriptionValidation denotes whether subscription + validation is enabled for the API + type: boolean + type: object + targetRef: + description: PolicyTargetReference identifies an API object to apply + policy to. This should be used as part of Policy resources that + can target Gateway API resources. For more information on how this + policy attachment model works, and a sample Policy resource, refer + to the policy attachment documentation for Gateway API. + properties: + group: + description: Group is the group of the target resource. + maxLength: 253 + pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + kind: + description: Kind is kind of the target resource. + maxLength: 63 + minLength: 1 + pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ + type: string + name: + description: Name is the name of the target resource. + maxLength: 253 + minLength: 1 + type: string + namespace: + description: Namespace is the namespace of the referent. When + unspecified, the local namespace is inferred. Even when policy + targets a resource in a different namespace, it MUST only apply + to traffic originating from the same namespace as the policy. + maxLength: 63 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + type: string + required: + - group + - kind + - name + type: object + type: object + status: + description: APIPolicyStatus defines the observed state of APIPolicy + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml index 5292da6c6..0db6a5e41 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-deployment.yaml @@ -42,6 +42,8 @@ spec: ports: - containerPort: 18005 protocol: TCP + - containerPort: 18002 + protocol: TCP - containerPort: 9543 protocol: TCP {{ include "apk-helm.deployment.resources" .Values.wso2.apk.dp.commonController.deployment.resources | indent 10 }} @@ -79,6 +81,8 @@ spec: subPath: ca.crt {{- end }} {{ if and .Values.wso2.apk.dp.enabled .Values.wso2.apk.dp.ratelimiter.enabled }} + # - name: enforcer-truststore-secret-volume + # mountPath: /home/wso2/security/truststore/enforcer.crt - name: ratelimiter-truststore-secret-volume mountPath: /home/wso2/security/truststore/ratelimiter.crt {{- if and .Values.wso2.apk.dp.ratelimiter.configs .Values.wso2.apk.dp.ratelimiter.configs.tls }} @@ -127,7 +131,7 @@ spec: runAsNonRoot: true seccompProfile: type: "RuntimeDefault" - volumes: + volumes: - name: common-controller-keystore-secret-volume secret: {{- if and .Values.wso2.apk.dp.commonController.configs .Values.wso2.apk.dp.commonController.configs.tls }} diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml index 7a261c76e..4877adc43 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/common-controller-service.yaml @@ -28,6 +28,9 @@ spec: - name: https-rate-limiter protocol: TCP port: 18005 + - name: https-enforcer-xds + protocol: TCP + port: 18002 - name: webhook-server protocol: TCP port: 443 diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml index f8a52b741..4d94ea9d8 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml @@ -49,14 +49,14 @@ webhooks: service: name: {{ template "apk-helm.resource.prefix" . }}-common-controller-service namespace: {{ .Release.Namespace }} - path: /mutate-dp-wso2-com-v1alpha1-apipolicy + path: /mutate-dp-wso2-com-v1alpha2-apipolicy failurePolicy: Fail name: mapipolicy.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml index a91d74199..9a81bd9cd 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml @@ -69,14 +69,14 @@ webhooks: service: name: {{ template "apk-helm.resource.prefix" . }}-common-controller-service namespace: {{ .Release.Namespace }} - path: /validate-dp-wso2-com-v1alpha1-apipolicy + path: /validate-dp-wso2-com-v1alpha2-apipolicy failurePolicy: Fail name: vapipolicy.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1alpha1 + - v1alpha2 operations: - CREATE - UPDATE diff --git a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml index 60bd1c693..c7ca9f256 100644 --- a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml +++ b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml @@ -64,12 +64,18 @@ spec: protocol: "TCP" - containerPort: 9092 protocol: "TCP" + - containerPort: 18002 + protocol: "TCP" {{ include "apk-helm.deployment.resources" .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.resources | indent 10 }} {{ include "apk-helm.deployment.env" .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.env | indent 10 }} - name: ADAPTER_HOST_NAME value: {{ template "apk-helm.resource.prefix" . }}-adapter-service.{{ .Release.Namespace }}.svc - name: ADAPTER_HOST value: {{ template "apk-helm.resource.prefix" . }}-adapter-service.{{ .Release.Namespace }}.svc + - name: COMMON_CONTROLLER_HOST_NAME + value: {{ template "apk-helm.resource.prefix" . }}-common-controller-service.{{ .Release.Namespace }}.svc + - name: COMMON_CONTROLLER_HOST + value: {{ template "apk-helm.resource.prefix" . }}-common-controller-service.{{ .Release.Namespace }}.svc - name: ENFORCER_PRIVATE_KEY_PATH value: /home/wso2/security/keystore/enforcer.key - name: ENFORCER_PUBLIC_CERT_PATH @@ -80,6 +86,8 @@ spec: value: "/home/wso2/security/truststore" - name: ADAPTER_XDS_PORT value : "18000" + - name: COMMON_CONTROLLER_XDS_PORT + value : "18002" - name: ENFORCER_LABEL value : default - name: ENFORCER_REGION @@ -185,6 +193,8 @@ spec: {{- else }} subPath: tls.crt {{- end }} + # - name: common-controller-truststore-secret-volume + # mountPath: /home/wso2/security/truststore/adapter.pem - name: router-keystore-secret-volume mountPath: /home/wso2/security/truststore/router.crt {{- if and .Values.wso2.apk.dp.gatewayRuntime.deployment.router.configs .Values.wso2.apk.dp.gatewayRuntime.deployment.router.configs.tls }} @@ -372,6 +382,14 @@ spec: secretName: {{ template "apk-helm.resource.prefix" . }}-ratelimiter-server-cert {{- end }} {{ end }} + # - name: common-controller-truststore-secret-volume + # secret: + # {{- if and .Values.wso2.apk.dp.commonController.configs .Values.wso2.apk.dp.commonController.configs.tls }} + # secretName: {{ .Values.wso2.apk.dp.commonController.configs.tls.secretName | default (printf "%s-common-controller-server-cert" (include "apk-helm.resource.prefix" .)) }} + # {{- else }} + # secretName: {{ template "apk-helm.resource.prefix" . }}-common-controller-server-cert + # {{- end }} + # defaultMode: 420 - name: enforcer-keystore-secret-volume secret: {{- if and .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.tls }} diff --git a/helm-charts/templates/serviceAccount/apk-cluster-role.yaml b/helm-charts/templates/serviceAccount/apk-cluster-role.yaml index ed87c6c67..069d9c640 100644 --- a/helm-charts/templates/serviceAccount/apk-cluster-role.yaml +++ b/helm-charts/templates/serviceAccount/apk-cluster-role.yaml @@ -113,4 +113,31 @@ rules: - apiGroups: ["dp.wso2.com"] resources: ["backendjwts/status"] verbs: ["get","patch","update"] + - apiGroups: ["cp.wso2.com"] + resources: ["applications"] + verbs: ["get","list","watch","update","delete","create"] + - apiGroups: ["cp.wso2.com"] + resources: ["applications/finalizers"] + verbs: ["update"] + - apiGroups: ["cp.wso2.com"] + resources: ["applications/status"] + verbs: ["get","patch","update"] + - apiGroups: ["cp.wso2.com"] + resources: ["subscriptions"] + verbs: ["get","list","watch","update","delete","create"] + - apiGroups: ["cp.wso2.com"] + resources: ["subscriptions/finalizers"] + verbs: ["update"] + - apiGroups: ["cp.wso2.com"] + resources: ["subscriptions/status"] + verbs: ["get","patch","update"] + - apiGroups: ["cp.wso2.com"] + resources: ["applicationmappings"] + verbs: ["get","list","watch","update","delete","create"] + - apiGroups: ["cp.wso2.com"] + resources: ["applicationmappings/finalizers"] + verbs: ["update"] + - apiGroups: ["cp.wso2.com"] + resources: ["applicationmappings/status"] + verbs: ["get","patch","update"] {{- end -}} \ No newline at end of file diff --git a/helm-charts/values.yaml b/helm-charts/values.yaml index b85da4dd0..7c52d2566 100644 --- a/helm-charts/values.yaml +++ b/helm-charts/values.yaml @@ -37,6 +37,7 @@ wso2: usernameClaim: "sub" organizationClaim: "organization" groupsClaim: "groups" + consumerKeyClaim: "clientId" # organizationResolver: "controlPlane" # controlplane,none # tls: # secretName: "wso2apk-idp-certificates" diff --git a/management-server/internal/notification/server.go b/management-server/internal/notification/server.go index 8cbeed994..d11ba70a6 100644 --- a/management-server/internal/notification/server.go +++ b/management-server/internal/notification/server.go @@ -52,10 +52,10 @@ func (s *notificationService) CreateApplication(ctx context.Context, application UUID: application.Uuid, Name: application.Name, Owner: application.Owner, - Policy: application.Policy, + // Policy: application.Policy, Attributes: application.Attributes, //Keys: application.Keys, - Organization: application.Organization, + // Organization: application.Organization, TimeStamp: application.TimeStamp, IsRemoveEvent: false, } @@ -71,10 +71,10 @@ func (s *notificationService) UpdateApplication(ctx context.Context, application UUID: application.Uuid, Name: application.Name, Owner: application.Owner, - Policy: application.Policy, + // Policy: application.Policy, Attributes: application.Attributes, //Keys: application.Keys, - Organization: application.Organization, + // Organization: application.Organization, TimeStamp: application.TimeStamp, IsRemoveEvent: false, } @@ -88,7 +88,7 @@ func (s *notificationService) DeleteApplication(ctx context.Context, application var event = internal_types.ApplicationEvent{ Label: config.ReadConfigs().ManagementServer.NodeLabels[0], UUID: application.Uuid, - Organization: application.Organization, + // Organization: application.Organization, IsRemoveEvent: true, } synchronizer.AddApplicationEventsToChannel(event) @@ -101,13 +101,13 @@ func (s *notificationService) CreateSubscription(ctx context.Context, subscripti var event = internal_types.SubscriptionEvent{ Label: config.ReadConfigs().ManagementServer.NodeLabels[0], UUID: subscription.Uuid, - ApplicationRef: subscription.ApplicationRef, - APIRef: subscription.ApiRef, - PolicyID: subscription.PolicyId, + // ApplicationRef: subscription.ApplicationRef, + // APIRef: subscription.ApiRef, + // PolicyID: subscription.PolicyId, SubStatus: subscription.SubStatus, - Subscriber: subscription.Subscriber, + // Subscriber: subscription.Subscriber, Organization: subscription.Organization, - TimeStamp: subscription.TimeStamp, + // TimeStamp: subscription.TimeStamp, IsRemoveEvent: false, } synchronizer.AddSubscriptionEventsToChannel(event) @@ -120,13 +120,13 @@ func (s *notificationService) UpdateSubscription(ctx context.Context, subscripti var event = internal_types.SubscriptionEvent{ Label: config.ReadConfigs().ManagementServer.NodeLabels[0], UUID: subscription.Uuid, - ApplicationRef: subscription.ApplicationRef, - APIRef: subscription.ApiRef, - PolicyID: subscription.PolicyId, + // ApplicationRef: subscription.ApplicationRef, + // APIRef: subscription.ApiRef, + // PolicyID: subscription.PolicyId, SubStatus: subscription.SubStatus, - Subscriber: subscription.Subscriber, + // Subscriber: subscription.Subscriber, Organization: subscription.Organization, - TimeStamp: subscription.TimeStamp, + // TimeStamp: subscription.TimeStamp, IsRemoveEvent: false, } synchronizer.AddSubscriptionEventsToChannel(event) diff --git a/management-server/internal/types/types.go b/management-server/internal/types/types.go index 56bb452ac..fb1dd872a 100644 --- a/management-server/internal/types/types.go +++ b/management-server/internal/types/types.go @@ -23,31 +23,31 @@ type ApplicationEvent struct { UUID string Name string Owner string - Policy string + // Policy string Attributes map[string]string - Keys []*ApplicationKey + // Keys []*ApplicationKey Organization string TimeStamp string IsRemoveEvent bool } // ApplicationKey is a data holder for an application key -type ApplicationKey struct { - Key string - KeyManager string -} +// type ApplicationKey struct { +// Key string +// KeyManager string +// } // SubscriptionEvent is a data holder for a subscription event type SubscriptionEvent struct { Label string UUID string - ApplicationRef string - APIRef string - PolicyID string + // ApplicationRef string + // APIRef string + // PolicyID string SubStatus string - Subscriber string + // Subscriber string Organization string - TimeStamp string + // TimeStamp string IsRemoveEvent bool IsUpdateEvent bool } diff --git a/management-server/internal/xds/server.go b/management-server/internal/xds/server.go index 1d2cf6e76..bf602ea08 100644 --- a/management-server/internal/xds/server.go +++ b/management-server/internal/xds/server.go @@ -99,20 +99,20 @@ func FeedData() { // AddSingleApplication will update the Application specified by the UUID to the xds cache func AddSingleApplication(label string, application internal_types.ApplicationEvent) { - appKeys := make([]*internal_application.Application_Key, len(application.Keys)) - for i, key := range application.Keys { - appKeys[i] = &internal_application.Application_Key{ - Key: key.Key, - KeyManager: key.KeyManager, - } - } + // appKeys := make([]*internal_application.Application_Key, len(application.Keys)) + // for i, key := range application.Keys { + // appKeys[i] = &internal_application.Application_Key{ + // Key: key.Key, + // KeyManager: key.KeyManager, + // } + // } convertedApplication := &internal_application.Application{ Uuid: application.UUID, Name: application.Name, - Policy: application.Policy, + // Policy: application.Policy, Owner: application.Owner, - Organization: application.Organization, - Keys: appKeys, + // Organization: application.Organization, + // Keys: appKeys, Attributes: application.Attributes, } logger.LoggerXds.Debugf("Converted Application: %v", convertedApplication) @@ -327,13 +327,13 @@ func InitAPKMgtServer() { func AddSingleSubscription(label string, subscription internal_types.SubscriptionEvent) { convertedSubscription := &internal_application.Subscription{ Uuid: subscription.UUID, - ApplicationRef: subscription.ApplicationRef, - ApiRef: subscription.APIRef, + // ApplicationRef: subscription.ApplicationRef, + // ApiRef: subscription.APIRef, SubStatus: subscription.SubStatus, - PolicyId: subscription.PolicyID, + // PolicyId: subscription.PolicyID, Organization: subscription.Organization, - Subscriber: subscription.Subscriber, - TimeStamp: subscription.TimeStamp, + // Subscriber: subscription.Subscriber, + // Timetamp: subscription.TimeStamp, } logger.LoggerXds.Debugf("Converted Subscription: %v", convertedSubscription) var newSnapshot wso2_cache.Snapshot diff --git a/runtime/config-deployer-service/ballerina/APIClient.bal b/runtime/config-deployer-service/ballerina/APIClient.bal index 995737006..c093a4dad 100644 --- a/runtime/config-deployer-service/ballerina/APIClient.bal +++ b/runtime/config-deployer-service/ballerina/APIClient.bal @@ -572,6 +572,7 @@ public class APIClient { defaultSpecData.responseInterceptors = [item]; } } + // TODO(Ashera): Need to implement subscription validation API policy CR creation for config deployer approach CORSConfiguration? corsConfiguration = apkConf.corsConfiguration; if corsConfiguration is CORSConfiguration { model:CORSPolicy? cORSPolicy = self.retrieveCORSPolicyDetails(apiArtifact, apkConf, corsConfiguration, organization); diff --git a/runtime/config-deployer-service/ballerina/modules/model/API.bal b/runtime/config-deployer-service/ballerina/modules/model/API.bal index b0510e540..fd508c975 100644 --- a/runtime/config-deployer-service/ballerina/modules/model/API.bal +++ b/runtime/config-deployer-service/ballerina/modules/model/API.bal @@ -29,7 +29,7 @@ public type APISpec record {| string apiType; string apiVersion; string basePath; - string organization; +string organization; boolean isDefaultVersion?; string definitionFileRef?; string environment?;