|
Author: jleroux
Date: Sat Nov 21 13:10:07 2009 New Revision: 882892 URL: http://svn.apache.org/viewvc?rev=882892&view=rev Log: Add an EncryptedString format possibilities in datafile (use in Record.java, needed some changes to build in framework/build.xml and datafile/build.xml) + datafile/dtd/datafiles.xsd enhanced with some documentations, and an enumeration for the type: I used all occurrences found in Record.setString() method) + datafile/dtd/datafiles-catalog.xml added + Few generics cleaning in login/LoginServices.java Added: ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml (with props) Modified: ofbiz/trunk/framework/build.xml ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java ofbiz/trunk/framework/datafile/build.xml ofbiz/trunk/framework/datafile/dtd/datafiles.xsd ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java Modified: ofbiz/trunk/framework/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/build.xml?rev=882892&r1=882891&r2=882892&view=diff ============================================================================== --- ofbiz/trunk/framework/build.xml (original) +++ ofbiz/trunk/framework/build.xml Sat Nov 21 13:10:07 2009 @@ -27,9 +27,9 @@ catalina/build.xml,jetty/build.xml, security/build.xml,service/build.xml,entityext/build.xml, webslinger/build.xml, - bi/build.xml,datafile/build.xml,minilang/build.xml, + bi/build.xml,minilang/build.xml, webapp/build.xml,guiapp/build.xml,widget/build.xml, - common/build.xml, + common/build.xml,datafile/build.xml, testtools/build.xml, appserver/build.xml,webtools/build.xml,example/build.xml"/> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java?rev=882892&r1=882891&r2=882892&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java Sat Nov 21 13:10:07 2009 @@ -23,7 +23,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.io.Serializable; import javax.transaction.Transaction; @@ -36,6 +35,8 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.common.authentication.AuthHelper; +import org.ofbiz.common.authentication.api.AuthenticatorException; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -48,13 +49,11 @@ import org.ofbiz.entity.util.EntityFindOptions; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.security.Security; -import org.ofbiz.common.authentication.api.AuthenticatorException; import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; import org.ofbiz.service.ServiceUtil; -import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.control.LoginWorker; -import org.ofbiz.common.authentication.AuthHelper; /** * <b>Title:</b> Login Services @@ -237,8 +236,7 @@ if (!isServiceAuth) { // get the UserLoginSession if this is not a service auth - Map userLoginSessionMap = LoginWorker.getUserLoginSession(userLogin); - GenericValue userLoginSession = null; + Map<?, ?> userLoginSessionMap = LoginWorker.getUserLoginSession(userLogin); // return the UserLoginSession Map if (userLoginSessionMap != null) { Modified: ofbiz/trunk/framework/datafile/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/datafile/build.xml?rev=882892&r1=882891&r2=882892&view=diff ============================================================================== --- ofbiz/trunk/framework/datafile/build.xml (original) +++ ofbiz/trunk/framework/datafile/build.xml Sat Nov 21 13:10:07 2009 @@ -39,6 +39,7 @@ <fileset dir="../base/build/lib" includes="*.jar"/> <fileset dir="../entity/lib" includes="*.jar"/> <fileset dir="../entity/build/lib" includes="*.jar"/> + <fileset dir="../common/build/lib" includes="*.jar"/> </path> <!-- ================================================================== --> Added: ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml?rev=882892&view=auto ============================================================================== --- ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml (added) +++ ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml Sat Nov 21 13:10:07 2009 @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" + "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> +<!-- + Comment the DTD declaration to avoid looking for it on the web. + Alternatively we can place a copy of the DTD locally and refer to it. +--> +<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> + <!-- <public publicId="-//W3C//DTD SVG 1.0//EN" uri="svg10.dtd"/> --> + + <system systemId="http://ofbiz.apache.org/dtds/datafiles.xsd" uri="datafiles.xsd"/> +</catalog> Propchange: ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/datafile/dtd/datafiles-catalog.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/framework/datafile/dtd/datafiles.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/datafile/dtd/datafiles.xsd?rev=882892&r1=882891&r2=882892&view=diff ============================================================================== --- ofbiz/trunk/framework/datafile/dtd/datafiles.xsd (original) +++ ofbiz/trunk/framework/datafile/dtd/datafiles.xsd Sat Nov 21 13:10:07 2009 @@ -92,11 +92,37 @@ </xs:complexType> </xs:element> <xs:attributeGroup name="attlist.field"> - <xs:attribute name="name" use="required"/> + <xs:attribute name="name" type="xs:string" use="required"/> <xs:attribute name="position"/> <xs:attribute name="length"/> - <xs:attribute name="type" use="required"/> - <xs:attribute name="format"/> + <xs:attribute name="type" use="required"> + <xs:annotation><xs:documentation>The field type is always required. See more about the type attribure in Record.setString() method</xs:documentation></xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="CustomDate"/> + <xs:enumeration value="CustomTime"/> + <xs:enumeration value="FixedPointDouble"/> + <xs:enumeration value="java.lang.String"/> + <xs:enumeration value="String"/> + <xs:enumeration value="java.sql.Timestamp"/> + <xs:enumeration value="Timestamp"/> + <xs:enumeration value="java.sql.Time"/> + <xs:enumeration value="Time"/> + <xs:enumeration value="java.lang.Integer"/> + <xs:enumeration value="Integer"/> + <xs:enumeration value="java.lang.Long"/> + <xs:enumeration value="Long"/> + <xs:enumeration value="java.lang.Float"/> + <xs:enumeration value="Float"/> + <xs:enumeration value="java.lang.Double"/> + <xs:enumeration value="Double"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="format"> + <xs:annotation><xs:documentation>You may use EncryptedString if you want to encrypt the string (password for instance). See more in Record.setString() method.</xs:documentation></xs:annotation> + </xs:attribute> + <xs:attribute name="valid-exp"/> <xs:attribute name="description"/> <xs:attribute name="default-value"/> Modified: ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java?rev=882892&r1=882891&r2=882892&view=diff ============================================================================== --- ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java (original) +++ ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java Sat Nov 21 13:10:07 2009 @@ -27,12 +27,16 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.StringTokenizer; import java.util.NoSuchElementException; +import java.util.StringTokenizer; + +import org.ofbiz.base.crypto.HashCrypt; +import org.ofbiz.common.login.LoginServices; /** * Record */ +@SuppressWarnings("serial") public class Record implements Serializable { /** Contains a map with field data by name */ @@ -197,7 +201,7 @@ (long)(byteArray[0]&0xff); } - /** Sets the named field to the passed value, converting the value from a String to the corrent type using <code>Type.valueOf()</code> + /** Sets the named field to the passed value, converting the value from a String to the current type using <code>Type.valueOf()</code> * @param name The field name to set * @param value The String value to convert and set */ @@ -262,7 +266,12 @@ set(name, Double.valueOf(number)); } // standard types else if (fieldType.equals("java.lang.String") || fieldType.equals("String")) - set(name, value); + if (field.format.equals("EncryptedString")) { + String hashType = LoginServices.getHashType(); + set(name, HashCrypt.getDigestHash(value, hashType)); + } else { + set(name, value); + } else if (fieldType.equals("NullTerminatedString")) { int terminate = value.indexOf(0x0); set(name, terminate>0?value.substring(0,terminate):value); |
| Free forum by Nabble | Edit this page |
