openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saibabu Vallurupalli <saibabu.vallurupa...@gmail.com>
Subject Re: Encryption and Decryption
Date Tue, 12 Jul 2011 16:29:30 GMT
Rick,

This is where exactly the message construction is called. I modified
JPAMessage.java file and this has constructors initiating the actual message
creation. The entity attributes are filled in and this is the place where
the @Externalizer and @Factory annotations get initiated.

I attached the Java files for your convenience. Let me know if you didn't
get them. Thank you very much.

Thanks,
Sai



On Tue, Jul 12, 2011 at 12:04 PM, Rick Curtis <curtisr7@gmail.com> wrote:

> OpenJPA-2.0.1 should fully support Externalizer / Factory. What are you
> trying to do on this line JPAMailboxMembership.java:59 ?
>
> On Tue, Jul 12, 2011 at 10:54 AM, Saibabu Vallurupalli <
> saibabu.vallurupalli@gmail.com> wrote:
>
> > Hi Rick,
> >
> > Yesterday I completed the development and spent lot of time in deploying
> to
> > run the tests. I did this fix in Apache James Mailbox/JPA environment.
> > Was not able to fix the other issue with runtime, after deploying and
> > starting James server it comes up well. During runtime when I am sending
> an
> > email IMAP Server fails throwing error as below:
> > ***************
> > DEBUG 13:57:43,019 | james.imapserver | ID=171407124 Error while
> processing
> > imap request
> > java.lang.NoSuchMethodError: org.apache.james.mailbox.jpa.
> >
> >
> mail.model.openjpa.JPAMessage.<init>(Ljava/io/InputStream;JILjava/util/List;Lorg/apache/james/mailbox/store/mail/model/PropertyBuilder;)V
> >    at
> >
> >
> org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMailboxMembership.<init>(JPAMailboxMembership.java:59)
> > ***************
> >
> > I am wondering if this has something to do with OpenJPA version I am
> using
> > as part of Apache James.
> > When I went and looked under James/lib folder I see "openjpa-2.0.1.jar".
> Is
> > this is correct JAR supporting the @Externalizer and @Factory
> > implementations?
> >
> > Please advise.
> >
> > Thank you,
> > Sai
> >
> >
> >
> >
> >
> > On Mon, Jul 11, 2011 at 11:41 AM, Rick Curtis <curtisr7@gmail.com>
> wrote:
> >
> > > 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*
> > >
> >
>
>
>
> --
> *Rick Curtis*
>

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