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