Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,35 @@ publishing {
password findProperty("mavenPassword")
}
if(project.version.endsWith('-SNAPSHOT')) {
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url "https://central.sonatype.com/repository/maven-snapshots/"
} else {
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
url "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
}
}
}
}

tasks.named('publish') {
finalizedBy tasks.named('postRelease')
}

tasks.register('postRelease') {
doLast {
if (!project.version.endsWith('-SNAPSHOT')) {
def username = findProperty("mavenUsername")
def password = findProperty("mavenPassword")
def url = "https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.apple.itunes.storekit"
def connection = new URL(url).openConnection() as HttpURLConnection
connection.setRequestMethod("POST")
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
connection.setRequestProperty('Authorization', 'Basic ' + "${username}:${password}".bytes.encodeBase64().toString())
def responseCode = connection.responseCode
if (responseCode == 200) {
def response = connection.inputStream.text
println "Success: $response"
} else {
def error = connection.errorStream?.text ?: "No error details"
println "Error $responseCode: $error"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ public SignedDataVerifier(Set<InputStream> rootCertificates, String bundleId, Lo
*/
public JWSTransactionDecodedPayload verifyAndDecodeTransaction(String signedTransaction) throws VerificationException {
JWSTransactionDecodedPayload transaction = decodeSignedObject(signedTransaction, JWSTransactionDecodedPayload.class);
if (!bundleId.equals(transaction.getBundleId())) {
throw new VerificationException(VerificationStatus.INVALID_APP_IDENTIFIER);
}
if (!this.environment.equals(transaction.getEnvironment())) {
throw new VerificationException(VerificationStatus.INVALID_ENVIRONMENT);
}
validateBundleId(transaction.getBundleId());
validateEnvironment(transaction.getEnvironment());
return transaction;
}

Expand All @@ -89,9 +85,7 @@ public JWSTransactionDecodedPayload verifyAndDecodeTransaction(String signedTran
*/
public JWSRenewalInfoDecodedPayload verifyAndDecodeRenewalInfo(String signedRenewalInfo) throws VerificationException {
JWSRenewalInfoDecodedPayload renewalInfo = decodeSignedObject(signedRenewalInfo, JWSRenewalInfoDecodedPayload.class);
if (!this.environment.equals(renewalInfo.getEnvironment())) {
throw new VerificationException(VerificationStatus.INVALID_ENVIRONMENT);
}
validateEnvironment(renewalInfo.getEnvironment());
return renewalInfo;
}

Expand Down Expand Up @@ -135,12 +129,9 @@ public ResponseBodyV2DecodedPayload verifyAndDecodeNotification(String signedPay
}

protected void verifyNotification(String bundleId, Long appAppleId, Environment notificationEnv) throws VerificationException {
if (!this.bundleId.equals(bundleId) || (this.environment.equals(Environment.PRODUCTION) && !this.appAppleId.equals(appAppleId))) {
throw new VerificationException(VerificationStatus.INVALID_APP_IDENTIFIER);
}
if (!this.environment.equals(notificationEnv)) {
throw new VerificationException(VerificationStatus.INVALID_ENVIRONMENT);
}
validateBundleId(bundleId);
validateAppAppleId(appAppleId);
validateEnvironment(notificationEnv);
}

/**
Expand All @@ -154,13 +145,28 @@ protected void verifyNotification(String bundleId, Long appAppleId, Environment
public AppTransaction verifyAndDecodeAppTransaction(String signedAppTransaction) throws VerificationException {
AppTransaction appTransaction = decodeSignedObject(signedAppTransaction, AppTransaction.class);
Environment environment = appTransaction.getReceiptType();
if (!this.bundleId.equals(appTransaction.getBundleId()) || (this.environment.equals(Environment.PRODUCTION) && !this.appAppleId.equals(appTransaction.getAppAppleId()))) {
validateBundleId(appTransaction.getBundleId());
validateAppAppleId(appTransaction.getAppAppleId());
validateEnvironment(environment);
return appTransaction;
}

protected void validateAppAppleId(Long appAppleId) throws VerificationException {
if (this.environment.equals(Environment.PRODUCTION) && !this.appAppleId.equals(appAppleId)) {
throw new VerificationException(VerificationStatus.INVALID_APP_IDENTIFIER);
}
}

protected void validateBundleId(String bundleId) throws VerificationException {
if (!this.bundleId.equals(bundleId)) {
throw new VerificationException(VerificationStatus.INVALID_APP_IDENTIFIER);
}
}

protected void validateEnvironment(Environment environment) throws VerificationException {
if (!this.environment.equals(environment)) {
throw new VerificationException(VerificationStatus.INVALID_ENVIRONMENT);
}
return appTransaction;
}

protected <T extends DecodedSignedData> T decodeSignedObject(String signedObject, Class<T> clazz) throws VerificationException {
Expand Down
Loading