summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js b/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js
index 7b0b12b..1e94c4b 100644
--- a/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js
+++ b/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js
@@ -1,214 +1,212 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
9 8
10* Clipperz Community Edition is free software: you can redistribute 9* Clipperz is free software: you can redistribute it and/or modify it
11 it and/or modify it under the terms of the GNU Affero General Public 10 under the terms of the GNU Affero General Public License as published
12 License as published by the Free Software Foundation, either version 11 by the Free Software Foundation, either version 3 of the License, or
13 3 of the License, or (at your option) any later version. 12 (at your option) any later version.
14 13
15* Clipperz Community Edition is distributed in the hope that it will 14* Clipperz is distributed in the hope that it will be useful, but
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 15 WITHOUT ANY WARRANTY; without even the implied warranty of
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
19 18
20* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
22 <http://www.gnu.org/licenses/>.
23 21
24*/ 22*/
25 23
26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
28if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } 26if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
29if (typeof(Clipperz.PM.Components.OTP) == 'undefined') { Clipperz.PM.Components.OTP = {}; } 27if (typeof(Clipperz.PM.Components.OTP) == 'undefined') { Clipperz.PM.Components.OTP = {}; }
30 28
31//############################################################################# 29//#############################################################################
32 30
33Clipperz.PM.Components.OTP.MainComponent = function(anElement, args) { 31Clipperz.PM.Components.OTP.MainComponent = function(anElement, args) {
34 args = args || {}; 32 args = args || {};
35 33
36//MochiKit.Logging.logDebug("new OTP.MainComponent"); 34//MochiKit.Logging.logDebug("new OTP.MainComponent");
37 Clipperz.PM.Components.OTP.MainComponent.superclass.constructor.call(this, anElement, args); 35 Clipperz.PM.Components.OTP.MainComponent.superclass.constructor.call(this, anElement, args);
38 36
39 this._user = args.user; 37 this._user = args.user;
40 this._shouldRender = true; 38 this._shouldRender = true;
41 39
42 this._deleteButton = null; 40 this._deleteButton = null;
43 this._printButton = null; 41 this._printButton = null;
44 42
45 Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler'); 43 Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler');
46 //Clipperz.NotificationCenter.register(null, 'oneTimePasswordAdded', this, 'render'); 44 //Clipperz.NotificationCenter.register(null, 'oneTimePasswordAdded', this, 'render');
47 45
48 return this; 46 return this;
49} 47}
50 48
51//============================================================================= 49//=============================================================================
52 50
53YAHOO.extendX(Clipperz.PM.Components.OTP.MainComponent, Clipperz.PM.Components.BaseComponent, { 51YAHOO.extendX(Clipperz.PM.Components.OTP.MainComponent, Clipperz.PM.Components.BaseComponent, {
54 52
55 'toString': function() { 53 'toString': function() {
56 return "Clipperz.PM.Components.OTP.MainComponent component"; 54 return "Clipperz.PM.Components.OTP.MainComponent component";
57 }, 55 },
58 56
59 //------------------------------------------------------------------------- 57 //-------------------------------------------------------------------------
60 58
61 'render': function() { 59 'render': function() {
62//MochiKit.Logging.logDebug("### OTP.MainComponent.render"); 60//MochiKit.Logging.logDebug("### OTP.MainComponent.render");
63 Clipperz.NotificationCenter.unregister(this); 61 Clipperz.NotificationCenter.unregister(this);
64 MochiKit.Signal.disconnectAllTo(this); 62 MochiKit.Signal.disconnectAllTo(this);
65 63
66 if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { 64 if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) {
67 this.element().update(""); 65 this.element().update("");
68 this.domHelper().append(this.element(), {tag:'div', cls:'oneTimePasswordReadOnlyMessage', htmlString:Clipperz.PM.Strings['oneTimePasswordReadOnlyMessage']}); 66 this.domHelper().append(this.element(), {tag:'div', cls:'oneTimePasswordReadOnlyMessage', htmlString:Clipperz.PM.Strings['oneTimePasswordReadOnlyMessage']});
69 } else { 67 } else {
70 var deferredResult; 68 var deferredResult;
71 69
72 deferredResult = new MochiKit.Async.Deferred(); 70 deferredResult = new MochiKit.Async.Deferred();
73 71
74//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 1: " + res); return res;}); 72//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 1: " + res); return res;});
75 deferredResult.addCallback(MochiKit.Base.bind(function() { 73 deferredResult.addCallback(MochiKit.Base.bind(function() {
76 this.element().update(""); 74 this.element().update("");
77 Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', htmlString:Clipperz.PM.Strings['oneTimePasswordLoadingMessage']}); 75 Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', htmlString:Clipperz.PM.Strings['oneTimePasswordLoadingMessage']});
78 }, this)); 76 }, this));
79//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 2: " + res); return res;}); 77//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 2: " + res); return res;});
80 deferredResult.addCallback(MochiKit.Base.method(this.user(), 'loadOneTimePasswords')); 78 deferredResult.addCallback(MochiKit.Base.method(this.user(), 'loadOneTimePasswords'));
81//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3: " + res); return res;}); 79//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3: " + res); return res;});
82//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3.1: " + Clipperz.Base.serializeJSON(res.serializedData())); return res;}); 80//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3.1: " + Clipperz.Base.serializeJSON(res.serializedData())); return res;});
83 deferredResult.addCallback(MochiKit.Base.bind(function(aResult) { 81 deferredResult.addCallback(MochiKit.Base.bind(function(aResult) {
84 vartbodyElement; 82 vartbodyElement;
85 varoneTimePasswordReferenceKeys; 83 varoneTimePasswordReferenceKeys;
86 var imageExtension; 84 var imageExtension;
87 var isThereAnyActiveOneTimePassword; 85 var isThereAnyActiveOneTimePassword;
88 86
89 isThereAnyActiveOneTimePassword = false; 87 isThereAnyActiveOneTimePassword = false;
90 88
91 this.element().update(""); 89 this.element().update("");
92 Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', id:'oneTimePasswordList', children:[ 90 Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', id:'oneTimePasswordList', children:[
93 {tag:'div', id:'oneTimePasswords_header', children:[ 91 {tag:'div', id:'oneTimePasswords_header', children:[
94 {tag:'table', width:'100%', children:[ 92 {tag:'table', width:'100%', children:[
95 {tag:'tbody', children:[ 93 {tag:'tbody', children:[
96 {tag:'tr', children:[ 94 {tag:'tr', children:[
97 {tag:'td', width:'10%', children:[ 95 {tag:'td', width:'10%', children:[
98 {tag:'div', id:this.getId('createNewOneTimePasswordButton')} 96 {tag:'div', id:this.getId('createNewOneTimePasswordButton')}
99 ]}, 97 ]},
100 {tag:'td', width:'40%', children:[ 98 {tag:'td', width:'40%', children:[
101 {tag:'div', id:this.getId('deleteSelectedOneTimePasswordButton')} 99 {tag:'div', id:this.getId('deleteSelectedOneTimePasswordButton')}
102 ]}, 100 ]},
103 {tag:'td', width:'50%', align:'right', children:[ 101 {tag:'td', width:'50%', align:'right', children:[
104 {tag:'div', id:this.getId('printOneTimePasswordButton')} 102 {tag:'div', id:this.getId('printOneTimePasswordButton')}
105 ]} 103 ]}
106 ]} 104 ]}
107 ]} 105 ]}
108 ]}, 106 ]},
109 {tag:'div', children:[ 107 {tag:'div', children:[
110 {tag:'ul', children:[ 108 {tag:'ul', children:[
111 {tag:'li', children:[ 109 {tag:'li', children:[
112 {tag:'span', htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_selectLabel']} 110 {tag:'span', htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_selectLabel']}
113 ]}, 111 ]},
114 {tag:'li', children:[ 112 {tag:'li', children:[
115 {tag:'a', href:'#', id:this.getId('selectAllOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_all']} 113 {tag:'a', href:'#', id:this.getId('selectAllOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_all']}
116 ]}, 114 ]},
117 {tag:'li', children:[ 115 {tag:'li', children:[
118 {tag:'a', href:'#', id:this.getId('selectNoneOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_none']} 116 {tag:'a', href:'#', id:this.getId('selectNoneOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_none']}
119 ]}, 117 ]},
120 {tag:'li', children:[ 118 {tag:'li', children:[
121 {tag:'a', href:'#', id:this.getId('selectUsedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_used']} 119 {tag:'a', href:'#', id:this.getId('selectUsedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_used']}
122 ]}, 120 ]},
123 {tag:'li', children:[ 121 {tag:'li', children:[
124 {tag:'a', href:'#', id:this.getId('selectUnusedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_unused']} 122 {tag:'a', href:'#', id:this.getId('selectUnusedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_unused']}
125 ]} 123 ]}
126 ]} 124 ]}
127 ]} 125 ]}
128 ]}, 126 ]},
129 {tag:'form', id:this.getId('oneTimePasswords_form'), children:[ 127 {tag:'form', id:this.getId('oneTimePasswords_form'), children:[
130 {tag:'table', cls:'oneTimePassword', cellspacing:'0', cellpadding:'2', children:[ 128 {tag:'table', cls:'oneTimePassword', cellspacing:'0', cellpadding:'2', children:[
131 {tag:'tbody', id:this.getId('oneTimePasswords_tbody'), children:[ 129 {tag:'tbody', id:this.getId('oneTimePasswords_tbody'), children:[
132 ]} 130 ]}
133 ]} 131 ]}
134 ]} 132 ]}
135 ]}); 133 ]});
136 134
137 imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; 135 imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png';
138 136
139 tbodyElement = this.getElement('oneTimePasswords_tbody'); 137 tbodyElement = this.getElement('oneTimePasswords_tbody');
140 oneTimePasswordReferenceKeys = MochiKit.Base.keys(this.user().oneTimePasswordManager().oneTimePasswords()).reverse(); 138 oneTimePasswordReferenceKeys = MochiKit.Base.keys(this.user().oneTimePasswordManager().oneTimePasswords()).reverse();
141 c = oneTimePasswordReferenceKeys.length; 139 c = oneTimePasswordReferenceKeys.length;
142 if (c>0) { 140 if (c>0) {
143 for (i=0; i<c; i++) { 141 for (i=0; i<c; i++) {
144 var otpReference; 142 var otpReference;
145 var currentOTP; 143 var currentOTP;
146 var loginSessionInfoConfig; 144 var loginSessionInfoConfig;
147 145
148 imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; 146 imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png';
149 147
150 otpReference = oneTimePasswordReferenceKeys[i]; 148 otpReference = oneTimePasswordReferenceKeys[i];
151 currentOTP = this.user().oneTimePasswordManager().oneTimePasswords()[otpReference]; 149 currentOTP = this.user().oneTimePasswordManager().oneTimePasswords()[otpReference];
152 150
153 switch (currentOTP.status()) { 151 switch (currentOTP.status()) {
154 case 'USED': 152 case 'USED':
155 var loginSessionInfo; 153 var loginSessionInfo;
156 154
157 loginSessionInfo = currentOTP.connectionInfo(); 155 loginSessionInfo = currentOTP.connectionInfo();
158 try { 156 try {
159 var ip; 157 var ip;
160 158
161 ip = (currentOTP.connectionInfo()['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? currentOTP.connectionInfo()['ip'] : Clipperz.PM.Strings['unknown_ip']; 159 ip = (currentOTP.connectionInfo()['ip'].match(/^\d{1,3}(.\d{1,3}){3}$/)) ? currentOTP.connectionInfo()['ip'] : Clipperz.PM.Strings['unknown_ip'];
162 160
163 loginSessionInfoConfig = [ 161 loginSessionInfoConfig = [
164 {tag:'div', cls:'oneTimePassword_usageDateDescription', children:[ 162 {tag:'div', cls:'oneTimePassword_usageDateDescription', children:[
165 {tag:'span', cls:'value', html:Clipperz.PM.Date.getElapsedTimeDescription(currentOTP.usageDate())} 163 {tag:'span', cls:'value', html:Clipperz.PM.Date.getElapsedTimeDescription(currentOTP.usageDate())}
166 ]}, 164 ]},
167 {tag:'div', cls:'oneTimePassword_usageDetails', children:[ 165 {tag:'div', cls:'oneTimePassword_usageDetails', children:[
168 {tag:'img', cls:'flag', title:Clipperz.PM.Strings['countries'][ loginSessionInfo['country']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + loginSessionInfo['country'].toLowerCase() + "." + imageExtension, width:'32', height:'32'}, 166 {tag:'img', cls:'flag', title:Clipperz.PM.Strings['countries'][ loginSessionInfo['country']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/flags/" + loginSessionInfo['country'].toLowerCase() + "." + imageExtension, width:'32', height:'32'},
169 {tag:'img', cls:'browser', title:Clipperz.PM.Strings['browsers'][ loginSessionInfo['browser']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + loginSessionInfo['browser'].toLowerCase() + "." + imageExtension, width:'32', height:'32'}, 167 {tag:'img', cls:'browser', title:Clipperz.PM.Strings['browsers'][ loginSessionInfo['browser']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/browsers/" + loginSessionInfo['browser'].toLowerCase() + "." + imageExtension, width:'32', height:'32'},
170 {tag:'img', cls:'operatingSystem', title:Clipperz.PM.Strings['operatingSystems'][loginSessionInfo['operatingSystem']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + loginSessionInfo['operatingSystem'].toLowerCase() + "." + imageExtension, width:'32', height:'32'} 168 {tag:'img', cls:'operatingSystem', title:Clipperz.PM.Strings['operatingSystems'][loginSessionInfo['operatingSystem']], src:Clipperz.PM.Strings['icons_baseUrl'] + "/operatingSystems/" + loginSessionInfo['operatingSystem'].toLowerCase() + "." + imageExtension, width:'32', height:'32'}
171 ]}, 169 ]},
172 {tag:'div', cls:'oneTimePassword_usageDate', html:Clipperz.PM.Date.formatDateWithTemplate(currentOTP.usageDate(), Clipperz.PM.Strings['fullDate_format'])}, 170 {tag:'div', cls:'oneTimePassword_usageDate', html:Clipperz.PM.Date.formatDateWithTemplate(currentOTP.usageDate(), Clipperz.PM.Strings['fullDate_format'])},
173 {tag:'div', cls:'oneTimePassword_IP', children:[ 171 {tag:'div', cls:'oneTimePassword_IP', children:[
174 {tag:'span', cls:'oneTimePassword_IPLabel', htmlString:Clipperz.PM.Strings['loginHistoryIPLabel']}, 172 {tag:'span', cls:'oneTimePassword_IPLabel', htmlString:Clipperz.PM.Strings['loginHistoryIPLabel']},
175 {tag:'span', cls:'oneTimePassword_IPValue', html:ip} 173 {tag:'span', cls:'oneTimePassword_IPValue', html:ip}
176 ]} 174 ]}
177 ]; 175 ];
178 } catch(exception) { 176 } catch(exception) {
179 MochiKit.Logging.logWarning("an error occured while showing the One Time Password session details"); 177 MochiKit.Logging.logWarning("an error occured while showing the One Time Password session details");
180 loginSessionInfoConfig = []; 178 loginSessionInfoConfig = [];
181 } 179 }
182 break; 180 break;
183 case 'DISABLED': 181 case 'DISABLED':
184 loginSessionInfoConfig = [ 182 loginSessionInfoConfig = [
185 {tag:'span', cls:'disabledOneTimePassword', htmlString:Clipperz.PM.Strings['disabledOneTimePassword_warning']} 183 {tag:'span', cls:'disabledOneTimePassword', htmlString:Clipperz.PM.Strings['disabledOneTimePassword_warning']}
186 ]; 184 ];
187 break; 185 break;
188 case 'ACTIVE': 186 case 'ACTIVE':
189 default: 187 default:
190 loginSessionInfoConfig = []; 188 loginSessionInfoConfig = [];
191 break; 189 break;
192 } 190 }
193 191
194 192
195 if (currentOTP.isExpired() == false) { 193 if (currentOTP.isExpired() == false) {
196 isThereAnyActiveOneTimePassword = true; 194 isThereAnyActiveOneTimePassword = true;
197 }; 195 };
198 196
199 197
200 this.domHelper().append(tbodyElement, {tag:'tr', cls:(currentOTP.isExpired() ? 'oneTimePassword_used': 'oneTimePassword_new'), children:[ 198 this.domHelper().append(tbodyElement, {tag:'tr', cls:(currentOTP.isExpired() ? 'oneTimePassword_used': 'oneTimePassword_new'), children:[
201 {tag:'td', valign:'top', children:[ 199 {tag:'td', valign:'top', children:[
202 {tag:'input', type:'checkbox', cls:'otpCheckbox', name:currentOTP.reference()} 200 {tag:'input', type:'checkbox', cls:'otpCheckbox', name:currentOTP.reference()}
203 ]}, 201 ]},
204 {tag:'td', valign:'top', children:[ 202 {tag:'td', valign:'top', children:[
205 {tag:'span', cls:'oneTimePassword_value', html:currentOTP.password()} 203 {tag:'span', cls:'oneTimePassword_value', html:currentOTP.password()}
206 ]}, 204 ]},
207 {tag:'td', valign:'top', children:[ 205 {tag:'td', valign:'top', children:[
208 {tag:'div', cls:'oneTimePassword_usageStats', children:loginSessionInfoConfig} 206 {tag:'div', cls:'oneTimePassword_usageStats', children:loginSessionInfoConfig}
209 ]} 207 ]}
210 ]}); 208 ]});
211 } 209 }
212 } else { 210 } else {
213 this.domHelper().append(tbodyElement, {tag:'tr', children:[ 211 this.domHelper().append(tbodyElement, {tag:'tr', children:[
214 {tag:'td', children:[ 212 {tag:'td', children:[