details:   /erp/devel/pi/rev/4eff7fc5adc8
changeset: 10204:4eff7fc5adc8
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Fri Jan 28 15:52:06 2011 +0100
summary:   Implement new references to password types for new UI
- Adds two new explicit references for storing encrypted or hashed passwords
- Adding domainType as preperation of handling encryption/hashing on updates
- Adding display part of new references in new UI (not showing raw-value but *)

details:   /erp/devel/pi/rev/fb9bed128a38
changeset: 10205:fb9bed128a38
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Fri Jan 28 15:57:55 2011 +0100
summary:   Fix logging

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
 |   9 +
 
modules/org.openbravo.client.kernel/src-db/database/sourcedata/OBCLKER_UIDEFINITION.xml
                                                                      |  10 +
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/PasswordUIDefinition.java
                                                      |  53 ++++++++++
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonToDataConverter.java
                                                                   |   5 +-
 src-db/database/sourcedata/AD_REFERENCE.xml                                    
                                                                              | 
 32 ++++++
 src/org/openbravo/base/model/domaintype/EncryptedStringDomainType.java         
                                                                              | 
 32 ++++++
 src/org/openbravo/base/model/domaintype/HashedStringDomainType.java            
                                                                              | 
 31 +++++
 7 files changed, 170 insertions(+), 2 deletions(-)

diffs (248 lines):

diff -r 4dbbf8721b30 -r fb9bed128a38 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
      Fri Jan 28 15:38:24 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-form-styles.js
      Fri Jan 28 15:57:55 2011 +0100
@@ -49,6 +49,15 @@
   textBoxStyle: 'OBFormFieldInput'
 });
 
+isc.OBEncryptedItem.addProperties({
+  errorOrientation: 'left',
+  height: 21,
+  width: '100%',
+  cellStyle: 'OBFormField',
+  titleStyle: 'OBFormFieldLabel',
+  textBoxStyle: 'OBFormFieldInput'
+});
+
 isc.OBTextAreaItem.addProperties({
   errorOrientation: 'left',
   height: 66,
diff -r 4dbbf8721b30 -r fb9bed128a38 
modules/org.openbravo.client.kernel/src-db/database/sourcedata/OBCLKER_UIDEFINITION.xml
--- 
a/modules/org.openbravo.client.kernel/src-db/database/sourcedata/OBCLKER_UIDEFINITION.xml
   Fri Jan 28 15:38:24 2011 +0100
+++ 
b/modules/org.openbravo.client.kernel/src-db/database/sourcedata/OBCLKER_UIDEFINITION.xml
   Fri Jan 28 15:57:55 2011 +0100
@@ -100,6 +100,16 @@
 <!--3969CD80A95047038FD4A03BCCEB8692-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3969CD80A95047038FD4A03BCCEB8692--></OBCLKER_UIDEFINITION>
 
+<!--39E287640048477A929A6702222281F1--><OBCLKER_UIDEFINITION>
+<!--39E287640048477A929A6702222281F1-->  
<OBCLKER_UIDEFINITION_ID><![CDATA[39E287640048477A929A6702222281F1]]></OBCLKER_UIDEFINITION_ID>
+<!--39E287640048477A929A6702222281F1-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--39E287640048477A929A6702222281F1-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--39E287640048477A929A6702222281F1-->  
<AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
+<!--39E287640048477A929A6702222281F1-->  
<AD_REFERENCE_ID><![CDATA[16EC6DF4A59747749FDF256B7FBBB058]]></AD_REFERENCE_ID>
+<!--39E287640048477A929A6702222281F1-->  
<CLASSNAME><![CDATA[org.openbravo.client.kernel.reference.PasswordUIDefinition]]></CLASSNAME>
+<!--39E287640048477A929A6702222281F1-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--39E287640048477A929A6702222281F1--></OBCLKER_UIDEFINITION>
+
 <!--3C4713015FD148DEAAFAD01193640AA1--><OBCLKER_UIDEFINITION>
 <!--3C4713015FD148DEAAFAD01193640AA1-->  
<OBCLKER_UIDEFINITION_ID><![CDATA[3C4713015FD148DEAAFAD01193640AA1]]></OBCLKER_UIDEFINITION_ID>
 <!--3C4713015FD148DEAAFAD01193640AA1-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 4dbbf8721b30 -r fb9bed128a38 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/PasswordUIDefinition.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/PasswordUIDefinition.java
   Fri Jan 28 15:57:55 2011 +0100
@@ -0,0 +1,53 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2010 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.client.kernel.reference;
+
+import org.openbravo.model.ad.ui.Field;
+
+/**
+ * Implementation of the encrypted string (password) ui definition. This 
UIDefinition is used for
+ * both encrypted (reversible) and hashed storage of passwords.
+ * 
+ * @author shuehner
+ * @See org.openbravo.base.model.domaintype.HashedStringDomainType
+ * @See org.openbravo.base.model.domaintype.EncryptedStringDomainType
+ */
+public class PasswordUIDefinition extends StringUIDefinition {
+
+  @Override
+  public String getFormEditorType() {
+    return "OBEncryptedItem";
+  }
+
+  // disable display of raw-value in grid mode
+  @Override
+  public String getTypeProperties() {
+    return "shortDisplayFormatter: function(value, field, component, record) {"
+        + "return new Array((value && value.length > 0 ? value.length+1 : 
0)).join(\"*\");" + "},"
+        + "normalDisplayFormatter: function(value, field, component, record) {"
+        + "return new Array((value && value.length > 0 ? value.length+1 : 
0)).join(\"*\");" + "},";
+  }
+
+  // disable hover as it would show useless raw-value
+  @Override
+  protected String getShowHoverGridFieldSettings(Field field) {
+    return "";
+  }
+
+}
diff -r 4dbbf8721b30 -r fb9bed128a38 
modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonToDataConverter.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonToDataConverter.java
        Fri Jan 28 15:38:24 2011 +0100
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonToDataConverter.java
        Fri Jan 28 15:57:55 2011 +0100
@@ -31,10 +31,10 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.log4j.Logger;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
-import org.jfree.util.Log;
 import org.openbravo.base.exception.OBException;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.Property;
@@ -105,6 +105,7 @@
  * @author mtaal
  */
 public class JsonToDataConverter {
+  private static final Logger log = 
Logger.getLogger(JsonToDataConverter.class);
 
   private static final String DOT = ".";
 
@@ -457,7 +458,7 @@
           qry.setFilterOnReadableOrganization(false);
           final List<BaseOBObject> result = qry.list();
           if (result.size() > 1) {
-            Log.warn("More than one result when querying " + entity + " using 
property "
+            log.warn("More than one result when querying " + entity + " using 
property "
                 + property.getReferencedProperty() + " with value " + 
referencedId
                 + ", choosing the first result");
             value = result.get(0);
diff -r 4dbbf8721b30 -r fb9bed128a38 src-db/database/sourcedata/AD_REFERENCE.xml
--- a/src-db/database/sourcedata/AD_REFERENCE.xml       Fri Jan 28 15:38:24 
2011 +0100
+++ b/src-db/database/sourcedata/AD_REFERENCE.xml       Fri Jan 28 15:57:55 
2011 +0100
@@ -4358,6 +4358,22 @@
 <!--08622CB965B844CFBD2A337BEDB70EFD-->  
<ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--08622CB965B844CFBD2A337BEDB70EFD--></AD_REFERENCE>
 
+<!--16EC6DF4A59747749FDF256B7FBBB058--><AD_REFERENCE>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<AD_REFERENCE_ID><![CDATA[16EC6DF4A59747749FDF256B7FBBB058]]></AD_REFERENCE_ID>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  <NAME><![CDATA[Password 
(decryptable)]]></NAME>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  <DESCRIPTION><![CDATA[A password 
which is shown with * in the UI and stored in a way so that the cleartext value 
can be recovered.]]></DESCRIPTION>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  <HELP><![CDATA[The value of the 
password is encrypted when being saved, however in a way that the cleartext 
password (as entered) can be recovered. Example use-case is to store a password 
which needs to be passed later as cleartext to some external service (i.e. a 
email server password)]]></HELP>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<ISBASEREFERENCE><![CDATA[Y]]></ISBASEREFERENCE>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<MODEL_IMPL><![CDATA[org.openbravo.base.model.domaintype.EncryptedStringDomainType]]></MODEL_IMPL>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<WAD_IMPL><![CDATA[org.openbravo.wad.controls.WADString]]></WAD_IMPL>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<UI_IMPL><![CDATA[org.openbravo.reference.ui.UIString]]></UI_IMPL>
+<!--16EC6DF4A59747749FDF256B7FBBB058-->  
<ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
+<!--16EC6DF4A59747749FDF256B7FBBB058--></AD_REFERENCE>
+
 <!--1722C8B5D1BC4B349332167C3E3A4561--><AD_REFERENCE>
 <!--1722C8B5D1BC4B349332167C3E3A4561-->  
<AD_REFERENCE_ID><![CDATA[1722C8B5D1BC4B349332167C3E3A4561]]></AD_REFERENCE_ID>
 <!--1722C8B5D1BC4B349332167C3E3A4561-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -5023,6 +5039,22 @@
 <!--C01DEDDA9B35427786058CB649FB972F-->  
<ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--C01DEDDA9B35427786058CB649FB972F--></AD_REFERENCE>
 
+<!--C5C21C28B39E4683A91779F16C112E40--><AD_REFERENCE>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<AD_REFERENCE_ID><![CDATA[C5C21C28B39E4683A91779F16C112E40]]></AD_REFERENCE_ID>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C5C21C28B39E4683A91779F16C112E40-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C5C21C28B39E4683A91779F16C112E40-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C5C21C28B39E4683A91779F16C112E40-->  <NAME><![CDATA[Password (not 
decryptable)]]></NAME>
+<!--C5C21C28B39E4683A91779F16C112E40-->  <DESCRIPTION><![CDATA[A password 
which is shown with * in the UI; the cleartext value cannot be recovered as 
only a hashed value is stored]]></DESCRIPTION>
+<!--C5C21C28B39E4683A91779F16C112E40-->  <HELP><![CDATA[Fro this type of 
passwords only a hashed value is stored in the database. It is possible to 
verify if the same value was entered (to implement a password check), however 
it is not possible to recover the cleartext value again.]]></HELP>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<ISBASEREFERENCE><![CDATA[Y]]></ISBASEREFERENCE>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<MODEL_IMPL><![CDATA[org.openbravo.base.model.domaintype.HashedStringDomainType]]></MODEL_IMPL>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<WAD_IMPL><![CDATA[org.openbravo.wad.controls.WADString]]></WAD_IMPL>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<UI_IMPL><![CDATA[org.openbravo.reference.ui.UIString]]></UI_IMPL>
+<!--C5C21C28B39E4683A91779F16C112E40-->  
<ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
+<!--C5C21C28B39E4683A91779F16C112E40--></AD_REFERENCE>
+
 <!--D15C950D445D408E8CC8135E530C246B--><AD_REFERENCE>
 <!--D15C950D445D408E8CC8135E530C246B-->  
<AD_REFERENCE_ID><![CDATA[D15C950D445D408E8CC8135E530C246B]]></AD_REFERENCE_ID>
 <!--D15C950D445D408E8CC8135E530C246B-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 4dbbf8721b30 -r fb9bed128a38 
src/org/openbravo/base/model/domaintype/EncryptedStringDomainType.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/base/model/domaintype/EncryptedStringDomainType.java    
Fri Jan 28 15:57:55 2011 +0100
@@ -0,0 +1,32 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2011 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.model.domaintype;
+
+/**
+ * The type for storing passwords. The value is encrypted before being saved 
in the database. The
+ * cleartext value can be recovered by calling the {@link 
org.openbravo.utils.CryptoUtility#decrypt
+ * decrypt} function.
+ * 
+ * @author shuehner
+ * @see org.openbravo.utils.CryptoUtility#encrypt
+ */
+public class EncryptedStringDomainType extends StringDomainType {
+
+}
diff -r 4dbbf8721b30 -r fb9bed128a38 
src/org/openbravo/base/model/domaintype/HashedStringDomainType.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/base/model/domaintype/HashedStringDomainType.java       
Fri Jan 28 15:57:55 2011 +0100
@@ -0,0 +1,31 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2011 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.base.model.domaintype;
+
+/**
+ * The type for storing passwords. Only a hash-code of the value is stored in 
the database so the
+ * cleartext value cannot be recovered.
+ * 
+ * @author shuehner
+ * @see org.openbravo.utils.CryptoSHA1BASE64#hash(String)
+ */
+public class HashedStringDomainType extends StringDomainType {
+
+}

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to