View Javadoc

1   /**
2    * This file Copyright (c) 2003-2011 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.context.MgnlContext;
38  
39  import java.util.Collection;
40  import java.util.Map;
41  
42  import javax.jcr.Value;
43  import javax.security.auth.Subject;
44  
45  /**
46   * Manages the JAAS users.
47   * @author philipp
48   * @version $Revision:9391 $ ($Author:scharles $)
49   */
50  public class ExternalUserManager implements UserManager {
51  
52      @Override
53      public User getUser(String name) throws UnsupportedOperationException {
54          // we only support accessing current User object
55          // - implement source specific UserManager if needed
56          if (name.equalsIgnoreCase(MgnlContext.getUser().getName())) {
57              return MgnlContext.getUser();
58          }
59          throw new UnsupportedOperationException("not implemented yet");
60      }
61  
62      /**
63       * Initialize new user using JAAS authenticated/authorized subject.
64       * @param subject
65       * @throws UnsupportedOperationException
66       */
67      @Override
68      public User getUser(Subject subject) throws UnsupportedOperationException {
69          return new ExternalUser(subject);
70      }
71  
72      @Override
73      public Collection<User> getAllUsers() throws UnsupportedOperationException {
74          throw new UnsupportedOperationException("not implemented yet");
75      }
76  
77      @Override
78      public User createUser(String name, String pw) throws UnsupportedOperationException {
79          throw new UnsupportedOperationException("not implemented yet");
80      }
81  
82      @Override
83      public User changePassword(User user, String newPassword) throws UnsupportedOperationException {
84          throw new UnsupportedOperationException("not implemented yet");
85      }
86  
87      /**
88       * SystemUserManager does this.
89       */
90      @Override
91      public User getSystemUser() throws UnsupportedOperationException {
92          throw new UnsupportedOperationException();
93      }
94  
95      /**
96       * SystemUserManager does this.
97       */
98      @Override
99      public User getAnonymousUser() throws UnsupportedOperationException {
100         throw new UnsupportedOperationException();
101     }
102 
103     @Override
104     public void updateLastAccessTimestamp(User user) throws UnsupportedOperationException {
105         throw new UnsupportedOperationException();
106     }
107 
108     @Override
109     public boolean hasAny(String name, String roleName, String nodeRoles) throws UnsupportedOperationException {
110         throw new UnsupportedOperationException("not implemented yet");
111     }
112 
113     @Override
114     public Map<String,ACL> getACLs(User user) {
115         throw new UnsupportedOperationException("not implemented yet");
116     }
117 
118     @Override
119     public User addRole(User user, String roleName) {
120         throw new UnsupportedOperationException("not implemented yet");
121     }
122 
123     @Override
124     public User addGroup(User user, String groupName) {
125         throw new UnsupportedOperationException("not implemented yet");
126     }
127 
128     @Override
129     public int getLockTimePeriod() {
130         throw new UnsupportedOperationException("Not supported by this user manager.");
131     }
132 
133     @Override
134     public int getMaxFailedLoginAttempts() {
135         throw new UnsupportedOperationException("Not supported by this user manager.");
136     }
137 
138     @Override
139     public void setLockTimePeriod(int lockTimePeriod){
140         throw new UnsupportedOperationException("Not supported by this user manager.");
141     }
142 
143     @Override
144     public void setMaxFailedLoginAttempts(int maxFailedLoginAttempts){
145         throw new UnsupportedOperationException("Not supported by this user manager.");
146     }
147 
148     @Override
149     public User setProperty(User user, String propertyName, Value propertyValue) {
150         throw new UnsupportedOperationException("Not supported by this user manager.");
151     }
152 
153     @Override
154     public User removeGroup(User user, String groupName) {
155         throw new UnsupportedOperationException("not implemented yet");
156     }
157 
158     @Override
159     public User removeRole(User user, String roleName) {
160         throw new UnsupportedOperationException("not implemented yet");
161     }
162 }