1
22
23 package com.liferay.taglib.security;
24
25 import com.liferay.portal.kernel.util.MethodInvoker;
26 import com.liferay.portal.kernel.util.MethodWrapper;
27 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
28 import com.liferay.portal.kernel.util.StringUtil;
29
30 import java.util.HashSet;
31 import java.util.Set;
32
33 import javax.servlet.jsp.JspException;
34 import javax.servlet.jsp.tagext.TagSupport;
35
36
42 public class EncryptTag extends TagSupport {
43
44 public int doStartTag() throws JspException {
45 ClassLoader contextClassLoader =
46 Thread.currentThread().getContextClassLoader();
47
48 try {
49 Thread.currentThread().setContextClassLoader(
50 PortalClassLoaderUtil.getClassLoader());
51
52 MethodWrapper methodWrapper = new MethodWrapper(
53 _TAG_CLASS, _TAG_DO_START_METHOD,
54 new Object[] {
55 _className, _style, _protocol, _unencryptedParamsSet, _url,
56 _target, pageContext
57 });
58
59 MethodInvoker.invoke(methodWrapper);
60 }
61 catch (Exception e) {
62 throw new JspException(e);
63 }
64 finally {
65 Thread.currentThread().setContextClassLoader(contextClassLoader);
66 }
67
68 return EVAL_BODY_INCLUDE;
69 }
70
71 public int doEndTag() throws JspException {
72 ClassLoader contextClassLoader =
73 Thread.currentThread().getContextClassLoader();
74
75 try {
76 Thread.currentThread().setContextClassLoader(
77 PortalClassLoaderUtil.getClassLoader());
78
79 MethodWrapper methodWrapper = new MethodWrapper(
80 _TAG_CLASS, _TAG_DO_END_METHOD, new Object[] {pageContext});
81
82 MethodInvoker.invoke(methodWrapper);
83 }
84 catch (Exception e) {
85 throw new JspException(e);
86 }
87 finally {
88 Thread.currentThread().setContextClassLoader(contextClassLoader);
89 }
90
91 return EVAL_PAGE;
92 }
93
94 public void setClassName(String className) {
95 _className = className;
96 }
97
98 public void setStyle(String style) {
99 _style = style;
100 }
101
102 public void setProtocol(String protocol) {
103 _protocol = protocol;
104 }
105
106 public void setUnencryptedParams(String unencryptedParams) {
107 _unencryptedParamsSet.clear();
108
109 String[] unencryptedParamsArray = StringUtil.split(unencryptedParams);
110
111 for (int i = 0; i < unencryptedParamsArray.length; i++) {
112 _unencryptedParamsSet.add(unencryptedParamsArray[i]);
113 }
114 }
115
116 public void setUrl(String url) {
117 _url = url;
118 }
119
120 public void setTarget(String target) {
121 _target = target;
122 }
123
124 private static final String _TAG_CLASS =
125 "com.liferay.portal.servlet.taglib.security.EncryptTagUtil";
126
127 private static final String _TAG_DO_START_METHOD = "doStartTag";
128
129 private static final String _TAG_DO_END_METHOD = "doEndTag";
130
131 private String _className;
132 private String _style;
133 private String _protocol;
134 private Set<String> _unencryptedParamsSet = new HashSet<String>();
135 private String _url;
136 private String _target;
137
138 }