1   /**
2    * Copyright (c) 2000-2007 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  import com.liferay.portal.service.http.TunnelUtil;
35  
36  /**
37   * <a href="PasswordPolicyServiceHttp.java.html"><b><i>View Source</i></b></a>
38   *
39   * <p>
40   * ServiceBuilder generated this class. Modifications in this class will be overwritten
41   * the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This class provides a HTTP utility for the <code>com.liferay.portal.service.PasswordPolicyServiceUtil</code>
46   * service 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> parameter.
49   * </p>
50   *
51   * <p>
52   * The benefits of using the HTTP utility is that it is fast and allows for tunneling
53   * without the cost of serializing to text. The drawback is that it only works with
54   * Java.
55   * </p>
56   *
57   * <p>
58   * Set the property <code>tunnel.servlet.hosts.allowed</code> in portal.properties
59   * to configure security.
60   * </p>
61   *
62   * <p>
63   * The HTTP utility is only generated for remote services.
64   * </p>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   * @see com.liferay.portal.security.auth.HttpPrincipal
69   * @see com.liferay.portal.service.PasswordPolicyServiceUtil
70   * @see com.liferay.portal.service.http.PasswordPolicyServiceSoap
71   *
72   */
73  public class PasswordPolicyServiceHttp {
74      public static com.liferay.portal.model.PasswordPolicy addPasswordPolicy(
75          HttpPrincipal httpPrincipal, java.lang.String name,
76          java.lang.String description, boolean changeable,
77          boolean changeRequired, long minAge, boolean checkSyntax,
78          boolean allowDictionaryWords, int minLength, boolean history,
79          int historyCount, boolean expireable, long maxAge, long warningTime,
80          int graceLimit, boolean lockout, int maxFailure, long lockoutDuration,
81          long resetFailureCount)
82          throws com.liferay.portal.SystemException, 
83              com.liferay.portal.PortalException {
84          try {
85              Object paramObj0 = name;
86  
87              if (name == null) {
88                  paramObj0 = new NullWrapper("java.lang.String");
89              }
90  
91              Object paramObj1 = description;
92  
93              if (description == null) {
94                  paramObj1 = new NullWrapper("java.lang.String");
95              }
96  
97              Object paramObj2 = new BooleanWrapper(changeable);
98              Object paramObj3 = new BooleanWrapper(changeRequired);
99              Object paramObj4 = new LongWrapper(minAge);
100             Object paramObj5 = new BooleanWrapper(checkSyntax);
101             Object paramObj6 = new BooleanWrapper(allowDictionaryWords);
102             Object paramObj7 = new IntegerWrapper(minLength);
103             Object paramObj8 = new BooleanWrapper(history);
104             Object paramObj9 = new IntegerWrapper(historyCount);
105             Object paramObj10 = new BooleanWrapper(expireable);
106             Object paramObj11 = new LongWrapper(maxAge);
107             Object paramObj12 = new LongWrapper(warningTime);
108             Object paramObj13 = new IntegerWrapper(graceLimit);
109             Object paramObj14 = new BooleanWrapper(lockout);
110             Object paramObj15 = new IntegerWrapper(maxFailure);
111             Object paramObj16 = new LongWrapper(lockoutDuration);
112             Object paramObj17 = new LongWrapper(resetFailureCount);
113             MethodWrapper methodWrapper = new MethodWrapper(PasswordPolicyServiceUtil.class.getName(),
114                     "addPasswordPolicy",
115                     new Object[] {
116                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
117                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
118                         paramObj10, paramObj11, paramObj12, paramObj13,
119                         paramObj14, paramObj15, paramObj16, paramObj17
120                     });
121             Object returnObj = null;
122 
123             try {
124                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
125             }
126             catch (Exception e) {
127                 if (e instanceof com.liferay.portal.SystemException) {
128                     throw (com.liferay.portal.SystemException)e;
129                 }
130 
131                 if (e instanceof com.liferay.portal.PortalException) {
132                     throw (com.liferay.portal.PortalException)e;
133                 }
134 
135                 throw new com.liferay.portal.SystemException(e);
136             }
137 
138             return (com.liferay.portal.model.PasswordPolicy)returnObj;
139         }
140         catch (com.liferay.portal.SystemException se) {
141             _log.error(se, se);
142             throw se;
143         }
144     }
145 
146     public static void deletePasswordPolicy(HttpPrincipal httpPrincipal,
147         long passwordPolicyId)
148         throws com.liferay.portal.SystemException, 
149             com.liferay.portal.PortalException {
150         try {
151             Object paramObj0 = new LongWrapper(passwordPolicyId);
152             MethodWrapper methodWrapper = new MethodWrapper(PasswordPolicyServiceUtil.class.getName(),
153                     "deletePasswordPolicy", new Object[] { paramObj0 });
154 
155             try {
156                 TunnelUtil.invoke(httpPrincipal, methodWrapper);
157             }
158             catch (Exception e) {
159                 if (e instanceof com.liferay.portal.SystemException) {
160                     throw (com.liferay.portal.SystemException)e;
161                 }
162 
163                 if (e instanceof com.liferay.portal.PortalException) {
164                     throw (com.liferay.portal.PortalException)e;
165                 }
166 
167                 throw new com.liferay.portal.SystemException(e);
168             }
169         }
170         catch (com.liferay.portal.SystemException se) {
171             _log.error(se, se);
172             throw se;
173         }
174     }
175 
176     public static com.liferay.portal.model.PasswordPolicy updatePasswordPolicy(
177         HttpPrincipal httpPrincipal, long passwordPolicyId,
178         java.lang.String name, java.lang.String description,
179         boolean changeable, boolean changeRequired, long minAge,
180         boolean checkSyntax, boolean allowDictionaryWords, int minLength,
181         boolean history, int historyCount, boolean expireable, long maxAge,
182         long warningTime, int graceLimit, boolean lockout, int maxFailure,
183         long lockoutDuration, long resetFailureCount)
184         throws com.liferay.portal.SystemException, 
185             com.liferay.portal.PortalException {
186         try {
187             Object paramObj0 = new LongWrapper(passwordPolicyId);
188             Object paramObj1 = name;
189 
190             if (name == null) {
191                 paramObj1 = new NullWrapper("java.lang.String");
192             }
193 
194             Object paramObj2 = description;
195 
196             if (description == null) {
197                 paramObj2 = new NullWrapper("java.lang.String");
198             }
199 
200             Object paramObj3 = new BooleanWrapper(changeable);
201             Object paramObj4 = new BooleanWrapper(changeRequired);
202             Object paramObj5 = new LongWrapper(minAge);
203             Object paramObj6 = new BooleanWrapper(checkSyntax);
204             Object paramObj7 = new BooleanWrapper(allowDictionaryWords);
205             Object paramObj8 = new IntegerWrapper(minLength);
206             Object paramObj9 = new BooleanWrapper(history);
207             Object paramObj10 = new IntegerWrapper(historyCount);
208             Object paramObj11 = new BooleanWrapper(expireable);
209             Object paramObj12 = new LongWrapper(maxAge);
210             Object paramObj13 = new LongWrapper(warningTime);
211             Object paramObj14 = new IntegerWrapper(graceLimit);
212             Object paramObj15 = new BooleanWrapper(lockout);
213             Object paramObj16 = new IntegerWrapper(maxFailure);
214             Object paramObj17 = new LongWrapper(lockoutDuration);
215             Object paramObj18 = new LongWrapper(resetFailureCount);
216             MethodWrapper methodWrapper = new MethodWrapper(PasswordPolicyServiceUtil.class.getName(),
217                     "updatePasswordPolicy",
218                     new Object[] {
219                         paramObj0, paramObj1, paramObj2, paramObj3, paramObj4,
220                         paramObj5, paramObj6, paramObj7, paramObj8, paramObj9,
221                         paramObj10, paramObj11, paramObj12, paramObj13,
222                         paramObj14, paramObj15, paramObj16, paramObj17,
223                         paramObj18
224                     });
225             Object returnObj = null;
226 
227             try {
228                 returnObj = TunnelUtil.invoke(httpPrincipal, methodWrapper);
229             }
230             catch (Exception e) {
231                 if (e instanceof com.liferay.portal.SystemException) {
232                     throw (com.liferay.portal.SystemException)e;
233                 }
234 
235                 if (e instanceof com.liferay.portal.PortalException) {
236                     throw (com.liferay.portal.PortalException)e;
237                 }
238 
239                 throw new com.liferay.portal.SystemException(e);
240             }
241 
242             return (com.liferay.portal.model.PasswordPolicy)returnObj;
243         }
244         catch (com.liferay.portal.SystemException se) {
245             _log.error(se, se);
246             throw se;
247         }
248     }
249 
250     private static Log _log = LogFactoryUtil.getLog(PasswordPolicyServiceHttp.class);
251 }