I am using ubuntu 12.04, liferay version 6.0.1, open jdk 6 on my system. I was trying to get remote ip and location in java. For this I have found Host Ip service by which using apache http get method we can get the location. I have executed this successfully on my local system. But On the actual server the liferay portlet is not running and its hard to find the error as multiple instances are running at the same time. The server is a Window based.
I am using this method in a doView() of a MVC Portlet to get ip
com.liferay.portal.util.PortalUtil.getHttpServletRequest(renderRequest).getRemoteAddr()
When I wan't to access http header info I use:
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);
HttpServletRequest originalServletRequest = PortalUtil.getOriginalServletRequest(httpServletRequest);
originalServletRequest.getRemoteAddr();
Usually you cant find the real header information in the httpServletRequest but they are available in the originalServletRequest
This is a partial answer. I do not know the location part of the answer. Hope this helps
Checkout the MyIP Portlet on Liferay Marketplace - it does have a util function that does only part of getting IP address from RenderRequest or PortletRequest object.
You may be interested in looking at the github source of same at : IPAddressUtil.java
Related
Enviornment - Source server#Wildlfy_9.0.2.Final,Destination_Server#Jboss5.x, EJB3.0,BuildingTool#ant
1.Wildfly to Wildfly EJB client without remote-outbound-connections
2.https://docs.jboss.org/author/display/WFLY9/Developer+Guide#DeveloperGuide-EJBinvocationsfromaremoteserver
From above two link i have successfully remote EJB lookup for Wildfly_9.0.2.Final to Wildfly_9.0.2.Final server. After this i want to replace destination server to Jboss 5.x server. I have spent hours looking for tutorials on Google. However I cannot seem to find anything that holds the hand. Can anyone direct me to some link?
You have to add an extension for this as the JNDI lokup has changed between AS5 (jnp) and WildFly. I don't know what is thge current status of https://github.com/jboss-set/jboss-as-legacy but this was the goal of this extension.
I have service (Web Service Proxy) running on DataPower. I am able to test the service from SOAPUI.
Client application / service is trying pull WSDL from URL like http://host:port/uri?WSDL
It is mandatory to pull the WSDL from URL to develop their code.
I have upload the WSDL and share the
http://host:port/system/dpViewer/ServiceName.wsdl?filename=local:/Path/ServiceName.wsdl
Still They were not able to access the URL from their system.
We performed the connectivity to both system. Everything is working fine.
Any help?
You can't access using
http://host:port/system/dpViewer/ServiceName.wsdl?filename=local:/Path/ServiceName.wsd
As it is internal for your reference and It will open your file in Management / Admin IP. (Most of the place there will be different IP for transactions)
http://host:port/uri?WSDL is possible in DataPower
Please follow the below step in your Web Service Proxy (WSP)
Edit front side handler (HTTP SOURCE HANDLER)
Enable 'GET method'
Apply changes and Save Config.
By Default , 'Get method' will not be enabled in WSProxy. As it is disabled, All WSDL get requests are rejected by DataPower.
I hope after this , We can access the WSDL using URL.
I've setup a demo NSB Gateway pretty much based on the samples. all working fine when running from visual studio. msg send from SiteA being received on SiteB.
However after I host SiteB in my local Windows Service (NServiceBus.Host.exe /install), I've noticed that SiteB's url is no longer accessible (ie. http://localhost:25899/SiteB) hence msg sent from SiteA all went into error queue.
Help would be apprecaited!
I've got it sorted!
when installing on the server i just need to add "NServiceBus.Lite NServiceBus.MultiSite" to the command line.
and it's all working as intended.
I tried to deploy a simple hello world application on Micro Cloud Foundry. I went through the process that mentioned in video and set up every thing (My IDE is STS eclipse and Windows 7). When I wanted to make a server on Micro Cloud Foundry: 1) I could not set my server host name to my domain for example "multisite.cloudfoundry.me" it said "The currently selected server type does not support remote hosts" and forced me to put "localhost" as the server name. 2) When I went through the process it started my Grails application and seemed it was running well but the url was broken "http://12431asd.multisite.cloudfoundry.me/" (It asked me for Grails app on this domain I choose "12431asd") and I got the message "VCAP ROUTER: 404 - DESTINATION NOT FOUND". when I tried this url "http://api.multisite.cloudfoundry.me/" I get the message "Welcome to VMware's Cloud Application Platform".
I appreciate any help and suggestions.
Reza
When you add a CloudFoundry server leave the first pane with the default settings and then on the second pane select the "Microcloud" url option setting the name to "multisite" in the popup dialog. Once the plugin has contacted your instance you can go ahead and put the email and the password in.
From there you should just be able to deploy by dragging the application to the server instance in your servers tab, setting the url in the dialog that follows. Once deployed you can double-click the application instance in the server tab and adjust its properties.
Can you verify that when you deployed the application, it's state was started? (it should say next to the application name under the server)
I have a grails 1.3.7 application that makes an https api call to a third party using the apache HttpClient. The third party URL I'm hitting has a valid certificate. I create and execute my request like so:
HttpClient client = new DefaultHttpClient()
List<BasicNameValuePair> queryParams = new ArrayList<BasicNameValuePair>()
queryParams.add(new BasicNameValuePair("a_parameter", "a_parameter_value"))
URI uri = URIUtils.createURI("https", "third.party.address", 443, "/some/url/for/us", URLEncodedUtils.format(queryParams, "UTF-8"), null)
HttpGet httpGet = new HttpGet(uri)
try {
log.debug "Sending request to ${uri}"
return client.execute(httpGet)
} catch(HttpException e) {
log.error "HttpException during location lookup request: ${e}"
return
} catch(IOException e) {
log.error "IOException during location lookup request: ${e}"
return
}
This works fine when I'm running my project in dev mode. I'm also able to directly call the same URL from curl and my browser with no errors. However, once my project is built into a war file and put on a tomcat instance that has a certificate/keystore defined so that clients can connect to US using https, my requests start failing with the following IOException:
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
I'm trying to figure out the point of failure here.
Why is making an https request from curl or my dev mode different than making an https request from an https configured tomcat instance?
The tomcat instance is not publicly accessible, but there are no certificate issues when I connect to it from my browser (chrome says the cert is fine, as does a verbose curl request).
I'm not an https/ssl expert by any stretch, so I'm looking for help explaining what is wrong, why it's wrong, and how I can fix it. I can provide any other needed info.
---Update---
I enabled the javax.net.debug as suggested below and the output included the following error:
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be\
non-empty
My googling has made me think that this issue is because I'm using the following java opt when starting tomcat:
-Djavax.net.ssl.trustStore=/path/to/tomcat/conf/myStore.jks
If that's true, how can I add the things I needed in myStore.jks and not override the defaults so everyone is happy?
The solution for me ended up being that we were overriding the default java trust store with our own with the java opt. This caused the cert sent by the third party to appear to be invalid since we didn't have any of the default root certs in our myStore.jks.
By adding our self-signed cert into the default java one (/lib/security/cacerts) and removing the java opt, everything was fine.
An alternative would be to add everything in the default java store into your custom store and still use the java opt. Whichever you find more maintainable for your situation.
I have seen this error so many times. I have used the following utility to grab a cert from a site that uses SSL. Go here and grab InstallCert. Compile and Run this utility. You can use the file which was generated by this utility as a keystore.