From 674cc6fbad53ba8818f05a982aa37717b9807afe Mon Sep 17 00:00:00 2001 From: Ashera Silva Date: Fri, 6 Oct 2023 23:31:16 +0530 Subject: [PATCH] Update enforcer logic to match with latest application and subscription related changes --- .../discovery/subscription/subscription.proto | 4 +- .../discovery/subscription/subscription.pb.go | 88 +- .../samples/cp_v1alpha2_subscription.yaml | 2 +- .../controllers/cp/subscription_controller.go | 8 +- .../wso2/apk/enforcer/admin/AdminUtils.java | 2 +- .../ApplicationMappingDiscoveryClient.java | 4 +- .../discovery/subscription/SubscribedAPI.java | 752 ++++++++++++++++++ .../subscription/SubscribedAPIOrBuilder.java | 46 ++ .../subscription/SubscribedAPIRef.java | 752 ++++++++++++++++++ .../SubscribedAPIRefOrBuilder.java | 46 ++ .../discovery/subscription/Subscription.java | 188 ++--- .../subscription/SubscriptionOrBuilder.java | 16 +- .../subscription/SubscriptionProto.java | 29 +- .../wso2/apk/enforcer/models/Application.java | 98 +-- .../models/ApplicationKeyMapping.java | 85 +- .../models/ApplicationKeyMappingCacheKey.java | 63 -- .../enforcer/models/ApplicationMapping.java | 71 ++ .../apk/enforcer/models/SubscribedAPI.java | 47 ++ .../apk/enforcer/models/Subscription.java | 64 +- .../apk/enforcer/security/KeyValidator.java | 8 +- .../SubscriptionDataStoreImpl.java | 93 ++- .../common-controller-deployment.yaml | 18 +- .../gateway-runtime-deployment.yaml | 20 +- 23 files changed, 2029 insertions(+), 475 deletions(-) create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPI.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIOrBuilder.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIRef.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIRefOrBuilder.java delete mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationKeyMappingCacheKey.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/ApplicationMapping.java create mode 100644 gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/SubscribedAPI.java diff --git a/adapter/api/proto/wso2/discovery/subscription/subscription.proto b/adapter/api/proto/wso2/discovery/subscription/subscription.proto index a56b0a778a..05f06ee3aa 100644 --- a/adapter/api/proto/wso2/discovery/subscription/subscription.proto +++ b/adapter/api/proto/wso2/discovery/subscription/subscription.proto @@ -31,11 +31,11 @@ message Subscription { string subStatus = 2; string uuid = 3; string organization = 4; - API api = 5; + SubscribedAPI subscribedApi = 5; string timeStamp = 6; } -message API { +message SubscribedAPI { string name = 1; repeated string versions = 2; } 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 3c2a2b13a5..b71a0a96bc 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/subscription/subscription.pb.go @@ -42,12 +42,12 @@ type Subscription struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EventId string `protobuf:"bytes,1,opt,name=eventId,proto3" json:"eventId,omitempty"` - SubStatus string `protobuf:"bytes,2,opt,name=subStatus,proto3" json:"subStatus,omitempty"` - Uuid string `protobuf:"bytes,3,opt,name=uuid,proto3" json:"uuid,omitempty"` - Organization string `protobuf:"bytes,4,opt,name=organization,proto3" json:"organization,omitempty"` - Api *API `protobuf:"bytes,5,opt,name=api,proto3" json:"api,omitempty"` - TimeStamp string `protobuf:"bytes,6,opt,name=timeStamp,proto3" json:"timeStamp,omitempty"` + EventId string `protobuf:"bytes,1,opt,name=eventId,proto3" json:"eventId,omitempty"` + SubStatus string `protobuf:"bytes,2,opt,name=subStatus,proto3" json:"subStatus,omitempty"` + Uuid string `protobuf:"bytes,3,opt,name=uuid,proto3" json:"uuid,omitempty"` + Organization string `protobuf:"bytes,4,opt,name=organization,proto3" json:"organization,omitempty"` + SubscribedApi *SubscribedAPI `protobuf:"bytes,5,opt,name=subscribedApi,proto3" json:"subscribedApi,omitempty"` + TimeStamp string `protobuf:"bytes,6,opt,name=timeStamp,proto3" json:"timeStamp,omitempty"` } func (x *Subscription) Reset() { @@ -110,9 +110,9 @@ func (x *Subscription) GetOrganization() string { return "" } -func (x *Subscription) GetApi() *API { +func (x *Subscription) GetSubscribedApi() *SubscribedAPI { if x != nil { - return x.Api + return x.SubscribedApi } return nil } @@ -124,7 +124,7 @@ func (x *Subscription) GetTimeStamp() string { return "" } -type API struct { +type SubscribedAPI struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -133,8 +133,8 @@ type API struct { Versions []string `protobuf:"bytes,2,rep,name=versions,proto3" json:"versions,omitempty"` } -func (x *API) Reset() { - *x = API{} +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)) @@ -142,13 +142,13 @@ func (x *API) Reset() { } } -func (x *API) String() string { +func (x *SubscribedAPI) String() string { return protoimpl.X.MessageStringOf(x) } -func (*API) ProtoMessage() {} +func (*SubscribedAPI) ProtoMessage() {} -func (x *API) ProtoReflect() protoreflect.Message { +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)) @@ -160,19 +160,19 @@ func (x *API) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use API.ProtoReflect.Descriptor instead. -func (*API) Descriptor() ([]byte, []int) { +// Deprecated: Use SubscribedAPI.ProtoReflect.Descriptor instead. +func (*SubscribedAPI) Descriptor() ([]byte, []int) { return file_wso2_discovery_subscription_subscription_proto_rawDescGZIP(), []int{1} } -func (x *API) GetName() string { +func (x *SubscribedAPI) GetName() string { if x != nil { return x.Name } return "" } -func (x *API) GetVersions() []string { +func (x *SubscribedAPI) GetVersions() []string { if x != nil { return x.Versions } @@ -186,7 +186,7 @@ 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, 0xd0, 0x01, + 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xee, 0x01, 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, 0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x53, @@ -194,26 +194,28 @@ var file_wso2_discovery_subscription_subscription_proto_rawDesc = []byte{ 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, 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, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x32, - 0x0a, 0x03, 0x61, 0x70, 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 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, 0x50, 0x49, 0x52, 0x03, 0x61, - 0x70, 0x69, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, - 0x22, 0x35, 0x0a, 0x03, 0x41, 0x50, 0x49, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x94, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, 0x2e, - 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 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, + 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, + 0x05, 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, + 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x3f, + 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, 0x1a, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x42, + 0x94, 0x01, 0x0a, 0x2c, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, + 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x42, 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 ( @@ -230,11 +232,11 @@ func file_wso2_discovery_subscription_subscription_proto_rawDescGZIP() []byte { 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 - (*API)(nil), // 1: wso2.discovery.subscription.API + (*Subscription)(nil), // 0: wso2.discovery.subscription.Subscription + (*SubscribedAPI)(nil), // 1: wso2.discovery.subscription.SubscribedAPI } var file_wso2_discovery_subscription_subscription_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.subscription.Subscription.api:type_name -> wso2.discovery.subscription.API + 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 @@ -261,7 +263,7 @@ func file_wso2_discovery_subscription_subscription_proto_init() { } } file_wso2_discovery_subscription_subscription_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*API); i { + switch v := v.(*SubscribedAPI); i { case 0: return &v.state case 1: diff --git a/common-controller/internal/operator/config/samples/cp_v1alpha2_subscription.yaml b/common-controller/internal/operator/config/samples/cp_v1alpha2_subscription.yaml index 4d45203113..e39b27a8ce 100644 --- a/common-controller/internal/operator/config/samples/cp_v1alpha2_subscription.yaml +++ b/common-controller/internal/operator/config/samples/cp_v1alpha2_subscription.yaml @@ -12,7 +12,7 @@ spec: subscriptionStatus: ACTIVE organization: carbon.super api: - name: PizzaShackAPI + name: AppSubTestAPI versions: - ^v1$ - ^1.* diff --git a/common-controller/internal/operator/controllers/cp/subscription_controller.go b/common-controller/internal/operator/controllers/cp/subscription_controller.go index fe1c249b06..84993065c5 100644 --- a/common-controller/internal/operator/controllers/cp/subscription_controller.go +++ b/common-controller/internal/operator/controllers/cp/subscription_controller.go @@ -104,17 +104,17 @@ func sendSubUpdates(subscriptionsList *cpv1alpha2.SubscriptionList) { func marshalSubscriptionList(subscriptionList []cpv1alpha2.Subscription) *subscription.SubscriptionList { subscriptions := []*subscription.Subscription{} for _, subInternal := range subscriptionList { - api := &subscription.API{} + subscribedApi := &subscription.SubscribedAPI{} sub := &subscription.Subscription{ Uuid: string(subInternal.UID), SubStatus: subInternal.Spec.SubscriptionStatus, Organization: subInternal.Spec.Organization, } if subInternal.Spec.API.Name != "" && len(subInternal.Spec.API.Versions) > 0 { - api.Name = subInternal.Spec.API.Name - api.Versions = subInternal.Spec.API.Versions + subscribedApi.Name = subInternal.Spec.API.Name + subscribedApi.Versions = subInternal.Spec.API.Versions } - sub.Api = api + sub.SubscribedApi = subscribedApi subscriptions = append(subscriptions, sub) } return &subscription.SubscriptionList{ diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/admin/AdminUtils.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/admin/AdminUtils.java index 13854490e7..99480571cd 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/admin/AdminUtils.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/admin/AdminUtils.java @@ -80,7 +80,7 @@ public static SubscriptionInfo toSubscriptionInfo(Subscription subscription, subscriptionInfo.setAppUUID(subscription.getAppUUID()); subscriptionInfo.setPolicyId(subscription.getPolicyId()); subscriptionInfo.setSubscriptionId(subscription.getSubscriptionId()); - subscriptionInfo.setSubscriptionState(subscription.getSubscriptionState()); + subscriptionInfo.setSubscriptionState(subscription.getSubscriptionStatus()); return subscriptionInfo; } 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 index 817c15767f..48e87b514a 100644 --- 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 @@ -138,8 +138,8 @@ public void onNext(DiscoveryResponse response) { for (Any res : response.getResourcesList()) { applicationMappingList.addAll(res.unpack(ApplicationMappingList.class).getListList()); } -// subscriptionDataStore.addApplicationMappings(applicationMappingList); - logger.info("Number of application key mappings received : " + applicationMappingList.size()); + 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 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 0000000000..410b309bc7 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPI.java @@ -0,0 +1,752 @@ +// 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_ = ""; + versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @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(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + versions_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + versions_.add(s); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + versions_ = versions_.getUnmodifiableView(); + } + 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 VERSIONS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList versions_; + /** + * repeated string versions = 2; + * @return A list containing the versions. + */ + public com.google.protobuf.ProtocolStringList + getVersionsList() { + return versions_; + } + /** + * repeated string versions = 2; + * @return The count of versions. + */ + public int getVersionsCount() { + return versions_.size(); + } + /** + * repeated string versions = 2; + * @param index The index of the element to return. + * @return The versions at the given index. + */ + public java.lang.String getVersions(int index) { + return versions_.get(index); + } + /** + * repeated string versions = 2; + * @param index The index of the value to return. + * @return The bytes of the versions at the given index. + */ + public com.google.protobuf.ByteString + getVersionsBytes(int index) { + return versions_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + for (int i = 0; i < versions_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, versions_.getRaw(i)); + } + 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_); + } + { + int dataSize = 0; + for (int i = 0; i < versions_.size(); i++) { + dataSize += computeStringSizeNoTag(versions_.getRaw(i)); + } + size += dataSize; + size += 1 * getVersionsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.wso2.apk.enforcer.discovery.subscription.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 (!getVersionsList() + .equals(other.getVersionsList())) 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(); + if (getVersionsCount() > 0) { + hash = (37 * hash) + VERSIONS_FIELD_NUMBER; + hash = (53 * hash) + getVersionsList().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_ = ""; + + versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + 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); + int from_bitField0_ = bitField0_; + result.name_ = name_; + if (((bitField0_ & 0x00000001) != 0)) { + versions_ = versions_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.versions_ = versions_; + 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.versions_.isEmpty()) { + if (versions_.isEmpty()) { + versions_ = other.versions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureVersionsIsMutable(); + versions_.addAll(other.versions_); + } + 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 int bitField0_; + + 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 com.google.protobuf.LazyStringList versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureVersionsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + versions_ = new com.google.protobuf.LazyStringArrayList(versions_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string versions = 2; + * @return A list containing the versions. + */ + public com.google.protobuf.ProtocolStringList + getVersionsList() { + return versions_.getUnmodifiableView(); + } + /** + * repeated string versions = 2; + * @return The count of versions. + */ + public int getVersionsCount() { + return versions_.size(); + } + /** + * repeated string versions = 2; + * @param index The index of the element to return. + * @return The versions at the given index. + */ + public java.lang.String getVersions(int index) { + return versions_.get(index); + } + /** + * repeated string versions = 2; + * @param index The index of the value to return. + * @return The bytes of the versions at the given index. + */ + public com.google.protobuf.ByteString + getVersionsBytes(int index) { + return versions_.getByteString(index); + } + /** + * repeated string versions = 2; + * @param index The index to set the value at. + * @param value The versions to set. + * @return This builder for chaining. + */ + public Builder setVersions( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVersionsIsMutable(); + versions_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @param value The versions to add. + * @return This builder for chaining. + */ + public Builder addVersions( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVersionsIsMutable(); + versions_.add(value); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @param values The versions to add. + * @return This builder for chaining. + */ + public Builder addAllVersions( + java.lang.Iterable values) { + ensureVersionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, versions_); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @return This builder for chaining. + */ + public Builder clearVersions() { + versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @param value The bytes of the versions to add. + * @return This builder for chaining. + */ + public Builder addVersionsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureVersionsIsMutable(); + versions_.add(value); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:wso2.discovery.subscription.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 0000000000..a43716682c --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIOrBuilder.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 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(); + + /** + * 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/SubscribedAPIRef.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIRef.java new file mode 100644 index 0000000000..a42e9b007b --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIRef.java @@ -0,0 +1,752 @@ +// 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.SubscribedAPIRef} + */ +public final class SubscribedAPIRef extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.subscription.SubscribedAPIRef) + SubscribedAPIRefOrBuilder { +private static final long serialVersionUID = 0L; + // Use SubscribedAPIRef.newBuilder() to construct. + private SubscribedAPIRef(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SubscribedAPIRef() { + name_ = ""; + versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SubscribedAPIRef(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SubscribedAPIRef( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + versions_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + versions_.add(s); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + versions_ = versions_.getUnmodifiableView(); + } + 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_SubscribedAPIRef_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPIRef_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef.class, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef.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 VERSIONS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList versions_; + /** + * repeated string versions = 2; + * @return A list containing the versions. + */ + public com.google.protobuf.ProtocolStringList + getVersionsList() { + return versions_; + } + /** + * repeated string versions = 2; + * @return The count of versions. + */ + public int getVersionsCount() { + return versions_.size(); + } + /** + * repeated string versions = 2; + * @param index The index of the element to return. + * @return The versions at the given index. + */ + public java.lang.String getVersions(int index) { + return versions_.get(index); + } + /** + * repeated string versions = 2; + * @param index The index of the value to return. + * @return The bytes of the versions at the given index. + */ + public com.google.protobuf.ByteString + getVersionsBytes(int index) { + return versions_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + for (int i = 0; i < versions_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, versions_.getRaw(i)); + } + 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_); + } + { + int dataSize = 0; + for (int i = 0; i < versions_.size(); i++) { + dataSize += computeStringSizeNoTag(versions_.getRaw(i)); + } + size += dataSize; + size += 1 * getVersionsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef)) { + return super.equals(obj); + } + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef other = (org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef) obj; + + if (!getName() + .equals(other.getName())) return false; + if (!getVersionsList() + .equals(other.getVersionsList())) 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(); + if (getVersionsCount() > 0) { + hash = (37 * hash) + VERSIONS_FIELD_NUMBER; + hash = (53 * hash) + getVersionsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef 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.SubscribedAPIRef parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef 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.SubscribedAPIRef parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef 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.SubscribedAPIRef 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.SubscribedAPIRef 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.SubscribedAPIRef 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.SubscribedAPIRef 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.SubscribedAPIRef 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.SubscribedAPIRef 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.SubscribedAPIRef 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.SubscribedAPIRef} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.subscription.SubscribedAPIRef) + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRefOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPIRef_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.apk.enforcer.discovery.subscription.SubscriptionProto.internal_static_wso2_discovery_subscription_SubscribedAPIRef_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef.class, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef.Builder.class); + } + + // Construct using org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef.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_ = ""; + + versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + 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_SubscribedAPIRef_descriptor; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef getDefaultInstanceForType() { + return org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef build() { + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef buildPartial() { + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef result = new org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef(this); + int from_bitField0_ = bitField0_; + result.name_ = name_; + if (((bitField0_ & 0x00000001) != 0)) { + versions_ = versions_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.versions_ = versions_; + 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.SubscribedAPIRef) { + return mergeFrom((org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef other) { + if (other == org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.versions_.isEmpty()) { + if (versions_.isEmpty()) { + versions_ = other.versions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureVersionsIsMutable(); + versions_.addAll(other.versions_); + } + 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.SubscribedAPIRef parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + 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 com.google.protobuf.LazyStringList versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureVersionsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + versions_ = new com.google.protobuf.LazyStringArrayList(versions_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string versions = 2; + * @return A list containing the versions. + */ + public com.google.protobuf.ProtocolStringList + getVersionsList() { + return versions_.getUnmodifiableView(); + } + /** + * repeated string versions = 2; + * @return The count of versions. + */ + public int getVersionsCount() { + return versions_.size(); + } + /** + * repeated string versions = 2; + * @param index The index of the element to return. + * @return The versions at the given index. + */ + public java.lang.String getVersions(int index) { + return versions_.get(index); + } + /** + * repeated string versions = 2; + * @param index The index of the value to return. + * @return The bytes of the versions at the given index. + */ + public com.google.protobuf.ByteString + getVersionsBytes(int index) { + return versions_.getByteString(index); + } + /** + * repeated string versions = 2; + * @param index The index to set the value at. + * @param value The versions to set. + * @return This builder for chaining. + */ + public Builder setVersions( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVersionsIsMutable(); + versions_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @param value The versions to add. + * @return This builder for chaining. + */ + public Builder addVersions( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureVersionsIsMutable(); + versions_.add(value); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @param values The versions to add. + * @return This builder for chaining. + */ + public Builder addAllVersions( + java.lang.Iterable values) { + ensureVersionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, versions_); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @return This builder for chaining. + */ + public Builder clearVersions() { + versions_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string versions = 2; + * @param value The bytes of the versions to add. + * @return This builder for chaining. + */ + public Builder addVersionsBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureVersionsIsMutable(); + versions_.add(value); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:wso2.discovery.subscription.SubscribedAPIRef) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.subscription.SubscribedAPIRef) + private static final org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef(); + } + + public static org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIRef getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SubscribedAPIRef parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SubscribedAPIRef(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.SubscribedAPIRef getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIRefOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIRefOrBuilder.java new file mode 100644 index 0000000000..3adc957390 --- /dev/null +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/SubscribedAPIRefOrBuilder.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 SubscribedAPIRefOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.subscription.SubscribedAPIRef) + 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/Subscription.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/subscription/Subscription.java index ca4687af7c..70476fe5de 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 @@ -82,14 +82,14 @@ private Subscription( break; } case 42: { - org.wso2.apk.enforcer.discovery.subscription.API.Builder subBuilder = null; - if (api_ != null) { - subBuilder = api_.toBuilder(); + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder subBuilder = null; + if (subscribedApi_ != null) { + subBuilder = subscribedApi_.toBuilder(); } - api_ = input.readMessage(org.wso2.apk.enforcer.discovery.subscription.API.parser(), extensionRegistry); + subscribedApi_ = input.readMessage(org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.parser(), extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom(api_); - api_ = subBuilder.buildPartial(); + subBuilder.mergeFrom(subscribedApi_); + subscribedApi_ = subBuilder.buildPartial(); } break; @@ -284,30 +284,30 @@ public java.lang.String getOrganization() { } } - public static final int API_FIELD_NUMBER = 5; - private org.wso2.apk.enforcer.discovery.subscription.API api_; + public static final int SUBSCRIBEDAPI_FIELD_NUMBER = 5; + private org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI subscribedApi_; /** - * .wso2.discovery.subscription.API api = 5; - * @return Whether the api field is set. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; + * @return Whether the subscribedApi field is set. */ @java.lang.Override - public boolean hasApi() { - return api_ != null; + public boolean hasSubscribedApi() { + return subscribedApi_ != null; } /** - * .wso2.discovery.subscription.API api = 5; - * @return The api. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; + * @return The subscribedApi. */ @java.lang.Override - public org.wso2.apk.enforcer.discovery.subscription.API getApi() { - return api_ == null ? org.wso2.apk.enforcer.discovery.subscription.API.getDefaultInstance() : api_; + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI getSubscribedApi() { + return subscribedApi_ == null ? org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.getDefaultInstance() : subscribedApi_; } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ @java.lang.Override - public org.wso2.apk.enforcer.discovery.subscription.APIOrBuilder getApiOrBuilder() { - return getApi(); + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder getSubscribedApiOrBuilder() { + return getSubscribedApi(); } public static final int TIMESTAMP_FIELD_NUMBER = 6; @@ -374,8 +374,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getOrganizationBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 4, organization_); } - if (api_ != null) { - output.writeMessage(5, getApi()); + if (subscribedApi_ != null) { + output.writeMessage(5, getSubscribedApi()); } if (!getTimeStampBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 6, timeStamp_); @@ -401,9 +401,9 @@ public int getSerializedSize() { if (!getOrganizationBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, organization_); } - if (api_ != null) { + if (subscribedApi_ != null) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, getApi()); + .computeMessageSize(5, getSubscribedApi()); } if (!getTimeStampBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, timeStamp_); @@ -431,10 +431,10 @@ public boolean equals(final java.lang.Object obj) { .equals(other.getUuid())) return false; if (!getOrganization() .equals(other.getOrganization())) return false; - if (hasApi() != other.hasApi()) return false; - if (hasApi()) { - if (!getApi() - .equals(other.getApi())) return false; + if (hasSubscribedApi() != other.hasSubscribedApi()) return false; + if (hasSubscribedApi()) { + if (!getSubscribedApi() + .equals(other.getSubscribedApi())) return false; } if (!getTimeStamp() .equals(other.getTimeStamp())) return false; @@ -457,9 +457,9 @@ public int hashCode() { hash = (53 * hash) + getUuid().hashCode(); hash = (37 * hash) + ORGANIZATION_FIELD_NUMBER; hash = (53 * hash) + getOrganization().hashCode(); - if (hasApi()) { - hash = (37 * hash) + API_FIELD_NUMBER; - hash = (53 * hash) + getApi().hashCode(); + if (hasSubscribedApi()) { + hash = (37 * hash) + SUBSCRIBEDAPI_FIELD_NUMBER; + hash = (53 * hash) + getSubscribedApi().hashCode(); } hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; hash = (53 * hash) + getTimeStamp().hashCode(); @@ -608,11 +608,11 @@ public Builder clear() { organization_ = ""; - if (apiBuilder_ == null) { - api_ = null; + if (subscribedApiBuilder_ == null) { + subscribedApi_ = null; } else { - api_ = null; - apiBuilder_ = null; + subscribedApi_ = null; + subscribedApiBuilder_ = null; } timeStamp_ = ""; @@ -646,10 +646,10 @@ public org.wso2.apk.enforcer.discovery.subscription.Subscription buildPartial() result.subStatus_ = subStatus_; result.uuid_ = uuid_; result.organization_ = organization_; - if (apiBuilder_ == null) { - result.api_ = api_; + if (subscribedApiBuilder_ == null) { + result.subscribedApi_ = subscribedApi_; } else { - result.api_ = apiBuilder_.build(); + result.subscribedApi_ = subscribedApiBuilder_.build(); } result.timeStamp_ = timeStamp_; onBuilt(); @@ -716,8 +716,8 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.subscription.Subscripti organization_ = other.organization_; onChanged(); } - if (other.hasApi()) { - mergeApi(other.getApi()); + if (other.hasSubscribedApi()) { + mergeSubscribedApi(other.getSubscribedApi()); } if (!other.getTimeStamp().isEmpty()) { timeStamp_ = other.timeStamp_; @@ -1056,123 +1056,123 @@ public Builder setOrganizationBytes( return this; } - private org.wso2.apk.enforcer.discovery.subscription.API api_; + private org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI subscribedApi_; private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.apk.enforcer.discovery.subscription.API, org.wso2.apk.enforcer.discovery.subscription.API.Builder, org.wso2.apk.enforcer.discovery.subscription.APIOrBuilder> apiBuilder_; + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder, org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder> subscribedApiBuilder_; /** - * .wso2.discovery.subscription.API api = 5; - * @return Whether the api field is set. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; + * @return Whether the subscribedApi field is set. */ - public boolean hasApi() { - return apiBuilder_ != null || api_ != null; + public boolean hasSubscribedApi() { + return subscribedApiBuilder_ != null || subscribedApi_ != null; } /** - * .wso2.discovery.subscription.API api = 5; - * @return The api. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; + * @return The subscribedApi. */ - public org.wso2.apk.enforcer.discovery.subscription.API getApi() { - if (apiBuilder_ == null) { - return api_ == null ? org.wso2.apk.enforcer.discovery.subscription.API.getDefaultInstance() : api_; + 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 apiBuilder_.getMessage(); + return subscribedApiBuilder_.getMessage(); } } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ - public Builder setApi(org.wso2.apk.enforcer.discovery.subscription.API value) { - if (apiBuilder_ == null) { + public Builder setSubscribedApi(org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI value) { + if (subscribedApiBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - api_ = value; + subscribedApi_ = value; onChanged(); } else { - apiBuilder_.setMessage(value); + subscribedApiBuilder_.setMessage(value); } return this; } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ - public Builder setApi( - org.wso2.apk.enforcer.discovery.subscription.API.Builder builderForValue) { - if (apiBuilder_ == null) { - api_ = builderForValue.build(); + public Builder setSubscribedApi( + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder builderForValue) { + if (subscribedApiBuilder_ == null) { + subscribedApi_ = builderForValue.build(); onChanged(); } else { - apiBuilder_.setMessage(builderForValue.build()); + subscribedApiBuilder_.setMessage(builderForValue.build()); } return this; } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ - public Builder mergeApi(org.wso2.apk.enforcer.discovery.subscription.API value) { - if (apiBuilder_ == null) { - if (api_ != null) { - api_ = - org.wso2.apk.enforcer.discovery.subscription.API.newBuilder(api_).mergeFrom(value).buildPartial(); + 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 { - api_ = value; + subscribedApi_ = value; } onChanged(); } else { - apiBuilder_.mergeFrom(value); + subscribedApiBuilder_.mergeFrom(value); } return this; } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ - public Builder clearApi() { - if (apiBuilder_ == null) { - api_ = null; + public Builder clearSubscribedApi() { + if (subscribedApiBuilder_ == null) { + subscribedApi_ = null; onChanged(); } else { - api_ = null; - apiBuilder_ = null; + subscribedApi_ = null; + subscribedApiBuilder_ = null; } return this; } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ - public org.wso2.apk.enforcer.discovery.subscription.API.Builder getApiBuilder() { + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.Builder getSubscribedApiBuilder() { onChanged(); - return getApiFieldBuilder().getBuilder(); + return getSubscribedApiFieldBuilder().getBuilder(); } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ - public org.wso2.apk.enforcer.discovery.subscription.APIOrBuilder getApiOrBuilder() { - if (apiBuilder_ != null) { - return apiBuilder_.getMessageOrBuilder(); + public org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder getSubscribedApiOrBuilder() { + if (subscribedApiBuilder_ != null) { + return subscribedApiBuilder_.getMessageOrBuilder(); } else { - return api_ == null ? - org.wso2.apk.enforcer.discovery.subscription.API.getDefaultInstance() : api_; + return subscribedApi_ == null ? + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI.getDefaultInstance() : subscribedApi_; } } /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.apk.enforcer.discovery.subscription.API, org.wso2.apk.enforcer.discovery.subscription.API.Builder, org.wso2.apk.enforcer.discovery.subscription.APIOrBuilder> - getApiFieldBuilder() { - if (apiBuilder_ == null) { - apiBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - org.wso2.apk.enforcer.discovery.subscription.API, org.wso2.apk.enforcer.discovery.subscription.API.Builder, org.wso2.apk.enforcer.discovery.subscription.APIOrBuilder>( - getApi(), + 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()); - api_ = null; + subscribedApi_ = null; } - return apiBuilder_; + return subscribedApiBuilder_; } private java.lang.Object timeStamp_ = ""; 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 a5d7f5357f..2607602b6a 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 @@ -56,19 +56,19 @@ public interface SubscriptionOrBuilder extends getOrganizationBytes(); /** - * .wso2.discovery.subscription.API api = 5; - * @return Whether the api field is set. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; + * @return Whether the subscribedApi field is set. */ - boolean hasApi(); + boolean hasSubscribedApi(); /** - * .wso2.discovery.subscription.API api = 5; - * @return The api. + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; + * @return The subscribedApi. */ - org.wso2.apk.enforcer.discovery.subscription.API getApi(); + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPI getSubscribedApi(); /** - * .wso2.discovery.subscription.API api = 5; + * .wso2.discovery.subscription.SubscribedAPI subscribedApi = 5; */ - org.wso2.apk.enforcer.discovery.subscription.APIOrBuilder getApiOrBuilder(); + org.wso2.apk.enforcer.discovery.subscription.SubscribedAPIOrBuilder getSubscribedApiOrBuilder(); /** * string timeStamp = 6; 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 2f3526fbc7..f573cefacd 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 @@ -20,10 +20,10 @@ public static void registerAllExtensions( com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_wso2_discovery_subscription_Subscription_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor - internal_static_wso2_discovery_subscription_API_descriptor; + internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_wso2_discovery_subscription_API_fieldAccessorTable; + internal_static_wso2_discovery_subscription_SubscribedAPI_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -34,16 +34,17 @@ public static void registerAllExtensions( static { java.lang.String[] descriptorData = { "\n.wso2/discovery/subscription/subscripti" + - "on.proto\022\033wso2.discovery.subscription\"\230\001" + + "on.proto\022\033wso2.discovery.subscription\"\254\001" + "\n\014Subscription\022\017\n\007eventId\030\001 \001(\t\022\021\n\tsubSt" + "atus\030\002 \001(\t\022\014\n\004uuid\030\003 \001(\t\022\024\n\014organization" + - "\030\004 \001(\t\022-\n\003api\030\005 \001(\0132 .wso2.discovery.sub" + - "scription.API\022\021\n\ttimeStamp\030\006 \001(\t\"%\n\003API\022" + - "\014\n\004name\030\001 \001(\t\022\020\n\010versions\030\002 \003(\tB\224\001\n,org." + - "wso2.apk.enforcer.discovery.subscription" + - "B\021SubscriptionProtoP\001ZOgithub.com/envoyp" + - "roxy/go-control-plane/wso2/discovery/sub" + - "scription;subscriptionb\006proto3" + "\030\004 \001(\t\022A\n\rsubscribedApi\030\005 \001(\0132*.wso2.dis" + + "covery.subscription.SubscribedAPI\022\021\n\ttim" + + "eStamp\030\006 \001(\t\"/\n\rSubscribedAPI\022\014\n\004name\030\001 " + + "\001(\t\022\020\n\010versions\030\002 \003(\tB\224\001\n,org.wso2.apk.e" + + "nforcer.discovery.subscriptionB\021Subscrip" + + "tionProtoP\001ZOgithub.com/envoyproxy/go-co" + + "ntrol-plane/wso2/discovery/subscription;" + + "subscriptionb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -54,12 +55,12 @@ 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", "SubStatus", "Uuid", "Organization", "Api", "TimeStamp", }); - internal_static_wso2_discovery_subscription_API_descriptor = + new java.lang.String[] { "EventId", "SubStatus", "Uuid", "Organization", "SubscribedApi", "TimeStamp", }); + internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor = getDescriptor().getMessageTypes().get(1); - internal_static_wso2_discovery_subscription_API_fieldAccessorTable = new + internal_static_wso2_discovery_subscription_SubscribedAPI_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_wso2_discovery_subscription_API_descriptor, + internal_static_wso2_discovery_subscription_SubscribedAPI_descriptor, new java.lang.String[] { "Name", "Versions", }); } 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 5c145b3e6d..790e1c8602 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,56 +53,6 @@ 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) { - - this.policy = policy; - } - - public String getTokenType() { - - 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); - } - public Map getAttributes() { return attributes; @@ -126,39 +68,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 2bf815b5b1..aadc9f92e3 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 48c06f8308..0000000000 --- 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 0000000000..ade548e222 --- /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/SubscribedAPI.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/models/SubscribedAPI.java new file mode 100644 index 0000000000..7f8c11b259 --- /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 List versions = new ArrayList<>(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getVersions() { + return versions; + } + + public void setVersions(List versions) { + this.versions = versions; + } +} 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 d3a2d6580d..34fa8c73eb 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 bd3bbe10a0..8e3be49d91 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 @@ -32,20 +32,14 @@ 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.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; /** @@ -253,7 +247,7 @@ public static APIKeyValidationInfoDTO validateSubscription(String apiUuid, Strin private static void validate(APIKeyValidationInfoDTO infoDTO, SubscriptionDataStore datastore, API api, String keyType, Application app, Subscription sub) { - String subscriptionStatus = sub.getSubscriptionState(); + String subscriptionStatus = sub.getSubscriptionStatus(); if (APIConstants.SubscriptionStatus.BLOCKED.equals(subscriptionStatus)) { infoDTO.setValidationStatus(APIConstants.KeyValidationStatus.API_BLOCKED); infoDTO.setAuthorized(false); 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 23e327b782..428d39d8af 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 @@ -34,14 +34,13 @@ import org.wso2.apk.enforcer.discovery.SubscriptionDiscoveryClient; import org.wso2.apk.enforcer.discovery.SubscriptionPolicyDiscoveryClient; import org.wso2.apk.enforcer.discovery.subscription.APIs; -import org.wso2.apk.enforcer.discovery.subscription.ApplicationMapping; import org.wso2.apk.enforcer.discovery.subscription.Certificate; import org.wso2.apk.enforcer.discovery.subscription.JWTIssuer; 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.ApplicationKeyMappingCacheKey; +import org.wso2.apk.enforcer.models.ApplicationMapping; import org.wso2.apk.enforcer.models.ApplicationPolicy; import org.wso2.apk.enforcer.models.Subscription; import org.wso2.apk.enforcer.models.SubscriptionPolicy; @@ -76,7 +75,7 @@ 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; @@ -105,6 +104,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(); } @@ -144,12 +144,15 @@ 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.setVersions(subscription.getSubscribedApi().getVersionsList()); + 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.setSubscriptionStatus(subscription.getSubStatus()); + newSubscription.setOrganization(subscription.getOrganization()); + newSubscription.setSubscribedApi(subscribedAPI); // newSubscription.setTimeStamp(Long.parseLong(subscription.getTimeStamp())); newSubscriptionMap.put(newSubscription.getCacheKey(), newSubscription); @@ -167,10 +170,8 @@ 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()) { @@ -276,7 +275,21 @@ public void addApplicationKeyMappings( public void addApplicationMappings( List applicationMappingList) { - // TODO: ############### + + 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 @@ -321,23 +334,19 @@ public API getMatchingAPI(String context, String version) { } @Override - public List getMatchingApplications(String name, String organizationID, String uuid) { + public List getMatchingApplications(String name, String uuid) { List applicationList = new ArrayList<>(); for (Application application : applicationMap.values()) { boolean isNameMatching = true; - boolean isOrgMatching = true; boolean isUUIDMatching = true; if (StringUtils.isNotEmpty(name)) { isNameMatching = application.getName().contains(name); } - if (StringUtils.isNotEmpty(organizationID)) { - isOrgMatching = application.getTenantDomain().equals(organizationID); - } if (StringUtils.isNotEmpty(uuid)) { isUUIDMatching = application.getUUID().equals(uuid); } - if (isNameMatching && isOrgMatching && isUUIDMatching) { + if (isNameMatching && isUUIDMatching) { applicationList.add(application); } } @@ -345,21 +354,22 @@ public List getMatchingApplications(String name, String organizatio } @Override - public List getMatchingKeyMapping(String applicationUUID, String consumerKey) { + public List getMatchingKeyMapping(String applicationUUID, String applicationIdentifier) { List applicationKeyMappingList = new ArrayList<>(); for (ApplicationKeyMapping applicationKeyMapping : applicationKeyMappingMap.values()) { - boolean isConsumerKeyMatching = true; + boolean isApplicationIdentifierMatching = true; boolean isAppUUIDMatching = true; if (StringUtils.isNotEmpty(applicationUUID)) { isAppUUIDMatching = applicationKeyMapping.getApplicationUUID().equals(applicationUUID); } - if (StringUtils.isNotEmpty(consumerKey)) { - isConsumerKeyMatching = applicationKeyMapping.getConsumerKey().equals(consumerKey); + if (StringUtils.isNotEmpty(applicationIdentifier)) { + isApplicationIdentifierMatching = applicationKeyMapping.getApplicationIdentifier() + .equals(applicationIdentifier); } - if (isConsumerKeyMatching && isAppUUIDMatching) { + if (isApplicationIdentifierMatching && isAppUUIDMatching) { applicationKeyMappingList.add(applicationKeyMapping); } } @@ -367,30 +377,37 @@ public List getMatchingKeyMapping(String applicationUUID, } @Override - public List getMatchingSubscriptions(String applicationUUID, String apiUUID, String state) { + public List getMatchingSubscriptions(String uuid, String apiName, String apiVersion, String state) { List subscriptionList = new ArrayList<>(); for (Subscription subscription : subscriptionMap.values()) { - boolean isApiUUIDMatch = true; - boolean isAppUUIDMatch = true; - boolean isStateMatch = true; - if (StringUtils.isNotEmpty(applicationUUID)) { - isAppUUIDMatch = subscription.getAppUUID().equals(applicationUUID); + boolean isUUIDMatching = true; + boolean isApiNameMatching = true; + boolean isApiVersionMatching = true; + boolean isStateMatching = true; + if (StringUtils.isNotEmpty(uuid)) { + isUUIDMatching = subscription.getSubscriptionId().equals(uuid); + } + if (StringUtils.isNotEmpty(apiName)) { + isApiNameMatching = subscription.getSubscribedApi().getName().equals(apiName); } - if (StringUtils.isNotEmpty(apiUUID)) { - isApiUUIDMatch = subscription.getApiUUID().equals(apiUUID); + if (StringUtils.isNotEmpty(apiVersion)) { + // Todo: Regex check } if (StringUtils.isNotEmpty(state)) { - isStateMatch = subscription.getSubscriptionState().equals(state); + isStateMatching = subscription.getSubscriptionStatus().equals(state); } - if (isApiUUIDMatch && isAppUUIDMatch && isStateMatch) { + if (isUUIDMatching && isApiNameMatching && isApiVersionMatching && isStateMatching) { subscriptionList.add(subscription); } } return subscriptionList; } +// @Override +// public List getMatchingApplicationMapping + @Override public void addJWTIssuers(List jwtIssuers) { 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 f4e3cda6b4..77c52cc3a3 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 @@ -79,8 +79,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: 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 }} @@ -143,13 +143,13 @@ spec: secretName: {{ template "apk-helm.resource.prefix" . }}-webhook-server-cert defaultMode: 420 {{ if and .Values.wso2.apk.dp.enabled .Values.wso2.apk.dp.ratelimiter.enabled }} - - name: enforcer-truststore-secret-volume - secret: - {{- if and .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.tls }} - secretName: {{ .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.tls.secretName | default (printf "%s-enforcer-server-cert" (include "apk-helm.resource.prefix" .)) }} - {{- else }} - secretName: {{ template "apk-helm.resource.prefix" . }}-enforcer-server-cert - {{- end }} + # - name: enforcer-truststore-secret-volume + # secret: + # {{- if and .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.tls }} + # secretName: {{ .Values.wso2.apk.dp.gatewayRuntime.deployment.enforcer.configs.tls.secretName | default (printf "%s-enforcer-server-cert" (include "apk-helm.resource.prefix" .)) }} + # {{- else }} + # secretName: {{ template "apk-helm.resource.prefix" . }}-enforcer-server-cert + # {{- end }} - name: ratelimiter-truststore-secret-volume secret: {{- if and .Values.wso2.apk.dp.ratelimiter.configs .Values.wso2.apk.dp.ratelimiter.configs.tls }} 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 2528cac8aa..690ccb5829 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 @@ -151,8 +151,8 @@ spec: {{- else }} subPath: tls.crt {{- end }} - - name: common-controller-truststore-secret-volume - mountPath: /home/wso2/security/truststore/adapter.pem + # - 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 }} @@ -340,14 +340,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: 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 }}