Changeset 6

Show
Ignore:
Timestamp:
06/06/2007 12:07:54 PM (2 years ago)
Author:
nicolas
Message:

Implemented the "session" for the gatekeeper. Now the important "session-like" variables are stored in the DOM of the tab button.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/client-side/Firefox-extension/chrome/content/code/console.js

    r3 r6  
    1 var consoleDetails = ""; 
    21 
    32function cprint(msg,detail,type) 
     
    65        detail=true; 
    76    if (!detail) 
     7    { 
     8        if (type=="error") 
     9            prefix = "*error*" 
     10        else 
     11        if (type=="success") 
     12            prefix = "*success*" 
     13        else 
     14            prefix = "" 
     15        setValue("consoleText",getValue("consoleText")+"œ"+prefix+msg); 
     16        dump(msg,type) 
     17    } 
     18    else 
     19        cprintDet(msg,type); 
     20} 
     21 
     22function cprintDet(msg,type) 
     23{ 
     24    msg = msg.replace(/\n/gi,"<br />"); 
     25    prefix = "<span>"; 
     26    sufix = "</span><br />" 
     27    if (type=="error") 
     28        prefix = "<span class='console-error'>"; 
     29    else if (type=="success") 
     30        prefix = "<span class='console-success'>"; 
     31    setValue("consoleDetails",getValue("consoleDetails")+prefix+msg+sufix); 
     32    dumpDetails(); 
     33} 
     34 
     35function dump(msg,type) 
     36{ 
     37    if (msg && type) 
    838    { 
    939        console = document.getElementById("kerpass-console"); 
     
    2151    } 
    2252    else 
    23         cprintDet(msg,type); 
    24 
     53    { 
     54        locator=document.getElementById("kerpass-console"); 
     55        junk=locator.getElementsByTagName("listitem"); 
     56        if (junk.length!=0) 
     57        do 
     58         locator.removeChild(junk[0]); 
     59        while (junk.length!=0) 
     60         
     61        tmp = getValue("consoleText") 
     62        cItems = tmp.split("œ") 
     63        for (item in cItems) 
     64        { 
     65            if (cItems[item]!="") 
     66            { 
     67                type="" 
     68                if (cItems[item].substr(0,7)=="*error*") 
     69                { 
     70                    type="error"; 
     71                    msg = cItems[item].substr(7) 
     72                } 
     73                else 
     74                if (cItems[item].substr(0,9)=="*success*") 
     75                { 
     76                    type="success" 
     77                    msg = cItems[item].substr(9) 
     78                } 
     79                else 
     80                    msg = cItems[item] 
    2581 
    26 function cprintDet(msg,type) 
    27 
    28     msg = msg.replace(/\n/gi,"<br />"); 
    29     prefix = "<span>"; 
    30     sufix = "</span><br />" 
    31     if (type=="error") 
    32         prefix = "<span class='console-error'>"; 
    33     else if (type=="success") 
    34         prefix = "<span class='console-success'>"; 
    35     consoleDetails += prefix+msg+sufix; 
    36     dumpDetails(); 
     82                console = document.getElementById("kerpass-console"); 
     83                entry = document.createElement("listitem"); 
     84                text = document.createElement("listcell"); 
     85 
     86                text.setAttribute("label",msg); 
     87                entry.appendChild(text); 
     88                console.appendChild(entry); 
     89 
     90                if (type=="error") 
     91                    entry.setAttribute("class","errorConsoleItem") 
     92                else if (type=="success") 
     93                    entry.setAttribute("class","successConsoleItem") 
     94                console.ensureElementIsVisible(entry) 
     95            } 
     96        } 
     97    } 
    3798} 
    3899 
    39100function dumpDetails() 
    40101{ 
    41         elm = window.content.document.getElementById("detailed-console"); 
    42         if (elm) 
    43         { 
    44             elm.innerHTML = consoleDetails; 
    45             elm.scrollTop = elm.scrollHeight; 
    46         } 
     102    container = document.getElementById("consoleWindow") 
     103     
     104    try 
     105    { 
     106        elm = container.contentDocument.getElementById("detailed-console"); 
     107        elm.innerHTML = getValue("consoleDetails"); 
     108        elm.scrollTop = elm.scrollHeight; 
     109    } 
     110    catch(error) 
     111    { 
     112    } 
    47113} 
    48114 
     
    55121     locator.removeChild(junk[0]); 
    56122    while (junk.length!=0) 
    57     consoleDetails = ""; 
     123    setValue("consoleDetails",""); 
     124    setValue("consoleText","") 
    58125    dumpDetails() 
    59126} 
    60127 
    61 function detailedMode() 
     128function openDetailedConsole() 
    62129{ 
    63         detailsTab = getBrowser().addTab("chrome://kerpass/content/detailView.html"); 
    64         detailsTab.setAttribute("state","gkDetailsTab"); 
    65         detailsTab.setAttribute("mode","kerpass"); 
    66         getBrowser().selectedTab = detailsTab; 
    67         detailsTab.focus(); 
    68         dumpDetails(); 
     130    console = document.getElementById("consoleHolder"); 
     131    console.setAttribute("hidden","false"); 
     132     
     133    spliter = document.getElementById("advConsole-splitter"); 
     134    consoleWindow = document.getElementById("consoleWindow"); 
     135    spliter.setAttribute("hidden","false"); 
     136    setValue("consoleOpened","true"); 
     137     
     138    setTimeout('dumpDetails()',100) 
    69139} 
    70140 
     141function closeDetaileConsole(terminate) 
     142{ 
     143    spliter = document.getElementById("advConsole-splitter"); 
     144    console = document.getElementById("consoleHolder"); 
     145 
     146    spliter.setAttribute("hidden","true"); 
     147    console.setAttribute("hidden","true"); 
     148    if (terminate) 
     149        setValue("consoleOpened","false"); 
     150 
     151} 
     152 
  • trunk/client-side/Firefox-extension/chrome/content/code/gatekeeper.js

    r3 r6  
    1313 
    1414//     loginBox = document.getElementById("kerLogin"); 
     15    kerOtp = document.getElementById("kerOtp"); 
     16    kerPassword = document.getElementById("kerPassword"); 
     17    bar = document.getElementById("kerpass-toolbar"); 
    1518 
    1619    var explicitRegexp = /(.*)@(?:(.*?)\.|)(.*)\.(.+)/; 
     
    2528//         result += "Site ext: "+matchExplicit[4]+"\n" 
    2629//         alert(result) 
    27         kerOtp = document.getElementById("kerOtp"); 
    28         kerPassword = document.getElementById("kerPassword"); 
    29         bar = document.getElementById("kerpass-toolbar"); 
    3030        switch (matchExplicit[2]) 
    3131        { 
     
    5353    if (matchImplicit != null && matchImplicit.length >1) 
    5454    { 
    55         kerOtp = document.getElementById("kerOtp"); 
    56         kerPassword = document.getElementById("kerPassword"); 
    57         bar = document.getElementById("kerpass-toolbar"); 
    5855        switch (matchImplicit[2]) 
    5956        { 
     
    8683        bar.setAttribute("style","height:100px;") 
    8784    } 
    88     check4Enter(event) 
    89 
    90  
    91 function check4Enter(event) 
    92 
    93     if (event.keyCode== 13) 
    94         step1() 
    95 
     85
     86 
    9687 
    9788function makeBar(style) 
     
    112103            break; 
    113104    } 
     105    setValue("barMode",style) 
    114106} 
    115107 
     
    162154} 
    163155 
     156function setValue(key,value) 
     157{ 
     158    tab = getBrowser().selectedTab; 
     159    tab.setAttribute(key,value); 
     160} 
     161 
     162function getValue(key) 
     163{ 
     164    tab = getBrowser().selectedTab; 
     165    return tab.getAttribute(key); 
     166} 
    164167 
    165168 
     
    258261 
    259262        authURL = ""; 
    260         if (pathToAuth.substr(0,1)!="/") 
    261             authURL = starterURL+pathToAuth
     263        if (getValue("pathToAuth").substr(0,1)!="/") 
     264            authURL = starterURL+getValue("pathToAuth")
    262265        else 
    263266        { 
    264267            baseUrlRegexp = /((?:https|http):\/\/(?:.*?)\/)/; 
    265268            baseUrl = baseUrlRegexp.exec(starterURL)[1]; 
    266             authURL = baseUrl+pathToAuth.substr(1); 
     269            authURL = baseUrl+getValue("pathToAuth").substr(1); 
    267270        } 
    268271 
     
    292295 
    293296} 
    294 var pathToAuth; 
    295 var gk_is_open; 
     297 
    296298var K_uas; 
    297299var r_chal; 
     
    300302{ 
    301303    cprint("Recived from server at step3: <br />"+data); 
     304    if (data=="Protocol error!") 
     305    { 
     306        cprint("Error authenticating user",false,"error"); 
     307        hideLoader(); 
     308        makeBar("bad"); 
     309    } 
    302310    M2_s = data.split("::")[0]; 
    303311    atoken_S = data.split("::")[1]; 
     
    315323        makeBar("bad"); 
    316324    } 
    317  
    318325 
    319326    K_uas = calcSHA1("3"+K).substr(0,16); 
     
    397404function popGatekeeper(path) 
    398405{ 
    399 //     handlePreferences() 
    400     makeBar("neutral"); 
    401     cprint("Welcome to Gatekeeper",false,"success"); 
    402     cprint("ATTENTION!!!",false,"error") 
    403     cprint("DO NOT enter your passwords elswere than gatekeeper.",false) 
    404     cprint("By this, you ensure that your password wown't be stolen.",false); 
    405     var tab = getBrowser().selectedTab; 
    406     tab.setAttribute("mode","kerpass"); 
     406    if (getValue("transInProg")=="true") 
     407        showLoader() 
     408    else 
     409        hideLoader() 
     410    dump() 
     411    makeBar(getValue("barMode")); 
     412    if (getValue("firstTime")!="true") 
     413    { 
     414        cprint("Welcome to Gatekeeper",false,"success"); 
     415        cprint("ATTENTION!!!",false,"error"); 
     416        cprint("DO NOT enter your passwords elswere than gatekeeper.",false); 
     417        cprint("By this, you ensure that your password wown't be stolen.",false); 
     418        setValue("firstTime","true"); 
     419        setValue("kerUid","login"); 
     420        setValue("kerPassword","mm"); 
     421        setValue("kerOtp",""); 
     422         
     423    } 
     424    setValue("mode","kerpass"); 
    407425    el = document.getElementById("kerpass-toolbar"); 
    408426    el.setAttribute("hidden","false"); 
    409     gk_is_open = true; 
    410     pathToAuth = path; 
    411 
    412  
    413 function closeToolbar() 
     427     
     428    if (path) 
     429        setValue("pathToAuth",path); 
     430    if (getValue("consoleOpened")=="true") 
     431        openDetailedConsole() 
     432
     433 
     434function closeToolbar(terminate) 
    414435{ 
    415436    var tab = getBrowser().selectedTab; 
     
    417438    el = document.getElementById("kerpass-toolbar"); 
    418439    el.setAttribute("hidden","true"); 
    419     tHeight = 10; 
    420     pathToAuth = null; 
    421     gk_is_open = false; 
     440    closeDetaileConsole(terminate) 
    422441//     removeFromListener(oHeaderInfoLive); 
    423442} 
  • trunk/client-side/Firefox-extension/chrome/content/code/observers.js

    r3 r6  
    7777    { 
    7878    } 
    79     if (headerProbe && !gk_is_open
     79    if (headerProbe && getValue("mode")!="kerpass"
    8080    { 
    8181        popGatekeeper(headerProbe); 
     
    121121    tab = getBrowser().selectedTab; 
    122122    el = document.getElementById("kerpass-toolbar"); 
    123     hidden = el.getAttribute("hidden") 
    124123    mode = tab.getAttribute("mode") 
    125124    state = tab.getAttribute("state") 
    126125    tHeight = 91; 
    127     if ((mode=="kerpass")&&(hidden=="true")) 
    128       popGatekeeper() 
    129     if ((mode!="kerpass")&&(hidden=="false")) 
     126    if ((mode=="kerpass")) 
     127    { 
     128        kerUid = document.getElementById("kerUid"); 
     129        kerUid.value = getValue("kerUid"); 
     130 
     131        kerPassword = document.getElementById("kerPassword"); 
     132        kerPassword.value = getValue("kerPassword"); 
     133 
     134        kerOtp = document.getElementById("kerOtp"); 
     135        kerOtp.value = getValue("kerOtp"); 
     136         
     137        popGatekeeper() 
     138    } 
     139    if ((mode!="kerpass")) 
    130140      closeToolbar() 
    131     if (state=="gkDetailsTab") 
    132     { 
    133         dumpDetails(); 
    134     } 
     141    dumpDetails(); 
     142     
     143     
    135144} 
    136145 
     
    148157            status = status.QueryInterface(Components.interfaces.nsISSLStatus); 
    149158            var cert = status.serverCert; 
    150             alert(cert.sha1Fingerprint); 
     159            setValue("cert",cert.sha1Fingerprint) 
     160            alert(getValue("cert")); 
    151161        } 
    152162        catch(error) 
    153163        { 
    154 //             alert("ERROR: "+error.description) 
    155 //             setTimeout("getCertificate()",1000) 
    156164        } 
    157165    } 
     
    162170    if (el.value=="Login " || el.value=="Password "|| el.value=="OTP ") 
    163171        el.value="" 
     172} 
     173 
     174function keyPressed(event,obj) 
     175{ 
     176    if (event.keyCode== 13) 
     177        step1() 
     178    setValue(obj.id,obj.value) 
    164179} 
    165180 
  • trunk/client-side/Firefox-extension/chrome/content/code/utils.js

    r3 r6  
    5050    el = document.getElementById("throber"); 
    5151    el.setAttribute("style","display:block"); 
     52    setValue("transInProg","true") 
    5253} 
    5354 
     
    5657    el = document.getElementById("throber"); 
    5758    el.setAttribute("style","display:none"); 
    58  
     59    setValue("transInProg","false") 
    5960} 
    6061 
  • trunk/client-side/Firefox-extension/chrome/content/detailView.html

    r3 r6  
    1010 </head> 
    1111 <style type="text/css"> 
     12    * 
     13    { 
     14        padding:0px; 
     15        margin:0px; 
     16    } 
    1217    body 
    1318    { 
     
    2429        background-color:white; 
    2530        border:1px solid black; 
    26     } 
    27      
    28     input 
    29     { 
    30         margin-top:10px; 
     31        margin:10px; 
    3132    } 
    3233     
     
    4647    { 
    4748        color:white; 
    48         text-align:center; 
     49        margin-top:2px; 
     50        margin-left:4px; 
    4951    } 
    5052 </style> 
     
    5355    <div id="detailed-console"> 
    5456    </div> 
    55     <form action="#"> 
    56         <input type="button" value="Close" onclick="window.close();"> 
    57     </form> 
    5857 </body> 
    5958</html> 
  • trunk/client-side/Firefox-extension/chrome/content/gatekeeperOverlay.xul

    r3 r6  
    88  
    99  
    10  <script type="application/x-javascript" src="chrome://kerpass/content/code/srp/hmac.js" /> 
    11  <script type="application/x-javascript" src="chrome://kerpass/content/code/srp/bigint.js" /> 
    12  <script type="application/x-javascript" src="chrome://kerpass/content/code/srp/aes.js" /> 
    13  <script type="application/x-javascript" src="chrome://kerpass/content/code/srp/sha1.js" /> 
     10 <script type="application/x-javascript" src="chrome://kerpass/content/code/crypto/hmac.js" /> 
     11 <script type="application/x-javascript" src="chrome://kerpass/content/code/crypto/bigint.js" /> 
     12 <script type="application/x-javascript" src="chrome://kerpass/content/code/crypto/aes.js" /> 
     13 <script type="application/x-javascript" src="chrome://kerpass/content/code/crypto/sha1.js" /> 
    1414 
    1515 <script type="application/x-javascript" src="chrome://kerpass/content/code/console.js" /> 
     
    2121<toolbox id="navigator-toolbox"> 
    2222  <toolbar insertafter="toolbar-menubar" id="kerpass-toolbar" customizable="true" class="chromeclass-toolbar" hidden="true" fullscreentoolbar="true"> 
    23     <hbox> 
    24     <vbox> 
    25         <image class="tabs-closebutton" onclick="closeToolbar()" /> 
    26     </vbox> 
    27     <vbox> 
    28         <image id="user" /> 
    29     </vbox> 
    30     <vbox id='throber'> 
    31         <image id="loading" /> 
    32     </vbox> 
    33     <vbox id="inputContainers"> 
    34         <!--value="9HA3NHTYB7EK"--> 
    35         <textbox value="login" type="text" onkeyup="parseIdInput(this,event)" id="kerUid"  onfocus="focusInput(this)"/> 
    36         <textbox id="kerPassword" type="password" value="mm" onfocus="focusInput(this)" onkeyup="check4Enter(event)"/> 
    37         <textbox id="kerOtp" class='otp' type="text" value="OTP " onfocus="focusInput(this)" onkeyup="check4Enter(event)" hidden="true"/> 
    38         <button id="loginBtn" label="Login" oncommand="step1()"/> 
    39     </vbox> 
    40     <vbox  id="console-holder"> 
    41         <tabpanel id="console-holder"> 
     23    <hbox flex="1"> 
     24        <vbox> 
     25            <image class="tabs-closebutton" onclick="closeToolbar()" /> 
     26        </vbox> 
    4227         
    43           <listbox flex="1" id="kerpass-console" rows="3" suppressonselect="false" context="console-menu"> 
    44               <listcols> 
    45                   <listcol flex="1"/> 
    46               </listcols> 
    47           </listbox> 
    48            
    49           <popup id="console-menu"> 
    50             <menuitem label="Clear" oncommand="clearConsole()"/> 
    51             <menuitem label="Detailed mode" oncommand="detailedMode()"/> 
    52           </popup> 
    53            
    54         </tabpanel> 
    55     </vbox> 
     28        <vbox> 
     29            <image id="user" /> 
     30        </vbox> 
     31         
     32        <vbox id='throber'> 
     33            <image id="loading" /> 
     34        </vbox> 
     35         
     36        <vbox id="inputContainers"> 
     37            <!--value="9HA3NHTYB7EK"--> 
     38            <textbox value="login" type="text" onkeyup="parseIdInput(this,event);keyPressed(event,this)" id="kerUid"  onfocus="focusInput(this)"/> 
     39            <textbox id="kerPassword" type="password" value="mm" onfocus="focusInput(this)" onkeyup="keyPressed(event,this)"/> 
     40            <textbox id="kerOtp" class='otp' type="text" value="OTP " onfocus="focusInput(this)" onkeyup="keyPressed(event,this)" hidden="true"/> 
     41            <button id="loginBtn" label="Login" oncommand="step1()"/> 
     42        </vbox> 
     43         
     44        <vbox  id="console-holder"> 
     45            <tabpanel id="console-holder"> 
     46 
     47              <listbox flex="1" id="kerpass-console" rows="3" suppressonselect="false" context="console-menu"> 
     48                  <listcols> 
     49                      <listcol flex="1"/> 
     50                  </listcols> 
     51              </listbox> 
     52 
     53              <popup id="console-menu"> 
     54                <menuitem label="Clear" oncommand="clearConsole()"/> 
     55                <menuitem label="Detailed mode" oncommand="openDetailedConsole()"/> 
     56              </popup> 
     57 
     58            </tabpanel> 
     59        </vbox> 
     60 
     61        <vbox id="logoContainer" flex="1"> 
     62            <image aign="right" id="logo"/> 
     63        </vbox> 
     64 
     65    </hbox> 
    5666     
    57     </hbox> 
    58     <image aign="right" id="logo" /> 
    5967  </toolbar> 
     68   
     69 
    6070</toolbox> 
    6171 
     
    7080 </hbox> 
    7181  
     82<vbox id="appcontent"> 
     83    <splitter id="advConsole-splitter" class="chromeclass-extrachrome" hidden="true"/> 
     84    <box flex="1" id="consoleHolder" hidden="true"> 
     85        <hbox> 
     86            <vbox> 
     87                <image id="consoleCloseBtn" class="tabs-closebutton" onclick="closeDetaileConsole(true)" /> 
     88            </vbox> 
     89        </hbox> 
     90        <browser id="consoleWindow" type="content" src="chrome://kerpass/content/detailView.html" flex="1"/> 
     91    </box> 
     92</vbox> 
     93  
    7294</overlay> 
    7395 
  • trunk/client-side/Firefox-extension/chrome/skin/toolbar.css

    r3 r6  
    184184    width:88px; 
    185185    height:88px; 
    186     background: url("chrome://kerpass/skin/images/gk_logo.png") left center no-repeat; 
    187     float:right; 
     186    background: url("chrome://kerpass/skin/images/gk_logo.png") right center no-repeat; 
    188187} 
    189188 
     189#consoleCloseBtn 
     190{ 
     191    position:absolute; 
     192} 
     193 
     194 
     195#consoleWindow 
     196{ 
     197    width:100%; 
     198} 
     199