示例#1
0
class IJoinSchema(Interface):

    """Schema for join form.
    """

    member_id = ASCIILine(
        title=_(u"Member ID"))

    email = EmailLine(
        title=_(u"Email Address"))

    password = Password(
        title=_(u"Password"),
        min_length=5)

    confirmation = Password(
        title=_(u"Password (confirm)"),
        min_length=5)

    send_password = Bool(
        title=_(u"Mail Password?"),
        description=_(u"Check this box to have the password mailed."))

    @invariant
    def check_passwords_match(schema):
        """Password and confirmation must match"""
        if schema.password != schema.confirmation:
            raise Invalid(_(u"Your password and confirmation did not match. "
                            u"Please try again."))
示例#2
0
class IEditPassword(Interface):
    """ schema for user password dialog """
    password_old = Password(
        title = _(u"Old password"),
        required=True
        )
    password1 = Password(
        title = _(u"Password"),
        min_length = 4,
        max_length = 20,
        required=True
        )
    password2 = Password(
        title = _(u"Password (again)"),
        min_length = 4,
        max_length = 20,
        required=True
        )
    @invariant
    def ensureP1eqP2(data_set):
        """Password 1 and password 2 must be equal
        """
        if hasattr(data_set, "password1") and \
           hasattr(data_set, "password2") and \
           data_set.password1 != data_set.password2:
            raise Invalid("new passwords not equal")
示例#3
0
class IExtranetMember(Interface):

    mnr = TextLine(
        title=_(u"Mitgliedsnummer"),
        description=_(
            u"Benutzername für den Mitbenutzer (Mitgliedsnummer-lfd.Nr.)"),
        required=True)

    rollen = Set(title=_(u"Berechtigung"),
                 description=_(u"Berechtigung"),
                 value_type=Choice(source=vocab_berechtigungen),
                 required=False)

    passwort = Password(
        title=_(u"Passwort"),
        description=_(u"Bitte tragen Sie hier das Passwort ein."),
        min_length=5,
        max_length=8,
        required=True)

    confirm = Password(
        title=_(u"Bestätigung"),
        description=_(u"Bitte bestätigen Sie das eingegebene Passwort."),
        min_length=5,
        max_length=8,
        required=True)

    @invariant
    def arePasswordsEqual(user):
        if user.passwort != user.confirm:
            raise Invalid(
                u"Das Passwort und die Wiederholung sind nicht gleich.")

    def getBaseUser():
        """Return the User Representation
示例#4
0
class IPasswordEditForm(Interface):
    """Schema for a person's edit form."""

    current = Password(title=_('Current password'), required=True)

    password = Password(title=_("New password"), required=True)

    verify_password = Password(title=_("Verify new password"), required=True)
示例#5
0
class IPasswordSchema(Interface):

    password = Password(title=_(u"New password"), min_length=5)

    confirmation = Password(title=_(u"Confirm new password"), required=False)

    @invariant
    def check_passwords_match(schema):
        """Password and confirmation must match"""
        if schema.password != schema.confirmation:
            raise Invalid(
                _(u"Your password and confirmation did not match. "
                  u"Please try again."))
示例#6
0
class ILogin(Interface):

    username = TextLine(
        title='Username', required=True)

    password = Password(
        title='Password', required=True)
示例#7
0
class IInternalPrincipal(interface.Interface):
    """Principal information"""

    login = TextLine(title=_("Login"),
                     description=_("The Login/Username of the principal. "
                                   "This value can change."))

    def setPassword(password, passwordManagerName=None):
        pass

    password = Password(title=_("Password"),
                        description=_("The password for the principal."))

    passwordManagerName = Choice(
        title=_("Password Manager"),
        vocabulary="Password Manager Names",
        description=_("The password manager will be used"
                      " for encode/check the password"),
        default="Plain Text",
        # TODO: The password manager name may be changed only
        # if the password changed
        readonly=True)

    title = TextLine(title=_("Title"),
                     description=_("Provides a title for the principal."))

    description = Text(
        title=_("Description"),
        description=_("Provides a description for the principal."),
        required=False,
        missing_value='',
        default=u'')
示例#8
0
class IReadEmailContainer(IReadContainer, ILocation):
    """Read interface for the IEmailContainer"""

    enabled = Bool(title=_('Enable'),
                   description=_('Mark to enable the service.'),
                   default=False)

    hostname = TextLine(
        title=_('Hostname'),
        description=_(
            'SMTP server hostname. Required if the service is enabled.'),
        required=False)

    port = Int(title=_('Port'),
               description=_('Port of the SMTP service. Using 25 by default.'),
               min=0,
               default=25,
               required=False)

    username = TextLine(
        title=_('Username'),
        description=_('Username used for optional SMTP authentication.'),
        required=False)

    password = Password(
        title=_('New Password'),
        description=_('The password to authenticate to the SMTP server.'),
        required=False)

    tls = Bool(title=_('TLS'),
               description=_('Use TLS connection?'),
               default=False,
               required=False)
示例#9
0
class IMailSchema(Interface):
    """Combined schema for the adapter lookup.
    """

    smtp_host = TextLine(title=_(u'label_smtp_server', default=u'SMTP server'),
                         description=_(
                             u"help_smtp_server",
                             default=u"The address of your local "
                             "SMTP (outgoing e-mail) server. Usually "
                             "'localhost', unless you use an "
                             "external server to send e-mail."),
                         default=u'localhost',
                         required=True)

    smtp_port = Int(title=_(u'label_smtp_port', default=u'SMTP port'),
                    description=_(
                        u"help_smtp_port",
                        default=u"The port of your local SMTP "
                        "(outgoing e-mail) server. Usually '587' or '25'."),
                    default=25,
                    required=True)

    smtp_userid = TextLine(title=_(u'label_smtp_userid',
                                   default=u'ESMTP username'),
                           description=_(
                               u"help_smtp_userid",
                               default=u"Username for authentication "
                               "to your e-mail server. Not required "
                               "unless you are using ESMTP."),
                           default=None,
                           required=False)

    smtp_pass = Password(title=_(u'label_smtp_pass',
                                 default=u'ESMTP password'),
                         description=_(u"help_smtp_pass",
                                       default=u"The password for the ESMTP "
                                       "user account."),
                         default=None,
                         required=False)

    email_from_name = TextLine(title=_(u"Site 'From' name"),
                               description=_(u"Plone generates e-mail using "
                                             "this name as the e-mail "
                                             "sender."),
                               default=None,
                               required=True)

    email_from_address = ASCII(title=_(u"Site 'From' address"),
                               description=_(u"Plone generates e-mail using "
                                             "this address as the e-mail "
                                             "return address. It is also "
                                             "used as the destination "
                                             "address for the site-wide "
                                             "contact form and the 'Send test "
                                             "e-mail' feature."),
                               default=None,
                               required=True)
class IRealm(Interface):

    active = Bool(title=_(u'label_realm_active', default=u'Active'))

    url = URI(title=_(u'label_realm_url', u'URL to the Plone-Site'))

    username = TextLine(title=_(u'label_realm_username', u'Username'))

    password = Password(title=_(u'label_realm_password', u'Password'))
示例#11
0
class IPathkeyForm(Interface):
    """
    A pathkey schema
    """

    path_key = Password(
        title=_(u'Pathkey'),
        description=_(
            u'If you want to protect contents of this folder, set a pathkey.'),
        required=False)
示例#12
0
class IParentAccessForm(Interface):

    username = TextLine(
        title=_("Username"),
        description=_(u"Cannot begin with '+' or '@,' contain non-ascii characters or '/.'"),
        required=True)

    password = Password(
        title=_("Password"),
        description=_(u"Users cannot log in until a password is assigned."),
        required=False)

    confirm = Password(
        title=_("Confirm password"),
        required=False)

    @invariant
    def isPasswordConfirmed(person):
        if person.password != person.confirm:
            raise Invalid(_(u"Passwords do not match"))
示例#13
0
class IEmailSettingsEditForm(Interface):

    server_status = TextLine(title=_('Server Status'), required=False)

    enabled = Bool(title=_('Enable'), default=False, required=False)

    hostname = TextLine(
        title=_('Hostname'),
        description=_(
            'SMTP server hostname. Required if the service is enabled.'),
        required=False)

    port = Int(title=_('Port'),
               description=_('Port of the SMTP service. Using 25 by default.'),
               min=0,
               default=25,
               required=False)

    username = TextLine(
        title=_('Username'),
        description=_('Username used for optional SMTP authentication.'),
        required=False)

    dummy_password = TextLine(
        title=_('Password'),
        description=_('Current password to authenticate to the SMTP server.'),
        required=False)

    password = Password(
        title=_('New Password'),
        description=_('The password to authenticate to the SMTP server.'),
        required=False)

    password_confirmation = Password(title=_('Confirm New Password'),
                                     required=False)

    tls = Bool(title=_('TLS'),
               description=_('Use TLS connection?'),
               default=False,
               required=False)
示例#14
0
class ILoginSchema(Interface):
    """Schema for login form.
    """

    came_from = URI(required=False)

    name = TextLine(title=_(u'Member ID'), description=_(u'Case sensitive'))

    password = Password(title=_(u'Password'), description=_(u'Case sensitive'))

    persistent = Bool(title=_(u'Remember my ID.'),
                      description=_(u'Saves your member ID in a cookie.'),
                      default=True)
示例#15
0
class ILoginForm(Interface):

    username = TextLine(
        title=_(u'Username'),
        required=True)

    password = Password(
        title=_(u"Password"),
        required=True)

    came_from = TextLine(
        title=_(u"Initial destination"),
        required=False)
示例#16
0
class IDirectoryInfo(Interface):
    """Synchronization task connection information"""

    host = DirectoryHandlerHostField(title=_("Host"),
                                     description=_("Protocol and host name"),
                                     required=True)

    port = Int(title=_("Port number"),
               description=_("Port number is required for remote protocols like SFTP or FTP"),
               default=22,
               required=False)

    auto_add_host_key = Bool(title=_("Automatically add host key?"),
                             description=_("If 'yes', an SSH connection will be accepted "
                                           "even if server key is unknown"),
                             required=False,
                             default=False)

    username = TextLine(title=_("User name"),
                        required=False)

    private_key = TextLine(title=_("Private key filename"),
                           description=_("Enter name of private key file; use '~' to identify "
                                         "running server user home directory, as in "
                                         "~/.ssh/id_rsa"),
                           required=False)

    password = Password(title=_("Password"),
                        description=_("If not using private key, you must provide user's "
                                      "password"),
                        required=False)

    directory = TextLine(title=_("Directory name"),
                         description=_("Enter absolute directory name"),
                         required=True)

    @invariant
    def check_remote_host(self):
        """Check for password or private key if remote host is defined"""
        if self.host and self.host[1] and (bool(self.private_key) == bool(self.password)):  # pylint: disable=unsubscriptable-object
            raise Invalid(_("You must provide a private key filename OR a password when "
                            "defining remote tasks"))

    def get_handler(self):
        """Get handler matching this directory"""
示例#17
0
class ISSHConnectionInfo(Interface):
    """SSH connection info interface"""

    hostname = TextLine(title=_("Hostname or IP address"),
                        description=_("Enter hostname or IP address of a remote host; "
                                      "keep empty for local server host"),
                        required=False)

    auto_add_host_key = Bool(title=_("Automatically add host key?"),
                             description=_("If 'yes', connection will be opened event if "
                                           "server key is unknown"),
                             required=False,
                             default=False)

    port = Int(title=_("Port number"),
               default=22,
               required=False)

    username = TextLine(title=_("User name"),
                        required=False)

    private_key = TextLine(title=_("Private key filename"),
                           description=_("Enter name of private key file; use '~' to identify "
                                         "running server user home directory, as in "
                                         "~/.ssh/id_rsa"),
                           required=False)

    password = Password(title=_("Password"),
                        description=_("If not using private key, you must provide user's "
                                      "password"),
                        required=False)

    @invariant
    def check_remote_host(self):
        """Check for password or private key if remote host is defined"""
        if self.hostname and (bool(self.private_key) == bool(self.password)):
            raise Invalid(_("You must provide a private key filename OR a password when "
                            "defining remote tasks"))

    def get_connection(self):
        """Get SSH connection"""

    def get_sftp_client(self):
        """Get SFTP client"""
示例#18
0
class IMember(Interface):
    login = TextLine(
        title=_("Login"),
        description=_("Unique Id")
    )
    password = Password(
        title=_("Password"),
        description=_("The password. It is in plain-text, whee!")
    )
    title = TextLine(
        title=_("Full Name"),
    )
    description = Text(
        title=_("Description"),
        description=_("Tell us a little bit about yourself."),
        required=False,
        missing_value='',
        default=u''
    )
示例#19
0
class IDocumentSynchronizer(Interface):
    """Documents synchronizer interface"""

    target = TextLine(
        title=_("Remote XML-RPC endpoint"),
        description=_("URL of the remote documents container XML-RPC endpoint "
                      "used for synchronization"),
        required=False)

    username = TextLine(
        title=_("User name"),
        description=_("Name of the remote user used for synchronization"),
        required=False)

    password = Password(
        title=_("Password"),
        description=_("Password of the remote user used for synchronization"),
        required=False)

    def synchronize(self, oid, mode=IMPORT_MODE, request=None):
        """Synchronize given OID to remote container"""
示例#20
0
class ISMTPMailer(IMailer):
    """A mailer that delivers mail to a relay host via SMTP."""

    hostname = TextLine(
        title=_(u"Hostname"),
        description=_(u"Name of server to be used as SMTP server."))

    port = Int(title=_(u"Port"),
               description=_(u"Port of SMTP service"),
               default=25)

    username = TextLine(
        title=_(u"Username"),
        description=_(u"Username used for optional SMTP authentication."))

    password = Password(
        title=_(u"Password"),
        description=_(u"Password used for optional SMTP authentication."))

    no_tls = Bool(title=_(u"No TLS"),
                  description=_(u"Never use TLS for sending email."))

    force_tls = Bool(title=_(u"Force TLS"),
                     description=_(u"Use TLS always for sending email."))
示例#21
0
class ILDAPBinding(Interface):
    ldap_type = Choice(
        title=_(u"label_ldap_type", default=u"LDAP server type"),
        description=_(
            u"help_ldap_server_type",
            default=u"Plone supports both Active Directory and standard "
            u"LDAP servers. For Active Directory the read-only "
            u"LDAP interface which is enabled for all Active "
            u"Directory servers can be used."),
        vocabulary="plone.app.ldap.engine.LDAPServerTypes",
        default=u"LDAP",
        required=True)

    rdn_attribute = Choice(
        title=_(u"label_ldap_dn_attribute", default=u"rDN attribute"),
        description=_(u"help_ldap_dn_attribute",
                      default=u"This is attribute is used to build the "
                      u"distinguished name (DN) for users that are being "
                      u"created in your LDAP directory. This is commonly "
                      u"either the users full name ('cn' property) or the "
                      u"userid ('uid' property)."),
        default="uid",
        vocabulary="plone.app.ldap.engine.LDAPSingleValueAttributes",
        required=True)

    userid_attribute = Choice(
        title=_(u"label_ldap_userid_attribute", default=u"User id attribute"),
        description=_(
            u"help_ldap_userid_attribute",
            default=u"This attribute is used as the userid inside Plone "
            u"for LDAP users. It has to be unique for all users."),
        default="uid",
        vocabulary="plone.app.ldap.engine.LDAPSingleValueAttributes",
        required=True)

    login_attribute = Choice(
        title=_(u"label_ldap_login_attribute",
                default=u"Login name attribute"),
        description=_(
            u"help_ldap_login_attribute",
            default=u"The attribute is used as the login name for LDAP "
            u"users logging into your site. In most cases this "
            u"should be the same as the user id attribute."),
        default="uid",
        vocabulary="plone.app.ldap.engine.LDAPSingleValueAttributes",
        required=True)

    user_object_classes = ASCIILine(
        title=_(u"label_ldap_user_object_classes",
                default=u"LDAP object classes"),
        description=_(
            u"help_ldap_user_object_classes",
            default=u"Each object in the LDAP database has a structural "
            u"object class and optionally several supplemental "
            u"object classes. These classes define the required "
            u"and optional properties that can be present on an "
            u"object. Classes can be entered in a comma seperated "
            u"list."),
        default="pilotPerson",
        required=True)

    bind_dn = ASCIILine(
        title=_(u"label_ldap_bind_dn", default=u"Bind DN"),
        description=_(
            u"help_ldap_bind_dn",
            default=u"The DN of a manager account in the LDAP directory. "
            u"This must be allowed to access all user and group "
            u"information as well as be able to update and create "
            u"users and groups. Please note that Plone only "
            u"supports simple binds. SASL is not supported."),
        required=False)

    bind_password = Password(
        title=_(u"label_ldap_bind_password", default=u"Bind password"),
        description=_(
            u"help_ldap_bind_password",
            default=u"Password to use when binding to the LDAP server."),
        required=False)

    user_base = ASCIILine(
        title=_(u"label_ldap_user_base", default=u"Base DN for users"),
        description=_(
            u"help_ldap_user_base",
            default=u"This is the location in your LDAP directory where "
            u"all users are stored."),
        required=True)

    user_scope = Choice(
        title=_(u"label_ldap_user_scope", default=u"Search scope for users"),
        description=_(
            u"help_ldap_user_scope",
            default=u"The search scope determines where the LDAP server "
            u"will search for users. With \"one level\" it will "
            u"only look for users directly in the user base "
            u"location; \"subtree\" will allow the server to also "
            u"look in subfolders of the user base location."),
        default=SCOPE_SUBTREE,
        vocabulary="plone.app.ldap.engine.LDAPScopes",
        required=True)

    group_base = ASCIILine(
        title=_(u"label_ldap_group_base", default=u"Base DN for groups"),
        description=_(
            u"help_ldap_group_base",
            default=u"This is the location in your LDAP directory where "
            u"all groups are stored. There are several options for "
            u"object class and members possible: the groupOfNames, "
            u"accessGroup or group object classes can be used with "
            u"members given in the member property, or the "
            u"groupOfUniqueNames object class can be used with "
            u"uniqueMember property. In Active Directory systems "
            u"only the group object class is supported."),
        required=True)

    group_scope = Choice(
        title=_(u"label_ldap_group_scope", default=u"Search scope for groups"),
        description=_(
            u"help_ldap_group_scope",
            default=u"The search scope determines where the LDAP server "
            u"will search for groups. With \"one level\" it will "
            u"only look for groups directly in the group base "
            u"location; \"subtree\" will allow the server to also "
            u"look in subfolders of the group base location."),
        default=SCOPE_SUBTREE,
        vocabulary="plone.app.ldap.engine.LDAPScopes",
        required=True)

    password_encryption = Choice(
        title=_(u"label_ldap_user_password_encryption",
                default=u"User password encryption"),
        description=_(
            u"help_ldap_user_password_encryption",
            default=u"Method of encryption used for user passwords."),
        default="crypt",
        vocabulary="plone.app.ldap.engine.LDAPPasswordEncryption",
    )

    default_user_roles = ASCIILine(
        title=_(u"label_ldap_default_user_roles",
                default=u"Default user roles"),
        description=_(u"help_ldap_default_user_roles",
                      default=u"Default roles for new users."),
        default="Member",
        required=True,
    )

    read_only = Bool(
        title=_(u"label_ldap_read_only", default=u"Read Only"),
        description=_(
            u"help_ldap_read_only",
            default=u"Control whether Plone should attempt to modify "
            u"objects and properties on the server."),
        default=False,
    )
示例#22
0
class IAdmUtilEsxVim(ISupernode):
    """
    major component for registration and event distribution 
    """
    esxVimServerActive = Bool(title=_("ESX VIM active"),
                              description=_("Esx connector active"),
                              default=False,
                              required=False)

    esxVimServerIp = HostIpValid(
        min_length=1,
        max_length=30,
        title=_("ESX VIM IP"),
        description=_("Active IP address of esx vim-server"),
        default=u"0.0.0.0",
        required=False)

    esxVimServerPort = Int(min=1,
                           max=65535,
                           title=_("ESX VIM Port"),
                           description=_("Port of esx vim-server"),
                           default=443,
                           required=False)

    esxVimUsername = TextLine(
        title=_("ESX VIM Username"),
        description=_("Name of user with admin rights on esx vim-server"),
        default=u"username",
        required=False)

    esxVimPassword = Password(
        title=_("ESX VIM Password"),
        description=_("Password of user with admin rights on esx vim-server"),
        default=u"password",
        required=False)

    connStatus = Attribute("Connection State")
    apiFullName = Attribute("Fullname of ESX VIM Api")

    def keys(self):
        '''See interface `IReadContainer`'''

    def __iter__(self):
        '''See interface `IReadContainer`'''

    def __getitem__(self, key):
        '''See interface `IReadContainer`'''

    def get(self, key, default=None):
        '''See interface `IReadContainer`'''

    def values(self):
        '''See interface `IReadContainer`'''

    def __len__(self):
        '''See interface `IReadContainer`'''

    def items(self):
        '''See interface `IReadContainer`'''

    def __contains__(self, key):
        '''See interface `IReadContainer`'''

    def connect2VimServer(self):
        ''' '''
示例#23
0
文件: zeo.py 项目: Py-AMS/pyams-utils
class IZEOConnection(Interface):
    """ZEO connection settings interface"""

    name = TextLine(title=_("Connection name"),
                    description=_("Registration name of ZEO connection"),
                    required=True)

    server_name = TextLine(title=_("ZEO server name"),
                           description=_("Hostname of ZEO server"),
                           required=True,
                           default='localhost')

    server_port = Int(title=_("ZEO server port"),
                      description=_("Port number of ZEO server"),
                      required=True,
                      default=8100)

    storage = TextLine(title=_("ZEO server storage"),
                       description=_("Storage name on ZEO server"),
                       required=True,
                       default='1')

    username = TextLine(
        title=_("ZEO user name"),
        description=_(
            "User name on ZEO server; only for ZEO server before 5.0"),
        required=False)

    password = Password(title=_("ZEO password"),
                        description=_(
                            "User password on ZEO server; only for ZEO server "
                            "before 5.0"),
                        required=False)

    server_realm = TextLine(
        title=_("ZEO server realm"),
        description=_(
            "Realm name on ZEO server; only for ZEO server before 5.0"),
        required=False)

    blob_dir = TextLine(title=_("BLOBs directory"),
                        description=_("Directory path for blob data"),
                        required=False)

    shared_blob_dir = Bool(
        title=_("Shared BLOBs directory ?"),
        description=_(
            "Flag whether the blob_dir is a server-shared filesystem "
            "that should be used instead of transferring blob data over zrpc."
        ),
        required=True,
        default=False)

    connection = Attribute("Current ZEO connection")

    def get_settings(self):
        """Get ZEO connection setting as a JSON dict"""

    def update(self, settings):
        """Update internal fields with given settings dict"""

    def get_connection(self, wait_timeout=30, get_storage=False):
        """Open ZEO connection with given settings"""
示例#24
0
def formfactory(configname):
    if configname in groupforms:
        return groupforms[configname]
    groups = []
    config = _load_config(configname)
    sections = config['transmogrifier']['pipeline'].splitlines()
    print sections
    for section_id in sections:
        if not section_id:
            continue
        if section_id == 'transmogrifier':
            continue
        cparser = config[section_id]
        g = type(section_id, (group.Group, ),
                 dict(label=section_id.capitalize()))
        fields = []
        for key, value in cparser.items():
            if key in ['@doc', 'blueprint']:
                continue
            if key.startswith('@'):
                key = key[1:]
                metavar, _, help = value.partition(':')
                default = unicode(cparser.get(key, ''))
                help = value
            else:
                if '@' + key in cparser:
                    # let the @option line be used instead
                    continue
                else:
                    metavar = 'LINE'
                    default = unicode(value)
                    help = ''
            title = key.capitalize().replace('-', ' ').replace('_', ' ')
            # name = "%s:%s"%(section_id,key[1:])
            if metavar == 'HIDDEN':
                continue
            elif metavar == 'PASSWORD':
                ftype = Password()
            elif metavar == 'INT':
                ftype = Int()
                if default:
                    default = int(default)
                else:
                    default = 0
            # elif metavar == 'URL':
            #    ftype = URI()
            elif metavar == 'LIST' or '\n' in default:
                ftype = List(value_type=TextLine(), )
                # ftype = Text()
                # if type(default) == type(""):
                default = default.splitlines()
                ftype.widgetFactory = multi.multiFieldWidgetFactory
            elif metavar.upper() != metavar:
                ftype = Bool()
                default = len(default)
            else:
                ftype = TextLine()
            ftype.__name__ = "%s-%s" % (section_id, key.replace('-', '_'))
            ftype.title = unicode(title)
            ftype.description = unicode(help)
            ftype.required = False
            ftype.default = default
            print(key, value, ftype, default)
            fields.append(ftype)
        if fields:
            g.fields = field.Fields(*fields)
            groups.append(g)
    groupforms[configname] = groups
    return groups
示例#25
0
class INotifierJabber(INotifier):
    """
    component for notifying with jabber
    """
    ipv4Connector = HostIpValid(
        min_length=1,
        max_length=30,
        title=_("Connector IP"),
        description=_("IP address of the jabber connector."),
        default=u"127.0.0.1",
        readonly=False,
        required=False)

    portConnector = Int(min=0,
                        max=65535,
                        title=_("Connector Port"),
                        description=_("Port of the jabber connector"),
                        default=8551,
                        required=False)

    hostnameServer = TextLine(max_length=80,
                              title=_("Jabber servername"),
                              description=_("Servername or IP of im server"),
                              default=u"jabber.org",
                              required=False)

    portServer = Int(min=0,
                     max=65535,
                     title=_("Jabber serverport"),
                     description=_("Port of the im server"),
                     default=5222,
                     required=False)

    authname = TextLine(max_length=80,
                        title=_("Username"),
                        description=_("Username for im-login"),
                        default=u"",
                        required=False)

    authpasswd = Password(max_length=80,
                          title=_("Password"),
                          description=_("Password for im-login"),
                          default=u"",
                          required=False)

    lastSeenConnector = Datetime(
        title=_("last seen Connector"),
        description=_("Time since last contact with the jabber connector"),
        required=False)

    connectorType = Attribute("Connector Type")
    connectorVersion = Attribute("Connector Version")
    enableConnector = Attribute("Connector enabled")

    def getObjectId(self):
        """
        get 'Universe ID' of object
        returns str
        """

    def sendNotify(self, notifyEvent=None, notifyObj=None):
        """ sending the real notification to the user
        """

    def start_connector(self):
        """ connects to the configured jabber-system
        """

    def stop_connector(self):
        """ disconnects to the configured jabber-system
        """

    def get_isUp(self):
        """ ask for an existing jabber-connector
        """

    def connect_server(self):
        """ connect the xmlrpc-agent with the jabber-server
        """

    def send_test(self):
        """ send a test message to an existing jabber-server
示例#26
0
class IPathkeyCheck(Interface):
    """Pathkey requester interface"""

    pathkey = Password(title=_(u"Pathkey"), required=True)
示例#27
0
class IHost(IComponent):
    """A host object."""

    contains('org.ict_ok.components.interface.interfaces.IInterface')

    hostname = TextLine(max_length=80,
                        title=_("Hostname"),
                        description=_("Name of the system."),
                        default=_("systemname"),
                        required=True)

    manufacturer = TextLine(max_length=500,
                            title=_("Manufacturer"),
                            description=_("Name/Address of the manufacturer."),
                            default=u"",
                            required=False)

    vendor = TextLine(max_length=500,
                      title=_("Vendor"),
                      description=_("Name/Address of the vendor."),
                      default=u"",
                      required=False)

    hostGroups = Set(title=_("host groups"),
                     value_type=Choice(title=_("host"),
                                       vocabulary="AllHostGroups"),
                     default=set([]),
                     readonly=False,
                     required=True)

    productionState = Choice(title=_("Production state"),
                             vocabulary="AllHostProductionStates",
                             default='production',
                             readonly=False,
                             required=True)

    workinggroup = TextLine(max_length=500,
                            title=_("Workinggroup"),
                            description=_("Name of the workinggroup."),
                            default=u"",
                            required=False)

    hardware = TextLine(max_length=500,
                        title=_("Hardware"),
                        description=_("Hardware of the system."),
                        default=u"",
                        required=False)

    user = TextLine(max_length=500,
                    title=_("User"),
                    description=_("User which is working with the system."),
                    default=u"",
                    required=False)

    inv_id = TextLine(max_length=500,
                      title=_("inventory id"),
                      description=_("Id of inventory."),
                      default=u"",
                      required=False)

    room = Choice(title=_("Room"),
                  description=_("The Room Description."),
                  vocabulary="AllRoomsVocab",
                  required=False)

    osList = List(title=_("operating systems"),
                  description=_("list of possible operating systems"),
                  value_type=TextLine(max_length=200,
                                      title=_("Operatingsystem"),
                                      description=_("The OS Description."),
                                      default=u"",
                                      required=False),
                  default=[],
                  required=False)

    snmpVersion = Choice(
        title=_("SNMP version"),
        vocabulary="SnmpVersions",
        default=u"0",  # SNMP V1
        required=False)

    snmpPort = Int(min=1,
                   max=65535,
                   title=_("SNMP port"),
                   default=161,
                   required=False)

    snmpReadCommunity = TextLine(max_length=80,
                                 title=_("SNMP read community"),
                                 default=u"public",
                                 required=False)

    snmpWriteCommunity = TextLine(max_length=80,
                                  title=_("SNMP write community"),
                                  default=u"private",
                                  required=False)

    url = TextLine(max_length=80,
                   title=_("URL"),
                   description=_("URL of system."),
                   default=u"",
                   required=False)

    url_type = Choice(
        title=_("URL browser type"),
        description=_("Type of browser window"),
        default="direct",
        values=['direct', 'proxy', 'direct extern', 'proxy extern'],
        required=True)

    url_authname = TextLine(max_length=80,
                            title=_("URL Username"),
                            description=_("Username for url-browser login"),
                            default=u"",
                            required=False)

    url_authpasswd = Password(max_length=80,
                              title=_("URL Password"),
                              description=_("Password for url-browser login"),
                              default=u"",
                              required=False)

    console = TextLine(max_length=80,
                       title=_("Console"),
                       description=_("Console of system."),
                       default=u"",
                       required=False)

    genNagios = Bool(title=_("for Nagios"),
                     description=_("enabled in Nagios"),
                     default=False,
                     required=False)

    def trigger_online():
        """
        trigger workflow
        """

    def trigger_offline():
        """
        trigger workflow
        """

    def trigger_not1():
        """
        trigger workflow
        """

    def getIpList():
        """ get a list of all possible ips
示例#28
0
class ISamlAuthoritySchema(IItemSchema):
    """Parameters configuring an Saml authority (aka entity)."""
    entity_id = IriRef(
        title=_(u'entity_id_title', u'Entity id'),
        description=_(
            u'entity_id_description',
            u"""The id identifying this entity/authority.""",
        ),
        required=True,
    )

    certificate = FilesystemPath(
        title=_(u'certificate_title', u'Certificate'),
        description=_(
            u'certificate_description',
            u"""`clienthome` relative or absolute path to the (DER) file containing the certificate corresponding to 'Private key'.""",
        ),
        required=False,
    )

    future_certificate = FilesystemPath(
        title=_(u'future_certificate_title', u'Future certificate'),
        description=_(
            u'future_certificate_description',
            u"""`clienthome` relative or absolute path to the (DER) file containing the certificate you plan to use in the near future.
      As other SAML2 authorities rely on your metadata published certificates
      to verify your signatures,
      you cannot simply change your privat/public key pair and publish
      a new certificate: until the other parties had updated their
      metadata for you, they would be unable to verify your signature
      signed with your new private key. This field allows you to publish
      in advance the certificate for a new private key you plan to
      use in the near future. If you ensure a sufficient delay,
      they can be prepared for the key change.
      """,
        ),
        required=False,
    )

    private_key = FilesystemPath(
        title=_(u'private_key_title', u'Private key'),
        description=_(
            u'private_key_description',
            u"""`clienthome` relative or absolute path to the (PEM) file containing the private key used for signing/encryption."""
        ),
        required=False,
    )

    private_key_password = Password(
        title=_(u'private_key_password_title', u'Private key password'),
        description=_(u'private_key_password_description',
                      u"""Password used to encrypt the private key"""),
        required=False)

    base_url = URI(
        title=_(u'base_url_title', u'Base url'),
        description=_(
            u'base_url_description',
            u"""A Zope system is often used via different urls (e.g. direct versus indirectly via a Web server).
      The urls of internal objects change accordingly. The authority generates
      and distributes metadata involving url. These must remain
      reliably and not change inadvertantly. Therefore, the base url is
      not derived automatically from the (varying) urls but specified by this attribute."""
        ),
        required=True,
    )

    metadata_validity = Timedelta(
        title=_(u'metadata_validity_title', u'Metadata validity'),
        description=_(u'metadata_validity_description',
                      u"""Validity period of generated metadata."""),
        required=True,
        default=timedelta(1),  # 1 day
    )
示例#29
0
class IRESTCallerTaskInfo(Interface):
    """REST API caller task info"""

    base_url = URI(
        title=_("Base target URI"),
        description=_(
            "Base URI, including protocol and hostname of remote service"),
        required=True)

    service = HTTPMethodField(
        title=_("REST service"),
        description=_("Method and relative URL of REST service"),
        required=True,
        default=('GET', '/'))

    params = Text(
        title=_("Service parameters"),
        description=_("Enter service parameters, in JSON object format"),
        required=False)

    verify_ssl = Bool(
        title=_("Verify SSL?"),
        description=_("If 'no', SSL certificates will not be verified"),
        required=False,
        default=True)

    connection_timeout = Int(
        title=_("Connection timeout"),
        description=_("Connection timeout, in seconds; keep empty to use "
                      "system's default, which is also none by default"),
        required=False,
        default=30)

    allow_redirects = Bool(
        title=_("Allow redirects?"),
        description=_("If disabled, redirections will now be handled"),
        required=False,
        default=True)

    ok_status = TextLine(
        title=_("OK status"),
        description=_("Comma-separated list of HTTP status which may be "
                      "considered as success"),
        required=True,
        default='200')

    authenticate = Bool(title=_("Required authentication?"),
                        description=_(""),
                        required=False,
                        default=False)

    username = TextLine(title=_("User name"),
                        description=_("Service login"),
                        required=False)

    password = Password(title=_("Password"),
                        description=_("Service password"),
                        required=False)

    use_proxy = Bool(title=_("Use proxy server?"),
                     description=_("Check if an HTTP proxy is required"),
                     required=False,
                     default=False)

    proxy_server = TextLine(title=_("Proxy server"),
                            description=_("Proxy server name"),
                            required=False)

    proxy_port = Int(title=_("Proxy port"),
                     description=_("Proxy server port"),
                     required=False,
                     default=8080)

    proxy_username = TextLine(title=_("Proxy user name"), required=False)

    proxy_password = Password(title=_("Proxy password"), required=False)

    use_jwt_authority = Bool(title=_("Use JWT authority?"),
                             description=_(
                                 "If 'yes', get JWT token from authentication "
                                 "authority"),
                             required=False,
                             default=False)

    jwt_authority_url = URI(title=_("JWT authority location"),
                            description=_(
                                "Base URL (protocol and hostname) or JWT "
                                "authentication authority"),
                            required=False)

    jwt_token_service = HTTPMethodField(
        title=_("Token getter service"),
        description=_("Method and relative URL of REST API used "
                      "to get access tokens"),
        required=False,
        default=('POST', '/api/auth/jwt/token'))

    jwt_token_attribute = TextLine(
        title=_("JWT token attribute"),
        description=_("Name of the attribute containing the access "
                      "token in JSON response"),
        required=False,
        default='accessToken')

    jwt_use_proxy = Bool(
        title=_("Use proxy settings for JWT API?"),
        description=_(
            "If 'yes', proxy settings defined above will also be used "
            "to get access to JWT authority"),
        required=False,
        default=False)
示例#30
0
def formfactory(configname):
    if configname in groupforms:
        return groupforms[configname]
    groups = []
    config = _load_config(configname)
    sections = config['transmogrifier']['pipeline'].splitlines()
    print sections
    for section_id in sections:
        if not section_id:
            continue
        if section_id == 'transmogrifier':
            continue
        cparser = config[section_id]
        g = type(section_id, (group.Group,),dict(label=section_id.capitalize()))
        fields = []
        doc = cparser.get('@doc','')
        for key,value in cparser.items():
            if key in ['@doc','blueprint']:
                continue 
            if key.startswith('@'):
                key = key[1:]
                metavar,_,help = value.partition(':')
                default = unicode(cparser.get(key,''))
                help = value
            else:
                if '@'+key in cparser:
                    # let the @option line be used instead
                    continue
                else:
                    metavar = 'LINE'
                    default = unicode(value)
                    help = ''
            title = key.capitalize().replace('-',' ').replace('_',' ')
#                name = "%s:%s"%(section_id,key[1:])
            if metavar == 'HIDDEN':
                continue
            elif metavar == 'PASSWORD':
                ftype = Password()
            elif metavar == 'INT':
                ftype = Int()
                if default:
                    default = int(default)
                else:
                    default = 0
            #elif metavar == 'URL':
            #    ftype = URI()
            elif metavar == 'LIST' or '\n' in default:
                ftype = List(
                    value_type=TextLine(),)
                #ftype = Text()
                #if type(default) == type(""):
                default = default.splitlines()
                ftype.widgetFactory = multi.multiFieldWidgetFactory
            elif metavar.upper() != metavar:
                ftype = Bool()
                default = len(default)
            else:
                ftype = TextLine()
            ftype.__name__ = "%s-%s"%(section_id,key.replace('-', '_'))
            ftype.title=unicode(title)
            ftype.description=unicode(help)
            ftype.required=False
            ftype.default = default
            print (key,value,ftype,default)
            fields.append(ftype)
        if fields:
            g.fields = field.Fields(*fields)
            groups.append(g)
    groupforms[configname]=groups
    return groups
示例#31
0
class IAdmUtilLinuxHa(Interface):
    """
    major component for registration and event distribution 
    """
    linuxHaServerActive = Bool(
        title = _("HA-Cluster active"),
        description = _("HA-Cluster connector active"),
        default = False,
        required = False)

    linuxHaServerIp = HostIpValid(
        min_length = 1,
        max_length = 30,
        title = _("HA-Cluster IP"),
        description = _("Active IP address of the ha cluster"),
        default = u"0.0.0.0",
        required = False)
    
    linuxHaServerPort = Int(
        min = 1,
        max = 65535,
        title = _("HA-Cluster Port"),
        description = _("Port of of the ha cluster"),
        default = 5560,
        required = False)
    
    linuxHaUsername = TextLine(
        title = _("HA-Cluster Username"),
        description = _("Name of user with admin rights on ha cluster"),
        default = u"username",
        required = False)

    linuxHaPassword = Password(
        title = _("HA-Cluster Password"),
        description = _("Password of user with admin rights on ha cluster"),
        default = u"password",
        required = False)

    connState = Attribute("Connection State")

    def keys(self):
        '''See interface `IReadContainer`'''

    def __iter__(self):
        '''See interface `IReadContainer`'''

    def __getitem__(self, key):
        '''See interface `IReadContainer`'''

    def get(self, key, default=None):
        '''See interface `IReadContainer`'''

    def values(self):
        '''See interface `IReadContainer`'''

    def __len__(self):
        '''See interface `IReadContainer`'''

    def items(self):
        '''See interface `IReadContainer`'''

    def __contains__(self, key):
        '''See interface `IReadContainer`'''

    def connect2HaCluster(self):
        ''' '''
    def getNodes(self):
        """ list of all cluster nodes objects