请告诉我如何在WildFly 10中将Jboss的应用程序迁移为6?(对不起,我的英语)。
目标-用户必须使用WildFly中使用的用户名和密码连接到数据库。
如果可以在WildFly中实现Jboss的可能性,那么真的想读一个实现Jboss为6的例子
配置Jboss 6:
<application-policy name = "IGRoles">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required">
<module-option name="usersProperties">IG_users.properties</module-option>
<module-option name="rolesProperties">IG_roles.properties</module-option>
</login-module>
</authentication>
</application-policy>
<application-policy name = "IG_CallerDS">
<authentication>
<login-module code = "org.jboss.resource.security.CallerIdentityLoginModule"
flag = "required">
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=OraDSIG</module-option>
</login-module>
</authentication>
</application-policy>
<datasources>
<local-tx-datasource>
<jndi-name>OraDSIG</jndi-name>
<connection-url>jdbc:oracle:thin:@localhost:1521:olg1</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<security-domain>IG_CallerDS</security-domain>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</local-tx-datasource>
</datasources>Configuration WildFly 10:测试完成以下操作: standalone.xml
<security-domain name="ejb-security-domain33" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="UsersRoles" flag="required">
<module-option name="defaultUsersProperties" value="${jboss.server.config.dir}/ejb-users.properties"/>
<module-option name="defaultRolesProperties" value="${jboss.server.config.dir}/ejb-roles.properties"/>
<module-option name="usersProperties" value="${jboss.server.config.dir}/ejb-users.properties"/>
<module-option name="rolesProperties" value="${jboss.server.config.dir}/ejb-roles.properties"/>
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain> 不传输密码,但EJB-users.properties文件需要
<security-domain name="ejb-security-domain" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="RealmDirect" flag="required">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="DatabaseUsers" flag="required">
<module-option name="dsJndiName" value="java:jboss/OraDSIG"/>
<module-option name="principalsQuery" value="select passwd AS PASSWORD from IG.USERS where login=?"/>
<module-option name="rolesQuery" value="select role 'Roles', RoleGroup from IG.USER_ROLES where login=?"/>
</login-module>
</authentication>
</security-domain> 我检查了许多变体,但错误总是如下:
2016-12-01 10:46:14,472 TRACE [org.jboss.security] (default task-2) PBOX00236: Begin initialize method
2016-12-01 10:46:14,472 TRACE [org.jboss.security] (default task-2) PBOX00240: Begin login method
2016-12-01 10:46:14,472 DEBUG [org.jboss.security.auth.spi.AbstractServerLoginModule] (default task-2) Storing username 'ejbUser'
2016-12-01 10:46:14,472 TRACE [org.jboss.security] (default task-2) PBOX00236: Begin initialize method
2016-12-01 10:46:14,472 TRACE [org.jboss.security] (default task-2) PBOX00240: Begin login method
2016-12-01 10:46:14,473 TRACE [org.jboss.security] (default task-2) PBOX00236: Begin initialize method
2016-12-01 10:46:14,473 TRACE [org.jboss.security] (default task-2) PBOX00262: Module options [dsJndiName: java:jboss/OraDSIG, principalsQuery: select passwd AS PASSWORD from IG.USERS where login=?, rolesQuery: select role 'Roles', RoleGroup from IG.USER_ROLES where login=?, suspendResume: true]
2016-12-01 10:46:14,474 TRACE [org.jboss.security] (default task-2) PBOX00240: Begin login method
2016-12-01 10:46:15,283 TRACE [org.jboss.security] (default task-2) PBOX00263: Executing query select passwd AS PASSWORD from IG.USERS where login=? with username ejbUser
2016-12-01 10:46:15,618 DEBUG [org.jboss.security] (default task-2) PBOX00283: Bad password for username ejbUser
2016-12-01 10:46:15,619 TRACE [org.jboss.security] (default task-2) PBOX00244: Begin abort method, overall result: true
2016-12-01 10:46:15,619 TRACE [org.jboss.security] (default task-2) PBOX00244: Begin abort method, overall result: true
2016-12-01 10:46:15,619 TRACE [org.jboss.security] (default task-2) PBOX00244: Begin abort method, overall result: false
2016-12-01 10:46:15,619 DEBUG [org.jboss.security] (default task-2) PBOX00206: Login failure: javax.security.auth.login.FailedLoginException: PBOX00070: Password invalid/Password required
<datasource jta="false" jndi-name="java:jboss/OraDSIG" pool-name="OraDSIG" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:@localhost:1521:olg1</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver>oracle</driver>
<security>
<user-name>ig</user-name>
<password>abcd</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<background-validation>true</background-validation>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
</validation>
</datasource>
<driver name="oracle" module="com.oracle.jdbc">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>客户端WildFly 10
CallerRemote remote=IGGetEJB.getEJBAccess3("ejbUser","1","127.0.0.1","8080");
public static CallerRemote getEJBAccess3(String uName, String uPass,String serverHost, String serverPort) {
String serverUrl = "http-remoting://" + serverHost + ":" + serverPort; // serverPort обычно 4447
Hashtable<String, Object> params = new Hashtable<String, Object>();
params.put(Context.PROVIDER_URL, serverUrl);
params.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
params.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
params.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "true");
// params.put(Context.SECURITY_PRINCIPAL, uName); //java.naming.security.principal
// params.put(Context.SECURITY_CREDENTIALS, uPass);//java.naming.security.credentials
Properties clientProp = new Properties();
clientProp.put("remote.connections", "default");
clientProp.put("remote.connection.default.host", serverHost);
clientProp.put("remote.connection.default.port", serverPort);
clientProp.put("remote.connection.default.username", uName);
// clientProp.put("remote.connection.default.password",uPass);
/* try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] passwordBytes = uPass.getBytes();
byte[] hash = md.digest(passwordBytes);
String passwordHash = Base64.getEncoder().encodeToString(hash);
System.out.println("password hash: "+passwordHash);
clientProp.put("remote.connection.default.password", "a4ayc/80/OGda4BO/1o/V0etpOqiLx1JwB5S3beHW0s=");
} catch (NoSuchAlgorithmException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}*/
clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "true");
// clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS","JBOSS-LOCAL-USER");
clientProp.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "true");
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);
// EJBClientContext.getCurrent().registerInterceptor(0, new ClientInterceptor());
try {
InitialContext context = new InitialContext(params);
final String jndiName = "/TestRemoteEJBEAR/CallerBean!remote.CallerRemote";
CallerRemote remote = (CallerRemote) context.lookup(jndiName);
// CallerRemote remote = connectEjb(context, jndiName);
return remote;
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
} //////////////////////////////////////////////////////////////////////////////
我更改了-公共抽象类UsernamePasswordLoginModule扩展了AbstractServerLoginModule
public boolean login() throws LoginException
{
System.out.println("1______________super.login()="+super.login());
// See if shared credentials exist
if( super.login() == true )
{要从客户端接收密码,应该使用if( super.login() == true ),但他总是错误的
2016-12-05 15:26:21,640 TRACE [org.jboss.security] (default task-10) PBOX00240: Begin login method
2016-12-05 15:26:21,641 INFO [stdout] (default task-10) 1______________super.login()=false
2016-12-05 15:26:21,641 TRACE [org.jboss.security] (default task-10) PBOX00240: Begin login method如果( super.login() == false ),那么密码总是===,而不是DataBase中的相同密码
2016-12-05 15:26:22,080 INFO [stdout] (default task-10) 11______________expectedPassword=Pass_BD
2016-12-05 15:26:22,081 INFO [stdout] (default task-10) 12______________password=org.jboss.as.security.remoting.RemotingConnectionCredential@b986e1
super.loginOk = false;
String[] info = getUsernameAndPassword();
...
protected String[] getUsernameAndPassword() throws LoginException
{
String[] info = {null, null};
// prompt for a username and password
if( callbackHandler == null )
{
throw PicketBoxMessages.MESSAGES.noCallbackHandlerAvailable();
}
NameCallback nc = new NameCallback(PicketBoxMessages.MESSAGES.enterUsernameMessage(), "guest");
PasswordCallback pc = new PasswordCallback(PicketBoxMessages.MESSAGES.enterPasswordMessage(), false);我喜欢客户把你的密码转过来?当我从EJB客户端调用login()时?
请告诉我。
发布于 2017-01-16 08:28:37
remoute客户端使用以下代码
public static CallerRemote getEJBAccessOK(String uName, String uPass,String serverHost, String serverPort) {
String serverUrl = "http-remoting://" + serverHost + ":" + serverPort; // serverPort обычно 4447
Hashtable<String, Object> params = new Hashtable<String, Object>();
params.put(Context.PROVIDER_URL, serverUrl);
params.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
params.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
params.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
params.put(Context.SECURITY_PRINCIPAL, uName);
params.put(Context.SECURITY_CREDENTIALS, uPass);
Properties clientProp = new Properties();
clientProp.put("remote.connections", "default");
clientProp.put("remote.connection.default.host", serverHost);
clientProp.put("remote.connection.default.port", serverPort);
clientProp.put("remote.connection.default.username", uName);
clientProp.put("remote.connection.default.password",uPass);
clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);
try {
InitialContext context = new InitialContext(params);
final String jndiName = "/TestRemoteEJBEAR/CallerBean!remote.CallerRemote";
CallerRemote remote = (CallerRemote) context.lookup(jndiName);
return remote;
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}创建表"IG"."USER_ROLES“
(“登录”VARCHAR2(64字节),
"ROLE" VARCHAR2(32 BYTE), "ROLEGROUP" VARCHAR2(80 BYTE))
插入USER_ROLES (登录、角色、ROLEGROUP)值(“ejbUser”、“ejbRole”、“角色”);
https://stackoverflow.com/questions/40910636
复制相似问题