00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00049 private int authentication;
00050
00051
00052 private int confidentiality;
00053
00054
00055 private int integrity;
00056
00057
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 }