Re: [appengine-java] Re: Serializing crypto classes

2011-11-18 Thread Thales Cloud
I'm now storing the relevant data as byte[] and it appears to be working 
fine.

Thanks again for pointing me in the right direction!

Pete.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/suSwVb4ws40J.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Serializing crypto classes

2011-11-16 Thread Thales Cloud
Thanks Gerald, Jeff,

This tells me what I need to know. We will approach the problem 
differently, to avoid storing the data in this form.

Pete.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/3FPuM1sZpjkJ.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Serializing crypto classes

2011-11-15 Thread Gerald Tan
Only Serializable objects can be used as properties, and Cipher isn't 
serializable. The solution is to store the algorithm as a String, then 
reinstantiating the Cipher from the algorithm string after retrieving it 
from the datastore.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/lVE027ITKAEJ.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Serializing crypto classes

2011-11-15 Thread Jeff Schnitzer
On Tue, Nov 15, 2011 at 10:30 PM, Gerald Tan woefulwab...@gmail.com wrote:

 Only Serializable objects can be used as properties, and Cipher isn't
 serializable. The solution is to store the algorithm as a String, then
 reinstantiating the Cipher from the algorithm string after retrieving it
 from the datastore.


This is almost right - it's not about being Serializable.

GAE only lets you store certain basic types (Long, String, Text, Blob,
GeoPt, and about a dozen others including collections of these types).
 They aren't stored with java serialization; I believe the native structure
is protobuf but this is opaque outside of Google.  Objectify extends this
list somewhat by automatically converting some types into ones the
datastore recognizes (for example, String[] into ListString, byte[] into
Blob, fields with @Serialized annotation into Blob, etc).  But there are
practical limits.  We didn't go through every single JDK class figuring out
how to store it in appengine.

Cipher, IvParameterSpec, SecretKeySpec are not storeable types.  Cipher
doesn't even make sense to store - you probably just want to store the
algorithm with which the Cipher was created.  IvParameterSpec and
SecretKeySpec are probably best stored as byte[] (which Ofy will convert to
Blob) or, if you prefer, can be Base64 or hex encoded into a String.

There are situations when you will want to build Objectify Converters so
that fields can have normal types; for example, if you use Joda Time or
Joda Money classes (Objectify includes converters for these, but they
aren't enabled by default).  I won't tell you that it's wrong to use
IvParameterSpec and SecretKeySpec fields, but for the most part you should
be cautious of using exotic types in your data model - especially when they
are interfaces without a concrete type definition.  I wouldn't do it.

Jeff

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.