def __init__(self):
        super(OAuthDataStore, self).__init__()
        
        global token_class
        token_class_path = config.get("tools.oauth.sodatastore.model.token",
            "gearshift.tools.oauth.sodatastore.TG_Token")
        token_class = load_class(token_class_path)
        if token_class:
            log.info("Successfully loaded \"%s\"" % token_class_path)

        global nonce_class
        nonce_class_path = config.get("tools.oauth.sodatastore.model.nonce",
            "gearshift.tools.oauth.sodatastore.TG_Nonce")
        nonce_class = load_class(nonce_class_path)
        if nonce_class:
            log.info("Successfully loaded \"%s\"" % nonce_class_path)
Exemple #2
0
def create_default_provider():
    """Create default identity provider.

    Creates an identity provider according to what is found in
    the configuration file for the current TurboGears application

    Returns an identity provider instance or
    raises an IdentityConfigurationException.

    """
    provider_plugin = gearshift.config.get(
        'tools.identity.provider',
        'gearshift.identity.soprovider.SqlObjectIdentityProvider')

    log.debug("Loading provider from plugin: %s", provider_plugin)

    provider_class = None
    if not provider_class:
        provider_class = load_class(provider_plugin)

    if not provider_class:
        raise IdentityConfigurationException(
            "IdentityProvider plugin missing: %s" % provider_plugin)
    else:
        return provider_class()
    def __init__(self):
        realm = config.get("tools.oauth.realm", "http://www.example.com")
        datastore_class_path = config.get(
            "tools.oauth.datastore",
            "gearshift.tools.oauth.sodatastore.OAuthDataStore")
        datastore_class = load_class(datastore_class_path)
        if datastore_class:
            log.info("Successfully loaded \"%s\"" % datastore_class_path)
        else:
            log.error("Unable to load \"%s\"" % datastore_class_path)
            return

        self.datastore = datastore_class()

        self.request_token_url = config.get('oauth.request_token.url',
                                            '/request_token')
        self.access_token_url = config.get('oauth.access_token.url',
                                           '/access_token')
        self.realm = realm

        self.oauth_server = oauth.OAuthServer(self.datastore)
        self.oauth_server.add_signature_method(
            oauth.OAuthSignatureMethod_PLAINTEXT())
        self.oauth_server.add_signature_method(
            oauth.OAuthSignatureMethod_HMAC_SHA1())

        log.info("OAuthTool initialized")

        return super(OAuthTool, self).__init__(point='before_handler',
                                               callable=self.before_handler,
                                               priority=10)
    def __init__(self):
        realm = config.get("tools.oauth.realm", "http://www.example.com")
        datastore_class_path = config.get("tools.oauth.datastore",
                        "gearshift.tools.oauth.sodatastore.OAuthDataStore")
        datastore_class = load_class(datastore_class_path)
        if datastore_class:
            log.info("Successfully loaded \"%s\"" % datastore_class_path)
        else:
            log.error("Unable to load \"%s\"" % datastore_class_path)
            return

        self.datastore = datastore_class()

        self.request_token_url = config.get('oauth.request_token.url', 
                                            '/request_token')
        self.access_token_url = config.get('oauth.access_token.url', 
                                           '/access_token')
        self.realm = realm

        self.oauth_server = oauth.OAuthServer(self.datastore)
        self.oauth_server.add_signature_method(
                                    oauth.OAuthSignatureMethod_PLAINTEXT())
        self.oauth_server.add_signature_method(
                                    oauth.OAuthSignatureMethod_HMAC_SHA1())

        log.info("OAuthTool initialized")

        return super(OAuthTool, self).__init__(point='before_handler', 
                                               callable=self.before_handler, 
                                               priority=10)
    def __init__(self):
        super(AppEngineIdentityProvider, self).__init__()
        get = gearshift.config.get

        global user_class, group_class, permission_class, visit_class, \
               foreign_user_class

        user_class_path = get("tools.identity.aeprovider.model.user",
                              __name__ + ".TG_User")
        user_class = load_class(user_class_path)
        if not user_class:
            log.error("Error loading \"%s\"" % user_class_path)
        try:
            self.user_class_db_encoding = \
                user_class.sqlmeta.columns['user_name'].dbEncoding
        except (KeyError, AttributeError):
            self.user_class_db_encoding = 'UTF-8'
        group_class_path = get("tools.identity.aeprovider.model.group",
                               __name__ + ".TG_Group")
        group_class = load_class(group_class_path)
        if not group_class:
            log.error("Error loading \"%s\"" % group_class_path)

        permission_class_path = get(
            "tools.identity.aeprovider.model.permission",
            __name__ + ".TG_Permission")
        permission_class = load_class(permission_class_path)
        if not permission_class:
            log.error("Error loading \"%s\"" % permission_class_path)

        visit_class_path = get("tools.identity.aeprovider.model.visit",
                               __name__ + ".TG_VisitIdentity")
        visit_class = load_class(visit_class_path)
        if not visit_class:
            log.info("Error loadeing \"%s\"" % visit_class_path)

        foreign_user_class_path = get(
            "tools.identity.aeprovider.model.foreign_user",
            __name__ + ".TG_ForeignUser")
        foreign_user_class = load_class(foreign_user_class_path)
        if not foreign_user_class:
            log.error("Error loading \"%s\"" % foreign_user_class_path)

        # Default encryption algorithm is to use plain text passwords
        algorithm = get("tools.identity.aeprovider.encryption_algorithm", None)
        self.encrypt_password = lambda pw: \
            identity.encrypt_pw_with_algorithm(algorithm, pw)
    def __init__(self):
        super(AppEngineIdentityProvider, self).__init__()
        get = gearshift.config.get

        global user_class, group_class, permission_class, visit_class, \
               foreign_user_class

        user_class_path = get("tools.identity.aeprovider.model.user",
            __name__ + ".TG_User")
        user_class = load_class(user_class_path)
        if not user_class:
            log.error("Error loading \"%s\"" % user_class_path)
        try:
            self.user_class_db_encoding = \
                user_class.sqlmeta.columns['user_name'].dbEncoding
        except (KeyError, AttributeError):
            self.user_class_db_encoding = 'UTF-8'
        group_class_path = get("tools.identity.aeprovider.model.group",
            __name__ + ".TG_Group")
        group_class = load_class(group_class_path)
        if not group_class:
            log.error("Error loading \"%s\"" % group_class_path)

        permission_class_path = get("tools.identity.aeprovider.model.permission",
            __name__ + ".TG_Permission")
        permission_class = load_class(permission_class_path)
        if not permission_class:
            log.error("Error loading \"%s\"" % permission_class_path)

        visit_class_path = get("tools.identity.aeprovider.model.visit",
            __name__ + ".TG_VisitIdentity")
        visit_class = load_class(visit_class_path)
        if not visit_class:
            log.info("Error loadeing \"%s\"" % visit_class_path)

        foreign_user_class_path = get("tools.identity.aeprovider.model.foreign_user",
            __name__ + ".TG_ForeignUser")
        foreign_user_class = load_class(foreign_user_class_path)
        if not foreign_user_class:
            log.error("Error loading \"%s\"" % foreign_user_class_path)

        # Default encryption algorithm is to use plain text passwords
        algorithm = get("tools.identity.aeprovider.encryption_algorithm", None)
        self.encrypt_password = lambda pw: \
            identity.encrypt_pw_with_algorithm(algorithm, pw)
    def __init__(self, timeout):
        global visit_class
        visit_class_path = config.get("tools.visit.aeprovider.model",
                                      "gearshift.visit.aevisit.TG_Visit")
        visit_class = load_class(visit_class_path)
        if not visit_class:
            log.error("Error loading \"%s\"" % visit_class_path)

        self.create_model()
        self.timeout = timeout
Exemple #8
0
 def __init__(self, timeout):
     global visit_class
     visit_class_path = config.get("tools.visit.aeprovider.model",
         "gearshift.visit.aevisit.TG_Visit")
     visit_class = load_class(visit_class_path)
     if not visit_class:
         log.error("Error loading \"%s\"" % visit_class_path)
     
     self.create_model()
     self.timeout = timeout
Exemple #9
0
 def __init__(self, timeout):
     global visit_class
     visit_class_path = config.get("tools.visit.stprovider.model",
         "gearshift.visit.stvisit.TG_Visit")
     visit_class = load_class(visit_class_path)
     if visit_class:
         log.info("Successfully loaded \"%s\"" % visit_class_path)
     # base-class' __init__ triggers self.create_model, so mappers need to
     # be initialized before.
     super(StormVisitManager, self).__init__(timeout)
Exemple #10
0
def _create_visit_manager(timeout):
    """Create a VisitManager based on the plugin specified in the config file."""
    plugin_name = config.get("tools.visit.manager", 
                             "gearshift.visit.sovisit.SqlObjectVisitManager")

    try:
        plugin = load_class(plugin_name)
    except Exception, e:
        log.error("Error loading visit plugin '%s': %s", plugin_name, e)
        raise RuntimeError("VisitManager plugin missing: %s" % plugin_name)
Exemple #11
0
def _create_visit_manager(timeout):
    """Create a VisitManager based on the plugin specified in the config file."""
    plugin_name = config.get("tools.visit.manager",
                             "gearshift.visit.sovisit.SqlObjectVisitManager")

    try:
        plugin = load_class(plugin_name)
    except Exception, e:
        log.error("Error loading visit plugin '%s': %s", plugin_name, e)
        raise RuntimeError("VisitManager plugin missing: %s" % plugin_name)
Exemple #12
0
 def __init__(self, timeout):
     global visit_class
     visit_class_path = config.get("tools.visit.stprovider.model",
                                   "gearshift.visit.stvisit.TG_Visit")
     visit_class = load_class(visit_class_path)
     if visit_class:
         log.info("Successfully loaded \"%s\"" % visit_class_path)
     # base-class' __init__ triggers self.create_model, so mappers need to
     # be initialized before.
     super(StormVisitManager, self).__init__(timeout)
    def __init__(self):
        super(SqlAlchemyIdentityProvider, self).__init__()
        get = config.get

        global user_class, group_class, permission_class, visit_class

        user_class_path = get("tools.identity.saprovider.model.user", None)
        user_class = load_class(user_class_path)
        group_class_path = get("tools.identity.saprovider.model.group", None)
        group_class = load_class(group_class_path)
        permission_class_path = get(
            "tools.identity.saprovider.model.permission", None)
        permission_class = load_class(permission_class_path)
        visit_class_path = get("tools.identity.saprovider.model.visit", None)
        log.info("Loading: %s", visit_class_path)
        visit_class = load_class(visit_class_path)
        # Default encryption algorithm is to use plain text passwords
        algorithm = get("tools.identity.saprovider.encryption_algorithm", None)
        self.encrypt_password = lambda pw: \
            identity.encrypt_pw_with_algorithm(algorithm, pw)
Exemple #14
0
    def __init__(self):
        super(SqlAlchemyIdentityProvider, self).__init__()
        get = config.get

        global user_class, group_class, permission_class, visit_class

        user_class_path = get("tools.identity.saprovider.model.user", None)
        user_class = load_class(user_class_path)
        group_class_path = get("tools.identity.saprovider.model.group", None)
        group_class = load_class(group_class_path)
        permission_class_path = get(
            "tools.identity.saprovider.model.permission", None)
        permission_class = load_class(permission_class_path)
        visit_class_path = get("tools.identity.saprovider.model.visit", None)
        log.info("Loading: %s", visit_class_path)
        visit_class = load_class(visit_class_path)
        # Default encryption algorithm is to use plain text passwords
        algorithm = get("tools.identity.saprovider.encryption_algorithm", None)
        self.encrypt_password = lambda pw: \
            identity.encrypt_pw_with_algorithm(algorithm, pw)
    def __init__(self):
        super(SqlObjectIdentityProvider, self).__init__()
        get = gearshift.config.get

        global user_class, group_class, permission_class, visit_class

        user_class_path = get("tools.identity.soprovider.model.user",
                              __name__ + ".TG_User")
        user_class = load_class(user_class_path)
        if user_class:
            log.info("Successfully loaded \"%s\"" % user_class_path)
        try:
            self.user_class_db_encoding = \
                user_class.sqlmeta.columns['user_name'].dbEncoding
        except (KeyError, AttributeError):
            self.user_class_db_encoding = 'UTF-8'
        group_class_path = get("tools.identity.soprovider.model.group",
                               __name__ + ".TG_Group")
        group_class = load_class(group_class_path)
        if group_class:
            log.info("Successfully loaded \"%s\"" % group_class_path)

        permission_class_path = get(
            "tools.identity.soprovider.model.permission",
            __name__ + ".TG_Permission")
        permission_class = load_class(permission_class_path)
        if permission_class:
            log.info("Successfully loaded \"%s\"" % permission_class_path)

        visit_class_path = get("tools.identity.soprovider.model.visit",
                               __name__ + ".TG_VisitIdentity")
        visit_class = load_class(visit_class_path)
        if visit_class:
            log.info("Successfully loaded \"%s\"" % visit_class_path)

        # Default encryption algorithm is to use plain text passwords
        algorithm = get("tools.identity.soprovider.encryption_algorithm", None)
        self.encrypt_password = lambda pw: \
            identity.encrypt_pw_with_algorithm(algorithm, pw)
    def __init__(self):
        super(SqlObjectIdentityProvider, self).__init__()
        get = gearshift.config.get

        global user_class, group_class, permission_class, visit_class

        user_class_path = get("tools.identity.soprovider.model.user",
            __name__ + ".TG_User")
        user_class = load_class(user_class_path)
        if user_class:
            log.info("Successfully loaded \"%s\"" % user_class_path)
        try:
            self.user_class_db_encoding = \
                user_class.sqlmeta.columns['user_name'].dbEncoding
        except (KeyError, AttributeError):
            self.user_class_db_encoding = 'UTF-8'
        group_class_path = get("tools.identity.soprovider.model.group",
            __name__ + ".TG_Group")
        group_class = load_class(group_class_path)
        if group_class:
            log.info("Successfully loaded \"%s\"" % group_class_path)

        permission_class_path = get("tools.identity.soprovider.model.permission",
            __name__ + ".TG_Permission")
        permission_class = load_class(permission_class_path)
        if permission_class:
            log.info("Successfully loaded \"%s\"" % permission_class_path)

        visit_class_path = get("tools.identity.soprovider.model.visit",
            __name__ + ".TG_VisitIdentity")
        visit_class = load_class(visit_class_path)
        if visit_class:
            log.info("Successfully loaded \"%s\"" % visit_class_path)

        # Default encryption algorithm is to use plain text passwords
        algorithm = get("tools.identity.soprovider.encryption_algorithm", None)
        self.encrypt_password = lambda pw: \
            identity.encrypt_pw_with_algorithm(algorithm, pw)
Exemple #17
0
    def __init__(self, timeout):
        global visit_class
        visit_class_path = config.get("tools.visit.saprovider.model",
                                      "gearshift.visit.savisit.TG_Visit")
        visit_class = load_class(visit_class_path)
        if visit_class is None:
            msg = 'No visit class found for %s' % visit_class_path
            msg += ', did you run setup.py develop?'
            log.error(msg)

        bind_metadata()
        if visit_class is TG_Visit:
            mapper(visit_class, visits_table)
        # base-class' __init__ triggers self.create_model, so mappers need to
        # be initialized before.
        super(SqlAlchemyVisitManager, self).__init__(timeout)
Exemple #18
0
    def __init__(self, timeout):
        global visit_class
        visit_class_path = config.get("tools.visit.saprovider.model",
            "gearshift.visit.savisit.TG_Visit")
        visit_class = load_class(visit_class_path)
        if visit_class is None:
            msg = 'No visit class found for %s' % visit_class_path
            msg += ', did you run setup.py develop?'
            log.error(msg)

        bind_metadata()
        if visit_class is TG_Visit:
            mapper(visit_class, visits_table)
        # base-class' __init__ triggers self.create_model, so mappers need to
        # be initialized before.
        super(SqlAlchemyVisitManager, self).__init__(timeout)
Exemple #19
0
def create_default_provider():
    """Create default identity provider.

    Creates an identity provider according to what is found in
    the configuration file for the current TurboGears application

    Returns an identity provider instance or
    raises an IdentityConfigurationException.

    """
    provider_plugin = gearshift.config.get(
        "tools.identity.provider", "gearshift.identity.soprovider.SqlObjectIdentityProvider"
    )

    log.debug("Loading provider from plugin: %s", provider_plugin)

    provider_class = None
    if not provider_class:
        provider_class = load_class(provider_plugin)

    if not provider_class:
        raise IdentityConfigurationException("IdentityProvider plugin missing: %s" % provider_plugin)
    else:
        return provider_class()