Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4B21268B6 for ; Tue, 12 Jul 2011 15:54:46 +0000 (UTC) Received: (qmail 31562 invoked by uid 500); 12 Jul 2011 15:54:46 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 31494 invoked by uid 500); 12 Jul 2011 15:54:45 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 31486 invoked by uid 99); 12 Jul 2011 15:54:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2011 15:54:45 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of saibabu.vallurupalli@gmail.com designates 209.85.213.174 as permitted sender) Received: from [209.85.213.174] (HELO mail-yx0-f174.google.com) (209.85.213.174) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2011 15:54:38 +0000 Received: by yxi11 with SMTP id 11so2602084yxi.33 for ; Tue, 12 Jul 2011 08:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=uqQNy8gOJuNUObSJVnPqBxEevJOno5JPMMDFoKczux4=; b=m9sUr17LHJXslK164Z5kfpZGFZMwdrxnSXIR3oL3C6jPmprObePKPOAp8mxsrCqh4B l9X9c3WfT/1/IFHoKm6JnsyJyHpAssvo8WoFgZrLEuVD+DvZLfZ5hI2VSXoS1rpVfrkI FEFphsBR9rcwQ8yrs82SrGxNKCAhfrlV6vRQM= MIME-Version: 1.0 Received: by 10.150.60.19 with SMTP id i19mr241016yba.270.1310486057833; Tue, 12 Jul 2011 08:54:17 -0700 (PDT) Received: by 10.146.168.18 with HTTP; Tue, 12 Jul 2011 08:54:17 -0700 (PDT) In-Reply-To: References: <1310086245721-6560604.post@n2.nabble.com> <1310157435767-6564070.post@n2.nabble.com> <1310158653372-6564126.post@n2.nabble.com> Date: Tue, 12 Jul 2011 11:54:17 -0400 Message-ID: Subject: Re: Encryption and Decryption From: Saibabu Vallurupalli To: dev@openjpa.apache.org Content-Type: multipart/alternative; boundary=000e0cd6a7b6f5d6ba04a7e14f0d --000e0cd6a7b6f5d6ba04a7e14f0d Content-Type: text/plain; charset=ISO-8859-1 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.(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.(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 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 > 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: > > > > 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* > --000e0cd6a7b6f5d6ba04a7e14f0d--