1 31 32 package org.objectweb.proactive.ext.security; 33 34 import java.io.Serializable ; 35 36 37 43 public class Communication implements Serializable { 44 public static int REQUIRED = 1; 45 public static int DENIED = -1; 46 public static int OPTIONAL = 0; 47 public static int ALLOWED = 1; 48 49 50 private int authentication; 51 52 53 private int confidentiality; 54 55 56 private int integrity; 57 58 59 private int communication; 60 private int migration; 61 private int aoCreation; 62 63 67 public Communication() { 68 authentication = 0; 69 confidentiality = 0; 70 integrity = 0; 71 communication = 1; 72 migration = 1; 73 aoCreation = 1; 74 } 75 76 83 public Communication(int authentication, int confidentiality, int integrity) { 84 this.authentication = authentication; 85 this.confidentiality = confidentiality; 86 this.integrity = integrity; 87 } 88 89 93 public boolean isAuthenticationEnabled() { 94 return authentication == 1; 95 } 96 97 101 public boolean isConfidentialityEnabled() { 102 return confidentiality == 1; 103 } 104 105 109 public boolean isIntegrityEnabled() { 110 return integrity == 1; 111 } 112 113 117 public boolean isAuthenticationForbidden() { 118 return authentication == -1; 119 } 120 121 125 public boolean isConfidentialityForbidden() { 126 return confidentiality == -1; 127 } 128 129 133 public boolean isIntegrityForbidden() { 134 return integrity == -1; 135 } 136 137 141 public boolean isCommunicationAllowed() { 142 return communication == 1; 143 } 144 145 public String toString() { 146 return "Com : " + communication + " Auth : " + authentication + 147 " Conf : " + confidentiality + " Integrity : " + integrity + "\n"; 148 } 149 150 153 public void setMigration(int i) { 154 migration = i; 155 } 156 157 160 public int getMigration() { 161 return migration; 162 } 163 164 171 public static Communication computeCommunication(Communication from, 172 Communication to) throws IncompatiblePolicyException { 173 if (from.isCommunicationAllowed() && to.isCommunicationAllowed()) { 174 if (((from.authentication == REQUIRED) && 175 (to.authentication == DENIED)) || 176 ((from.confidentiality == REQUIRED) && 177 (to.confidentiality == DENIED)) || 178 ((from.integrity == REQUIRED) && (to.integrity == DENIED)) || 179 ((from.authentication == DENIED) && 180 (to.authentication == REQUIRED)) || 181 ((from.confidentiality == DENIED) && 182 (to.confidentiality == REQUIRED)) || 183 ((from.integrity == DENIED) && (to.integrity == REQUIRED))) { 184 throw new IncompatiblePolicyException("incompatible policies"); 185 } 186 } 187 188 return new Communication(from.authentication + to.authentication, 189 from.confidentiality + to.confidentiality, 190 from.integrity + to.integrity); 191 } 192 193 196 public void setAOCreation(int aocreation) { 197 this.aoCreation = aocreation; 198 } 199 200 203 public int getAOCreation() { 204 return this.aoCreation; 205 } 206 207 210 public int getCommunication() { 211 return communication; 212 } 213 214 217 public void setCommunication(int i) { 218 communication = i; 219 } 220 } 221 | Popular Tags |