openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Encryption and Decryption
Date Mon, 11 Jul 2011 15:41:04 GMT
Great! Let us know how it goes.

On Mon, Jul 11, 2011 at 10:31 AM, Saibabu Vallurupalli <
saibabu.vallurupalli@gmail.com> wrote:

> Hi Rick,
> After running into the issue I mentioned above. I read the documentation of
> using @Externalizer / @Factory annotations and tried something below:
>
> Modified org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMessage.java by
> adding the lines below:
> *************
> /** The value for the body field. Lazy loaded */
>    /** We use a max length to represent 1gb data. Thats prolly overkill,
> but who knows */
>     @Basic(optional = false, fetch = FetchType.LAZY)
>    @Column(name = "MAIL_BYTES", length = 1048576000, nullable = false)
>    * @Externalizer("CustomJPAMessage.getEncryptedMessage")
>    @Factory("CustomJPAMessage.getDecryptedMessage")*
>    @Lob private byte[] body;
> *************
>
> Created CustomerJPAMessage java class and added the methods like below:
> *************
> package org.apache.james.mailbox.jpa.mail.model.openjpa;
>
> public class CustomJPAMessage
> {
>
>    public static byte[] getEncryptedMessage(byte[] body)
>    {
>        return body;
>    }
>
>    public static byte[] getDecryptedMessage(byte[] body)
>    {
>        return body;
>    }
> }
> *************
>
> Everything worked great. Now, I understood how to use these annotations.
>
> Working on using JASYPT API.
>
> Thank you all so much for putting me in right direction.
>
> Thanks,
> Sai
>
>
> On Mon, Jul 11, 2011 at 10:27 AM, Rick Curtis <curtisr7@gmail.com> wrote:
>
> > Saibabu -
> >
> > I'll put together a small example of how to use @Externalizer / @Factory
> > with JASYPT sometime here this morning.
> >
> > Thanks,
> > Rick
> >
> > On Mon, Jul 11, 2011 at 7:58 AM, Saibabu Vallurupalli <
> > saibabu.vallurupalli@gmail.com> wrote:
> >
> > > Hi Pinaki,
> > >
> > > Good morning.
> > > I tried the approach of using @Externalizer annotation as below and got
> > an
> > > error says @Externalizer can be only used for methods not for fields.
> > Then
> > > I
> > > have gone through the documentation and found I should be using
> > > @ExternalValues and after using I started getting error as below:
> > >
> > > ***********
> > > Caused by: <openjpa-2.1.0-r422266:1071316 fatal user error>
> > > org.apache.openjpa.p
> > > ersistence.ArgumentException: The field
> > > "org.apache.james.mailbox.jpa.mail.model
> > > .openjpa.JPAMessage.body" cannot use the external-values property.
> > External
> > > valu
> > > es can only be declared for fields of primitives, primitive wrappers,
> or
> > > strings
> > > .
> > >        at
> > > org.apache.openjpa.meta.FieldMetaData.transform(FieldMetaData.java:15
> > > 38)
> > > **********
> > >
> > > Can you please advise me where I am going wrong.
> > >
> > > Thank you,
> > > Sai
> > >
> > > On Fri, Jul 8, 2011 at 4:57 PM, pvalluri <
> saibabu.vallurupalli@gmail.com
> > > >wrote:
> > >
> > > > Hi Pinaki,
> > > >
> > > > Yes, This is really easy and cool. I am still in process of setting
> up
> > my
> > > > development environment for James to add this annotation in my class
> > and
> > > a
> > > > question popped up in my mind.
> > > > Just adding annotation will take care of both Encryption/Decryption.
> I
> > > > don't
> > > > have to do anything else :-)
> > > > Can't believe, Thanks so much for suggesting this solution.
> > > >
> > > > I have a class with filed declared as shown below:
> > > > *********
> > > > public class JPAMessage extends AbstractJPAMessage {
> > > >
> > > >    /** The value for the body field. Lazy loaded */
> > > >    /** We use a max length to represent 1gb data. Thats prolly
> > overkill,
> > > > but who knows */
> > > >     @Externalizer
> > > >     @Basic(optional = false, fetch = FetchType.LAZY)
> > > >    @Column(name = "MAIL_BYTES", length = 1048576000, nullable =
> false)
> > > >    @Lob private byte[] body;
> > > >
> > > > // methods related to this class getter and creator...here...
> > > > }
> > > > ********
> > > > Is this the correct way of doing it. Sorry for asking the same
> question
> > > > again. I am very new to OpenJPA and this has become real critical for
> > us.
> > > >
> > > > Thank you very much in advance.
> > > >
> > > > Thanks, Sai.
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > *Rick Curtis*
> >
>



-- 
*Rick Curtis*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message