@@ -70,12 +70,8 @@ public SignedDataVerifier(Set<InputStream> rootCertificates, String bundleId, Lo
7070     */ 
7171    public  JWSTransactionDecodedPayload  verifyAndDecodeTransaction (String  signedTransaction ) throws  VerificationException  {
7272        JWSTransactionDecodedPayload  transaction  = decodeSignedObject (signedTransaction , JWSTransactionDecodedPayload .class );
73-         if  (!bundleId .equals (transaction .getBundleId ())) {
74-             throw  new  VerificationException (VerificationStatus .INVALID_APP_IDENTIFIER );
75-         }
76-         if  (!this .environment .equals (transaction .getEnvironment ())) {
77-             throw  new  VerificationException (VerificationStatus .INVALID_ENVIRONMENT );
78-         }
73+         validateBundleId (transaction .getBundleId ());
74+         validateEnvironment (transaction .getEnvironment ());
7975        return  transaction ;
8076    }
8177
@@ -89,9 +85,7 @@ public JWSTransactionDecodedPayload verifyAndDecodeTransaction(String signedTran
8985     */ 
9086    public  JWSRenewalInfoDecodedPayload  verifyAndDecodeRenewalInfo (String  signedRenewalInfo ) throws  VerificationException  {
9187        JWSRenewalInfoDecodedPayload  renewalInfo  = decodeSignedObject (signedRenewalInfo , JWSRenewalInfoDecodedPayload .class );
92-         if  (!this .environment .equals (renewalInfo .getEnvironment ())) {
93-             throw  new  VerificationException (VerificationStatus .INVALID_ENVIRONMENT );
94-         }
88+         validateEnvironment (renewalInfo .getEnvironment ());
9589        return  renewalInfo ;
9690    }
9791
@@ -135,12 +129,9 @@ public ResponseBodyV2DecodedPayload verifyAndDecodeNotification(String signedPay
135129    }
136130
137131    protected  void  verifyNotification (String  bundleId , Long  appAppleId , Environment  notificationEnv ) throws  VerificationException  {
138-         if  (!this .bundleId .equals (bundleId ) || (this .environment .equals (Environment .PRODUCTION ) && !this .appAppleId .equals (appAppleId ))) {
139-             throw  new  VerificationException (VerificationStatus .INVALID_APP_IDENTIFIER );
140-         }
141-         if  (!this .environment .equals (notificationEnv )) {
142-             throw  new  VerificationException (VerificationStatus .INVALID_ENVIRONMENT );
143-         }
132+         validateBundleId (bundleId );
133+         validateAppAppleId (appAppleId );
134+         validateEnvironment (notificationEnv );
144135    }
145136
146137    /** 
@@ -154,13 +145,28 @@ protected void verifyNotification(String bundleId, Long appAppleId, Environment
154145    public  AppTransaction  verifyAndDecodeAppTransaction (String  signedAppTransaction ) throws  VerificationException  {
155146        AppTransaction  appTransaction  = decodeSignedObject (signedAppTransaction , AppTransaction .class );
156147        Environment  environment  = appTransaction .getReceiptType ();
157-         if  (!this .bundleId .equals (appTransaction .getBundleId ()) || (this .environment .equals (Environment .PRODUCTION ) && !this .appAppleId .equals (appTransaction .getAppAppleId ()))) {
148+         validateBundleId (appTransaction .getBundleId ());
149+         validateAppAppleId (appTransaction .getAppAppleId ());
150+         validateEnvironment (environment );
151+         return  appTransaction ;
152+     }
153+ 
154+     protected  void  validateAppAppleId (Long  appAppleId ) throws  VerificationException  {
155+         if  (this .environment .equals (Environment .PRODUCTION ) && !this .appAppleId .equals (appAppleId )) {
156+             throw  new  VerificationException (VerificationStatus .INVALID_APP_IDENTIFIER );
157+         }
158+     }
159+ 
160+     protected  void  validateBundleId (String  bundleId ) throws  VerificationException  {
161+         if  (!this .bundleId .equals (bundleId )) {
158162            throw  new  VerificationException (VerificationStatus .INVALID_APP_IDENTIFIER );
159163        }
164+     }
165+ 
166+     protected  void  validateEnvironment (Environment  environment ) throws  VerificationException  {
160167        if  (!this .environment .equals (environment )) {
161168            throw  new  VerificationException (VerificationStatus .INVALID_ENVIRONMENT );
162169        }
163-         return  appTransaction ;
164170    }
165171
166172    protected  <T  extends  DecodedSignedData > T  decodeSignedObject (String  signedObject , Class <T > clazz ) throws  VerificationException  {
0 commit comments