无法在 webapp 上使用 WSO2 IS 进行身份验证
Can't authentication with WSO2 IS on webapp
我正在尝试在 WSO2 IS 上创建身份验证机制,但我遇到了以下问题:
- 我对 remote_user 实施如下 link,结果正常。我可以从控制台
登录并访问 WSO API
https://svn.wso2.org/repos/wso2/people/asela/user-mgt/remote-user-api/4.2.X/
但是当我在网页上尝试时,我无法向 WSO IS 进行身份验证。以下是我的代码:
public void init() throws AxisFault{
userName = HDConstants.USER_NAME;
password = HDConstants.PASSWORD;
backEndServerURL = HDConstants.SERVER_URL;
setKeyStore();
configCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
}
public void setKeyStore() {
System.setProperty("javax.net.ssl.trustStore", HDConstants.TRUST_STORE_PATH);
System.setProperty("javax.net.ssl.trustStorePassword", HDConstants.TRUST_STORE_PASSWORD);
System.setProperty("javax.net.ssl.trustStoreType", HDConstants.TRUST_STORE_TYPE);
}
public boolean authenticateUser(String userName, String password) throws Exception {
String serviceURL = null;
ServiceClient client = null;
Options option = null;
boolean isAuthenticated = false;
AuthenticationAdminStub authStub = null;
serviceURL = backEndServerURL + "AuthenticationAdmin";
authStub = new AuthenticationAdminStub(configCtx, serviceURL);
client = authStub._getServiceClient();
option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, authCookie);
isAuthenticated = authStub.login(userName, password, HDConstants.APP_ID);
authCookie = (String) authStub._getServiceClient().getServiceContext()
.getProperty(HTTPConstants.COOKIE_STRING);
System.out.println(" Auth Cookie ==== " + authCookie);
return isAuthenticated;
}
`
我在控制器中使用以下代码调用身份验证方法:
AuthenticationServiceClient authenticationServiceClient = new AuthenticationServiceClient();
authenticationServiceClient.init();
authenticationServiceClient.authenticateUser("admin", "admin");
但结果并不好。系统提示:
at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:688)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:124)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:887)
at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
at com.home.hduser.wsois.AuthenticationServiceClient.init(AuthenticationServiceClient.java:29)
我不知道为什么我可以在控制台上进行身份验证,但不能在 webapp 上进行身份验证
以及下面文件中附加的完整跟踪错误:
https://drive.google.com/open?id=0B9zEqmu0HBunSlp3X0dpWC1YU0E
非常感谢您在此案例中提供的帮助。
谢谢
我假设您正在 IS 本身中部署您的网络应用程序。我可以看到很多罐子都装在你的 war 文件中。它们中的大多数已经在 IS 服务器中可用。
上述错误可能是由于依赖冲突造成的。 See this 获取更多信息。
要消除错误,您可以尝试将 <scope>provided</scope>
设置为服务器中已经可用的依赖项。
只需在 pom.xml 文件中更改此依赖项,设置提供的范围:
<dependency>
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.um.ws.api</artifactId>
<version>${carbon.identity.version}</version>
<scope>provided</scope>
</dependency>
要删除 tomcat 依赖项:
[INFO] +- org.wso2.carbon.identity:org.wso2.carbon.um.ws.api:jar:4.5.4:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.user.core:jar:4.4.1:provided
[INFO] | | +- org.wso2.carbon:javax.cache.wso2:jar:4.4.1:provided
[INFO] | | | \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:provided
[INFO] | | +- commons-dbcp.wso2:commons-dbcp:jar:1.4.0.wso2v1:provided
[INFO] | | +- org.apache.tomcat.wso2:jdbc-pool:jar:7.0.34.wso2v2:provided
[INFO] | | | \- org.apache.tomcat:tomcat-jdbc:jar:7.0.47:provided
[INFO] | | \- commons-collections.wso2:commons-collections:jar:3.2.0.wso2v1:provided
[INFO] | +- org.wso2.carbon.identity:org.wso2.carbon.user.mgt.common:jar:4.5.4:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.core:jar:4.4.1:provided
[INFO] | | +- org.wso2.orbit.com.hazelcast:hazelcast:jar:3.5.0.wso2v1:provided
[INFO] | | | \- com.hazelcast:hazelcast-all:jar:3.5:provided
[INFO] | | | +- com.eclipsesource.minimal-json:minimal-json:jar:0.9.2:provided
[INFO] | | | \- org.freemarker:freemarker:jar:2.3.22:provided
[INFO] | | +- org.eclipse.equinox:org.eclipse.equinox.http.helper:jar:1.1.0.wso2v1:provided
[INFO] | | \- org.apache.tomcat:tomcat-catalina-ha:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-juli:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-tribes:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-catalina:jar:7.0.59:provided
[INFO] | | | +- org.apache.tomcat:tomcat-annotations-api:jar:7.0.59:provided
[INFO] | | | \- org.apache.tomcat:tomcat-api:jar:7.0.59:provided
[INFO] | | \- org.apache.tomcat:tomcat-util:jar:7.0.59:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.authenticator.proxy:jar:4.4.1:provided
[INFO] | | \- org.wso2.carbon:org.wso2.carbon.core.common:jar:4.4.1:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.registry.core:jar:4.4.1:provided
[INFO] | | +- commons-io.wso2:commons-io:jar:2.0.0.wso2v2:provided
[INFO] | | +- net.sourceforge.findbugs:annotations:jar:1.3.2:provided
[INFO] | | +- org.wso2.carbon:org.wso2.carbon.registry.xboot:jar:4.4.1:provided
[INFO] | | +- org.compass-project.wso2:compass:jar:2.0.1.wso2v2:provided
[INFO] | | +- org.apache.abdera.wso2:abdera:jar:1.0.0.wso2v3:provided
[INFO] | | +- org.apache.poi.wso2:poi-scratchpad:jar:3.9.0.wso2v1:provided
[INFO] | | | \- org.apache.poi:poi-scratchpad:jar:3.9:provided
[INFO] | | | \- org.apache.poi:poi:jar:3.9:provided
[INFO] | | \- commons-pool.wso2:commons-pool:jar:1.5.6.wso2v1:provided
[INFO] | | \- commons-pool:commons-pool:jar:1.5.6:provided
[INFO] | \- org.wso2.carbon.identity:org.wso2.carbon.um.ws.api.stub:jar:4.5.4:provided
编辑:我必须设置 IS_HOME 绝对路径。
编辑 2:使用相对路径:
此方法 return wso2carbon.jks 文件的路径:
public String setKeyStorePath(){
String path = System.getProperty("carbon.home") + File.separator +
"repository" + File.separator + "resources" +
File.separator + "security" +
File.separator + "wso2carbon.jks";
System.out.println("wso2carbon.jks path: " + path);
return path;
}
修改 setKeyStore 以使用 setKeyStorePath()
public void setKeyStore() {
System.setProperty("javax.net.ssl.trustStore", setKeyStorePath());
System.setProperty("javax.net.ssl.trustStorePassword", HDConstants.TRUST_STORE_PASSWORD);
System.setProperty("javax.net.ssl.trustStoreType", HDConstants.TRUST_STORE_TYPE);
}
我正在尝试在 WSO2 IS 上创建身份验证机制,但我遇到了以下问题: - 我对 remote_user 实施如下 link,结果正常。我可以从控制台
登录并访问 WSO APIhttps://svn.wso2.org/repos/wso2/people/asela/user-mgt/remote-user-api/4.2.X/
但是当我在网页上尝试时,我无法向 WSO IS 进行身份验证。以下是我的代码:
public void init() throws AxisFault{
userName = HDConstants.USER_NAME;
password = HDConstants.PASSWORD;
backEndServerURL = HDConstants.SERVER_URL;
setKeyStore();
configCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
}
public void setKeyStore() {
System.setProperty("javax.net.ssl.trustStore", HDConstants.TRUST_STORE_PATH);
System.setProperty("javax.net.ssl.trustStorePassword", HDConstants.TRUST_STORE_PASSWORD);
System.setProperty("javax.net.ssl.trustStoreType", HDConstants.TRUST_STORE_TYPE);
}
public boolean authenticateUser(String userName, String password) throws Exception {
String serviceURL = null;
ServiceClient client = null;
Options option = null;
boolean isAuthenticated = false;
AuthenticationAdminStub authStub = null;
serviceURL = backEndServerURL + "AuthenticationAdmin";
authStub = new AuthenticationAdminStub(configCtx, serviceURL);
client = authStub._getServiceClient();
option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, authCookie);
isAuthenticated = authStub.login(userName, password, HDConstants.APP_ID);
authCookie = (String) authStub._getServiceClient().getServiceContext()
.getProperty(HTTPConstants.COOKIE_STRING);
System.out.println(" Auth Cookie ==== " + authCookie);
return isAuthenticated;
}
`
我在控制器中使用以下代码调用身份验证方法:
AuthenticationServiceClient authenticationServiceClient = new AuthenticationServiceClient();
authenticationServiceClient.init();
authenticationServiceClient.authenticateUser("admin", "admin");
但结果并不好。系统提示:
at org.apache.axis2.deployment.AxisConfigBuilder.processTransportSenders(AxisConfigBuilder.java:688)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:124)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:887)
at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
at com.home.hduser.wsois.AuthenticationServiceClient.init(AuthenticationServiceClient.java:29)
我不知道为什么我可以在控制台上进行身份验证,但不能在 webapp 上进行身份验证
以及下面文件中附加的完整跟踪错误: https://drive.google.com/open?id=0B9zEqmu0HBunSlp3X0dpWC1YU0E
非常感谢您在此案例中提供的帮助。 谢谢
我假设您正在 IS 本身中部署您的网络应用程序。我可以看到很多罐子都装在你的 war 文件中。它们中的大多数已经在 IS 服务器中可用。
上述错误可能是由于依赖冲突造成的。 See this 获取更多信息。
要消除错误,您可以尝试将 <scope>provided</scope>
设置为服务器中已经可用的依赖项。
只需在 pom.xml 文件中更改此依赖项,设置提供的范围:
<dependency>
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.um.ws.api</artifactId>
<version>${carbon.identity.version}</version>
<scope>provided</scope>
</dependency>
要删除 tomcat 依赖项:
[INFO] +- org.wso2.carbon.identity:org.wso2.carbon.um.ws.api:jar:4.5.4:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.user.core:jar:4.4.1:provided
[INFO] | | +- org.wso2.carbon:javax.cache.wso2:jar:4.4.1:provided
[INFO] | | | \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:provided
[INFO] | | +- commons-dbcp.wso2:commons-dbcp:jar:1.4.0.wso2v1:provided
[INFO] | | +- org.apache.tomcat.wso2:jdbc-pool:jar:7.0.34.wso2v2:provided
[INFO] | | | \- org.apache.tomcat:tomcat-jdbc:jar:7.0.47:provided
[INFO] | | \- commons-collections.wso2:commons-collections:jar:3.2.0.wso2v1:provided
[INFO] | +- org.wso2.carbon.identity:org.wso2.carbon.user.mgt.common:jar:4.5.4:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.core:jar:4.4.1:provided
[INFO] | | +- org.wso2.orbit.com.hazelcast:hazelcast:jar:3.5.0.wso2v1:provided
[INFO] | | | \- com.hazelcast:hazelcast-all:jar:3.5:provided
[INFO] | | | +- com.eclipsesource.minimal-json:minimal-json:jar:0.9.2:provided
[INFO] | | | \- org.freemarker:freemarker:jar:2.3.22:provided
[INFO] | | +- org.eclipse.equinox:org.eclipse.equinox.http.helper:jar:1.1.0.wso2v1:provided
[INFO] | | \- org.apache.tomcat:tomcat-catalina-ha:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-juli:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-tribes:jar:7.0.59:provided
[INFO] | | +- org.apache.tomcat:tomcat-catalina:jar:7.0.59:provided
[INFO] | | | +- org.apache.tomcat:tomcat-annotations-api:jar:7.0.59:provided
[INFO] | | | \- org.apache.tomcat:tomcat-api:jar:7.0.59:provided
[INFO] | | \- org.apache.tomcat:tomcat-util:jar:7.0.59:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.authenticator.proxy:jar:4.4.1:provided
[INFO] | | \- org.wso2.carbon:org.wso2.carbon.core.common:jar:4.4.1:provided
[INFO] | +- org.wso2.carbon:org.wso2.carbon.registry.core:jar:4.4.1:provided
[INFO] | | +- commons-io.wso2:commons-io:jar:2.0.0.wso2v2:provided
[INFO] | | +- net.sourceforge.findbugs:annotations:jar:1.3.2:provided
[INFO] | | +- org.wso2.carbon:org.wso2.carbon.registry.xboot:jar:4.4.1:provided
[INFO] | | +- org.compass-project.wso2:compass:jar:2.0.1.wso2v2:provided
[INFO] | | +- org.apache.abdera.wso2:abdera:jar:1.0.0.wso2v3:provided
[INFO] | | +- org.apache.poi.wso2:poi-scratchpad:jar:3.9.0.wso2v1:provided
[INFO] | | | \- org.apache.poi:poi-scratchpad:jar:3.9:provided
[INFO] | | | \- org.apache.poi:poi:jar:3.9:provided
[INFO] | | \- commons-pool.wso2:commons-pool:jar:1.5.6.wso2v1:provided
[INFO] | | \- commons-pool:commons-pool:jar:1.5.6:provided
[INFO] | \- org.wso2.carbon.identity:org.wso2.carbon.um.ws.api.stub:jar:4.5.4:provided
编辑:我必须设置 IS_HOME 绝对路径。
编辑 2:使用相对路径:
此方法 return wso2carbon.jks 文件的路径:
public String setKeyStorePath(){
String path = System.getProperty("carbon.home") + File.separator +
"repository" + File.separator + "resources" +
File.separator + "security" +
File.separator + "wso2carbon.jks";
System.out.println("wso2carbon.jks path: " + path);
return path;
}
修改 setKeyStore 以使用 setKeyStorePath()
public void setKeyStore() {
System.setProperty("javax.net.ssl.trustStore", setKeyStorePath());
System.setProperty("javax.net.ssl.trustStorePassword", HDConstants.TRUST_STORE_PASSWORD);
System.setProperty("javax.net.ssl.trustStoreType", HDConstants.TRUST_STORE_TYPE);
}