MOOC Piattaforme digitali per la gestione del territorio - 4.4
-
Upload
alessandro-bogliolo -
Category
Education
-
view
346 -
download
0
Transcript of MOOC Piattaforme digitali per la gestione del territorio - 4.4
PIATTAFORME DIGITALI PER LA GESTIONE DEL TERRITORIO
UNIT 4.4
Infrastrutture e tecnologie abilitantiInterfacce
PIATTAFORME DIGITALI PER LA GESTIONE DEL TERRITORIO
Interfacce
e codice Interfacce
interprocesso
Interfacce
remote
Interfacce
Autenticazione e
autorizzazione
Formati e
codifiche
Interfaccee codice
Codice
Piattaforma di esecuzione
SistemaOperativoC Runtime
fopen() open()
Piattaforma di esecuzione
Applicazione
Framework
Runtime
Sistema Operativo
Hardware
Pro
gram
ma
Linguaggio C
int divisione (int a, int b);
Calling convention
int divisione (int a, int b);
Nome della funzione
Ordine, formato e codifica degli argomenti
Formato e codifica del dato di ritorno
Formato dei dati
Big/little-endian
Numeri floating point (IEEE 754)
Stringhe
Etc…
C
thing.cmain.cmemory.c
...
gate.c
gate.h
gate_open(int when);
C
gate.h
gate_open(int when);
programma.c
#include "gate.h"
int main(void) {// ...
gate_open(3);
// ...}
Interfacceinter-processo
Interfacce inter-processo
•Redirezione dei canali standard
•Pipe
• Socket
Unix Philosophy
This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to
handle text streams, because that is a universal interface.
Canali Standard
PROCESSO
STDOUT
STDIN
STDERR
Piping
Pipe
• Sono file speciali utilizzati per connettere due processi con un canale di comunicazione ( read() / write() )
• Possono essere bidirezionali ma vengono solitamente utilizzate in modo unidirezionale
Pipe nel terminale
$ who | sort | more
EsercitazionePipe tra processi su Linux
Socket
• Permettono la comunicazione fra processi che eseguono su machine differenti
193.240.253.14 10.53.178.1
Socket - collegare due processi
Server:
1. Istanziazione
Client:
SERVER CLIENT
SFD
Socket - collegare due processi
Server:
1. Istanziazione
2. Bind
Client:
SERVER CLIENT
SFD
10.0.0.1:80
Socket - collegare due processi
Server:
1. Istanziazione
2. Bind
3. Accept
Client:
SERVER CLIENT
SFD
10.0.0.1:80
Socket - collegare due processi
Server:
1. Istanziazione
2. Bind
3. Accept
4. Listen
Client:
SERVER CLIENT
SFD
10.0.0.1:80
Socket - collegare due processi
Server:
1. Istanziazione
2. Bind
3. Accept
4. Listen
Client:
5. Istanziazione
SERVER CLIENT
SFD C_SFD
10.0.0.1:80
Socket - collegare due processi
Server:
1. Istanziazione
2. Bind
3. Accept
4. Listen
Client:
5. Istanziazione
6. Connect
SERVER CLIENT
SFD C_SFD
10.0.0.1:80
S_SFD
Socket - collegare due processi
Server:
1. Istanziazione
2. Bind
3. Accept
4. Listen
7. Read/Write
Client:
5. Istanziazione
6. Connect
7. Read/Write
SERVER CLIENT
SFD C_SFD
10.0.0.1:80
S_SFD
Interfacceremote
API “Remote”
???
6*7
HTTP
Protocollo principe di Internet
Basato su TCP/IP
Orientato al trasferimento di documenti (iper)testuali
…ma sfruttabile per ogni tipo di trasferimento
Leggibile
Stateless
HTTP
GET /repos/golang/goUser-Agent: NCSA Mosaic/1.0Host: api.github.com
HTTPHTTP/1.1 200 OKServer: GitHub.comContent-Type: application/jsonContent-Length: 5171{"id":23096959,"name":"go","full_name":"golang/go","private":false,"description":"The Go programminglanguage",...
HTTP Verbs
GET
POST
HEAD
PUT
DELETE
HTTP Status
200 OK
201 Created
301 Moved Permanently
400 Bad Request
403 Forbidden
404 Not Found
500 Internal Server Error
RESTful services
«REpresentational State Transfer»
Linee guida architetturaliper l’architettura base del Web.
• Client-server
• Senza stato (stateless)
• Cacheable
• Stratificato
• Interfaccia uniforme
RESTful HTTP
GET /posts
GET /posts/1
GET /posts/1/comments
PUT /posts/1/comments
DELETE /posts/2
RESTful HTTP
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: 5171
Date: Wed, 16 Mar 2016 17:14:47 GMT
{ "post_id" : 1,
"content" : "Lorem ipsum dolor...",
"author_id" : 123,
... EsercitazioneRichieste ad API RESTful con Postman
Autenticazionee Sicurezza
Principi
Autenticazione
vs.
Autorizzazione
Principi
Mantenimento del segreto
Tecniche
White-listing
Username + Password / Chiave
Crittografia asimmetrica
HTTP e Sicurezza
Alice
Bob
HTTP e Sicurezza
Alice
Bob
Trudy
Man in the middle
Crittografia Asimmetrica
HTTPS
Alice
Bob
HTTPS
Alice
Bob???
Autenticazione e Autorizzazione
LOGIN
OK
GET RESOURCE
RESOURCE
Autenticazione Federata
GET RESOURCE
RESOURCE
Autenticazione Federata
Formati eCodifiche
L’importanza delle convenzioni
igor kisselev/Shutterstock
L’importanza delle convenzioni
Il programma Mars Surveyor
Mars Climate Orbiter
L’importanza delle convenzioni
Il Mars Climate Orbiter esplode in orbita
Posizionato ad un’altezza di soli 57 km invece che 140/150 km
Alcuni calcoli eseguiti usando il Sistema Imperiale (libbre-forza/secondi) e altri Tramite il Sistema Metrico Decimale (newton/secondi)
Costo totale: 328 milioni di dollari
Comunicazione M2M (chiusa)
42
XDFTEMKCE#°££1&»1¤é99?
Comunicazione M2M (aperta)
???
6*7
Principali formati di interscambio dati
• Binario
• Testo Libero
• CSV
• XML
• JSON
Binario
I dati vengono scritti come vengono memorizzati in memoria.
Un intero occuperà sempre sizeof(int)
Testo(Plain text)
Il formato è completamente a discrezione del progettista ma basato su caratteri testuali.
CMD1;CMD2;CMD3
OK;NO;ERROR
CSV(Comma-Separated Values)
Dati divisi in colonne, separate da virgole (o tabulazioni, o punto e virgola o altro).
Year, Make, Model, Description,Price
1997, Ford, E350, "ac, abs, moon",3000.00
1999, Chevy, VentureEE, great car,4900.00
1996, Jeep, Cherokee, MUST SELL!,4799.00
XML(eXtensible Markup Language)
<?xml version="1.0" encoding="UTF-8"?><breakfast_menu><food><name>Belgian Waffles</name><price currency="euro" >5.95</price><description>Our famous Belgian Waffles with plenty of real maple syrup</description><calories>650</calories><image file="waffles.jpg" />
</food><food><name>French Toast</name><price currency=“dollar" >4.50</price><description>Thick slices made from our homemade sourdough bread</description><calories>600</calories>
</food><food><name>Homestyle Breakfast</name><price currency="euro" >6.95</price><description>Two eggs, bacon or sausage, toast, and our ever-popular hash
browns</description><calories>950</calories>
</food></breakfast_menu>
HTML(Hyper Text Markup Language)
Facilmente traversabile: CSS Selector, Xpath
Goal CSS 3 XPath
All Elements * //*
All P Elements p //p
All Child Elements p > * //p/*
Element By ID #foo //*[@id=’foo’]
Element By Class .foo //*[contains(@class,’foo’)]
Element With Attribute *[title] //*[@title]
First Child of All P p > *:first-child //p/*[0]
All P with an A child Not possible //p[a]
Next Element p + * //p/following-sibling::*[0]
JSON(JavaScript Object Notation)
{ "employees" : [{"firstName":"John", "lastName":"Doe"},{"firstName":"Anna", "lastName":"Smith"},{"firstName":"Peter", "lastName":"Jones"}
]}
JSON(JavaScript Object Notation)
• Più sintetico di XML
<employees><employee>
<firstName>John</firstName> <lastName>Doe</lastName></employee><employee>
<firstName>Anna</firstName> <lastName>Smith</lastName></employee><employee>
<firstName>Peter</firstName> <lastName>Jones</lastName></employee>
</employees>
GPX(GPS Exchange Format)
GeoJSON{
"type" : "Point","coordinates": [42.2, 27.1]
}