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