I am trying to ecnrypt my password for EJB remote client. I tried encode64 or added it to config but nothing worked. I am not sure if it is possible. Any suggestions?
Here is my code:
Context context;
final clientProperties = new Properties();
clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
clientProperties.put("remote.connection.default.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
clientProperties.put(remote.connections", default);
clientProperties.put("remote.connection.default.host", "server_host");
clientProperties.put("remote.connection.default.port", "8080");
clientProperties.put("remote.connection.default.username", "ejb");
clientProperties.put("remote.connection.default.password", "password");
clientProperties.put(Context.INITIAL_CONTEXT_FACTORY, org.wildfly.naming.client.WildflyInitialContextFactory");
context = new InitialContext(clientProperties);
Related
I have my T3 client code like this:
private InitialContext initContext() {
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, context.providerURL);
for (Map.Entry<String, String> entry : getEnvironmentProperties().entrySet()) {
p.put(entry.getKey(), entry.getValue());
}
InitialContext res = null;
try {
res = new InitialContext(p);
} catch (NamingException e) {
e.printStackTrace();
}
return res;
}
My t3 client deployed on Tomcat (uses wlthint3client-12.1.3.jar) and trying to lookup remote bean of external system which deployed on Weblogic.
However when I trying to perform new InitialContext(p) I receive SSLHandshake exception, because it gets standart SSLSocketFactory with standart SSLConext and standart java trust store.
My question - is there any way to give to InitialContext some property which will override SSLSocketFacory. My aim is to populate my cutom trust store to this t3 client.
Changing standart trust store like this
System.setProperty("javax.net.ssl.trustStore", "pathToTrustStore");
works fine, however in case if my t3 client is used to communicate with 2 different external systems, it might be a problem in doing so.
Is there some property that I can populate?
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
**p.put("CUSTOM SSL SOCKET FACTORY, "MY CLASS");**
Problem was solved by adding few parameters on application side
export JAVA_OPTS ="$JAVA_OPTS -Djavax.net.ssl.trustStore=path/truststore.jks"
export JAVA_OPTS ="$JAVA_OPTS -Djavax.net.ssl.trustStorePassword=changeIT"
Need to SSH to destination host through jumphost. Had tried the same mentioned in JSch JumpHosts example.
Session[] sessions = new Session[2];
Session session = null;
sessions[0] = session = jsch.getSession(getUserName(), "jumphost1.com", 22);
session.setPassword(getHostPassword());
UserInfo userInfo = new UserInfo();
userInfo.setPassword(getHostPassword());
session.setUserInfo(userInfo);
Properties prop = new Properties();
prop.put("StrictHostKeyChecking", "no");
prop.put("PreferredAuthentications", "publickey,keyboard-interactive,password");
session.setConfig(prop);
session.connect();
String host = "host1.com";
int assignedPort = session.setPortForwardingL(0, host, 22);
LOGGER.info("Jump host the {} of agent {} and port forwarding {}", i, host, assignedPort);
sessions[i] = session = jsch.getSession(getUserName(), "127.0.0.1", assignedPort);
session.setPassword(getHostPassword());
userInfo = new UserInfo();
userInfo.setPassword(getHostPassword());
session.setUserInfo(userInfo);
session.setHostKeyAlias(host);
session.connect();
Getting below exception when connection to destination host:
Caused by: com.jcraft.jsch.JSchException: reject HostKey: 127.0.0.1
at com.jcraft.jsch.Session.checkHost(Session.java:799)
at com.jcraft.jsch.Session.connect(Session.java:345)
at com.jcraft.jsch.Session.connect(Session.java:183)
I am trying to login to host host1.com through jumphost1.com
login to jumphost1.com
then ssh host1.com
execute the commands in the host1
Your code for connecting through jumphost is correct.
The only problem is that your local host key repository contains a different host key for the second host, than what you receive from the real (second) host.
You actually do not seem to care about security, as you set StrictHostKeyChecking=no for the jumphost session (what the official example rightly does not do!). But you do not do the same for the second session, hence the error.
See also How to resolve Java UnknownHostKey, while using JSch SFTP library?
I am new to using JNDI and I am trying to connect to Active Directory using JNDI and I am facing either Authentication Error or Connection Time out. I am unable to understand what is the potential reason.This how my Active Directory looks like
I have tried the following code
public class ConnectAD {
static DirContext ldapContext;
public static void main(String[] args) throws NamingException {
try {
System.out.println("Début du test Active Directory");
Hashtable<String, String> ldapEnv = new Hashtable<String, String>();
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
ldapEnv.put(Context.PROVIDER_URL, "ldap://172.16.1.179:389");
ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
ldapEnv.put(Context.SECURITY_PRINCIPAL, "ou=Users,ou=Test1,dc=gigabyte,dc=local");
ldapEnv.put(Context.SECURITY_CREDENTIALS, "5uperCharger");
ldapContext = new InitialDirContext(ldapEnv);
//LdapContext ctx = new InitialLdapContext(ldapEnv,null);
I get the error at while creating the InitialDirContext.
I have an administrator user but I tried giving the cn=administrator but could not connect. I was getting an Authentication Error when I do so.
I also have a name to my ADServer which is GIGA(just trying to provide as much as i can)
Can you please let me know what can be the issue.
I'm getting this error when tried to read mail using JavaMail. Please let me know how to resolve this error :
Part of my code :
referhEmail();
}
private void referhEmail(){
try {
Properties props = new Properties();
props.setProperty("mail.store.protocol", "pop3");
props.setProperty("mail.pop3.port", "110");
props.setProperty("mail.pop3.host", "localhost");
Session session = Session.getInstance(props);
final Store store = session.getStore("pop3");
store.connect("localhost","xxxx#localhost", "xxx");
And the error :
javax.mail.AuthenticationFailedException: Username or password is invalid or incorrect.
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:213)
at javax.mail.Service.connect(Service.java:366)
at javax.mail.Service.connect(Service.java:246)
at emailclientgamal.EmailClientGamal.referhEmail(EmailClientGamal.java:462)
at emailclientgamal.EmailClientGamal.connect(EmailClientGamal.java:449)
at emailclientgamal.EmailClientGamal.main(EmailClientGamal.java:551)
I am trying to invoke EJB but get SASL PROPERTY: No such filed error. I have added SASL jar "jboss-sasl-1.0.0.Beta1.jar" as a dependency too.
This is my code:
Properties properties = new Properties();
properties.put("endpoint.name", "client-endpoint");
properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
properties.put("remote.connections", "default");
properties.put("remote.connection.default.host", "localhost");
properties.put("remote.connection.default.port", "4447");
properties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
properties.put("remote.connection.default.username", "user");
properties.put("remote.connection.default.password", "pass");
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(properties);
final ContextSelector<EJBClientContext> ejbClientContextSelector = new ConfigBasedEJBClientContextSelector(cc);
final ContextSelector<EJBClientContext> previousSelector = EJBClientContext.setSelector(ejbClientContextSelector);
StatelessEJBLocator<SomeClass> locator = new StatelessEJBLocator(SomeClass.class, "app", "module", "viewType", "distinctName");
SecurityDomainService ejb = org.jboss.ejb.client.EJBClient.createProxy(locator);`
But I get this exception:
java.lang.NoSuchFieldError: SASL_PROPERTIES
org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration.<clinit>(PropertiesBasedEJBClientConfiguration.java:79)
Can anyone help?
It turns out I was getting this error because I wasn't using the correct EJB Client jar.
I guess jboss-ejb-client-1.0.16.Final.jar introduced this field, and it works fine when used with this jar.