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.
Related
I had a service which tries to use kerberos ticket cache but I always get error like
Caused by: java.lang.RuntimeException: GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos credentails).
If I do not use ticket caching, everything seems just works.
Below is the parameters I use to specify ticket caching.
loginContext = new LoginContext("", null, null, new Configuration()
{
#Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name)
{
Map<String, String> options = new HashMap<>();
options.put("refreshKrb5Config", "true");
options.put("doNotPrompt", "true");
if (LOG.isDebugEnabled()) {
options.put("debug", "true");
}
if (config.getKeytab() != null) {
options.put("keyTab", config.getKeytab().getAbsolutePath());
}
options.put("isInitiator", "false");
options.put("useKeyTab", "true");
options.put("principal", servicePrincipal);
//options.put("storeKey", "true");
//manually specify /tmp/krb5cc_ServiceUid for ticketCache
options.put("ticketCache", config.getCredentialCache().getAbsolutePath());
options.put("useTicketCache", "true");
options.put("renewTGT", "true");
return new AppConfigurationEntry[] {new AppConfigurationEntry(Krb5LoginModule.class.getName(), REQUIRED, options)};
}
});
loginContext.login();
Then I use below code snippets to get the credential:
String name = loginContext.getSubject().getPrincipals().iterator().next().getName();
serverCredential = doAs(loginContext.getSubject(), () -> gssManager.createCredential(
//gssManager.createName(config.getServiceName() + "#" + hostname, GSSName.NT_HOSTBASED_SERVICE),
gssManager.createName(name, GSSName.NT_HOSTBASED_SERVICE),
//INDEFINITE_LIFETIME,
DEFAULT_LIFETIME,
/*new Oid[] {
new Oid("1.2.840.113554.1.2.2"), // kerberos 5
new Oid("1.3.6.1.5.5.2") // spnego
},*/
new Oid("1.2.840.113554.1.2.2"),
ACCEPT_ONLY));
Is there anything wrong with above code snippets? I also confirmed that /tmp/krb5cc_ServiceUid indeed exists.
Thank you
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);
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"
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)
Im trying to create a client application connmecting to Sharepoint 2013.
Im receiving this kind of exception, seems the response cant be parsed by the library i used which is chemistry cmis library.
Below is my code:
public Session fillParams() {//define some values for the connection string
Map<String, String> parameter = new HashMap<String, String>();
// Set the user credentials
parameter.put(SessionParameter.USER, "**");
parameter.put(SessionParameter.PASSWORD, "**");
// Specify the connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://bbdurl.bbd.cloudappsportal.com/sites/_api/web");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Set the alfresco object factory
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// Create a session
SessionFactory factory = SessionFactoryImpl.newInstance();
List<Repository> repositories = new ArrayList<Repository>();
repositories = factory.getRepositories(parameter);
Repository repository = repositories.get(0);
Session session = factory.createSession(parameter);
return session;
}
Full stack trace:
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Unexpected document! Received: Atom Entry
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.parse(AbstractAtomPubService.java:602)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getRepositoriesInternal(AbstractAtomPubService.java:783)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:65)
at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:88)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:133)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:111)
at sample.CMISConnect.fillParams(CMISConnect.java:59)
at sample.CMISConnect.main(CMISConnect.java:70)
This is not a CMIS URL. Make sure that the CMIS producer is activated on SharePoint 2013 (it's turned off by default) and then try this URL pattern: http:///_vti_bin/cmis/rest?getRepositories