Commit 1afddcad authored by codesign's avatar codesign

codesign macos ok

parent f8c10ca7
......@@ -14,5 +14,5 @@
*/
package org.bonitasoft.exception
class BuildDmgException : Throwable() {
class BuildDmgException(message : String) : Throwable(message) {
}
\ No newline at end of file
......@@ -14,5 +14,5 @@
*/
package org.bonitasoft.exception
class SignException() : Throwable(){
class SignException(message : String) : Throwable(message){
}
\ No newline at end of file
......@@ -64,14 +64,15 @@ class CodeSigningRestController {
fileSigned = windowsCodeSign.signWindowsProduct(exeCopy)
}
} catch (e: SignException) {
response.setStatus(500);
logger.error(e)
response.setStatus(500)
return StreamingResponseBody { outputStream ->
outputStream.write("An error occured while signing file.".toByteArray())
}
}
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename='${fileSigned.name}'");
response.setContentType("application/octet-stream")
response.setHeader("Content-Disposition", "attachment; filename='${fileSigned.name}'")
return StreamingResponseBody { outputStream ->
FileInputStream(fileSigned.canonicalFile).use { inputStream ->
......@@ -125,11 +126,13 @@ class CodeSigningRestController {
}
}
} catch (e : SignException) {
logger.error(e)
response.setStatus(500);
return StreamingResponseBody { outputStream ->
outputStream.write("An error occured while signing file.".toByteArray())
}
} catch (e : BuildDmgException) {
logger.error(e)
response.setStatus(500);
return StreamingResponseBody { outputStream ->
outputStream.write("An error occured while building dmg.".toByteArray())
......
......@@ -31,41 +31,39 @@ class MacCodeSign {
throw Throwable()
}
logger.info("Signing macOS file...")
logger.info("Signing osx application...")
val signResult = ProcessBuilder()
.inheritIO()
.command("echo", "bonitasoft", "|", "sudo", "-S", "codesign", "--deep", "-s", "Bonitasoft", file.canonicalPath)
.command("codesign", "--deep", "-s", "Bonitasoft" , file.canonicalPath)
.start()
.waitFor()
if (signResult != 0) {
logger.error("An error occured while signing file.")
throw SignException()
throw SignException("An error occured while signing file.")
}
var newZipFile = zip(file);
deleteApplication(file)
logger.info("Osx application has been signed successfully")
return newZipFile
}
fun buildAndSignMacInstaller(zipFile: File) : File {
val file : File = unzip(zipFile);
if (!zipFile.delete()) {
logger.error("Failed to delete temp file $zipFile")
throw Throwable()
throw Throwable("Failed to delete temp file $zipFile")
}
logger.info("Signing macOS installer...")
var signResult = ProcessBuilder()
.inheritIO()
.command("echo", "bonitasoft", "|", "sudo", "-S", "codesign", "--deep", "-s", "Bonitasoft", file.canonicalPath)
.command("codesign", "--deep", "-s", "Bonitasoft", file.canonicalPath)
.start()
.waitFor()
if (signResult != 0) {
logger.error("An error occured while signing installer.")
throw SignException()
throw SignException("An error occured while signing installer.")
}
logger.info("Building dmg...")
......@@ -78,8 +76,7 @@ class MacCodeSign {
.waitFor()
var dmg = File(dmgPath);
if (buildDmgResult != 0 || ! dmg.exists()) {
logger.error("An error occured while building dmg.")
throw BuildDmgException()
throw BuildDmgException("An error occured while building dmg")
}
logger.info("Signing macOS dmg...")
......@@ -89,12 +86,13 @@ class MacCodeSign {
.start()
.waitFor()
if (signResult != 0) {
logger.error("An error occured while signing dmg.")
throw SignException()
throw SignException("An error occured while signing dmg.")
}
deleteApplication(file)
logger.info("dmg has been created and signed successfully")
return dmg
}
......@@ -135,4 +133,5 @@ class MacCodeSign {
.waitFor()
}
}
\ No newline at end of file
......@@ -31,8 +31,7 @@ class WindowsCodeSign {
val signResult = processBuilder.inheritIO().start().waitFor()
if (signResult != 0) {
logger.error("An error occured while signing file.")
throw SignException()
throw SignException("An error occured while signing file.")
}
return file;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment