View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.administration;
18  
19  import java.util.List;
20  import java.util.Map;
21  
22  import javax.portlet.PortletConfig;
23  import javax.portlet.PortletRequest;
24  import javax.portlet.PortletResponse;
25  import org.apache.jetspeed.security.User;
26  
27  /***
28   * PortalAdministration
29   * 
30   * Aggregate portal administration functions:
31   *  - Emails
32   *  - Registration
33   *  - Password Generation
34   * 
35   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
36   * @version $Id: $
37   */
38  public interface PortalAdministration
39  {    
40      /***
41       * Registers and creates a new user, assigning userInfo, roles, groups, 
42       * profiling rules and a folder template. If any values are null, defaults
43       * are used from the system wide configuration.
44       * 
45       * @param userName Unique user principal identifier
46       * @param password Password for this user
47       * @param roles A list of roles to assign to this user
48       * @param groups A list of groups to assign to this user
49       * @param userInfo Portlet API User Information Attributes name value pairs (PLT.D) 
50       * @param rules A map of name value pairs of profiling rules. 
51       *              Well known rules names are 'page' and 'menu' 
52       * @param folderTemplate The full PSML path name of a folder to be deep
53       *               copied as the new user's set of folders, pages, links
54       * @param subsite The subsite folder to place the new user in
55       * @since 2.1.2              
56       */
57      void registerUser(String userName, 
58                        String password, 
59                        List roles, 
60                        List groups,
61                        Map userInfo,                       
62                        Map rules,
63                        String template,
64                        String subsiteFolder)
65          throws RegistrationException;
66  
67      void registerUser(String userName, 
68              String password, 
69              List roles, 
70              List groups,
71              Map userInfo,                       
72              Map rules,
73              String template)
74          throws RegistrationException;
75   
76      /***
77       * Register a new user using all default values
78       * 
79       * @param userName
80       * @param password
81       */
82      void registerUser(String userName, String password)
83          throws RegistrationException;
84      
85      /***
86       * Generate a unique password
87       * 
88       * @return unique password
89       */
90      String generatePassword();
91      
92      /***
93       * Helper to send an email to a recipient
94       * 
95       * @param recipient the email address of the recipient
96       * @param localizedSubject the subject of the email as a localized string
97       * @param message the email message content
98       * @parm userAttributes map of user attributes
99       * @throws AdministrationEmailException
100      */
101     public void sendEmail(PortletConfig portletConfig,
102                           String emailAddress, 
103                           String localizedSubject, 
104                           String templatePath,
105                           Map userAttributes)
106         throws AdministrationEmailException;
107     
108     /***
109      * Helper to send an email to a recipient without the portal default sender, and without mail merge
110      * 
111      * @param from the email address of the sender
112      * @param subject the subject of the email
113      * @param to the recipient email address
114      * @param text the message text
115      * @throws AdministrationEmailException
116      */
117     public void sendEmail(String from, String subject, String to, String text) throws AdministrationEmailException;    
118     
119     /***
120      * Lookup a user given an email address
121      * 
122      * @param email Given email address
123      * @return a Jetspeed <code>User</code>, or throw exception if not found
124      * @throws AdministrationEmailException
125      */
126     public User lookupUserFromEmail(String email)
127     throws AdministrationEmailException;
128     
129     /***
130      * Provide a common way to get portal URLs
131      * Necessary for generating return URLs for features such as 
132      * forgotten password. The URL generated will be a combination
133      * of the Jetspeed base URL plus the path parameter appended 
134      * Example:
135      *  base URL = http://www.apache.org/jetspeed/portal
136      *      path = /system/forgotten-password.psml
137      *  Returns: 
138      *     http://www.apache.org/jetspeed/portal/system/forgotten-password.psml
139      *     
140      * @param request The portlet request.
141      * @param response The portlet response, used to encode the path
142      * @param path The relative path to a portal resource
143      * @return the base Jetspeed portal URL plus the appended path parameter
144      */
145     String getPortalURL(PortletRequest request, PortletResponse response, String path);
146     
147     
148     /***
149      * @param guid    The ID which is passed throughte URL to the user
150      * @return
151      */
152     public Map getNewLoginInfo(String guid);
153     /***
154      * @param guid    the ID which is passed through the URL to the user.. 
155      * @param info    a Map, info from which will be used to reset the password
156      *                the password in this case is NOT encrypted, but this should probably
157      *                change if this information is stored on disk... ie a database
158      */
159     public void putNewLoginInfo(String guid, Map info);
160     
161     /***
162      * @param guid    the ID which will be removed from the storage when the info is no longer valid
163      */
164     public void removeNewLoginInfo(String guid);
165         
166 }
167