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