• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
SOLVED] Re: D2W Custom component
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SOLVED] Re: D2W Custom component


  • Subject: SOLVED] Re: D2W Custom component
  • From: Erwin <email@hidden>
  • Date: Fri, 22 Apr 2005 08:29:47 +0200

Thanks Chuck, I did not realize this 'double encrypting' possibility... but why '... you risk.. having' ?
is it not a repetitive behavior ? does this 'side effect' happen randomly ? I still have to re-read this chap 3
(btw , I re-read WPO that I'll have to buy another copy before end 2005.. ;-)))


As I was encrypting only the password (creating new records in DB for tests) I did it easily with your trick....
I'll not do much with D2W


Beside this simple need, I was trying to understand how to perform more complicated work on the data record before saving it to DB.... so I read back PWO Book (chap 3) again, and I realize that placing values was not so simple as performing data initialization... hopefully it's well explained in this chapter.... and it worth taking care of it from the beginning


Le Apr 21, 2005, à 7:23 PM, Chuck Hill a écrit :

Yes, using the EOStateTransition interface will work for this. However, if the method below is setPassword and you are just encrypting it, then it might not be a horrible thing to do. However, doing it like that you risk having EOF call this method with the already encrypted password and double encrypting it. I'd add another method, setPlainTextPassword(), bind to that, and then in that method do the encrypting and pass the value off to setPassword().

Chuck



On Apr 21, 2005, at 3:51 AM, Erwin wrote:

As I use D2W for the first time, I try to understand where and when I can modify EO records before Save..
I found a trick but its only a trick :
in D2WEditPassword


    public void setValue(String newValue) {
		Siteuser aUser = (Siteuser) new Administrator();
		String epwValue = aUser.getEncryptedPassword(newValue);
        object.takeValueForKey(epwValue, key);
    }

It works fine , I can save a new record with encrypted password...

BUT I am sure that's not the correct way to do that...

In Siteuser.java, I can initialize the EO record with :
	public void awakeFromInsertion(EOEditingContext editingContext) {
...
	}

I should be able also to modify a value before insertion... using saveChange() or better
using willUpdate() in the EOStateTransition interface from PWO maybe
I am not sure ...



Erwin

Le Apr 21, 2005, à 2:18 AM, John Bruce a écrit :

I set values in my D2W components this way:

public void takeValuesFromRequest(WORequest request, WOContext
context) throws NSValidation.ValidationException {
		super.takeValuesFromRequest(request, context);

		if (isEdit()) {
			object().takeValueForKeyPath(value, propertyKey());
		}
	}

also in this case I'd separate out the encrytion method and call it
directly - so for example I would have in Siteuser.java

public void encryptAndSetPassword(final String password) {

this.setPassword(transformString(password, Cipher.ENCRYPT_MODE));

}

then modify the D2W component to include:

public void takeValuesFromRequest(WORequest request, WOContext
context) throws NSValidation.ValidationException {
		super.takeValuesFromRequest(request, context);

		if (isEdit()) {
                        Siteuser user = (Siteuser)object();
                        user.encryptAndSetPassword(value);
		}
	}

I'm not sure what specifically is causing your problem without seeing
more code but the above is the way I would've implemented it.

HTH

Cheers,

John

On 4/21/05, Erwin <email@hidden> wrote:
I am trying to use (for the 1st time) D2W to test my EOModel
I have a D2WEditPassword custom component that's doing its job (take
the value in a pwd Txtfield)

D2WEditpassword.java  (extends WOComponent)
.....
     public String value() {
         return (String) object.valueForKey(key);
     }
     public void setValue(String newValue) {
         object.takeValueForKey(newValue, key);
     }
.....

I would like this value to be encrypted via the setPassword() in my
Siteuser class before being written to the DB
(as it will be in my WOApp) but I just get the String value in my
DB..... why ? how can I do it ? (hint in doc...)
Thanks  erwin

Siteuser.java (extends EOGenericRecord)
.....
public void setPassword(String password){
setCredential(transformString(password, Cipher.ENCRYPT_MODE));
}
....



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village.net


This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >D2W Custom component (From: Erwin <email@hidden>)
 >Re: D2W Custom component (From: John Bruce <email@hidden>)
 >Re: D2W Custom component (From: Erwin <email@hidden>)
 >Re: D2W Custom component (From: Chuck Hill <email@hidden>)

  • Prev by Date: AJAX and WebObjects?
  • Next by Date: Re: WOHyperlink secure binding and insecure domain
  • Previous by thread: Re: D2W Custom component
  • Next by thread: New mySQL Exception
  • Index(es):
    • Date
    • Thread