KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > security > SimpleOfficer


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package sync4j.framework.security;
19
20 import java.security.Principal JavaDoc;
21
22 import sync4j.framework.security.Officer;
23 import sync4j.framework.core.Cred;
24
25 /**
26  * This is a simple implementation of the <i>Officier</i> interface. It always
27  * authenticates and authorizes users and resource accesses.
28  *
29  * @author Stefano Fornari @ Funambol.com
30  * @version $Id: SimpleOfficer.java,v 1.12 2005/03/02 20:57:38 harrie Exp $
31  */

32 public class SimpleOfficer implements Officer {
33     
34     /**
35      * Authenticates a credential.
36      *
37      * @param credential the credential to be authenticated
38      *
39      * @return true if the credential is autenticated, false otherwise
40      */

41     public boolean authenticate(Cred credential) {
42         return true;
43     }
44     
45     /**
46      * Authorizes a resource.
47      *
48      * @param principal the requesting entity
49      * @param resource the name (or the identifier) of the resource to be authorized
50      *
51      * @return true if the credential is authorized to access the resource, false
52      * otherwise
53      */

54     public boolean authorize(Principal JavaDoc principal, String JavaDoc resource) {
55         return true;
56     }
57     
58     /** Un-authenticates a credential.
59      *
60      * @param credential the credential to be unauthenticated
61      */

62     public void unAuthenticate(Cred credential) {
63     }
64     
65     /**
66      * @see sync4j.framework.security.Officer
67      */

68     public boolean isAccountExpired() {
69         return false;
70     }
71     
72     // ------------------------------------------------------------ Private data
73

74     /**
75      * Which type of authetication does impose the server?
76      */

77     private String JavaDoc clientAuth = Cred.AUTH_TYPE_BASIC;
78     public String JavaDoc getClientAuth() {
79         return this.clientAuth;
80     }
81     
82     public void setClientAuth(String JavaDoc clientAuth) {
83         this.clientAuth = clientAuth;
84     }
85     
86     /**
87      * Which type of authetication use the server to send his credential?
88      */

89     private String JavaDoc serverAuth = Cred.AUTH_NONE;
90     public String JavaDoc getServerAuth() {
91         return this.serverAuth;
92     }
93     
94     public void setServerAuth(String JavaDoc serverAuth) {
95         this.serverAuth = serverAuth;
96     }
97 }
Popular Tags