コード例 #1
0
ファイル: OAuth2Service.py プロジェクト: prrvchr/DropboxOOo
 def getAuthorization(self, url, username, close=True, parent=None):
     authorized = False
     msg = "Wizard Loading ..."
     print("OAuth2Service.getAuthorization() 1")
     wizard = Wizard(self.ctx, g_wizard_page, True, parent)
     print("OAuth2Service.getAuthorization() 2")
     controller = WizardController(self.ctx, wizard, self.Session, url,
                                   username, close)
     print("OAuth2Service.getAuthorization() 3")
     arguments = (g_wizard_paths, controller)
     print("OAuth2Service.getAuthorization() 4")
     wizard.initialize(arguments)
     msg += " Done ..."
     #wizard.DialogWindow.toFront()
     print("OAuth2Service.getAuthorization() 5")
     if wizard.execute() == OK:
         msg += " Retrieving Authorization Code ..."
         if controller.Error:
             msg += " ERROR: cant retrieve Authorization Code: %s" % controller.Error
         else:
             msg += " Done"
             authorized = self.initializeSession(controller.ResourceUrl,
                                                 controller.UserName)
     else:
         msg += " ERROR: Wizard as been aborted"
         controller.Server.cancel()
     wizard.DialogWindow.dispose()
     logMessage(self.ctx, INFO, msg, 'OAuth2Service', 'getAuthorization()')
     return authorized
コード例 #2
0
 def getAuthorization(self, url, username, close=True):
     authorized = False
     msg = "Wizard Loading ..."
     controller = WizardController(self.ctx, self.Session, url, username,
                                   close)
     msg += " Done ..."
     if controller.Wizard.execute() == OK:
         msg += " Retrieving Authorization Code ..."
         if controller.Error:
             msg += " ERROR: cant retrieve Authorization Code: %s" % controller.Error
         else:
             msg += " Done"
             authorized = self.initializeSession(controller.ResourceUrl,
                                                 controller.UserName)
     else:
         msg += " ERROR: Wizard as been aborted"
         controller.Server.cancel()
     controller.Wizard.DialogWindow.dispose()
     logMessage(self.ctx, INFO, msg, 'OAuth2Service', 'getAuthorization()')
     return authorized
コード例 #3
0
 def _getAuthorizationCode(self):
     code = None
     level = uno.getConstantByName('com.sun.star.logging.LogLevel.INFO')
     self.Setting.Logger.logp(level, "OAuth2Service",
                              "_getAuthorizationCode",
                              "WizardController Loading...")
     controller = WizardController(self.ctx, self.ResourceUrl,
                                   self.UserName)
     self.Setting.Logger.logp(level, "OAuth2Service",
                              "_getAuthorizationCode",
                              "WizardController Loading... Done")
     if controller.Handler.Wizard.execute():
         if controller.AuthorizationCode.IsPresent:
             controller.Configuration.commit()
             code = controller.AuthorizationCode.Value
             self.UserName = controller.UserName
             self.ResourceUrl = controller.ResourceUrl
     controller.Server.cancel()
     self.Setting.Logger.logp(level, "OAuth2Service",
                              "_getAuthorizationCode",
                              "WizardController closed")
     return code, controller.CodeVerifier
コード例 #4
0
ファイル: oauth2dispatch.py プロジェクト: prrvchr/OAuth2OOo
 def _showWizard(self, arguments):
     try:
         state = FAILURE
         result = ()
         close = True
         msg = ''
         for argument in arguments:
             if argument.Name == 'Url':
                 url = argument.Value
             elif argument.Name == 'UserName':
                 name = argument.Value
             elif argument.Name == 'Close':
                 close = argument.Value
         print("OAuth2Dispatch._showWizard() 1")
         wizard = Wizard(self._ctx, g_wizard_page, True, self._parent)
         print("OAuth2Dispatch._showWizard() 2")
         controller = WizardController(self._ctx, wizard, None, url, name, close)
         print("OAuth2Dispatch._showWizard() 3")
         arguments = (g_wizard_paths, controller)
         print("OAuth2Dispatch._showWizard() 4")
         wizard.initialize(arguments)
         print("OAuth2Dispatch._showWizard() 5")
         if wizard.execute() == OK:
             msg +=  " Retrieving Authorization Code ..."
             if controller.Error:
                 msg += " ERROR: cant retrieve Authorization Code: %s" % controller.Error
             else:
                 msg += " Done"
                 state = SUCCESS
                 result = (controller.ResourceUrl, controller.UserName)
         else:
             msg +=  " ERROR: Wizard as been aborted"
             controller.Server.cancel()
         wizard.DialogWindow.dispose()
         print("OAuth2Dispatch._showWizard() 6 %s" % msg)
         return state, result
     except Exception as e:
         msg = "Error: %s - %s" % (e, traceback.print_exc())
         print(msg)