KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > security > implementation > basic > ClassLoginModule


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.security.implementation.basic;
11
12 import java.util.Map JavaDoc;
13
14 import org.mmbase.security.Rank;
15
16 /**
17  * Support for authentication method 'class' for 'basic' authentication.
18  *
19  * @author Michiel Meeuwissen
20  * @version $Id: ClassLoginModule.java,v 1.3 2005/01/30 16:46:37 nico Exp $
21  * @since MMBase-1.8
22  */

23 public class ClassLoginModule implements LoginModule {
24
25     private Map JavaDoc ranks;
26
27     public void load(Map JavaDoc properties) {
28         ranks = properties;
29     }
30
31     public boolean login(NameContext user, Map JavaDoc loginInfo, Object JavaDoc[] parameters) {
32         org.mmbase.security.classsecurity.ClassAuthentication.Login li = org.mmbase.security.classsecurity.ClassAuthentication.classCheck("class");
33         if (li == null) {
34             throw new SecurityException JavaDoc("Class authentication failed (class not authorized)");
35         }
36         String JavaDoc userName = (String JavaDoc) li.getMap().get("username");
37
38         String JavaDoc r = (String JavaDoc) ranks.get(userName);
39         Rank rank;
40         if (r == null) {
41             rank = Rank.BASICUSER;
42         } else {
43             rank = Rank.getRank(r);
44         }
45
46         user.setIdentifier(userName);
47         user.setRank(rank);
48         return true;
49     }
50 }
51
Popular Tags