From d94a13fcf6b43e04482f08a879202732a48fcbf1 Mon Sep 17 00:00:00 2001
From: "CTFang@WireLab" <ctfang.cs12@nycu.edu.tw>
Date: Tue, 16 Jul 2024 03:24:54 +0000
Subject: [PATCH] fix: remove r16 models and fix type error

---
 models/model_authentication_info_result.go    | 20 --------------
 models/model_created_ee_subscription.go       | 20 --------------
 models/model_monitoring_report.go             | 26 -------------------
 ...el_nrf_access_token_access_token_claims.go |  3 +++
 models/model_reachability_for_sms_report.go   | 22 ----------------
 .../model_sip_authentication_info_result.go   | 12 ++++-----
 oauth/oauth.go                                |  4 +--
 7 files changed, 10 insertions(+), 97 deletions(-)
 delete mode 100644 models/model_authentication_info_result.go
 delete mode 100644 models/model_created_ee_subscription.go
 delete mode 100644 models/model_monitoring_report.go
 delete mode 100644 models/model_reachability_for_sms_report.go

diff --git a/models/model_authentication_info_result.go b/models/model_authentication_info_result.go
deleted file mode 100644
index bbea25bc..00000000
--- a/models/model_authentication_info_result.go
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Nudm_UEAU
- *
- * UDM UE Authentication Service. © 2020, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
- *
- * Source file: 3GPP TS 29.503 Unified Data Management Services, version 16.6.0
- * Url: http://www.3gpp.org/ftp/Specs/archive/29_series/29.503/
- *
- * API version: 1.1.2
- * Generated by: OpenAPI Generator (https://openapi-generator.tech)
- */
-
-package models
-
-type AuthenticationInfoResult struct {
-	AuthType             AuthType              `json:"authType" yaml:"authType" bson:"authType,omitempty"`
-	SupportedFeatures    string                `json:"supportedFeatures,omitempty" yaml:"supportedFeatures" bson:"supportedFeatures,omitempty"`
-	AuthenticationVector *AuthenticationVector `json:"authenticationVector,omitempty" yaml:"authenticationVector" bson:"authenticationVector,omitempty"`
-	Supi                 string                `json:"supi,omitempty" yaml:"supi" bson:"supi,omitempty"`
-}
diff --git a/models/model_created_ee_subscription.go b/models/model_created_ee_subscription.go
deleted file mode 100644
index b1bbe7ca..00000000
--- a/models/model_created_ee_subscription.go
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Nudm_EE
- *
- * Nudm Event Exposure Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
- *
- * Source file: 3GPP TS 29.503 Unified Data Management Services, version 16.9.0
- * Url: http://www.3gpp.org/ftp/Specs/archive/29_series/29.503/
- *
- * API version: 1.1.2
- * Generated by: OpenAPI Generator (https://openapi-generator.tech)
- */
-
-package models
-
-type CreatedEeSubscription struct {
-	EeSubscription *EeSubscription    `json:"eeSubscription" yaml:"eeSubscription" bson:"eeSubscription,omitempty"`
-	NumberOfUes    int32              `json:"numberOfUes,omitempty" yaml:"numberOfUes" bson:"numberOfUes,omitempty"`
-	EventReports   []MonitoringReport `json:"eventReports,omitempty" yaml:"eventReports" bson:"eventReports,omitempty"`
-	EpcStatusInd   bool               `json:"epcStatusInd,omitempty" yaml:"epcStatusInd" bson:"epcStatusInd,omitempty"`
-}
diff --git a/models/model_monitoring_report.go b/models/model_monitoring_report.go
deleted file mode 100644
index 9503ad12..00000000
--- a/models/model_monitoring_report.go
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Nudm_EE
- *
- * Nudm Event Exposure Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
- *
- * Source file: 3GPP TS 29.503 Unified Data Management Services, version 16.9.0
- * Url: http://www.3gpp.org/ftp/Specs/archive/29_series/29.503/
- *
- * API version: 1.1.2
- * Generated by: OpenAPI Generator (https://openapi-generator.tech)
- */
-
-package models
-
-import (
-	"time"
-)
-
-type MonitoringReport struct {
-	ReferenceId              int32                     `json:"referenceId" yaml:"referenceId" bson:"referenceId,omitempty"`
-	EventType                EventType                 `json:"eventType" yaml:"eventType" bson:"eventType,omitempty"`
-	Report                   *Report                   `json:"report,omitempty" yaml:"report" bson:"report,omitempty"`
-	ReachabilityForSmsReport *ReachabilityForSmsReport `json:"reachabilityForSmsReport,omitempty" yaml:"reachabilityForSmsReport" bson:"reachabilityForSmsReport,omitempty"`
-	Gpsi                     string                    `json:"gpsi,omitempty" yaml:"gpsi" bson:"gpsi,omitempty"`
-	TimeStamp                *time.Time                `json:"timeStamp" yaml:"timeStamp" bson:"timeStamp,omitempty"`
-}
diff --git a/models/model_nrf_access_token_access_token_claims.go b/models/model_nrf_access_token_access_token_claims.go
index 663af312..76c9a3ab 100644
--- a/models/model_nrf_access_token_access_token_claims.go
+++ b/models/model_nrf_access_token_access_token_claims.go
@@ -12,6 +12,8 @@
 
 package models
 
+import "github.com/golang-jwt/jwt"
+
 // The claims data structure for the access token
 type NrfAccessTokenAccessTokenClaims struct {
 	// String uniquely identifying a NF instance. The format of the NF Instance ID shall be a  Universally Unique Identifier (UUID) version 4, as described in IETF RFC 4122.
@@ -33,4 +35,5 @@ type NrfAccessTokenAccessTokenClaims struct {
 	ProducerNfServiceSetId string `json:"producerNfServiceSetId,omitempty" yaml:"producerNfServiceSetId" bson:"producerNfServiceSetId,omitempty"`
 	// String uniquely identifying a NF instance. The format of the NF Instance ID shall be a  Universally Unique Identifier (UUID) version 4, as described in IETF RFC 4122.
 	SourceNfInstanceId string `json:"sourceNfInstanceId,omitempty" yaml:"sourceNfInstanceId" bson:"sourceNfInstanceId,omitempty"`
+	jwt.StandardClaims
 }
diff --git a/models/model_reachability_for_sms_report.go b/models/model_reachability_for_sms_report.go
deleted file mode 100644
index 7a5e3443..00000000
--- a/models/model_reachability_for_sms_report.go
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Nudm_EE
- *
- * Nudm Event Exposure Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
- *
- * Source file: 3GPP TS 29.503 Unified Data Management Services, version 16.9.0
- * Url: http://www.3gpp.org/ftp/Specs/archive/29_series/29.503/
- *
- * API version: 1.1.2
- * Generated by: OpenAPI Generator (https://openapi-generator.tech)
- */
-
-package models
-
-import (
-	"time"
-)
-
-type ReachabilityForSmsReport struct {
-	SmsfAccessType      AccessType `json:"smsfAccessType" yaml:"smsfAccessType" bson:"smsfAccessType,omitempty"`
-	MaxAvailabilityTime *time.Time `json:"maxAvailabilityTime,omitempty" yaml:"maxAvailabilityTime" bson:"maxAvailabilityTime,omitempty"`
-}
diff --git a/models/model_sip_authentication_info_result.go b/models/model_sip_authentication_info_result.go
index adef34fc..9e9fd201 100644
--- a/models/model_sip_authentication_info_result.go
+++ b/models/model_sip_authentication_info_result.go
@@ -12,12 +12,10 @@
 
 package models
 
-
-
 type SipAuthenticationInfoResult struct {
-	Impi string `json:"impi" yaml:"impi" bson:"impi"`
-	Var3gAkaAvs []*Model3GAkaAv `json:"3gAkaAvs,omitempty" yaml:"3gAkaAvs" bson:"3gAkaAvs"`
-	DigestAuth *DigestAuthentication `json:"digestAuth,omitempty" yaml:"digestAuth" bson:"digestAuth"`
-	LineIdentifierList []string `json:"lineIdentifierList,omitempty" yaml:"lineIdentifierList" bson:"lineIdentifierList"`
-	IpAddress *IpAddress `json:"ipAddress,omitempty" yaml:"ipAddress" bson:"ipAddress"`
+	Impi               string                `json:"impi" yaml:"impi" bson:"impi"`
+	Var3gAkaAvs        []*Model3GAkaAv       `json:"3gAkaAvs,omitempty" yaml:"3gAkaAvs" bson:"3gAkaAvs"`
+	DigestAuth         *DigestAuthentication `json:"digestAuth,omitempty" yaml:"digestAuth" bson:"digestAuth"`
+	LineIdentifierList []string              `json:"lineIdentifierList,omitempty" yaml:"lineIdentifierList" bson:"lineIdentifierList"`
+	IpAddress          *IpAddr               `json:"ipAddress,omitempty" yaml:"ipAddress" bson:"ipAddress"`
 }
diff --git a/oauth/oauth.go b/oauth/oauth.go
index 65e4eec9..1565fc68 100644
--- a/oauth/oauth.go
+++ b/oauth/oauth.go
@@ -70,7 +70,7 @@ func VerifyOAuth(
 	access_token := auth_fields[1]
 	token, err := jwt.ParseWithClaims(
 		access_token,
-		&models.AccessTokenClaims{},
+		&models.NrfAccessTokenAccessTokenClaims{},
 		func(token *jwt.Token) (interface{}, error) {
 			if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
 				return nil, errors.Wrapf(err, "Unexpected signing method")
@@ -84,7 +84,7 @@ func VerifyOAuth(
 		return errors.Wrapf(err, "verify OAuth parse")
 	}
 
-	if !verifyScope(token.Claims.(*models.AccessTokenClaims).Scope, serviceName) {
+	if !verifyScope(token.Claims.(*models.NrfAccessTokenAccessTokenClaims).Scope, serviceName) {
 		return errors.Wrapf(err, "verify OAuth scope")
 	}
 	return nil