Skip to content

Commit 524a478

Browse files
Merge pull request #185 from alexanderjordanbaker/UpdatesToPublishingProccess
Updates to publishing proccess
2 parents 3662ff0 + a6bd9ce commit 524a478

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed

build.gradle

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,35 @@ publishing {
7575
password findProperty("mavenPassword")
7676
}
7777
if(project.version.endsWith('-SNAPSHOT')) {
78-
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
78+
url "https://central.sonatype.com/repository/maven-snapshots/"
7979
} else {
80-
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
80+
url "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
81+
}
82+
}
83+
}
84+
}
85+
86+
tasks.named('publish') {
87+
finalizedBy tasks.named('postRelease')
88+
}
89+
90+
tasks.register('postRelease') {
91+
doLast {
92+
if (!project.version.endsWith('-SNAPSHOT')) {
93+
def username = findProperty("mavenUsername")
94+
def password = findProperty("mavenPassword")
95+
def url = "https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.apple.itunes.storekit"
96+
def connection = new URL(url).openConnection() as HttpURLConnection
97+
connection.setRequestMethod("POST")
98+
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
99+
connection.setRequestProperty('Authorization', 'Basic ' + "${username}:${password}".bytes.encodeBase64().toString())
100+
def responseCode = connection.responseCode
101+
if (responseCode == 200) {
102+
def response = connection.inputStream.text
103+
println "Success: $response"
104+
} else {
105+
def error = connection.errorStream?.text ?: "No error details"
106+
println "Error $responseCode: $error"
81107
}
82108
}
83109
}

src/main/java/com/apple/itunes/storekit/verification/SignedDataVerifier.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)