View Javadoc

1   /**
2    * This file Copyright (c) 2003-2012 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.cms.security;
35  
36  import info.magnolia.cms.security.auth.ACL;
37  import info.magnolia.cms.security.auth.GroupList;
38  import info.magnolia.cms.security.auth.RoleList;
39  import info.magnolia.context.MgnlContext;
40  
41  import java.util.Collection;
42  import java.util.Map;
43  
44  import javax.jcr.Value;
45  import javax.security.auth.Subject;
46  
47  /**
48   * Manages the JAAS users.
49   * @author philipp
50   * @version $Revision:9391 $ ($Author:scharles $)
51   */
52  public class ExternalUserManager implements UserManager {
53  
54      @Override
55      public User getUser(String name) throws UnsupportedOperationException {
56          // we only support accessing current User object
57          // - implement source specific UserManager if needed
58          if (name.equalsIgnoreCase(MgnlContext.getUser().getName())) {
59              return MgnlContext.getUser();
60          }
61          throw new UnsupportedOperationException("not implemented yet");
62      }
63  
64      @Override
65      public User getUserById(final String id) throws UnsupportedOperationException {
66          throw new UnsupportedOperationException("not implemented yet");
67      }
68  
69      /**
70       * Initialize new user using JAAS authenticated/authorized subject.
71       * @param subject
72       * @throws UnsupportedOperationException
73       */
74      @Override
75      public User getUser(Subject subject) throws UnsupportedOperationException {
76          return new ExternalUser(subject);
77      }
78  
79      public User getUser(Map<String, String> properties, GroupList groupList, RoleList roleList){
80          return new ExternalUser(properties, groupList, roleList);
81      }
82  
83      @Override
84      public Collection<User> getAllUsers() throws UnsupportedOperationException {
85          throw new UnsupportedOperationException("not implemented yet");
86      }
87  
88      @Override
89      public User createUser(String name, String pw) throws UnsupportedOperationException {
90          throw new UnsupportedOperationException("not implemented yet");
91      }
92  
93      @Override
94      public User createUser(String path, String name, String pw) throws UnsupportedOperationException {
95          throw new UnsupportedOperationException("not implemented yet");
96      }
97  
98      @Override
99      public User changePassword(User user, String newPassword) throws UnsupportedOperationException {
100         throw new UnsupportedOperationException("not implemented yet");
101     }
102 
103     /**
104      * SystemUserManager does this.
105      */
106     @Override
107     public User getSystemUser() throws UnsupportedOperationException {
108         throw new UnsupportedOperationException();
109     }
110 
111     /**
112      * SystemUserManager does this.
113      */
114     @Override
115     public User getAnonymousUser() throws UnsupportedOperationException {
116         throw new UnsupportedOperationException();
117     }
118 
119     @Override
120     public void updateLastAccessTimestamp(User user) throws UnsupportedOperationException {
121         throw new UnsupportedOperationException();
122     }
123 
124     @Override
125     public boolean hasAny(String name, String roleName, String nodeRoles) throws UnsupportedOperationException {
126         throw new UnsupportedOperationException("not implemented yet");
127     }
128 
129     @Override
130     public Map<String,ACL> getACLs(User user) {
131         throw new UnsupportedOperationException("not implemented yet");
132     }
133 
134     @Override
135     public User addRole(User user, String roleName) {
136         throw new UnsupportedOperationException("not implemented yet");
137     }
138 
139     @Override
140     public User addGroup(User user, String groupName) {
141         throw new UnsupportedOperationException("not implemented yet");
142     }
143 
144     @Override
145     public int getLockTimePeriod() {
146         throw new UnsupportedOperationException("Not supported by this user manager.");
147     }
148 
149     @Override
150     public int getMaxFailedLoginAttempts() {
151         throw new UnsupportedOperationException("Not supported by this user manager.");
152     }
153 
154     @Override
155     public void setLockTimePeriod(int lockTimePeriod){
156         throw new UnsupportedOperationException("Not supported by this user manager.");
157     }
158 
159     @Override
160     public void setMaxFailedLoginAttempts(int maxFailedLoginAttempts){
161         throw new UnsupportedOperationException("Not supported by this user manager.");
162     }
163 
164     @Override
165     public User setProperty(User user, String propertyName, Value propertyValue) {
166         throw new UnsupportedOperationException("Not supported by this user manager.");
167     }
168 
169     @Override
170     public User setProperty(User user, String propertyName, String propertyValue) {
171         throw new UnsupportedOperationException("Not supported by this user manager.");
172     }
173 
174     @Override
175     public User removeGroup(User user, String groupName) {
176         throw new UnsupportedOperationException("not implemented yet");
177     }
178 
179     @Override
180     public User removeRole(User user, String roleName) {
181         throw new UnsupportedOperationException("not implemented yet");
182     }
183 }