Hi Lasantha, Please find my comments inline.
> As sajith said can read certificate file using Jaggery File object. But > is there a way to get public key from that way?? > You cannot get the public key using Jaggery File object since File object represent a file, not a security certificate. *code* > inputStream = new Packages.java.io.FileInputStream(certificatePath); > var key = > Packages.java.security.cert.CertificateFactory.getInstance("X.509").generateCertificate(inputStream).getPublicKey(); > This Java code should work. Set certificatePath = "/repository/deployment/server/jaggeryapps/Parkingapp/resources/wso2defaultpub.ce" . Thanks. On Thu, Oct 1, 2015 at 7:29 AM, Lasantha Dharmakeerthi <lasant...@wso2.com> wrote: > Hi > All > > I use java inside my jaggery app to read certificate file and get public > key. > > *code* > inputStream = new Packages.java.io.FileInputStream(certificatePath); > var key = > Packages.java.security.cert.CertificateFactory.getInstance("X.509").generateCertificate(inputStream).getPublicKey(); > > As sajith said can read certificate file using Jaggery File object. But > is there a way to get public key from that way?? > > Can't I read certificate file in my application context by giving path > likewise in my local app ? > > If it is possible to read file as in local app how can I get absolute path > to my certificate file in cloud app?? > > *url* > > https://appserver.dev.cloud.wso2.com/t/dlpds3331/jaggeryapps/wso2parkingapp-default-SNAPSHOT > > Thanks > Lasantha. > > > > > On Wed, Sep 30, 2015 at 7:50 PM, Sajith Ariyarathna <sajit...@wso2.com> > wrote: > >> Hi Lasantha, >> >> Jaggery server runs on top of Carbon. So Java libraries which are added >> to Carbon are also available in Jaggery. External Java libraries can be >> added to Carbon by dropping them into <CARBON_PRODUCT_HOME> >> /repository/components/lib directory (more details [1]). Don't forget to >> restart the server. >> >> [1] >> http://wso2.com/library/knowledgebase/add-external-jar-libraries-wso2-carbon-based-products/ >> >> >> On Wed, Sep 30, 2015 at 4:40 PM, Lasantha Dharmakeerthi < >> lasant...@wso2.com> wrote: >> >>> hi >>> Sajitha >>> >>> I use some .jar files and I have included them into components/lib >>> folder. Can I add those .jar files inside the jagerry app and use to get >>> same functionalities? >>> >>> Above code is working well when I give absolute path. >>> >>> Thanks >>> >>> Lasantha >>> >>> On Wed, Sep 30, 2015 at 4:38 PM, Lasantha Dharmakeerthi < >>> lasant...@wso2.com> wrote: >>> >>>> Hi >>>> Sajith >>>> >>>> Can I get public key of certificate using this way. I tried this one >>>> but couldn't get public key. >>>> >>>> this is the my code >>>> >>>> function getPublicKey(certificatePath){ >>>> >>>> var inputStream = null; >>>> >>>> try{ >>>> >>>> log.debug("Reading certificate from "); >>>> inputStream = new >>>> Packages.java.io.FileInputStream(certificatePath); >>>> >>>> var key = >>>> Packages.java.security.cert.CertificateFactory.getInstance("X.509").generateCertificate(inputStream).getPublicKey(); >>>> >>>> return key; >>>> }catch(e){ >>>> log.error("Error while getting the public key. " + e); >>>> throw e; >>>> }finally{ >>>> >>>> if(inputStream){ >>>> inputStream.close(); >>>> } >>>> } >>>> >>>> return null; >>>> >>>> } >>>> >>>> Thanks >>>> Lasantha >>>> >>>> On Wed, Sep 30, 2015 at 4:23 PM, Sajith Ariyarathna <sajit...@wso2.com> >>>> wrote: >>>> >>>>> Hi Lasantha, >>>>> >>>>> Assuming, >>>>> >>>>> You are reading the certificate file using Jaggery. >>>>> >>>>> In your Jaggery app, certificate file is in ' >>>>> *resources/wso2defaultpub.cer*' path >>>>> >>>>> You can read your file using Jaggery File [1] object. Refer following >>>>> code snippet. >>>>> >>>>> var certFile = new File("/resources/wso2defaultpub.cer"); >>>>> var content = certFile.readAll(); >>>>> >>>>> [1] http://jaggeryjs.org/documentation.jag?api=file >>>>> >>>>> Thanks. >>>>> >>>>> On Wed, Sep 30, 2015 at 3:11 PM, Lasantha Dharmakeerthi < >>>>> lasant...@wso2.com> wrote: >>>>> >>>>>> Hi >>>>>> Devs >>>>>> >>>>>> I have created jaggery app and deployed it in wso2 app cloud. I have >>>>>> method to read a certificate file and certificate is in the jaggery >>>>>> app. >>>>>> >>>>>> In local Aplication Server I used file path like wise “ >>>>>> repository/deployment/server/jaggeryapps/Parkingapp >>>>>> /resources/wso2defaultpub.cer” >>>>>> >>>>>> So how can I get path to my certificate file in WSO2 App Cloud? Is it >>>>>> same structure? >>>>>> >>>>>> Thanks >>>>>> Lasantha. >>>>>> >>>>>> -- >>>>>> Dharmakeerthi Lasantha >>>>>> Software Engineer Trainee, WSO2 >>>>>> Mobile 0774928852 >>>>>> >>>>>> _______________________________________________ >>>>>> Dev mailing list >>>>>> Dev@wso2.org >>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Sajith Ariyarathna >>>>> Software Engineer; WSO2, Inc.; http://wso2.com/ >>>>> mobile: +94 77 6602284, +94 71 3951048 >>>>> >>>> >>>> >>>> >>>> -- >>>> Dharmakeerthi Lasantha >>>> Software Engineer Trainee, WSO2 >>>> Mobile 0774928852 >>>> >>> >>> >>> >>> -- >>> Dharmakeerthi Lasantha >>> Software Engineer Trainee, WSO2 >>> Mobile 0774928852 >>> >> >> >> >> -- >> Sajith Ariyarathna >> Software Engineer; WSO2, Inc.; http://wso2.com/ >> mobile: +94 77 6602284, +94 71 3951048 >> > > > > -- > Dharmakeerthi Lasantha > Software Engineer Trainee, WSO2 > Mobile 0774928852 > -- Sajith Ariyarathna Software Engineer; WSO2, Inc.; http://wso2.com/ mobile: +94 77 6602284, +94 71 3951048
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev