Jasypt Users Forum

setting environment variables

View: New views
3 Messages — Rating Filter:   Alert me  

setting environment variables

by Biswanath :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
  i am using iasypt library for encrypt and derypt the password of hibernate.cfg.xml.According this site i am doing like
<hibernate-configuration>

        <session-factory>
          <property name="connection.provider_class">
      org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider
    </property>
       <property name="connection.encryptor_registered_name">
      configurationHibernateEncryptor
    </property>
                <property name="connection.username">root</property>
                <property name="connection.url">
                        jdbc:mysql://localhost/
                </property>
                <property name="dialect">
                        org.hibernate.dialect.MySQLDialect
                </property>
                <property name="myeclipse.connection.profile">mysql</property>
                <property name="connection.password">ENC(ABpwtroqwLWCJBWAm9oetdYToGPP9337)</property>
                <property name="connection.driver_class">
                        com.mysql.jdbc.Driver
                </property>
                <mapping resource="com/genie/hibernate/User.hbm.xml" />

        </session-factory>

</hibernate-configuration>
after that the error is coming No String encrypter of this name "configurationHibernateEncryptor"

after that i am creating one java class file HibernatePBEEncryptorRegistry and my code is given below
import org.jasypt.encryption.pbe.PBEStringEncryptor;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;

public final class HibernatePBEEncryptorRegistry
extends Object{
       
        protected PBEStringEncryptor createPBEStringEncryptor() {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        HibernatePBEEncryptorRegistry registry =
            HibernatePBEEncryptorRegistry.getInstance();
        registry.registerPBEStringEncryptor("configurationHibernateEncryptor", encryptor);
        //encryptor.setAlgorithm("PBEWithMD5AndDES");
        return encryptor;
   
       
        }
        private void registerPBEStringEncryptor(String string,
                        StandardPBEStringEncryptor encryptor) {
                // TODO Auto-generated method stub
               
        }
        public static HibernatePBEEncryptorRegistry getInstance(){
                return null;
               
        }
       
}

after that am deployed my application same error is coming No String encrypter of this name "configurationHibernateEncryptor"
.
Please anybody help me about this topic.I am already encrypted the password thing through cil tool.only thing is to decrypt the password.Plese help me this regard otherwise help me in setting the environment variable stuff.

regards
Biswanath

Re: setting environment variables

by dfernandez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

+------------------------+
  Jasypt Users List      
  http://www.jasypt.org 
+------------------------+



This is probably because you are registering the StandardPBEStringEncryptor *after* the hibernate type is being initialized, and so it doesn't find it... it would be better if you called that registration code at deployment time, from a ContextListener declared in web.xml...

Regards,
Daniel.


On Tue, Apr 29, 2008 at 11:53 AM, Biswanath <biswanath.parida@...> wrote:
+------------------------+
 Jasypt Users List
 http://www.jasypt.org
+------------------------+

Hi
 i am using iasypt library for encrypt and derypt the password of
hibernate.cfg.xml.According this site i am doing like
<hibernate-configuration>

       <session-factory>
         <property name="connection.provider_class">

org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider
   </property>
      <property name="connection.encryptor_registered_name">
     configurationHibernateEncryptor
   </property>
               <property name="connection.username">root</property>
               <property name="connection.url">
                       jdbc:mysql://localhost/
               </property>
               <property name="dialect">
                       org.hibernate.dialect.MySQLDialect
               </property>
               <property name="myeclipse.connection.profile">mysql</property>
               <property
name="connection.password">ENC(ABpwtroqwLWCJBWAm9oetdYToGPP9337)</property>
               <property name="connection.driver_class">
                       com.mysql.jdbc.Driver
               </property>
               <mapping resource="com/genie/hibernate/User.hbm.xml" />

       </session-factory>

</hibernate-configuration>
after that the error is coming No String encrypter of this name
"configurationHibernateEncryptor"

after that i am creating one java class file HibernatePBEEncryptorRegistry
and my code is given below
import org.jasypt.encryption.pbe.PBEStringEncryptor;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;

public final class HibernatePBEEncryptorRegistry
extends Object{

       protected PBEStringEncryptor createPBEStringEncryptor() {
       StandardPBEStringEncryptor encryptor = new
StandardPBEStringEncryptor();
       HibernatePBEEncryptorRegistry registry =
           HibernatePBEEncryptorRegistry.getInstance();

registry.registerPBEStringEncryptor("configurationHibernateEncryptor",
encryptor);
       //encryptor.setAlgorithm("PBEWithMD5AndDES");
       return encryptor;


       }
       private void registerPBEStringEncryptor(String string,
                       StandardPBEStringEncryptor encryptor) {
               // TODO Auto-generated method stub

       }
       public static HibernatePBEEncryptorRegistry getInstance(){
               return null;

       }

}

after that am deployed my application same error is coming No String
encrypter of this name "configurationHibernateEncryptor"
.
Please anybody help me about this topic.I am already encrypted the password
thing through cil tool.only thing is to decrypt the password.Plese help me
this regard otherwise help me in setting the environment variable stuff.

regards
Biswanath
--
View this message in context: http://www.nabble.com/setting-environment-variables-tp16957059s21332p16957059.html
Sent from the Jasypt - Users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
jasypt-users mailing list
jasypt-users@...
https://lists.sourceforge.net/lists/listinfo/jasypt-users


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
jasypt-users mailing list
jasypt-users@...
https://lists.sourceforge.net/lists/listinfo/jasypt-users

Re: setting environment variables

by Biswanath :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Daniel

           Thanks for the given idea.According to you i did this type,i created one class named as MyWebPBEInitializer and code of this class given below

import org.apache.log4j.Logger;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.WebPBEConfig;
import org.jasypt.web.pbeconfig.WebPBEInitializer;

public class MyWebPBEInitializer implements WebPBEInitializer {
        // Logger
        private final Logger log = Logger.getLogger(getClass());
         
    public void initializeWebPBEConfigs() {
   
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setAlgorithm("PBEWithMD5AndDES");
       
        WebPBEConfig webConfig = new WebPBEConfig();
        webConfig.setValidationWord("jasypt");
        webConfig.setName("Main Password");

        encryptor.setConfig(webConfig);
       
        // Get some user-defined singleton or similar, and register
        // the encryptor with it so that it can be accessed from the
        // rest of the application.
        HibernatePBEEncryptorRegistry registry =
            HibernatePBEEncryptorRegistry.getInstance();
        registry.registerPBEStringEncryptor("HibernateEncryptor", encryptor);
        log.debug("HibernateEncrypter registered");
       
    }
   
}

and after that i registering the context listener in web.xml like this

<context-param>
      <param-name>webPBEInitializerClassName</param-name>
      <param-value>com.genie.jasypt.pbe.MyWebPBEInitializer</param-value>
    </context-param>

    <listener>
      <listener-class>
        org.jasypt.web.pbeconfig.WebPBEInitializationContextListener
      </listener-class>
    </listener>
    <filter>
        <filter-name>webPBEConfigFilter</filter-name>
        <filter-class>org.jasypt.web.pbeconfig.WebPBEConfigFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>webPBEConfigFilter</filter-name>
        <servlet-name>strutsActionServlet</servlet-name>
    </filter-mapping>  

After that i deployed my application then this type of exception happen in console

Apr 30, 2008 10:58:49 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.jasypt.web.pbeconfig.WebPBEInitializationContextListener
java.lang.NullPointerException
        at com.genie.jasypt.pbe.MyWebPBEInitializer.initializeWebPBEConfigs(MyWebPBEInitializer.java:28)
        at org.jasypt.web.pbeconfig.WebPBEInitializationContextListener.contextInitialized(WebPBEInitializationContextListener.java:111)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Apr 30, 2008 10:58:49 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Apr 30, 2008 10:58:49 AM org.apache.catalina.core.StandardContext start

Please Daniel help me.

regards
Biswanath
 


dfernandez wrote:
+------------------------+
  Jasypt Users List      
  http://www.jasypt.org 
+------------------------+

This is probably because you are registering the StandardPBEStringEncryptor
*after* the hibernate type is being initialized, and so it doesn't find
it... it would be better if you called that registration code at deployment
time, from a ContextListener declared in web.xml...

Regards,
Daniel.


On Tue, Apr 29, 2008 at 11:53 AM, Biswanath <biswanath.parida@hotmail.com>
wrote:

> +------------------------+
>  Jasypt Users List
>  http://www.jasypt.org
> +------------------------+
>
> Hi
>  i am using iasypt library for encrypt and derypt the password of
> hibernate.cfg.xml.According this site i am doing like
> <hibernate-configuration>
>
>        <session-factory>
>          <property name="connection.provider_class">
>
>
> org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider
>    </property>
>       <property name="connection.encryptor_registered_name">
>      configurationHibernateEncryptor
>    </property>
>                <property name="connection.username">root</property>
>                <property name="connection.url">
>                        jdbc:mysql://localhost/
>                </property>
>                <property name="dialect">
>                        org.hibernate.dialect.MySQLDialect
>                </property>
>                <property
> name="myeclipse.connection.profile">mysql</property>
>                <property
>
> name="connection.password">ENC(ABpwtroqwLWCJBWAm9oetdYToGPP9337)</property>
>                <property name="connection.driver_class">
>                        com.mysql.jdbc.Driver
>                </property>
>                <mapping resource="com/genie/hibernate/User.hbm.xml" />
>
>        </session-factory>
>
> </hibernate-configuration>
> after that the error is coming No String encrypter of this name
> "configurationHibernateEncryptor"
>
> after that i am creating one java class file HibernatePBEEncryptorRegistry
> and my code is given below
> import org.jasypt.encryption.pbe.PBEStringEncryptor;
> import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
>
> public final class HibernatePBEEncryptorRegistry
> extends Object{
>
>        protected PBEStringEncryptor createPBEStringEncryptor() {
>        StandardPBEStringEncryptor encryptor = new
> StandardPBEStringEncryptor();
>        HibernatePBEEncryptorRegistry registry =
>            HibernatePBEEncryptorRegistry.getInstance();
>
> registry.registerPBEStringEncryptor("configurationHibernateEncryptor",
> encryptor);
>        //encryptor.setAlgorithm("PBEWithMD5AndDES");
>        return encryptor;
>
>
>        }
>        private void registerPBEStringEncryptor(String string,
>                        StandardPBEStringEncryptor encryptor) {
>                // TODO Auto-generated method stub
>
>        }
>        public static HibernatePBEEncryptorRegistry getInstance(){
>                return null;
>
>        }
>
> }
>
> after that am deployed my application same error is coming No String
> encrypter of this name "configurationHibernateEncryptor"
> .
> Please anybody help me about this topic.I am already encrypted the
> password
> thing through cil tool.only thing is to decrypt the password.Plese help me
> this regard otherwise help me in setting the environment variable stuff.
>
> regards
> Biswanath
> --
> View this message in context:
> http://www.nabble.com/setting-environment-variables-tp16957059s21332p16957059.html
> Sent from the Jasypt - Users mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
>
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> jasypt-users mailing list
> jasypt-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jasypt-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
jasypt-users mailing list
jasypt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasypt-users
LightInTheBox - Buy quality products at wholesale price