Commit c9b366e0 authored by Alexandre GICQUEL's avatar Alexandre GICQUEL
Browse files

Ca marche il reste que des modif

parent 969c46ae
......@@ -5,13 +5,10 @@ import M1.SimpleCs;
public class M0 {
public static void main(String[] args) {
Server myServer = new Server("myServer",1);
SimpleCs mySystem = new SimpleCs("mySystel",myServer, 1);
Server myServer = new Server("myServer");
SimpleCs mySystem = new SimpleCs("mySystel",myServer);
Client myClient = (Client) mySystem.getListComponent().get(1);
System.out.println(myClient.getNomComponent());
String r = myClient.service("1+1");
System.out.println(r);
}
......
......@@ -15,12 +15,12 @@ public class Client extends Component {
public String service(String requete) {
String send = this.getNomComponent()+"::"+requete;
this.getListPortCompRequis().get(0).setContenue(send);
System.out.println("Port sendRequeste :"+this.getListPortCompRequis().get(0).getContenue());
System.out.println("Etape 1 : Client - sendRequest :"+this.getListPortCompRequis().get(0).getContenue());
String[] receiver = this.getListPortCompRequis().get(0).getContenue().split("::");
while(receiver[0].compareTo("Server")!=0) {
receiver = this.getListPortCompRequis().get(0).getContenue().split("::");
}
System.out.println("Port sendRequeste au retour :"+this.getListPortCompRequis().get(0).getContenue());
System.out.println("Etape 23 : Client - sendRequest(answer) :"+this.getListPortCompRequis().get(0).getContenue());
String receive = receiver[1];
this.getListPortCompRequis().get(0).setContenue("sendRequest");
return receive;
......
......@@ -17,21 +17,18 @@ public class RPC extends Connector {
public void glue() {
while(true) {
if(this.getRoleRequis().getContenue().compareTo("caller")!=0) {
System.out.println(this.getRoleRequis().getContenue());
String[] port = this.getRoleRequis().getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
this.getRoleFournis().setContenue((this.getRoleRequis().getContenue()));
this.getRoleRequis().setContenue("caller");
System.out.println("Role called :"+this.getRoleFournis().getContenue());
}
String[] portAller = this.getRoleRequis().getContenue().split("::");
String[] portRetour = this.getRoleFournis().getContenue().split("::");
if(portAller[0].compareTo("Client0")==0) {
this.getRoleFournis().setContenue((this.getRoleRequis().getContenue()));
this.getRoleRequis().setContenue("caller");
System.out.println("Etape 3 : RPC - Role called :"+this.getRoleFournis().getContenue());
}
if(this.getRoleFournis().getContenue().compareTo("called")!=0) {
String[] port = this.getRoleFournis().getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getRoleRequis().setContenue((this.getRoleFournis().getContenue()));
this.getRoleFournis().setContenue("called");
}
if(portRetour[0].compareTo("Server")==0) {
this.getRoleRequis().setContenue((this.getRoleFournis().getContenue()));
this.getRoleFournis().setContenue("called");
System.out.println("Etape 21 : RPC - Role caller :"+this.getRoleRequis().getContenue());
}
}
......
......@@ -18,23 +18,19 @@ public class ReceiveCalled extends AttachementReqFour {
public void attachement() {
while(true) {
String[] portAller = this.getRoleFournis().getContenue().split("::");
String[] portRetour = this.getPortCompRequis().getContenue().split("::");
if(this.getRoleFournis().getContenue().compareTo("called")!=0){
System.out.println(this.getRoleFournis().getContenue());
String[] port = this.getRoleFournis().getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
this.getPortCompRequis().setContenue(this.getRoleFournis().getContenue());
this.getRoleFournis().setContenue("called");
System.out.println("Port receiveRequest :"+this.getPortCompRequis().getContenue());
}
if(portAller[0].compareTo("Client0")==0){
this.getPortCompRequis().setContenue(this.getRoleFournis().getContenue());
this.getRoleFournis().setContenue("called");
System.out.println("Etape 4 : ReceiveCaller-PortReceiveResquest : "+this.getPortCompRequis().getContenue());
}
if(this.getPortCompRequis().getContenue().compareTo("receiveRequest")!=0) {
String[] port = this.getPortCompRequis().getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getRoleFournis().setContenue(this.getPortCompRequis().getContenue());
this.getPortCompRequis().setContenue("receiveRequest");
}
if(portRetour[0].compareTo("Server")==0) {
this.getRoleFournis().setContenue(this.getPortCompRequis().getContenue());
this.getPortCompRequis().setContenue("receiveRequest");
System.out.println("Etape 20 : ReceiveCaller-Rolecalled : "+this.getRoleFournis().getContenue());
}
}
}
......
......@@ -18,24 +18,19 @@ public class SendCaller extends AttachementFourReq {
@Override
public void attachement() {
while(true) {
if(this.getPortCompFournis().getContenue().compareTo("sendRequest")!=0) {
System.out.println(this.getPortCompFournis().getContenue());
String[] port = this.getPortCompFournis().getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
this.getRoleRequis().setContenue(this.getPortCompFournis().getContenue());
this.getPortCompFournis().setContenue("sendRequest");
System.out.println("Role caller :"+this.getRoleRequis().getContenue());
}
String[] portAller = this.getPortCompFournis().getContenue().split("::");
String[] portRetour = this.getRoleRequis().getContenue().split("::");
if(portAller[0].compareTo("Client0")==0) {
this.getRoleRequis().setContenue(this.getPortCompFournis().getContenue());
this.getPortCompFournis().setContenue("sendRequest");
System.out.println("Etape 2: SendCaller-Role caller :"+this.getRoleRequis().getContenue());
}
if(this.getRoleRequis().getContenue().compareTo("caller")!=0) {
String[] port = this.getRoleRequis().getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getPortCompFournis().setContenue(this.getRoleRequis().getContenue());
this.getRoleRequis().setContenue("caller");
System.out.println(this.getPortCompFournis().getContenue());
}
if(portRetour[0].compareTo("Server")==0) {
this.getPortCompFournis().setContenue(this.getRoleRequis().getContenue());
this.getRoleRequis().setContenue("caller");
System.out.println("Etape 22 : sendCaller-portSendRequest"+this.getPortCompFournis().getContenue());
}
}
}
}
......@@ -6,10 +6,10 @@ import M2Bis.Port;
public class Server extends Component {
public Server(String nomComponent,int nbClient) {
public Server(String nomComponent) {
super(nomComponent);
this.getListPortCompFournis().add(new Port("receiveRequest"));
ServerDetail sDetail = new ServerDetail("serveurDetail",this.getListPortCompFournis().get(0),nbClient);
ServerDetail sDetail = new ServerDetail("serveurDetail",this.getListPortCompFournis().get(0));
this.setConfiguration(sDetail);
}
......
......@@ -6,21 +6,19 @@ import M2Bis.Configuration;
public class SimpleCs extends Configuration {
public SimpleCs(String nomConfiguration, Server server,int nbClient) {
public SimpleCs(String nomConfiguration, Server server) {
super(nomConfiguration, server);
for(int i=0;i<nbClient;i++) {
Client client = new Client("Client"+i);
this.getListComponent().add(client);
RPC link = new RPC("RPC"+i);
this.getListConnector().add(link);
ReceiveCalled rCalled = new ReceiveCalled(server.getListPortCompFournis().get(0),
link.getRoleFournis());
this.getListAttachement().add(rCalled);
SendCaller sCaller = new SendCaller(client.getListPortCompRequis().get(0),
link.getRoleRequis());
this.getListAttachement().add(sCaller);
Client client = new Client("Client0");
this.getListComponent().add(client);
RPC link = new RPC("RPC");
this.getListConnector().add(link);
ReceiveCalled rCalled = new ReceiveCalled(server.getListPortCompFournis().get(0),
link.getRoleFournis());
this.getListAttachement().add(rCalled);
SendCaller sCaller = new SendCaller(client.getListPortCompRequis().get(0),
link.getRoleRequis());
this.getListAttachement().add(sCaller);
}
}
......
......@@ -16,13 +16,11 @@ public class CMtoSM extends Connector{
public void glue() {
while(true) {
if(this.getRoleRequis().getContenue().compareTo("callerSM")!=0) {
String[] port = this.getRoleRequis().getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
String[] port = this.getRoleRequis().getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
this.getRoleFournis().setContenue((this.getRoleRequis().getContenue()));
this.getRoleRequis().setContenue("callerSM");
System.out.println("Role called CM: "+getRoleFournis().getContenue());
}
System.out.println("Etape 8 : CMtoSM - calledCM : "+getRoleFournis().getContenue());
}
}
}
......
......@@ -18,10 +18,11 @@ public class CheckQueryToCallerDB extends AttachementFourReq {
public void attachement() {
while(true) {
if(this.getPortCompFournis().getContenue().compareTo("CheckQuery")!=0) {
String[] port = this.getPortCompFournis().getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
this.getRoleRequis().setContenue(this.getPortCompFournis().getContenue());
this.getPortCompFournis().setContenue("CheckQuery");
System.out.println("Role Caller Cb: "+getRoleRequis().getContenue());
System.out.println("Etape 11 : Role Caller Cb: "+getRoleRequis().getContenue());
}
}
}
......
......@@ -22,21 +22,19 @@ public class ConnectionManager extends Component {
public void serviceExtToSecurity() {
while(true) {
if(this.getListPortCompRequis().get(0).getContenue().compareTo("ExternalSocket")!=0) {
String[] port = this.getListPortCompRequis().get(0).getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
this.getListPortCompFournis().get(0).setContenue(this.getListPortCompRequis().get(0).getContenue());
this.getListPortCompRequis().get(0).setContenue("ExternalSocket");
System.out.println("port SecurityCheck :"+this.getListPortCompFournis().get(0).getContenue());
}
String[] portAller = this.getListPortCompRequis().get(0).getContenue().split("::");
String[] portRetour = this.getListPortCompRequis().get(1).getContenue().split("::");
if(portAller[0].compareTo("Client0")==0) {
this.getListPortCompFournis().get(0).setContenue(this.getListPortCompRequis().get(0).getContenue());
this.getListPortCompRequis().get(0).setContenue("ExternalSocket");
System.out.println("Etape 6 : CM - SecurityCheck :"+this.getListPortCompFournis().get(0).getContenue());
}
if(this.getListPortCompRequis().get(1).getContenue().compareTo("DBQuery")!=0) {
String[] port = this.getListPortCompRequis().get(1).getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getListPortCompRequis().get(0).setContenue( this.getListPortCompRequis().get(1).getContenue());
this.getListPortCompRequis().get(1).setContenue("DBQuery");
System.out.println("Port ExternalSocket: "+getListPortCompRequis().get(0).getContenue());
}
if(portRetour[0].compareTo("Server")==0) {
this.getListPortCompRequis().get(0).setContenue( this.getListPortCompRequis().get(1).getContenue());
this.getListPortCompRequis().get(1).setContenue("DBQuery");
System.out.println("Etape 18 - CM-ExternalSocket: "+getListPortCompRequis().get(0).getContenue());
}
}
}
......
......@@ -8,13 +8,21 @@ public class DBQueryToCalledDB extends AttachementReqFour {
public DBQueryToCalledDB(Port portCompRequis, Role roleFournis) {
super(portCompRequis, roleFournis);
this.start();
}
public void run() {
this.attachement();
}
public void attachement() {
while(true) {
if(this.getRoleFournis().getContenue().compareTo("calledDB")!=0) {
String[] port = this.getRoleFournis().getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getPortCompRequis().setContenue(this.getRoleFournis().getContenue());
this.getRoleFournis().setContenue("calledDB");
System.out.println("Port DBQuery: "+getPortCompRequis().getContenue());
System.out.println("Etape 17 : DBQtoCDB - DBQuery: "+getPortCompRequis().getContenue());
}
}
......
......@@ -17,10 +17,11 @@ public class DBtoCM extends Connector {
public void glue() {
while(true) {
if(this.getRoleRequis().getContenue().compareTo("callerCM")!=0) {
String[] port = this.getRoleRequis().getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getRoleFournis().setContenue(this.getRoleRequis().getContenue());
this.getRoleRequis().setContenue("callerCM");
System.out.println("Role calledDB: "+getRoleFournis().getContenue());
System.out.println("Etape 16 : DBtoCm - calledDB: "+getRoleFournis().getContenue());
}
}
}
......
......@@ -24,22 +24,21 @@ public class DataBase extends Component {
public void serviceDB() {
while(true) {
if(this.getListPortCompRequis().get(0).getContenue().compareTo("SecurityManagement")!=0) {
String[] port = this.getListPortCompRequis().get(0).getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
//hashmap
if(port[1].compareTo("1+1")==0) {
this.getListPortCompFournis().get(0).setContenue("2");
String[] port = this.getListPortCompRequis().get(0).getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
if(port[1].compareTo("errorAuthentification")!=0) {
//hashmap
if(port[1].compareTo("1+1")==0) {
this.getListPortCompFournis().get(0).setContenue("Server::2");
}else {
this.getListPortCompFournis().get(0).setContenue("Server::ErrorMapping");
}
}else {
this.getListPortCompFournis().get(0).setContenue("Server::ErrorMapping");
this.getListPortCompFournis().get(0).setContenue(this.getListPortCompRequis().get(0).getContenue());
}
}else {
this.getListPortCompFournis().get(0).setContenue(this.getListPortCompRequis().get(0).getContenue());
}
this.getListPortCompRequis().get(0).setContenue("SecurityManagement");
System.out.println("Port QueryInterrogation: "+this.getListPortCompFournis().get(0).getContenue());
}
this.getListPortCompRequis().get(0).setContenue("SecurityManagement");
System.out.println("Etape 14 : DataBase - QueryInterrogation: "+this.getListPortCompFournis().get(0).getContenue());
}
}
}
......
......@@ -18,10 +18,11 @@ public class QueryInterrogationToCallerCM extends AttachementFourReq {
public void attachement() {
while(true) {
if(this.getPortCompFournis().getContenue().compareTo("QueryInterrogation")!=0) {
String[] port = this.getPortCompFournis().getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getRoleRequis().setContenue(this.getPortCompFournis().getContenue());
this.getPortCompFournis().setContenue("QueryInterrogation");
System.out.println("Role callerCM: "+getRoleRequis().getContenue());
System.out.println("Etape 15 : QItoCCM - callerCM: "+getRoleRequis().getContenue());
}
}
}
......
......@@ -17,21 +17,20 @@ public class ReceiverRequestExternalSocket extends BindingRequis {
public void binding() {
while(true) {
if(this.getPortConfRequis().getContenue().compareTo("receiveRequest")!=0) {
String[] port = this.getPortConfRequis().getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
this.getPortCompRequis().setContenue(this.getPortConfRequis().getContenue());
this.getPortConfRequis().setContenue("receiveRequest");
System.out.println("Port ExternalSocket :"+this.getPortCompRequis().getContenue());
}
String[] portAller = this.getPortConfRequis().getContenue().split("::");
String[] portRetour = this.getPortCompRequis().getContenue().split("::");
if(portAller[0].compareTo("Client0")==0) {
this.getPortCompRequis().setContenue(this.getPortConfRequis().getContenue());
this.getPortConfRequis().setContenue("receiveRequest");
System.out.println("Etape 5 : Binding - Port ExternalSocket :"+this.getPortCompRequis().getContenue());
}
if(this.getPortCompRequis().getContenue().compareTo("ExternalSocket")!=0) {
String[] port = this.getPortCompRequis().getContenue().split("::");
if(port[0].compareTo("Server")==0) {
this.getPortConfRequis().setContenue(this.getPortCompRequis().getContenue());
this.getPortCompRequis().setContenue("ExternalSocket");
System.out.println("Port receiveRequest: "+getPortConfRequis().getContenue());
}
if(portRetour[0].compareTo("Server")==0) {
this.getPortConfRequis().setContenue(this.getPortCompRequis().getContenue());
this.getPortCompRequis().setContenue("ExternalSocket");
System.out.println("Etape 19 : Binding - Port receiveRequest: "+getPortConfRequis().getContenue());
}
}
}
......
......@@ -17,10 +17,11 @@ public class SMtoDB extends Connector {
public void glue() {
while(true) {
if(this.getRoleRequis().getContenue().compareTo("callerDB")!=0) {
String[] port = this.getRoleRequis().getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
this.getRoleFournis().setContenue(this.getRoleRequis().getContenue());
this.getRoleRequis().setContenue("callerDB");
System.out.println("Role Called SM: "+getRoleFournis().getContenue());
System.out.println("Etape 12 : SMtoDB - CalledSM: "+getRoleFournis().getContenue());
}
}
}
......
......@@ -17,15 +17,14 @@ public class SecurityAuthentificationToCalledCM extends AttachementReqFour {
public void attachement() {
while(true) {
if(this.getRoleFournis().getContenue().compareTo("calledSM")!=0) {
String[] port = this.getRoleFournis().getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
String[] port = this.getRoleFournis().getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
this.getPortCompRequis().setContenue(this.getRoleFournis().getContenue());
this.getRoleFournis().setContenue("calledSM");
System.out.println("Port securityAuthen: "+getPortCompRequis().getContenue());
}
}
}
this.getRoleFournis().setContenue("calledCM");
System.out.println("Etape 9 : SAtoCCM securityAuthen: "+getPortCompRequis().getContenue());
}
}
}
......
......@@ -18,14 +18,11 @@ public class SecurityCheckToCallerSM extends AttachementFourReq {
public void attachement() {
while(true) {
if(this.getPortCompFournis().getContenue().compareTo("SecurityCheck")!=0) {
String[] port = this.getPortCompFournis().getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
this.getRoleRequis().setContenue(this.getPortCompFournis().getContenue());
this.getPortCompFournis().setContenue("SecurityCheck");
System.out.println("Role CallerSM :"+this.getRoleRequis().getContenue());
}
String[] port = this.getPortCompFournis().getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
this.getRoleRequis().setContenue(this.getPortCompFournis().getContenue());
this.getPortCompFournis().setContenue("SecurityCheck");
System.out.println("Etape 7 : SCtoCSM - CallerSM :"+this.getRoleRequis().getContenue());
}
}
......
......@@ -16,10 +16,15 @@ public class SecurityManagementToCalledSM extends AttachementReqFour {
}
public void attachement() {
while(true) {
if(this.getRoleFournis().getContenue().compareTo("calledSM")!=0) {
String[] port = this.getRoleFournis().getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
this.getPortCompRequis().setContenue(this.getRoleFournis().getContenue());
this.getRoleFournis().setContenue("calledSM");
System.out.println("Port SecurityManagement: "+getPortCompRequis().getContenue());
System.out.println("Etape 13 : SMtoCSM SecurityManagement: "+getPortCompRequis().getContenue());
}
}
}
......
......@@ -10,13 +10,10 @@ import M2Bis.Port;
public class SecurityManager extends Component {
ArrayList<String> nameClient;
public SecurityManager(String nom,int nbClient) {
public SecurityManager(String nom) {
super(nom);
nameClient = new ArrayList<String>();
for(int i = 0; i<nbClient; i++) {
nameClient.add("Client"+i);
}
nameClient.add("Client0");
this.getListPortCompFournis().add(new Port("CheckQuery"));
this.getListPortCompRequis().add(new Port("SecurityAuthentification"));
......@@ -33,22 +30,19 @@ public class SecurityManager extends Component {
public void serviceSM() {
while(true) {
if(this.getListPortCompRequis().get(0).getContenue().compareTo("SecurityAuthentification")!=0) {
String[] port = this.getListPortCompRequis().get(0).getContenue().split("::");
if(port[0].compareTo("Server")!=0) {
String[] port = this.getListPortCompRequis().get(0).getContenue().split("::");
if(port[0].compareTo("Client0")==0) {
if(nameClient.contains(port[0])) {
this.getListPortCompFournis().get(0).setContenue(this.getListPortCompRequis().get(0).getContenue());
System.out.println("Port CheckQuery: "+getListPortCompFournis().get(0).getContenue());
System.out.println("Etape 10 : SM - Port CheckQuery: "+getListPortCompFournis().get(0).getContenue());
this.getListPortCompRequis().get(0).setContenue("SecurityAuthentification");
}
else {
this.getListPortCompFournis().get(0).setContenue("Server::errorAuthentification");
this.getListPortCompFournis().get(0).setContenue("Client0::errorAuthentification");
this.getListPortCompRequis().get(0).setContenue("SecurityAuthentification");
}
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment