How to process credit card in hosted mode via QBMS Java API - intuit-partner-platform

I modified the sample provided here, but it doesn't work for the hosted app.
Clearly the problem is the connection ticket, which should not be used from my understanding.
The following is the java class:
public class MyPayment {
public static void main(String[] args) throws Exception{
QbmsConfiguration qbmsConfiguration =new QbmsConfiguration("/qbmsconnector.properties");
// Create a JAXB-backed QbmsConnector
QbmsConnector qbmsConnector =new JaxbQbmsConnector(qbmsConfiguration);
// Build a charge request...
CreditCardChargeRequest request =new CreditCardChargeRequest();
request.setCreditCardNumber("4111111111111111");
request.setNameOnCard("John Doe");
request.setExpirationMonth(12);
request.setExpirationYear(2014);
request.setAmount(130.00);
// ...define a connection ticket...
String connectionTicket ="TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX";
// ...and make the payment.
try{
CreditCardChargeResponse response = qbmsConnector.creditCardCharge(connectionTicket, request);
System.out.println(response);
}catch(QbmsOperationException e){
System.out.println("Payment failed: "+ e.getMessage());
e.printStackTrace();
}
}
}
Here is the qbmsconnector.properties
qbmsconnector.applicationLogin=loginidxxxxxx
qbmsconnector.applicationId=123456789
qbmsconnector.environment=ptc
qbmsconnector.model=hosted
qbmsconnector.keyStoreLocation=/qbms
qbmsconnector.keyStorePassword=password111
qbmsconnector.certPassword=password111
qbmsconnector.certAlias=alias_abc
It throws the following errors:
Payment failed: Application agent not found TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX
com.intuit.qbmsconnector.response.QbmsResponseStatusException: Application agent not found TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX
at com.intuit.qbmsconnector.jaxb.JaxbResponseExtractor.processSignonNode(Unknown Source)
at com.intuit.qbmsconnector.jaxb.JaxbResponseExtractor.unmarshal(Unknown Source)
at com.intuit.qbmsconnector.jaxb.JaxbResponseExtractor.extractCreditCardChargeResponse(Unknown Source)
at com.intuit.qbmsconnector.jaxb.JaxbQbmsConnector.creditCardCharge(Unknown Source)
at qbo.MyPayment.main(MyPayment.java:30)

This error:
Application agent not found TGT-XXX-XXXXXXXXXXXXXXXXXXXXXX
Generally indicates 1 or 2 things:
You're not using a valid connection ticket (is that the actual connection ticket you're using, or did you XXX out the connection ticket?)
OR
You're using a valid connection ticket, but you're using it with the wrong environment. Connection tickets generated in the PTC environment do not work with the production environment, and vice versa. Did you generate the connection ticket for PTC, or for production?

Related

HttpClient socket exception

I am trying to call some external API hosted on azure from my web Api. The API is working fine on my local machine but when I deploy it IIS on server it starts throwing System.Net.Sockets.SocketException (10060).A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. Although I have increased the request timeout to 5 minutes but connection is silently stopping after 21 seconds and throwing aforementioned exception.
Here is my code:
var telemetries = new TelemetryResponse();
var client = httpClientFactory.CreateClient("Lynx");
client.Timeout = TimeSpan.FromMinutes(5);
var httpResponseMessage = await client.GetAsync("vehicletelemetries/All?key=iLJIbAVXOnpKz5xyF0zV44yepu5OVfmZFhkHM7x");
if (httpResponseMessage.IsSuccessStatusCode)
{
string content = await httpResponseMessage.Content.ReadAsStringAsync();
telemetries = JsonConvert.DeserializeObject<TelemetryResponse>(content);
}
Exception I am getting is:
System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
You got an error code:
WSAETIMEDOUT
10060
Connection timed out.
A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond.
https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2#WSAETIMEDOUT
Check your network connection, ip adress, port and maybe the connection got blocked from a firewall.
Hi guys the culprit was the proxy and we have to configure our HttpClient with proxy while creating it/registering in the DI container. I have registered the HttpClient in DI like this.
var proxySettings = new ProxySetting();
Configuration.Bind(nameof(ProxySetting), proxySettings);
services.AddHttpClient("Lynx", client =>
{
client.BaseAddress = new Uri(Configuration.GetSection("LynxUrl").Value);
}).ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { Proxy = new MyProxy(proxySettings)});
And my proxy code is
public class MyProxy : IWebProxy
{
private readonly ProxySetting _proxySetting;
public MyProxy(ProxySetting proxySetting)
{
_proxySetting = proxySetting;
}
public ICredentials Credentials
{
//get { return new NetworkCredential("username", "password"); }
get { return new NetworkCredential(_proxySetting.UserName, _proxySetting.Password,_proxySetting.Domain); }
set { }
}
public Uri GetProxy(Uri destination)
{
return new Uri(_proxySetting.ProxyUrl);
}
public bool IsBypassed(Uri host)
{
return false;
}
}
It has resolved my problem completely.

Hi im getting below error when im trying to run selenium through eclipse for my local URL test

Getting below error when tried to execute selenium firefox driver for my local URL:
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
ession ID: 107f76f0-251f-4d62-9308-2968ed6e354f
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
at Gmail_login.main(Gmail_login.java:14)
Code
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
public class Gmail_login {
public static void main(String[] args) {
// TODO Auto-generated method stub
// objects and variables instantiation
System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
String appUrl = "https://localhost/qwer";
// launch the firefox browser and open the application url
driver.get(appUrl);
//maximize the browser window
driver.manage().window().maximize();
//declare and initialize the variable to store the expected title of the webpage.
String expectedTitle = "Web Login Service";
//fetch the title of the web page and save it into a string variable
String actualTitle = driver.getTitle();
//compare the expected title of the page with the actual title of the page and print the result
if (expectedTitle.equals(actualTitle))
{
System.out.println("Verification Successful - The correct title is displayed on the web page.");
}
else
{
System.out.println("Verification Failed - An incorrect title is displayed on the web page.");
}
// enter a valid username in the email textbox
WebElement username = driver.findElement(By.id("username"));
username.clear();
username.sendKeys("karthiktest#gmail.com");
// enter a valid password in the password textbox
WebElement password = driver.findElement(By.id("password"));
password.clear();
password.sendKeys("Welcome");
// click on the Sign in button
WebElement SignInButton = driver.findElement(By.name("_eventId_proceed"));
SignInButton.click();
// close the web browser
driver.close();
System.out.println("Test script executed successfully.");
// terminate the program
System.exit(0);
}
}
Firefox driver throws this error if url is not accessible, for example domain name can't be resolved or server blocks connection. It will work if you install webserver on your localhost and serve some content for this url.
You can try to switch firefox to chrome which doesn't throw exception for this scenario. You can also write try-catch block around your driver.get() statement.
This is an INFO message and just so people can see what is going on.
Its not an error and something to worry about.
this message occurs when using version above selenium3.0.0 and geckodriver
this will not stop the script execution.

LDAP Authentication not working with Online LDAP Test Server

I am using the below configuration to connect to Online LDAP Test Server
<className>com.worklight.core.auth.ext.LdapLoginModule</className>
<parameter name="ldapProviderUrl" value="ldap://forumsys.com:389"/>
<parameter name="ldapTimeoutMs" value="2000"/>
<parameter name="ldapSecurityAuthentication" value="simple"/>
<parameter name="validationType" value="searchPattern"/>
<parameter name="ldapSecurityPrincipalPattern" value="uid={username},ou=mathematicians,dc=example,dc=com"/>
<parameter name="ldapSearchFilterPattern" value="(uid={username})"/>
<parameter name="ldapSearchBase" value="dc=example,dc=com"/>
But i am getting
"FWLSE4014W: LdapLoginModule authentication failed. Reason 'javax.naming.CommunicationException: forumsys.com:389 [Root exception is java.net.SocketTimeoutException: connect timed out]" error.
Is there anything wrong with the settings ?
that server is pretty old and the LDAP service is no longer active
This exception is not unique to MobileFirst and so I remove this information from the question.
See here: http://www-01.ibm.com/support/docview.wss?uid=swg21599197.
I suggest that you will follow the same solution steps, which are to verify that you are attempting to correctly connect to your LDAP server.
Recommended but optional: Download a third-party tool (such as the ldapsearch tool) that can verify your server(s) are able to communicate with the LDAP server independent of the Portal ConfigEngine configuration task. Run the tool directly from the Portal server (and Deployment Manager if clustered) to verify all servers can communicate with the LDAP server.
In this particular use case, a network firewall was configured to block all traffic to the LDAP server except from IP addresses that were explicitly whitelisted / permitted to connect. The primary Portal server had been configured in the network firewall to communicate with the LDAP server, but the Deployment Manager had not been configured. Adding the Deployment Manager IP address to the firewall rules allowed the configuration task to complete successfully.
I recently used ForumSys LDAP Test server mentioned using KeyCloak successfully:
You can find all the configuration here.
If you are looking for an easily configurable dockerized test LDAP authentication server.
try
https://hub.docker.com/r/upekshejay/simple-ldap-test-server
I used ForumSys LDAP Test Server
, here is fully tested sample used to check if a user is already inside an active directory.
public class ActiveDirectoryManagerTwo {
final static String domainTree = "dc=example,dc=com";
public static void main(String[] args) {
System.out.println(isInsideActiveDirectory("tesla"));
}
public static String isInsideActiveDirectory(String userName) {
String isFound = "NO";
String rootDN = "cn=read-only-admin,dc=example,dc=com";
String rootPWD = "password";
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, "ldap://ldap.forumsys.com :389");
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PRINCIPAL, rootDN);
environment.put(Context.SECURITY_CREDENTIALS, rootPWD);
DirContext dirContext = null;
NamingEnumeration<?> results = null;
try {
System.out.println("inside try");
dirContext = new InitialDirContext(environment);
SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String filter = "(&(uid=" + userName + "))";
results = dirContext.search(domainTree, filter, controls);
if (results.hasMore()) {
isFound = "YES";
} else {
}
} catch (NamingException e) {
System.out.println("inside catch");
e.printStackTrace();
} finally {
if (results != null) {
try {
results.close();
} catch (Exception e) {
}
}
if (dirContext != null) {
try {
dirContext.close();
} catch (Exception e) {
}
}
}
return isFound;
}
}

SocketIO4Net Handshake Error

I've got a problem with the connection of a client to a socket.io server.
I have following code:
private Client _Client;
private void Initialize(string websocket)
{
try
{
this._Client = new Client(websocket);
this._Client.Connect();
if (!this._Client.IsConnected) throw new Exception("Connection to websocket wasn't successfully: " + this._Client.HandShake.ErrorMessage);
}
catch (Exception ex)
{
Logging.Write("Fehler bei der SocketIO-Connection: " + ex.Message);
Logging.WriteLine("incomplete!", ConsoleColor.Red);
return;
}
Logging.WriteLine("completed!", ConsoleColor.Green);
}
I'm using the websocket-uri
http://127.0.0.1:5116/
When I open that address in browser, it shows me the right socket.io socketserver.
At connection to this socket.io server I get the following error:
Error getting handsake from Socket.IO host instance:
Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.
So it is a http error (400) bad request. But why?
What can I do? I just tried the following code (a solution from a user from a other question):
System.Net.WebRequest.DefaultWebProxy = null;
But that didn't work for me.
I fixed this error by myself.
It was very simple. The handshake of the socket.io version 1.0.x isn't the same as in version 0.9.x. And SocketIO4Net only working with socket.io version 0.9.x. I downgraded to version 0.9.17 and now it's working perfectly :)

Problem calling Request using RequestBuilder

My Code is
String url = "http: gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL
.encode(url));
try {
Request request = builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
Couldn't connect to server (could be timeout, SOP
violation, etc.)
}
public void onResponseReceived(Request request,
Response response) {
System.out.println(response.getText() + "Response");
if (200 == response.getStatusCode()) {
Window.alert(response.getText());
} else {
Window.alert(response.getText());
}
}
});
} catch (RequestException e) {
e.printStackTrace();
}
i receive following error
com.google.gwt.http.client.RequestPermissionException: The URL http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity is invalid or violates the same-origin security restriction
at com.google.gwt.http.client.RequestBuilder.doSend(RequestBuilder.java:378)
at com.google.gwt.http.client.RequestBuilder.sendRequest(RequestBuilder.java:254)
at com.ip.client.IpAddressTest.onModuleLoad(IpAddressTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.google.gwt.http.client.RequestException: (NS_ERROR_DOM_BAD_URI): Access to restricted URI denied
We use GWT for UI which is served by a Coldfusion server and started seeing this error in Hosted Mode.
Changing the Security Level to Medium-Low in the trusted sites zone in IE fixed it for me.
The "Same Origin Policy" is something that browsers implement for the user's security. If you load javascrip code from one web site, that code can't start sending requests to other web sites. It can only send requests to the same site that the code came from.
More details available at GWT docs.
If you are in control of the server that serves the gwt javascript to the browser, you can have some code on that server that sends a request to gd.geobytes.com for you.