This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the filter: | |
@Override | |
public void doFilter( | |
ServletRequest servletRequest, ServletResponse servletResponse, | |
FilterChain filterChain) | |
throws IOException, ServletException { | |
HttpServletRequest request = (HttpServletRequest) servletRequest; | |
HttpServletResponse response = (HttpServletResponse) servletResponse; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl 'http://localhost:8080/web/guest/xxx2?p_p_id=31&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&_31_struts_action=%2Fdocument_library%2Fedit_file_entry&_31_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fxxx2%3Fp_p_id%3D20%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_count%3D1&_31_repositoryId=10184&_31_workflowAction=1' -H 'Pragma: no-cache' -H 'Origin: http://localhost:8080' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: localhost:8080' -H 'Accept-Language: en-US,en;q=0.8,cs;q=0.6' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36' -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary3YXv4YcpdvGMNpE2' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: no-cache' -H 'Referer: http://localhost:8080/web/guest/xxx2?p_p_id=20&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ThemeDisplay themeDisplay = (ThemeDisplay)resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); | |
long groupId = themeDisplay.getScopeGroupId(); // I presume the layout is in the same site as the portlet | |
boolean private = !themeDisplay.getLayout().isPublic(); // I presume the layout is on the same pages as portlet (public pages vs. private pages) | |
String friendlyURL = "/my/page"; | |
Layout targetLayout = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, private, friendlyURL); | |
String portletId = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. | |
* | |
* This library is free software; you can redistribute it and/or modify it under | |
* the terms of the GNU Lesser General Public License as published by the Free | |
* Software Foundation; either version 2.1 of the License, or (at your option) | |
* any later version. | |
* | |
* This library is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. | |
* | |
* This library is free software; you can redistribute it and/or modify it under | |
* the terms of the GNU Lesser General Public License as published by the Free | |
* Software Foundation; either version 2.1 of the License, or (at your option) | |
* any later version. | |
* | |
* This library is distributed in the hope that it will be useful, but WITHOUT | |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>Document</title> | |
</head> | |
<body> | |
innerHTML: <span id="e1"></span><br /> | |
innerText: <span id="e2"></span><br /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>Document</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
/*<![CDATA[*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
It's mainly a mind shift - from ALLOW by default to DENY by default - so that it's OBVIOUS when user is allowed to run each action. | |
This means we list all cases when user IS ALLOWED to perform an action, not the cases when user is denied. | |
Some rules we might find useful: | |
1, every action should have BORDERS => outside the borders is no permission checking for the action | |
2, in every action we list the cases when user IS ALLOWED => no more {PrincipalException}s thrown in each check | |
3, in the end we DENY the execution by throwing PrincipalException => default behavior of the checkPermission method is DENY | |
4, render, processAction and serveResource must always call the checkPermission method(s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimplePortlet extends GenericPortlet { | |
public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { | |
String page = request.getParameter("page"); | |
PortletContext portletContext = getPortletContext(); | |
PortletRequestDispatcher portletRequestDispatcher = null; | |
if(page == null){ | |
portletRequestDispatcher = portletContext.getRequestDispatcher("/WEB-INF/my-portlet-folder/view.jsp"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> values = new ArrayList<String>(); | |
for (String param : actionRequest.getParameterMap().keySet()) { | |
if (param.startsWith(prefix) && !param.endsWith("--Checkbox")) { | |
values.add(actionRequest.getParameter(param)); | |
} | |
} |