|
@@ -1,7 +1,5 @@
|
|
|
package com.psi.gabontel.mobileapp.thirdparty.helper;
|
|
package com.psi.gabontel.mobileapp.thirdparty.helper;
|
|
|
|
|
|
|
|
-import java.io.PrintWriter;
|
|
|
|
|
-import java.io.StringWriter;
|
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.Hashtable;
|
|
import java.util.Hashtable;
|
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
@@ -12,8 +10,6 @@ import javax.annotation.PostConstruct;
|
|
|
import javax.ejb.Singleton;
|
|
import javax.ejb.Singleton;
|
|
|
import javax.ejb.Startup;
|
|
import javax.ejb.Startup;
|
|
|
import javax.naming.Context;
|
|
import javax.naming.Context;
|
|
|
-import javax.naming.InitialContext;
|
|
|
|
|
-import javax.naming.NamingException;
|
|
|
|
|
|
|
|
|
|
import org.jboss.logging.Logger;
|
|
import org.jboss.logging.Logger;
|
|
|
import org.wildfly.naming.client.WildFlyInitialContextFactory;
|
|
import org.wildfly.naming.client.WildFlyInitialContextFactory;
|
|
@@ -27,7 +23,6 @@ import com.psi.common.db.DataRowCollection;
|
|
|
import com.psi.common.db.DbQuery;
|
|
import com.psi.common.db.DbQuery;
|
|
|
import com.psi.common.db.DbWrapper;
|
|
import com.psi.common.db.DbWrapper;
|
|
|
import com.psi.common.util.StringUtil;
|
|
import com.psi.common.util.StringUtil;
|
|
|
-import com.psi.ussd.interfaces.UssdReceiverFunction;
|
|
|
|
|
|
|
|
|
|
@Startup
|
|
@Startup
|
|
|
@Singleton
|
|
@Singleton
|
|
@@ -35,8 +30,8 @@ public class InitializerBean {
|
|
|
private static final Logger log = Logger.getLogger(InitializerBean.class);
|
|
private static final Logger log = Logger.getLogger(InitializerBean.class);
|
|
|
private static final Hashtable<String,String> ussdgwmenuejb = new Hashtable<String,String>();
|
|
private static final Hashtable<String,String> ussdgwmenuejb = new Hashtable<String,String>();
|
|
|
private static final Properties jndiProperties = new Properties();
|
|
private static final Properties jndiProperties = new Properties();
|
|
|
- private static AuthenticationConfiguration commonconfig = AuthenticationConfiguration.empty().setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("DIGEST-MD5"));
|
|
|
|
|
- private static AuthenticationConfiguration userconfig = AuthenticationConfiguration.empty().setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("DIGEST-MD5"));
|
|
|
|
|
|
|
+ private static final AuthenticationConfiguration commonconfig = AuthenticationConfiguration.empty().setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("DIGEST-MD5"));
|
|
|
|
|
+ private static AuthenticationConfiguration userconfig;
|
|
|
|
|
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
|
public void initialize() {
|
|
public void initialize() {
|
|
@@ -60,40 +55,16 @@ public class InitializerBean {
|
|
|
String username = extraparam.getOrDefault("username", "");
|
|
String username = extraparam.getOrDefault("username", "");
|
|
|
String password = extraparam.getOrDefault("password", "");
|
|
String password = extraparam.getOrDefault("password", "");
|
|
|
password = DbQuery.dbDecrypt(password, name);
|
|
password = DbQuery.dbDecrypt(password, name);
|
|
|
- //jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
|
|
|
|
|
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
|
|
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
|
|
|
jndiProperties.put(Context.PROVIDER_URL, url);
|
|
jndiProperties.put(Context.PROVIDER_URL, url);
|
|
|
- //jndiProperties.put(Context.SECURITY_PRINCIPAL, username);
|
|
|
|
|
- //jndiProperties.put(Context.SECURITY_CREDENTIALS, password);
|
|
|
|
|
- //jndiProperties.put("org.jboss.ejb.client.scoped.context", "true");
|
|
|
|
|
|
|
+ jndiProperties.put(Context.SECURITY_PRINCIPAL, username);
|
|
|
|
|
+ jndiProperties.put(Context.SECURITY_CREDENTIALS, password);
|
|
|
userconfig = commonconfig.useName(username).usePassword(password);
|
|
userconfig = commonconfig.useName(username).usePassword(password);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public static String getUssdgwmenuejb(String key){
|
|
|
|
|
- return ussdgwmenuejb.get(key);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
public static boolean containsKey(String key) {
|
|
public static boolean containsKey(String key) {
|
|
|
return ussdgwmenuejb.containsKey(key);
|
|
return ussdgwmenuejb.containsKey(key);
|
|
|
}
|
|
}
|
|
|
- public static Properties getJndiProperties() {
|
|
|
|
|
- return jndiProperties;
|
|
|
|
|
- }
|
|
|
|
|
- public static UssdReceiverFunction getInterface(String jndi) {
|
|
|
|
|
- try {
|
|
|
|
|
- final Context context = new InitialContext(jndiProperties);
|
|
|
|
|
- UssdReceiverFunction ussdplugin = (UssdReceiverFunction) context.lookup(jndi);
|
|
|
|
|
- return ussdplugin;
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error(jndi,e);
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public static String getPropertiesAsString() {
|
|
|
|
|
- StringWriter writer = new StringWriter();
|
|
|
|
|
- jndiProperties.list(new PrintWriter(writer));
|
|
|
|
|
- return writer.getBuffer().toString();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
public static String callUssd(final String key, final String ... params) {
|
|
public static String callUssd(final String key, final String ... params) {
|
|
|
try {
|
|
try {
|