Integerate JSP into Joomla as iframe - linux

I have a Joomla (nginx + mysql) site running as UI and some JSP (tomcat + mysql) handling calculation logic.
I want to integrate JSP pages in to Joomla as iframe. I succeeded doing that, but the question is:
How do I make JSP pages NOT visitable to public but only visitable via Joomla site?
For example,
Joomla site is under mydomain.com/Joomla
JSP pages are under mydomain.com/JSP
When a user visit mydomain.com/JSP in the browser, the user cannot see the JSP page(see error or empty page instead).
But when the user open mydomain.com/Joomla in the browser and go to the page that contains the JSP site within an iframe, the user can see the JSP page there.
I am thinking about changing folder/file owner and permission. Am I on the right track? How should I approach exactly?
Thanks,
Milo

You need to change the way you're currently workin on.
1) Use composent JUMI to create virtual Joomla component based on your scripts.
2) On each page add this code at the very beginning of each of your scripts:
<?php
defined( '_JEXEC' ) or die ('Restricted Access');
?>
It'll prevent users for loading directly your scripts without any active Joomla session.

Related

WebSphere Portal - Retain friendly URL after Portlet Action/Render call

I have implemented friendly URL in WebSphere Portal 7.0. So lets say I have page with friendly URL "test" and a portlet added to the page. When I hit Portal URL /wps/myportal/test, the page is loaded with no junk characters(no state information). But as soon as I click on any button inside portlet(any action call to Portlet) I see that the junk characters comes back.
Is there a way to keep URL friendly all the time? How can we avoid generating junk characters on portlet action/render calls?
Note:- We have different portlets for different pages and they were developed based on different framework (Spring, Struts, JSR 286 etc)..
in 7.0 by default no, the action url is needed to tell portal what portlet to target. What you could do is use the resourceAction and do everything rest based and avoid the action url, or set up a servlet to handle actions for the portlet and handle urls through that as well in a rest manner.
You could also redirect after the action url back to a friendly url in your portlet code

How to stop the link from redirecting in Kentico CMS when the user log in as admin/CMS editor?

Is it possible / how to stop the link from redirecting in Kentico CMS when the user log in as admin/CMS editor?
If you want to prevent the logging to CMS (from /CMSPages/logon.aspx) you can create a custom login page and redirect user where you want.
Use the Logon Form web part to achive this. In the properties of that web part you can setup Default target URL, which leads users to approporiate page You want

Programmatically get the url of a page in liferay

I want to create a link in a portlet so that I can navigate to a different page in the liferay portal. I order to do that I am looking for an API (can be liferay specific) that given a page name, would return it's url (it can be the friendlyURL as well).
Portal pages in Liferay are indeed called Layouts in APIs and DB tables. They're identified by plid field, can be obtained using LayoutLocalServiceUtil and related APIs, and also from some other calls like themeDisplay.getLayout().
However in order to build String containing URL to a page you'll have to concatenate friendly URL of portal, group and layout itself (i.e. /web/guest/home - web is portal URL for public pages, guest is friendly URL of guest group by default and home is friendly URL of home page/layout by default). This can be tricky, as you have to check whether this is a public or private page, etc.
And once you start using virtual hosts with friendly URLs for groups, things change. So this is not a good way.
To avoid manually creating URLs and have URLs that are guaranteed to be correct you should use com.liferay.portal.util.PortalUtil.getLayoutFriendlyURL(Layout layout, ThemeDisplay themeDisplay) a static method of PortalUtil - it'll do all the necessary work for you. Though you also need to provide ThemeDisplay and not only Layout.
The API to access pages in Liferay is the LayoutService. However, page names are not unique in Liferay and furthermore they are internationalized. So you need some unique property for a page to retrieve its url, besides its name.
If you really only have the page name, you can use LayoutLocalServiceUtil.getLayouts(...) to loop over all Layouts and check for some property (in this case its name).
At least in Liferay 6.1.20 one can use 'Link Portlet URLs to Page' to make links proceed to antoher page in your portal. It is under ´look and feel´ menu item of your portlet. For me this works fine.
cheers
try this one for current url
${themeDisplay.getURLCurrent()}
try this one for portal url
${themeDisplay.getPortalURL()}

How can I embed an html page into a jsp whilst avoiding repeated logins yet hosting the html separately to the web app?

I have a tomcat hosted web-app, in one of the jsp pages the webapp displays I am using an iframe to embed an html document.
I need to have the html pages separate to the web-app so that they can be altered without requiring a relaunch of the original web-app or access by editors to the web-app.
It is also essential that html pages are secure and not available directly in any way, i.e. only available within this web-app or by authenticating the user. I also want to avoid making the user login to both the web-app and the page in the iframe.
I am not sure how to approach this, I have an apache server, php, and of course tomcat at my disposal.
I can think of two approaches but am not sure how to implement either:
I pass through the authentication details from the jsp page and store all the usernames etc elsewhere for the .htaccess file to check against (not ideal as this means the upkeep of two username / password files)
I somehow enforce that these pages can only be accessed when they are being shown within this iframe i.e. use the web-app as an authenticator and hold the web pages to be only accessible via it.
Presently I can only think of a rather clunky, double log-in way, using .htaccess on an apache server which will require the user to enter a username and password again before viewing the documents.
Can anyone think of a more elegant solution?
Thanks!
CJ
Easiest approach would be to not serve the HTML pages by a public webserver, but just host them in some fixed path outside the public webcontent. Then you can create an servlet which gets an InputStream of the HTML file by FileInputStream and writes it to the OutputStream of the servlet response as obtained by HttpServletResponse#getOutputStream() the usual Java IO way.
Then, in your JSP just change the <iframe> src to point to that servlet instead, along with the desired HTML file as request parameter or pathinfo.
<iframe src="htmlservlet/file.html" />
This way you can control the authentication at one place, the JSP/Servlet webapp.

Liferay error page if at least one portlet is unavailable

I'm trying to setup a custom error page in Liferay portal if at least one portlet fails.
The portal always forwards to portlet_error.jsp and display a red zone in the portlet position.
How can I set a redirect or a forward to a page that fills the complete page layout?
Regards
Inside your JSP you can redirect to a page in Liferay, which can have just one portlet or the way you want it.
Or write your own servlet which in case of error redirects to page in liferay instead of a JSP
If the response is 404 then you can use this property in portal-ext.properties for add your custom page
layout.friendly.url.page.not.found=/html/portal/page_not_found.html

Resources