[英]ORA-01017: invalid username/password; logon denied when using wss4j
I have many tests which access our Oracle DB without a problem, however when I run these tests along with other tests in our codebase which use a keystore, the tests that interact with the DB are no longer able to connect. 我有很多测试可以毫无问题地访问我们的Oracle数据库,但是当我在使用密钥库的代码库中运行这些测试以及其他测试时,与数据库交互的测试不再能够连接。 Here is the exception they get:
以下是他们获得的例外情况:
Caused by: java.sql.SQLException: ORA-01017: invalid username/password;
引起:java.sql.SQLException:ORA-01017:用户名/密码无效; logon denied at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:388) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:381) at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:564) at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:431) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186) at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366) at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:359) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:531) at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:221) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503) at org.apache.com
在oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java)上的oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:338)的oracle.jdbc.driver.T4CTTIoer.process错误(T4CTTIoer.process :381)oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:564)at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:431)at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun。 java:436)oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate .java:752)oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:359)at oracle.jdbc.driver.PhysicalConnection。(PhysicalConnection.java:531)at oracle.jdbc.driver.T4CConnection。(T4CConnection。 java:221)在orracle.apache.com的oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503) mons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37) at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290) at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:877) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851) ... 68 more
mons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)位于org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java: 877)在org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)... 68更多
Obviously the username and password are still correct. 显然用户名和密码仍然正确。 I'm having a really hard time figuring out what in our code is causing the connection to fail, and I don't really know how to debug what's happening when the Oracle driver tries to connect.
我很难弄清楚我们的代码中导致连接失败的原因,而且我真的不知道如何调试Oracle驱动程序尝试连接时发生的情况。 I'm using the Oracle thin driver with Oracle 11g.
我在Oracle 11g中使用Oracle瘦驱动程序。 We use Spring, Hibernate, and the Apache Commons DBCP.
我们使用Spring,Hibernate和Apache Commons DBCP。 It seems like the driver is maybe trying to establish an SSL connection to the DB?
似乎驱动程序可能正在尝试与数据库建立SSL连接? I'm not sure though.
我不确定。 I seem to remember a very similar issue with SQL Server when we were still using that, at the time I just ignored it.
我似乎还记得当我们使用它时,SQL Server的一个非常类似的问题,当时我只是忽略了它。 Right now we run the tests that interact with the keystore in a separate batch and JVM.
现在,我们在单独的批处理和JVM中运行与密钥库交互的测试。
Any help would be greatly appreciated. 任何帮助将不胜感激。
UPDATED 更新
I did a bunch more debugging and finally traced this down to our use of the wss4j library (version 1.5.9) via Spring-WS. 我做了一些调试,最后通过Spring-WS跟踪我们对wss4j库(版本1.5.9)的使用。 Eventually the WSSConfig class gets to a set of code that does this:
最终,WSSConfig类获取了一组执行此操作的代码:
int ret = 0;
for (int i = 0; i < provs.length; i++) {
if ("SUN".equals(provs[i].getName())
|| "IBMJCE".equals(provs[i].getName())) {
ret =
java.security.Security.insertProviderAt(
(java.security.Provider) c.newInstance(), i + 2
);
break;
}
}
Immediately after this code my connections to Oracle stop working. 在此代码之后,我与Oracle的连接立即停止工作。 It looks like when the insertProviderAt method is called using a bouncy castle provider my Oracle connection starts failing.
看起来当使用充气城堡提供程序调用insertProviderAt方法时,我的Oracle连接开始失败。 Any ideas?
有任何想法吗?
Minimal Test Case 最小的测试用例
The first connection attempt succeeds, but the second attempt fails. 第一次连接尝试成功,但第二次尝试失败。
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@server/servicename", "username", "password");
conn.prepareStatement("select * from dual").getResultSet();
conn.close();
org.apache.ws.security.WSSConfig.getDefaultWSConfig();
conn = DriverManager.getConnection("jdbc:oracle:thin:server/servicename", "username", "password");
conn.prepareStatement("select * from dual").getResultSet();
conn.close();
WSSConfig Initialize Method WSSConfig初始化方法
private synchronized void
staticInit() {
if (!staticallyInitialized) {
org.apache.xml.security.Init.init();
if (addJceProviders) {
/*
* The last provider added has precedence, that is if JuiCE can be added
* then WSS4J uses this provider.
*/
addJceProvider("BC", "org.bouncycastle.jce.provider.BouncyCastleProvider");
addJceProvider("JuiCE", "org.apache.security.juice.provider.JuiCEProviderOpenSSL");
}
Transform.init();
try {
Transform.register(
STRTransform.implementedTransformURI,
"org.apache.ws.security.transform.STRTransform"
);
} catch (Exception ex) {
if (log.isDebugEnabled()) {
log.debug(ex.getMessage(), ex);
}
}
staticallyInitialized = true;
}
}
缺少第二个连接字符串中的添加符号
logon denied error can be shown if in oracle the parameter SEC_CASE_SENSITIVE_LOGON
is set true
. 如果在oracle中参数
SEC_CASE_SENSITIVE_LOGON
设置为true
则可以显示登录被拒绝错误。 You can check it via SHOW PARAMETER SEC_CASE_SENSITIVE_LOGON
and alter it through ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;
您可以通过
SHOW PARAMETER SEC_CASE_SENSITIVE_LOGON
进行检查,并通过ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;
进行ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON = FALSE;
Now the error should get resolved. 现在错误应该得到解决。
1. Modify the file 1.修改文件
%JAVA_HOME%/jre/lib/security/java.security
security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
Example: 例:
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.sun.net.ssl.internal.ssl.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
security.provider.6=com.sun.security.sasl.Provider
security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.8=sun.security.smartcardio.SunPCSC
security.provider.9=sun.security.mscapi.SunMSCAPI
security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
or 2. 或2。
WSSConfig.setAddJceProviders(false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.