org/objectweb/proactive/ext/security/Communication.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.ext.security;
00032 
00033 import java.io.Serializable;
00034 
00035 import org.objectweb.proactive.ext.security.exceptions.IncompatiblePolicyException;
00036 
00037 
00042 public class Communication implements Serializable {
00043     public static int REQUIRED = 1;
00044     public static int DENIED = -1;
00045     public static int OPTIONAL = 0;
00046     public static int ALLOWED = 1;
00047 
00048     /* indicates if authentication is required,optional or denied */
00049     private int authentication;
00050 
00051     /* indicates if confidentiality is required,optional or denied */
00052     private int confidentiality;
00053 
00054     /* indicates if integrity is required,optional or denied */
00055     private int integrity;
00056 
00057     /* indicates if communication between active objects is allowed or not */
00058     private int communication;
00059     private int migration;
00060     private int aoCreation;
00061 
00066     public Communication() {
00067         authentication = 0;
00068         confidentiality = 0;
00069         integrity = 0;
00070         communication = 1;
00071         migration = 1;
00072         aoCreation = 1;
00073     }
00074 
00081     public Communication(int authentication, int confidentiality, int integrity) {
00082         this.authentication = authentication;
00083         this.confidentiality = confidentiality;
00084         this.integrity = integrity;
00085     }
00086 
00091     public boolean isAuthenticationEnabled() {
00092         return authentication == 1;
00093     }
00094 
00099     public boolean isConfidentialityEnabled() {
00100         return confidentiality == 1;
00101     }
00102 
00107     public boolean isIntegrityEnabled() {
00108         return integrity == 1;
00109     }
00110 
00115     public boolean isAuthenticationForbidden() {
00116         return authentication == -1;
00117     }
00118 
00123     public boolean isConfidentialityForbidden() {
00124         return confidentiality == -1;
00125     }
00126 
00131     public boolean isIntegrityForbidden() {
00132         return integrity == -1;
00133     }
00134 
00139     public boolean isCommunicationAllowed() {
00140         return communication == 1;
00141     }
00142 
00143     public String toString() {
00144         return "Com : " + communication + " Auth : " + authentication +
00145         " Conf : " + confidentiality + " Integrity : " + integrity + "\n";
00146     }
00147 
00151     public void setMigration(int i) {
00152         migration = i;
00153     }
00154 
00158     public int getMigration() {
00159         return migration;
00160     }
00161 
00169     public static Communication computeCommunication(Communication from,
00170         Communication to) throws IncompatiblePolicyException {
00171         if (from.isCommunicationAllowed() && to.isCommunicationAllowed()) {
00172             if (((from.authentication == REQUIRED) &&
00173                     (to.authentication == DENIED)) ||
00174                     ((from.confidentiality == REQUIRED) &&
00175                     (to.confidentiality == DENIED)) ||
00176                     ((from.integrity == REQUIRED) && (to.integrity == DENIED)) ||
00177                     ((from.authentication == DENIED) &&
00178                     (to.authentication == REQUIRED)) ||
00179                     ((from.confidentiality == DENIED) &&
00180                     (to.confidentiality == REQUIRED)) ||
00181                     ((from.integrity == DENIED) && (to.integrity == REQUIRED))) {
00182                 throw new IncompatiblePolicyException("incompatible policies");
00183             }
00184         }
00185 
00186         return new Communication(from.authentication + to.authentication,
00187             from.confidentiality + to.confidentiality,
00188             from.integrity + to.integrity);
00189     }
00190 
00194     public void setAOCreation(int aocreation) {
00195         this.aoCreation = aocreation;
00196     }
00197 
00201     public int getAOCreation() {
00202         return this.aoCreation;
00203     }
00204 
00208     public int getCommunication() {
00209         return communication;
00210     }
00211 
00215     public void setCommunication(int i) {
00216         communication = i;
00217     }
00218 }

Generated on Mon Jan 22 15:16:10 2007 for ProActive by  doxygen 1.5.1