示例#1
0
 def createPassword():
     Security.deletePassword()
     p = Security.promptForPassword(True)
     Msg.flush()
     Msg.show("Thanks ... please wait")
     Msg.flush()
     h = Security.hashAndSaltPassword(p)
     File.setContent(Security.__passwordPath, {"Password": h}, asJson=True)
示例#2
0
 def __runTranslator(action=None):
     WebApp.checkAuthentication()
     header = WebApp.getHeader("Translator")
     footer = WebApp.getFooter()
     pluginName = Web.cocoscats.cfg["Workflow"]["Translator"]["Plugin"]
     navigation = WebApp.getNavigation("Translator", 3, pluginName)
     path = Web.cocoscats.frameworkParams["translatorPath"]
     if not action is None and action == "Save":
         File.setContent(path, bottle.request.forms.Content)
         WebApp.translatorTainted = True
         WebApp.outputTainted = False
         return "Successfully saved to '" + path + "'"
     content = None
     if WebApp.translatorTainted:
         content = File.getContent(path)
     else:
         content = Web.cocoscats.runTranslator()
     editor = WebApp.getEditor(content)
     body = """{0}{1}""".format(navigation, editor)
     return "{0}{1}{2}".format(header, body, footer)
示例#3
0
 def createCertsAndKeys(host=None):
     if host is None:
         host = socket.gethostname()
     File.deletes([
         Security.__privateKeyPath, Security.__publicKeyPath,
         Security.__certificatePemPath, Security.__certificateCrtPath
     ])
     key = OpenSSL.crypto.PKey()
     key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)
     certificate = OpenSSL.crypto.X509()
     certificate.get_subject().C = "US"
     certificate.get_subject().ST = "Oregon"
     certificate.get_subject().L = "Portland"
     certificate.get_subject().O = "Cocoscats"
     certificate.get_subject().OU = "Cocoscats"
     certificate.get_subject().CN = host
     certificate.set_serial_number(random.randint(1, 99999999999))
     certificate.gmtime_adj_notBefore(0)
     certificate.gmtime_adj_notAfter(10 * 365 * 24 * 60 * 60)
     certificate.set_issuer(certificate.get_subject())
     certificate.set_pubkey(key)
     certificate.sign(key, "sha512")
     privateKeyData = OpenSSL.crypto.dump_privatekey(
         OpenSSL.crypto.FILETYPE_PEM, key)
     publicKeyData = OpenSSL.crypto.dump_publickey(
         OpenSSL.crypto.FILETYPE_PEM, key)
     certificateData = OpenSSL.crypto.dump_certificate(
         OpenSSL.crypto.FILETYPE_PEM, certificate)
     File.setContent(Security.__privateKeyPath,
                     privateKeyData,
                     asBytes=True,
                     mkdirs=True)
     File.setContent(Security.__publicKeyPath,
                     publicKeyData,
                     asBytes=True,
                     mkdirs=True)
     File.setContent(Security.__certificatePemPath,
                     certificateData,
                     asBytes=True,
                     mkdirs=True)
     if Security.hasOpenSSL():
         ret = os.system(
             "openssl x509 -outform der -in {0} -out {1}".format(
                 Security.__certificatePemPath,
                 Security.__certificateCrtPath))
示例#4
0
 def runInput(self):
     content = self.__callPluginMethod("IO",
                                       self.getWorkflowPlugin("Input"),
                                       self.frameworkParams)
     File.setContent(self.frameworkParams["originalPath"], content)
     return content
示例#5
0
 def saveTranslatedCaptions(self, content):
     File.setContent(self.__TRANSLATED_PATH, content)
示例#6
0
 def downloadCaption(self):
     captions = self.download_caption().decode()
     File.setContent(self.__DOWNLOADED_PATH, captions)
     return captions
示例#7
0
 def __setContent(self, outputType, content):
     return File.setContent(self.__frameworkParams[outputType], content)