]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/PasswordCredentialImpl.js
add description field
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.ria / src / argeo-ria-lib / security / class / org / argeo / security / ria / components / PasswordCredentialImpl.js
1 qx.Class.define("org.argeo.security.ria.components.PasswordCredentialImpl", {
2 extend : qx.ui.container.Composite,
3 implement : [org.argeo.security.ria.components.ICredentialPane],
4 events : {
5 "modified" : "qx.event.type.Event"
6 },
7 properties : {
8 valid : {
9 init : false
10 },
11 encoderCallback : {
12 init : function(string){
13 var encoderShort = org.argeo.ria.util.Encoder;
14 return "{SHA}"+encoderShort.base64Encode(encoderShort.hexDecode(encoderShort.hash(string, "sha1")));
15 },
16 check : "Function"
17 }
18 },
19
20 construct : function(){
21 this.base(arguments);
22 this.setLayout(new qx.ui.layout.HBox(5, "center"));
23 this.add(new qx.ui.basic.Label("Password"), {flex:1});
24 this.pass1 = new qx.ui.form.PasswordField();
25 this.add(this.pass1, {flex:2});
26 this.add(new qx.ui.basic.Label("Confirm Password"), {flex:1});
27 this.pass2 = new qx.ui.form.PasswordField();
28 this.add(this.pass2, {flex:2});
29 this.pass1.addListener("changeValue", function(){this.fireEvent("modified");}, this);
30 this.pass2.addListener("changeValue", function(){this.fireEvent("modified");}, this);
31 this.pass2.addListener("changeValue", this.validate, this);
32 },
33
34 members : {
35 getContainer : function(){
36 return this;
37 },
38 getData : function(format){
39 var encoded = null;
40 if(this.pass1.getValue() != null && this.pass1.getValue() != ""){
41 var encoder = this.getEncoderCallback();
42 encoded = encoder(this.pass1.getValue());
43 }
44 return encoded;
45 },
46 clear : function(){
47 this.pass1.setValue("");
48 this.pass2.setValue("");
49 },
50 validate : function(){
51 if(this.pass1.getValue() != this.pass2.getValue()){
52 this.pass1.setValid(false);
53 this.pass2.setValid(false);
54 this.setValid(false);
55 }else{
56 this.pass1.setValid(true);
57 this.pass2.setValid(true);
58 this.setValid(true);
59 }
60 return this.getValid();
61 },
62 setEditMode : function(editMode){return true;}
63 }
64 });