Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js index 1d38509..8f8696d 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js | |||
@@ -1,216 +1,213 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | Clipperz.Base.module('Clipperz.PM.DataModel'); | 26 | Clipperz.Base.module('Clipperz.PM.DataModel'); |
30 | 27 | ||
31 | Clipperz.PM.DataModel.DirectLogin = function(args) { | 28 | Clipperz.PM.DataModel.DirectLogin = function(args) { |
32 | args = args || {}; | 29 | args = args || {}; |
33 | 30 | ||
34 | Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments); | 31 | Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments); |
35 | 32 | ||
36 | this._reference =args.reference | 33 | this._reference =args.reference |
37 | ||Clipperz.PM.Crypto.randomKey(); | 34 | ||Clipperz.PM.Crypto.randomKey(); |
38 | this._record =args.record | 35 | this._record =args.record |
39 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 36 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
40 | 37 | ||
41 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction | 38 | this._retrieveIndexDataFunction = args.retrieveIndexDataFunction |
42 | ||this.record().retrieveDirectLoginIndexDataFunction() | 39 | ||this.record().retrieveDirectLoginIndexDataFunction() |
43 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 40 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
44 | this._setIndexDataFunction = args.setIndexDataFunction | 41 | this._setIndexDataFunction = args.setIndexDataFunction |
45 | ||this.record().setDirectLoginIndexDataFunction() | 42 | ||this.record().setDirectLoginIndexDataFunction() |
46 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 43 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
47 | this._removeIndexDataFunction =args.removeIndexDataFunction | 44 | this._removeIndexDataFunction =args.removeIndexDataFunction |
48 | ||this.record().removeDirectLoginIndexDataFunction() | 45 | ||this.record().removeDirectLoginIndexDataFunction() |
49 | ||Clipperz.Base.exception.raise('MandatoryParameter'); | 46 | ||Clipperz.Base.exception.raise('MandatoryParameter'); |
50 | 47 | ||
51 | this._inputs = null; | 48 | this._inputs = null; |
52 | this._bindings = null; | 49 | this._bindings = null; |
53 | this._formValues = null; | 50 | this._formValues = null; |
54 | 51 | ||
55 | // this._inputsDeferredLock = new MochiKit.Async.DeferredLock(); | 52 | // this._inputsDeferredLock = new MochiKit.Async.DeferredLock(); |
56 | // this._bindingsDeferredLock = new MochiKit.Async.DeferredLock(); | 53 | // this._bindingsDeferredLock = new MochiKit.Async.DeferredLock(); |
57 | // this._formValuesDeferredLock = new MochiKit.Async.DeferredLock(); | 54 | // this._formValuesDeferredLock = new MochiKit.Async.DeferredLock(); |
58 | 55 | ||
59 | this._transientState = null; | 56 | this._transientState = null; |
60 | 57 | ||
61 | this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference); | 58 | this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference); |
62 | 59 | ||
63 | this.record().addDirectLogin(this); | 60 | this.record().addDirectLogin(this); |
64 | 61 | ||
65 | return this; | 62 | return this; |
66 | } | 63 | } |
67 | 64 | ||
68 | Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { | 65 | Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, { |
69 | 66 | ||
70 | 'toString': function() { | 67 | 'toString': function() { |
71 | return "DirectLogin (" + this.reference() + ")"; | 68 | return "DirectLogin (" + this.reference() + ")"; |
72 | }, | 69 | }, |
73 | 70 | ||
74 | //========================================================================= | 71 | //========================================================================= |
75 | 72 | ||
76 | 'reference': function () { | 73 | 'reference': function () { |
77 | return this._reference; | 74 | return this._reference; |
78 | }, | 75 | }, |
79 | 76 | ||
80 | //------------------------------------------------------------------------- | 77 | //------------------------------------------------------------------------- |
81 | 78 | ||
82 | 'record': function () { | 79 | 'record': function () { |
83 | return this._record; | 80 | return this._record; |
84 | }, | 81 | }, |
85 | 82 | ||
86 | //========================================================================= | 83 | //========================================================================= |
87 | 84 | ||
88 | 'isBrandNew': function () { | 85 | 'isBrandNew': function () { |
89 | return this._isBrandNew; | 86 | return this._isBrandNew; |
90 | }, | 87 | }, |
91 | 88 | ||
92 | //========================================================================= | 89 | //========================================================================= |
93 | 90 | ||
94 | 'removeIndexDataFunction': function () { | 91 | 'removeIndexDataFunction': function () { |
95 | return this._removeIndexDataFunction; | 92 | return this._removeIndexDataFunction; |
96 | }, | 93 | }, |
97 | 94 | ||
98 | 'remove': function () { | 95 | 'remove': function () { |
99 | return Clipperz.Async.callbacks("DirectLogin.remove", [ | 96 | return Clipperz.Async.callbacks("DirectLogin.remove", [ |
100 | MochiKit.Base.partial(this.removeIndexDataFunction(), this.reference()), | 97 | MochiKit.Base.partial(this.removeIndexDataFunction(), this.reference()), |
101 | MochiKit.Base.method(this.record(), 'removeDirectLogin', this) | 98 | MochiKit.Base.method(this.record(), 'removeDirectLogin', this) |
102 | ], {trace:false}); | 99 | ], {trace:false}); |
103 | }, | 100 | }, |
104 | 101 | ||
105 | //========================================================================= | 102 | //========================================================================= |
106 | /* | 103 | /* |
107 | 'inputsDeferredLock': function () { | 104 | 'inputsDeferredLock': function () { |
108 | return this._inputsDeferredLock; | 105 | return this._inputsDeferredLock; |
109 | }, | 106 | }, |
110 | 107 | ||
111 | 'bindingsDeferredLock': function () { | 108 | 'bindingsDeferredLock': function () { |
112 | return this._bindingsDeferredLock; | 109 | return this._bindingsDeferredLock; |
113 | }, | 110 | }, |
114 | 111 | ||
115 | 'formValuesDeferredLock': function () { | 112 | 'formValuesDeferredLock': function () { |
116 | return this._formValuesDeferredLock; | 113 | return this._formValuesDeferredLock; |
117 | }, | 114 | }, |
118 | */ | 115 | */ |
119 | //========================================================================= | 116 | //========================================================================= |
120 | 117 | ||
121 | 'label': function () { | 118 | 'label': function () { |
122 | return this.getIndexDataForKey('label'); | 119 | return this.getIndexDataForKey('label'); |
123 | }, | 120 | }, |
124 | 121 | ||
125 | 'setLabelKeepingBackwardCompatibilityWithBeta': function (aValue) { | 122 | 'setLabelKeepingBackwardCompatibilityWithBeta': function (aValue) { |
126 | return Clipperz.Async.callbacks("DirectLogin.setLabelKeepingBackwardCompatibilityWithBeta", [ | 123 | return Clipperz.Async.callbacks("DirectLogin.setLabelKeepingBackwardCompatibilityWithBeta", [ |
127 | MochiKit.Base.method(this, 'setIndexDataForKey', 'label', aValue), | 124 | MochiKit.Base.method(this, 'setIndexDataForKey', 'label', aValue), |
128 | MochiKit.Base.method(this, 'setValue', 'label', aValue) | 125 | MochiKit.Base.method(this, 'setValue', 'label', aValue) |
129 | ], {trace:false}); | 126 | ], {trace:false}); |
130 | }, | 127 | }, |
131 | 128 | ||
132 | 'setLabel': function (aValue) { | 129 | 'setLabel': function (aValue) { |
133 | return this.setLabelKeepingBackwardCompatibilityWithBeta(aValue); | 130 | return this.setLabelKeepingBackwardCompatibilityWithBeta(aValue); |
134 | // return this.setIndexDataForKey('label', aValue); | 131 | // return this.setIndexDataForKey('label', aValue); |
135 | }, | 132 | }, |
136 | 133 | ||
137 | //========================================================================= | 134 | //========================================================================= |
138 | 135 | ||
139 | 'favicon': function () { | 136 | 'favicon': function () { |
140 | return this.getIndexDataForKey('favicon'); | 137 | return this.getIndexDataForKey('favicon'); |
141 | }, | 138 | }, |
142 | 139 | ||
143 | 'setFavicon': function (aValue) { | 140 | 'setFavicon': function (aValue) { |
144 | return this.setIndexDataForKey('favicon', aValue); | 141 | return this.setIndexDataForKey('favicon', aValue); |
145 | }, | 142 | }, |
146 | 143 | ||
147 | 'faviconUrlWithBookmarkletConfiguration': function (aBookmarkletConfiguration) { | 144 | 'faviconUrlWithBookmarkletConfiguration': function (aBookmarkletConfiguration) { |
148 | varresult; | 145 | varresult; |
149 | 146 | ||
150 | if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['page']['favicon'])) { | 147 | if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['page']['favicon'])) { |
151 | result = aBookmarkletConfiguration['page']['favicon']; | 148 | result = aBookmarkletConfiguration['page']['favicon']; |
152 | } else if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['form']['attributes']['action'])) { | 149 | } else if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['form']['attributes']['action'])) { |
153 | var actionUrl; | 150 | var actionUrl; |
154 | var hostname; | 151 | var hostname; |
155 | 152 | ||
156 | actionUrl = aBookmarkletConfiguration['form']['attributes']['action']; | 153 | actionUrl = aBookmarkletConfiguration['form']['attributes']['action']; |
157 | hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); | 154 | hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); |
158 | result = "http://" + hostname + "/favicon.ico"; | 155 | result = "http://" + hostname + "/favicon.ico"; |
159 | } else { | 156 | } else { |
160 | result = null; | 157 | result = null; |
161 | } | 158 | } |
162 | 159 | ||
163 | 160 | ||
164 | return result; | 161 | return result; |
165 | }, | 162 | }, |
166 | 163 | ||
167 | //------------------------------------------------------------------------- | 164 | //------------------------------------------------------------------------- |
168 | /* | 165 | /* |
169 | 'faviconData': function () { | 166 | 'faviconData': function () { |
170 | var regexp = new RegExp('^data\:\/\/.*', 'i'); | 167 | var regexp = new RegExp('^data\:\/\/.*', 'i'); |
171 | 168 | ||
172 | return Clipperz.Async.callbacks("DirectLogin.favicon", [ | 169 | return Clipperz.Async.callbacks("DirectLogin.favicon", [ |
173 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), | 170 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), |
174 | MochiKit.Base.method(regexp, 'test'), | 171 | MochiKit.Base.method(regexp, 'test'), |
175 | Clipperz.Async.deferredIf("is data URL", [ | 172 | Clipperz.Async.deferredIf("is data URL", [ |
176 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon') | 173 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon') |
177 | ], [ | 174 | ], [ |
178 | MochiKit.Base.method(this, 'transientState'), | 175 | MochiKit.Base.method(this, 'transientState'), |
179 | MochiKit.Base.itemgetter('faviconData'), | 176 | MochiKit.Base.itemgetter('faviconData'), |
180 | Clipperz.Async.deferredIf('has a chaced value for the favicon data', [ | 177 | Clipperz.Async.deferredIf('has a chaced value for the favicon data', [ |
181 | MochiKit.Base.operator.identity | 178 | MochiKit.Base.operator.identity |
182 | ], [ | 179 | ], [ |
183 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), | 180 | MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'), |
184 | MochiKit.Base.method(this, 'loadFaviconDataFromURL') | 181 | MochiKit.Base.method(this, 'loadFaviconDataFromURL') |
185 | ]) | 182 | ]) |
186 | 183 | ||
187 | ]) | 184 | ]) |
188 | ], {trace:false}); | 185 | ], {trace:false}); |
189 | }, | 186 | }, |
190 | 187 | ||
191 | //------------------------------------------------------------------------- | 188 | //------------------------------------------------------------------------- |
192 | 189 | ||
193 | 'loadFaviconDataFromURL': function (anURL) { | 190 | 'loadFaviconDataFromURL': function (anURL) { |
194 | var deferredResult; | 191 | var deferredResult; |
195 | var image; | 192 | var image; |
196 | 193 | ||
197 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.loadFaviconDataFromURL", {trace:false}); | 194 | deferredResult = new Clipperz.Async.Deferred("DirectLogin.loadFaviconDataFromURL", {trace:false}); |
198 | deferredResult.addCallback(function (anEvent) { | 195 | deferredResult.addCallback(function (anEvent) { |
199 | var image = anEvent.src(); | 196 | var image = anEvent.src(); |
200 | var canvas = document.createElement("canvas"); | 197 | var canvas = document.createElement("canvas"); |
201 | var result; | 198 | var result; |
202 | 199 | ||
203 | canvas.width = image.width; | 200 | canvas.width = image.width; |
204 | canvas.height = image.height; | 201 | canvas.height = image.height; |
205 | 202 | ||
206 | var ctx = canvas.getContext("2d"); | 203 | var ctx = canvas.getContext("2d"); |
207 | ctx.drawImage(image, 0, 0); | 204 | ctx.drawImage(image, 0, 0); |
208 | 205 | ||
209 | result = canvas.toDataURL(/*"image/png"* /); | 206 | result = canvas.toDataURL(/*"image/png"* /); |
210 | 207 | ||
211 | return result; | 208 | return result; |
212 | }); | 209 | }); |
213 | deferredResult.addErrback(MochiKit.Async.succeed, Clipperz.PM.Strings.getValue('defaultFaviconUrl')); | 210 | deferredResult.addErrback(MochiKit.Async.succeed, Clipperz.PM.Strings.getValue('defaultFaviconUrl')); |
214 | deferredResult.addBoth(MochiKit.Base.bind(function (aDataUrl) { | 211 | deferredResult.addBoth(MochiKit.Base.bind(function (aDataUrl) { |
215 | this.transientState()['faviconData'] = aDataUrl; | 212 | this.transientState()['faviconData'] = aDataUrl; |
216 | 213 | ||