# -*- coding:utf-8 -*-
from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 9
_modified_time = 1422216484.880529
_enable_loop = True
_template_filename = '/usr/lib/python2.7/dist-packages/privacyidea/lib/tokens/motptoken.mako'
_template_uri = '/motptoken.mako'
_source_encoding = 'utf-8'
from webhelpers.html import escape
_exports = []


def render_body(context,**pageargs):
    __M_caller = context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        c = context.get('c', UNDEFINED)
        _ = context.get('_', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 2
        __M_writer(u'\n\n')
        # SOURCE LINE 4
        if c.scope == 'config.title' :
            # SOURCE LINE 5
            __M_writer(u' ')
            __M_writer(escape(_("mOTP Token Settings")))
            __M_writer(u'\n')
        # SOURCE LINE 7
        __M_writer(u'\n\n')
        # SOURCE LINE 9
        if c.scope == 'config' :
            pass
        # SOURCE LINE 11
        __M_writer(u'\n\n')
        # SOURCE LINE 13
        if c.scope == 'enroll.title' :
            # SOURCE LINE 14
            __M_writer(escape(_("mOTP - mobile otp")))
            __M_writer(u'\n')
        # SOURCE LINE 16
        __M_writer(u'\n')
        # SOURCE LINE 17
        if c.scope == 'enroll' :
            # SOURCE LINE 18
            __M_writer(u'<script>\n\n/*\n * \'typ\'_get_enroll_params()\n *\n * this method is called, when the token  is submitted\n * - it will return a hash of parameters for admin/init call\n *\n */\n\nfunction motp_get_enroll_params(){\n    var url = {};\n    url[\'type\'] = \'motp\';\n   \turl[\'description\'] = $(\'#enroll_motp_desc\').val();\n\n    // If we have got to generate the hmac key, we do it here:\n    if  ( $(\'#motp_key_cb\').attr(\'checked\') ) {\n    \turl[\'genkey\'] = 1;\n\n    } else {\n        // OTP Key\n        url[\'otpkey\'] \t= $(\'#motp_initsecret\').val();\n    }   \t\n   \t\n\turl[\'otppin\']\t= $(\'#motp_pin1\').val();\n    jQuery.extend(url, add_user_data());\n\n    return url;\n}\n</script>\n\n<p><span id="motp_key_intro">\n\t')
            # SOURCE LINE 50
            __M_writer(escape(_("Please enter or copy the init-secret, that was generated by your app.")))
            __M_writer(u'\n</span>\n</p>\n<table><tr>\n<td><label for="motp_initsecret" id=\'motp_initsecret_label\'>')
            # SOURCE LINE 54
            __M_writer(escape(_("Init secret")))
            __M_writer(u'</label></td>\n<td><input type="text" name="motp_initsecret" id="motp_initsecret"\n\ttitle=\'')
            # SOURCE LINE 56
            __M_writer(escape(_("Please enter or copy the init-secret, that was generated by your app.")))
            __M_writer(u'\' \n\tvalue="" class="text ui-widget-content ui-corner-all" /></td>\n</tr><tr>\n\t<td> </td><td><input type=\'checkbox\' id=\'motp_key_cb\' onclick="cb_changed(\'motp_key_cb\',[\'motp_initsecret\',\'motp_initsecret_label\',\'motp_key_intro\']);">\n\t<label for=hmac_key_cb>')
            # SOURCE LINE 60
            __M_writer(escape(_("Generate MOTP key.")))
            __M_writer(u'</label></td>\n</tr>\n<tr><td colspan="2">')
            # SOURCE LINE 62
            __M_writer(escape(_("Also enter the PIN you are using on your phone.")))
            __M_writer(u'</td></tr>\n<tr>\n<td><label for="motp_pin1">mOTP PIN</label></td>\n<td><input onkeyup="checkpins(\'motp_pin1\',\'motp_pin2\');" autocomplete="off"\n     title=\'')
            # SOURCE LINE 66
            __M_writer(escape(_("Also enter the PIN you are using on your phone.")))
            __M_writer(u'\' \n     type="password" name="motp_pin1" id="motp_pin1" value="" class="text ui-widget-content ui-corner-all" /></td>\n</tr><tr>\n<td><label for="motp_pin2">')
            # SOURCE LINE 69
            __M_writer(escape(_("(again)")))
            __M_writer(u'</label></td>\n<td><input onkeyup="checkpins(\'motp_pin1\',\'motp_pin2\');" autocomplete="off" type="password" name="motp_pin2" id="motp_pin2" value="" class="text ui-widget-content ui-corner-all" /></td>\n</tr>\n<tr>\n    <td><label for="enroll_motp_desc" id=\'enroll_motp_desc_label\'>')
            # SOURCE LINE 73
            __M_writer(escape(_("Description")))
            __M_writer(u'</label></td>\n    <td><input type="text" name="enroll_motp_desc" id="enroll_motp_desc" value="webGUI_generated" class="text" /></td>\n</tr>\n</table>\n\n')
        # SOURCE LINE 79
        __M_writer(u'\n\n\n\n')
        # SOURCE LINE 83
        if c.scope == 'selfservice.title.enroll':
            # SOURCE LINE 84
            __M_writer(escape(_("Register mOTP")))
            __M_writer(u'\n')
        # SOURCE LINE 86
        __M_writer(u'\n')
        # SOURCE LINE 87
        if c.scope == 'selfservice.title.provision':
            # SOURCE LINE 88
            __M_writer(escape(_("Webprovisioning mOTP")))
            __M_writer(u'\n')
        # SOURCE LINE 90
        __M_writer(u'\n\n')
        # SOURCE LINE 92
        if c.scope == 'selfservice.enroll':
            # SOURCE LINE 93
            __M_writer(u'<script>\n\tjQuery.extend(jQuery.validator.messages, {\n\t\trequired:  "')
            # SOURCE LINE 95
            __M_writer(escape(_('required input field')))
            __M_writer(u'",\n\t\tminlength: "')
            # SOURCE LINE 96
            __M_writer(escape(_('minimum length must be greater than {0}')))
            __M_writer(u'",\n\t\tmaxlength: "')
            # SOURCE LINE 97
            __M_writer(escape(_('maximum length must be lower than {0}')))
            __M_writer(u'",\n\t\trange: \'')
            # SOURCE LINE 98
            __M_writer(escape(_("Please enter a valid init secret. It may only contain numbers and the letters A-F.")))
            __M_writer(u'\',\n\t});\n\n\tjQuery.validator.addMethod("motp_secret", function(value, element, param){\n\t\tif ( $(\'#motp_key_cb\').attr(\'checked\') ) {\n\t\t\treturn true\n\t\t} else {\n\t\t\tif (value.length < 16) {\n\t\t\t\treturn false\n\t\t\t}\n        \treturn value.match(/^[a-fA-F0-9]+$/i);\n\t\t}\n    }, \'')
            # SOURCE LINE 110
            __M_writer(escape(_("Please enter a valid init secret. It may only contain numbers and the letters A-F.")))
            __M_writer(u'\' );\n\n\t$(\'#form_registermotp\').validate({\n        rules: {\n            motp_secret: {\n                minlength: 16,\n                maxlength: 32,\n                number: false,\n                motp_secret: true\n            }\n        }\n\t});\n\nfunction self_motp_get_param()\n{\n\tvar urlparam = {};\n\n\turlparam[\'type\'] \t\t= \'motp\';\n\turlparam[\'description\'] = $("#motp_self_desc").val();  \n    urlparam[\'otpkey\'] \t= $(\'#motp_secret\').val();\n\turlparam[\'otppin\']\t\t= $(\'#motp_s_pin1\').val();\n\n\treturn urlparam;\n}\nfunction self_motp_clear()\n{\n\t$(\'#motp_s_pin1\').val(\'\');\n\t$(\'#motp_secret\').val(\'\');\n\t$(\'#motp_s_pin2\').val(\'\');\n}\nfunction self_motp_submit(){\n\n\tvar ret = false;\n\tif ($(\'#form_registermotp\').valid()) {\n\t\tvar params =  self_motp_get_param();\n\t\tenroll_token( params );\n\t\tself_motp_clear();\n\t\tret = true;\n\t} else {\n\t\talert(\'')
            # SOURCE LINE 149
            __M_writer(escape(_("Form data not valid.")))
            __M_writer(u"');\n\t}\n\treturn ret;\n\n}\n</script>\n\n<h1>")
            # SOURCE LINE 156
            __M_writer(escape(_("Register your mOTP Token")))
            __M_writer(u'</h1>\n<div id=\'registermotpform\'>\n\t<form class="cmxform" id=\'form_registermotp\'>\n\t<fieldset>\n\t\t<table>\n\t\t<tr>\n\t\t<td><label for=\'secret\' id=\'motp_secret_label\'>')
            # SOURCE LINE 162
            __M_writer(escape(_("Init Secret of motp-Token")))
            __M_writer(u'</label></td>\n\t\t<td><input id=\'motp_secret\' name=\'secret\' class="ui-widget-content ui-corner-all"\n\t\t\tpattern="[a-fA-F0-9]{0,16,32}"\n\t\t\tmaxlength="32" />\n\t\t</td>\n\t\t</tr>\n        <tr>\n        <td><label for=\'motp_s_pin1\'>')
            # SOURCE LINE 169
            __M_writer(escape(_("mOTP PIN")))
            __M_writer(u'</label></td>\n        <td><input autocomplete="off" type="password" onkeyup="checkpins(\'motp_s_pin1\', \'motp_s_pin2\');" id="motp_s_pin1" class="required text ui-widget-content ui-corner-all" /></td>\n        </tr>\n        <tr>\n        <td><label for=\'motp_s_pin2\'>')
            # SOURCE LINE 173
            __M_writer(escape(_("mOTP PIN (again)")))
            __M_writer(u'</label></td>\n        <td><input autocomplete="off" type="password" onkeyup="checkpins(\'motp_s_pin1\', \'motp_s_pin2\');" id="motp_s_pin2" class="required text ui-widget-content ui-corner-all" /></td>\n        </tr>\n\t\t<tr>\n\t    <td><label for="motp_self_desc" id=\'motp_self_desc_label\'>')
            # SOURCE LINE 177
            __M_writer(escape(_("Description")))
            __M_writer(u'</label></td>\n\t    <td><input type="text" name="motp_self_desc" id="motp_self_desc" value="self enrolled" class="text" /></td>\n\t\t</tr>\n        </table>\n        <button class=\'action-button\' id=\'button_register_motp\'\n        \t\tonclick="self_motp_submit();">')
            # SOURCE LINE 182
            __M_writer(escape(_("register mOTP Token")))
            __M_writer(u'</button>\n    </fieldset>\n    </form>\n</div>\n\n\n')
        # SOURCE LINE 189
        __M_writer(u'\n\n')
        # SOURCE LINE 191
        if c.scope == 'selfservice.provision':
            # SOURCE LINE 192
            __M_writer(u'<script>\n\nfunction self_motp_provision_get_param()\n{\n\tvar urlparam = {};\n\n\turlparam[\'type\'] \t\t= \'motp\';\n\turlparam[\'description\'] = $("#motpP_self_desc").val();  \n   \turlparam[\'genkey\'] = 1;\n\turlparam[\'otppin\']\t\t= $(\'#motpP_s_pin1\').val();\n\n\treturn urlparam;\n}\nfunction self_motp_provision_clear()\n{\n\t$(\'#motpP_s_pin1\').val(\'\');\n\t$(\'#motpP_s_pin2\').val(\'\');\n}\nfunction self_motp_provision_submit(){\n\n\tvar ret = false;\n\tif ($(\'#form_provisionmotp\').valid()) {\n\t\tvar params =  self_motp_provision_get_param();\n\t\tenroll_token( params );\n\t\tself_motp_provision_clear();\n\t\tret = true;\n\t} else {\n\t\talert(\'')
            # SOURCE LINE 219
            __M_writer(escape(_("Form data not valid.")))
            __M_writer(u"');\n\t}\n\treturn ret;\n\n}\n</script>\n\n<h1>")
            # SOURCE LINE 226
            __M_writer(escape(_("Webprovisioning your mOTP Token")))
            __M_writer(u'</h1>\n<div id=\'provisionmotpform\'>\n\t<form class="cmxform" id=\'form_provisionmotp\'>\n\t<fieldset>\n\t\t<table>\n\t\t<tr> <td colspan=2>\n\t\t')
            # SOURCE LINE 232
            __M_writer(escape(_("Your mOTP secret will be created by the server.")))
            __M_writer(u"\n\t\t</td>\n\t\t</tr>\n        <tr>\n        <td><label for='motpP_s_pin1'>")
            # SOURCE LINE 236
            __M_writer(escape(_("mOTP PIN")))
            __M_writer(u'</label></td>\n        <td><input autocomplete="off" type="password" \n        \tonkeyup="checkpins(\'motpP_s_pin1\', \'motpP_s_pin2\');" \n        \tid="motpP_s_pin1" \n        \tclass="required text ui-widget-content ui-corner-all" /></td>\n        </tr>\n        <tr>\n        <td><label for=\'motpP_s_pin2\'>')
            # SOURCE LINE 243
            __M_writer(escape(_("mOTP PIN (again)")))
            __M_writer(u'</label></td>\n        <td><input autocomplete="off" type="password"\n        \tonkeyup="checkpins(\'motpP_s_pin1\', \'motpP_s_pin2\');"\n        \tid="motpP_s_pin2"\n        \tclass="required text ui-widget-content ui-corner-all" /></td>\n        </tr>\n\t\t<tr>\n\t    <td><label for="motpP_self_desc"\n\t    \tid=\'motpP_self_desc_label\'>')
            # SOURCE LINE 251
            __M_writer(escape(_("Description")))
            __M_writer(u'</label></td>\n\t    <td><input type="text"\n\t    \tname="motpP_self_desc"\n\t    \tid="motpP_self_desc"\n\t    \tvalue="self enrolled" class="text" /></td>\n\t\t</tr>\n        </table>\n        <button class=\'action-button\'\n        \t\tid=\'button_provision_motp\'\n        \t\tonclick="self_motp_provision_submit();">')
            # SOURCE LINE 260
            __M_writer(escape(_("provision mOTP Token")))
            __M_writer(u'</button>\n    </fieldset>\n    </form>\n</div>\n\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


