1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.http;
21  
22  import com.liferay.portal.kernel.log.Log;
23  import com.liferay.portal.kernel.log.LogFactoryUtil;
24  import com.liferay.portal.kernel.util.BooleanWrapper;
25  import com.liferay.portal.kernel.util.IntegerWrapper;
26  import com.liferay.portal.kernel.util.LongWrapper;
27  import com.liferay.portal.kernel.util.MethodWrapper;
28  import com.liferay.portal.kernel.util.NullWrapper;
29  import com.liferay.portal.security.auth.HttpPrincipal;
30  import com.liferay.portal.service.PasswordPolicyServiceUtil;
31  
32  /**
33   * <a href="PasswordPolicyServiceHttp.java.html"><b><i>View Source</i></b></a>
34   *
35   * <p>
36   * ServiceBuilder generated this class. Modifications in this class will be
37   * overwritten the next time is generated.
38   * </p>
39   *
40   * <p>
41   * This class provides a HTTP utility for the
42   * <code>com.liferay.portal.service.PasswordPolicyServiceUtil</code> service
43   * utility. The static methods of this class calls the same methods of the
44   * service utility. However, the signatures are different because it requires an
45   * additional <code>com.liferay.portal.security.auth.HttpPrincipal</code>
46   * parameter.
47   * </p>
48   *
49   * <p>
50   * The benefits of using the HTTP utility is that it is fast and allows for
51   * tunneling without the cost of serializing to text. The drawback is that it
52   * only works with Java.
53   * </p>
54   *
55   * <p>
56   * Set the property <code>tunnel.servlet.hosts.allowed</code> in
57   * portal.properties to configure security.
58   * </p>
59   *
60   * <p>
61   * The HTTP utility is only generated for remote services.
62   * </p>
63   *
64   * @author Brian Wing Shun Chan
65   *
66   * @see com.liferay.portal.security.auth.HttpPrincipal
67   * @see com.liferay.portal.service.PasswordPolicyServiceUtil
68   * @see com.liferay.portal.service.http.PasswordPolicyServiceSoap
69   *
70   */
71  public class PasswordPolicyServiceHttp {
72      public static com.liferay.portal.model.PasswordPolicy addPasswordPolicy(
73          HttpPrincipal httpPrincipal, java.lang.String name,
74          java.lang.String description, boolean changeable,
75          boolean changeRequired, long minAge, boolean checkSyntax,
76          boolean allowDictionaryWords, int minLength, boolean history,
77          int historyCount, boolean expireable, long maxAge, long warningTime,
78          int graceLimit, boolean lockout, int maxFailure, long lockoutDuration,
79          long resetFailureCount)
80          throws com.liferay.portal.PortalException,
81              com.liferay.portal.SystemException {
82          try {
83              Object paramObj0 = name;
84  
85              if (name == null) {
86                  paramObj0 = new NullWrapper("java.lang.String");
87              }
88  
89              Object paramObj1 = description;
90  
91              if (description == null) {
92                  paramObj1 = new NullWrapper("java.lang.String");
93              }
94  
95              Object paramObj2 = new BooleanWrapper(changeable);
96  
97              Object paramObj3 = new BooleanWrapper(changeRequired);
98  
99              Object paramObj4 = new LongWrapper(minAge);
100 
101             Object paramObj5 = new BooleanWrapper(checkSyntax);
102 
103             Object paramObj6 = new BooleanWrapper(allowDictionaryWords);
104 
105             Object paramObj7 = new IntegerWrapper(minLength);
106 
107             Object paramObj8 = new BooleanWrapper(history);
108 
109             Object paramObj9 = new IntegerWrapper(historyCount);
110 
111             Object paramObj10 = new BooleanWrapper(expireable);
112 
113             Object paramObj11 = new LongWrapper(maxAge);
114 
115             Object paramObj12 = new LongWrapper(warningTime);
116 
117             Object paramObj13 = new IntegerWrapper(graceLimit);
118 
119             Object paramObj14 = new BooleanWrapper(lockout);
120 
121             Object paramObj15 = new IntegerWrapper(maxFailure);
122 
123             Object paramObj16 = new LongWrapper(lockoutDuration);
124 
125             Object paramObj17 = new LongWrapper(resetFailureCount);
126 
127             MethodWrapper methodWrapper = new MethodWrapper(PasswordPolicyServiceUtil.class.getName(),
128                     "addPasswordPolicy",
129                     new Object[] {
130                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
131                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
132                         paramObj10, paramObj11, paramObj12, paramObj13,
133                         paramObj14, paramObj15, paramObj16, paramObj17
134                     });
135 
136             Object returnObj = null;
137 
138             try {
139                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
140             }
141             catch (Exception e) {
142                 if (e instanceof com.liferay.portal.PortalException) {
143                     throw (com.liferay.portal.PortalException)e;
144                 }
145 
146                 if (e instanceof com.liferay.portal.SystemException) {
147                     throw (com.liferay.portal.SystemException)e;
148                 }
149 
150                 throw new com.liferay.portal.SystemException(e);
151             }
152 
153             return (com.liferay.portal.model.PasswordPolicy)returnObj;
154         }
155         catch (com.liferay.portal.SystemException se) {
156             _log.error(se, se);
157 
158             throw se;
159         }
160     }
161 
162     public static void deletePasswordPolicy(HttpPrincipal httpPrincipal,
163         long passwordPolicyId)
164         throws com.liferay.portal.PortalException,
165             com.liferay.portal.SystemException {
166         try {
167             Object paramObj0 = new LongWrapper(passwordPolicyId);
168 
169             MethodWrapper methodWrapper = new MethodWrapper(PasswordPolicyServiceUtil.class.getName(),
170                     "deletePasswordPolicy", new Object[] { paramObj0 });
171 
172             try {
173                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
174             }
175             catch (Exception e) {
176                 if (e instanceof com.liferay.portal.PortalException) {
177                     throw (com.liferay.portal.PortalException)e;
178                 }
179 
180                 if (e instanceof com.liferay.portal.SystemException) {
181                     throw (com.liferay.portal.SystemException)e;
182                 }
183 
184                 throw new com.liferay.portal.SystemException(e);
185             }
186         }
187         catch (com.liferay.portal.SystemException se) {
188             _log.error(se, se);
189 
190             throw se;
191         }
192     }
193 
194     public static com.liferay.portal.model.PasswordPolicy updatePasswordPolicy(
195         HttpPrincipal httpPrincipal, long passwordPolicyId,
196         java.lang.String name, java.lang.String description,
197         boolean changeable, boolean changeRequired, long minAge,
198         boolean checkSyntax, boolean allowDictionaryWords, int minLength,
199         boolean history, int historyCount, boolean expireable, long maxAge,
200         long warningTime, int graceLimit, boolean lockout, int maxFailure,
201         long lockoutDuration, long resetFailureCount)
202         throws com.liferay.portal.PortalException,
203             com.liferay.portal.SystemException {
204         try {
205             Object paramObj0 = new LongWrapper(passwordPolicyId);
206 
207             Object paramObj1 = name;
208 
209             if (name == null) {
210                 paramObj1 = new NullWrapper("java.lang.String");
211             }
212 
213             Object paramObj2 = description;
214 
215             if (description == null) {
216                 paramObj2 = new NullWrapper("java.lang.String");
217             }
218 
219             Object paramObj3 = new BooleanWrapper(changeable);
220 
221             Object paramObj4 = new BooleanWrapper(changeRequired);
222 
223             Object paramObj5 = new LongWrapper(minAge);
224 
225             Object paramObj6 = new BooleanWrapper(checkSyntax);
226 
227             Object paramObj7 = new BooleanWrapper(allowDictionaryWords);
228 
229             Object paramObj8 = new IntegerWrapper(minLength);
230 
231             Object paramObj9 = new BooleanWrapper(history);
232 
233             Object paramObj10 = new IntegerWrapper(historyCount);
234 
235             Object paramObj11 = new BooleanWrapper(expireable);
236 
237             Object paramObj12 = new LongWrapper(maxAge);
238 
239             Object paramObj13 = new LongWrapper(warningTime);
240 
241             Object paramObj14 = new IntegerWrapper(graceLimit);
242 
243             Object paramObj15 = new BooleanWrapper(lockout);
244 
245             Object paramObj16 = new IntegerWrapper(maxFailure);
246 
247             Object paramObj17 = new LongWrapper(lockoutDuration);
248 
249             Object paramObj18 = new LongWrapper(resetFailureCount);
250 
251             MethodWrapper methodWrapper = new MethodWrapper(PasswordPolicyServiceUtil.class.getName(),
252                     "updatePasswordPolicy",
253                     new Object[] {
254                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
255                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
256                         paramObj10, paramObj11, paramObj12, paramObj13,
257                         paramObj14, paramObj15, paramObj16, paramObj17,
258                         paramObj18
259                     });
260 
261             Object returnObj = null;
262 
263             try {
264                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
265             }
266             catch (Exception e) {
267                 if (e instanceof com.liferay.portal.PortalException) {
268                     throw (com.liferay.portal.PortalException)e;
269                 }
270 
271                 if (e instanceof com.liferay.portal.SystemException) {
272                     throw (com.liferay.portal.SystemException)e;
273                 }
274 
275                 throw new com.liferay.portal.SystemException(e);
276             }
277 
278             return (com.liferay.portal.model.PasswordPolicy)returnObj;
279         }
280         catch (com.liferay.portal.SystemException se) {
281             _log.error(se, se);
282 
283             throw se;
284         }
285     }
286 
287     private static Log _log = LogFactoryUtil.getLog(PasswordPolicyServiceHttp.class);
288 }