1

MySQL サーバー 5 で構成ファイルに暗号化されたパスワード用に Spring3.1、Hibernate4、および Jasypt1.90 を構成しましたが、機能せず、次のエラーが発生しました。

Caused by:java.sql.SQLException: Access denied for user 'root'@'iplcewks01056.noida.innodata.net' (using 
password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:934)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4104)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1299)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338)
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2186)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2168)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at 
org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.
getConnection(DatasourceConnectionProviderImpl.java:141)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.
obtainConnection(AbstractSessionImpl.java:292)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.
obtainConnection(LogicalConnectionImpl.java:297)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.
getConnection(LogicalConnectionImpl.java:169)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1395)
at org.springframework.orm.hibernate4.HibernateTransactionManager.
doBegin(HibernateTransactionManager.java:399)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.
getTransaction(AbstractPlatformTransactionManager.java:371)
at org.springframework.transaction.interceptor.TransactionAspectSupport.
createTransactionIfNecessary(TransactionAspectSupport.java:334)
at org.springframework.transaction.interceptor.TransactionInterceptor.
invoke(TransactionInterceptor.java:105)
at org.springframework.aop.framework.ReflectiveMethodInvocation.
proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.
invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.
proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy59.getAllRoles(Unknown Source)
at com.synodex.webapp.listener.StartupListener.setupContext(StartupListener.java:113)

説明させてください、私がこれまでに行ったことは何でも:

ステップ-I-Jasypt-Spring-Hibernate Maven 依存関係

<dependency>
    <groupId>org.jasypt</groupId>
    <artifactId>jasypt</artifactId>
    <version>1.9.0</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.jasypt</groupId>
    <artifactId>jasypt-spring31</artifactId>
    <version>1.9.0</version>
    <scope>compile</scope>
</dependency>
<dependency>
        <groupId>org.jasypt</groupId>
        <artifactId>jasypt-hibernate4</artifactId>
        <version>1.9.0</version>
        <scope>compile</scope>
</dependency>

applicationContext-resources.xml の Step-II-Jasypt-Spring-Hibernate 構成: ここでは 2 つのアプローチを使用しましたが、どちらも機能していません。

最初のアプローチ:

<bean id="propertyConfigurer" 
            class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
             <constructor-arg ref="configurationEncryptor" />
             <property name="locations">
                 <list>
                    <value>classpath:jdbc.properties</value>
                    <value>classpath:mail.properties</value>
                    <value>classpath:hibernate.properties</value>
                    <value>classpath:ldap.properties</value>
                 </list>
               </property>
            </bean>
            <bean id="configurationEncryptor" class="com.synodex.util.JasyptDecryptorUtil" 
            factory-method="getEncriptorInstance" />


public class JasyptDecryptorUtil {
private final static JasyptDecryptorUtil jasyptutil = new JasyptDecryptorUtil();
private static StandardPBEStringEncryptor encryptor;

private JasyptDecryptorUtil() {
    String PWD = "SDHLKSHUWEHDKSLKLJKSALJDLKA00IUAY98273492JLKASJDLKASJDKLAJSD";
    encryptor = new StandardPBEStringEncryptor();
    encryptor.setAlgorithm("PBEWithMD5AndDES");
    encryptor.setPassword(PWD);
}

public static String getDecryptedString(String dec) {
    return encryptor.decrypt(dec);
}

public static String getEncryptedString(String dec) {
    return encryptor.encrypt(dec);
}

public static synchronized StandardPBEStringEncryptor getEncriptorInstance() {
    return encryptor;
}

/*
 * Get decrypted values stored in a property file
 */
public static Properties getDecryptedProperties(String pfile)throws IOException, FileNotFoundException {
    Properties properties = new EncryptableProperties(encryptor);
    properties.load(new FileInputStream(new File(pfile)));

    return properties;
}

}

2 番目のアプローチ:

<bean id="propertyConfigurer" 
           class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
           <constructor-arg ref="configurationEncryptor" />
           <property name="locations">
               <list>
                   <value>classpath:jdbc.properties</value>
                   <value>classpath:mail.properties</value>
                   <value>classpath:hibernate.properties</value>
                   <value>classpath:ldap.properties</value>
               </list>
              </property>
            </bean>
           <bean id="configurationEncryptor" 
           class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
              <property name="config" ref="environmentVariablesConfiguration" />
           </bean>
           <bean id="environmentVariablesConfiguration" 
           class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
              <property name="algorithm" value="PBEWithMD5AndDES" />
              <property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" />
          </bean>

注: APP_ENCRYPTION_PASSWORD システム プロパティをマスター パスワードの pom.xml に設定する必要があります。

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>8.1.3.v20120416</version>
            <configuration>
                <webApp>
                    <contextPath>/sc</contextPath>
                </webApp>
               <systemProperties>
                <systemProperty>
                  <name>APP_ENCRYPTION_PASSWORD</name>
                  <value>SDHLKSHUWEHDKSLKLJKSALJDLKA00IUAY98273492JLKASJDLKASJDKLAJSD</value>
                </systemProperty>
               </systemProperties>
                <connectors>
                    <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                        <port>8080</port>
                        <maxIdleTime>60000</maxIdleTime>
                    </connector>
                    <connector implementation="org.eclipse.jetty.server.ssl.SslSocketConnector">
                        <port>8443</port>
                        <maxIdleTime>60000</maxIdleTime>
                        <keystore>${project.build.directory}/jetty-ssl.keystore</keystore>
                        <password>jetty6</password>
                        <keyPassword>jetty6</keyPassword>
                    </connector>
                </connectors> 
            </configuration>
        </plugin>

ステップ III - dbcp プーリングの代わりに c3p0 接続プーリングを使用しましたが、これも機能しません。

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="maxPoolSize" value="100" />
    <property name="maxStatements" value="10" />
    <property name="minPoolSize" value="20" />
    <property name="testConnectionOnCheckin" value="true"/> 
</bean>

ここに欠けているものは何でも教えてください.私はたくさんの試みをしましたが、成功しませんでした.

4

1 に答える 1