Arborescence des pages

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

La configuration de la génération de ce QR-Code se fait dans src/main/resources/META-INF/spring/applicationContext-crous.xml

Bloc de code
languagexml
themeRDark
<bean id="escUidFactoryService" class="org.esupportail.sgc.services.esc.EscUidFactoryService">
<property name="pic" value="le-code-pic-de-letablissement"/>
<property name="prefixe" value="1 " /> <!-- si plusieurs sgc, l'établissement doit les distinguer par un préfixe différent -->
<property name="qrCodeUrlPrefixe" value="http://esc.gg/" /> <!-- pour l'instance ESC de pre-production on mettra http://pp.esc.gg/ -->
</bean>

...

La configuration d'esup-sgc en tant que client ESCR pour enregistrer les cartes se fait dans src/main/resources/META-INF/spring/applicationContext-crous.xml

Bloc de code
languagexml
themeRDark
	<bean id="europeanStudentCardService" class="org.esupportail.sgc.services.esc.ApiEscrService">
		<property name="enable" value="true"/>
		<property name="webUrl" value="https://api.europeanstudentcard.eu/v1" />
		<property name="key" value="clef-a-recuperer-auprès-d-escr" />
		<property name="restTemplate" ref="restTemplate" />
		<property name="countryCode" value="FR"/>
		<property name="picInstitutionCode" value="le-code-pic-de-letablissement"/>
		<!-- 
		Type of cards. Possibles values are :
		1 - passive card, with no electronic
		2 - Smartcard without European common data zone
		3 - Smartcard with European common data zone
		4 - Smartcard on which application may be installed by service providers
		 -->
 		<property name="cardType" value="2"/>
	</bean>

...

Au niveau d'esup-sgc, vous pouvez mettre dans security.properties


Bloc de code
languagetext
themeRDark
accessRestrictionWSescr=hasHeader('escr-key','123456789ABCDEF')

...

Dans applicationContext-crous.xml, modifiez le bean escDeuInfoService pour le décommenter au besoin et faire pointer la clef et certificat vers la clef et certificat récupéré depuis la procédure ESC : 

Bloc de code
languagexml
themeRDark
	<bean id="escDeuInfoService" class="org.esupportail.sgc.services.esc.EscDeuInfoService">
        <property name="pic" value="le-code-pic-de-letablissement"/>
		<property name="deuInfoPrivateKey" value="classpath:META-INF/security/esc/ca.intermediate.key.der"/>
		<property name="deuInfoPublicKey" value="classpath:META-INF/security/esc/ca.intermediate.cert.der" />
	</bean>

Utilisez openssl au besoin pour convertir vos pem en der - dans src/main/resources/META-INF/security/esc/ vous retrouvez 2 scripts bash d'exemple pour ce faire.

La récupération éventuelle des certificats des établissements partenaires lors de la lecture et validation de la DEUINFO d'une carte partenaire utilise l'API europeanStudentCardService déjà paramétré. 

...

Pour ce faire, vous pouvez paramétrer votre bean europeanStudentCardService ainsi : 

Bloc de code
languagexml
themeRDark
	<bean id="europeanStudentCardService" class="org.esupportail.sgc.services.esc.ApiEscrService">
		<property name="enable" value="true"/>
		<property name="webUrl" value="https://api.europeanstudentcard.eu/v1" />
		<property name="key" value="clef-a-recuperer-auprès-d-escr" />
		<property name="restTemplate" ref="restTemplate" />
		<property name="countryCode" value="FR"/>
		<property name="picInstitutionCode" value="le-code-pic-de-letablissement"/>
		<!-- 
		Type of cards. Possibles values are :
		1 - passive card, with no electronic
		2 - Smartcard without European common data zone
		3 - Smartcard with European common data zone
		4 - Smartcard on which application may be installed by service providers
		 -->
 		<property name="cardType" value="2"/>
        <property name="cardTypes">
          <map>
             <entry key="2021-03-25 10:41:00" value="3"/>
          </map>
        </property>
	</bean>

...

Dans la structure de votre carte dans laquelle se trouve déjà par exemple votre applciation de contrôle d'accès, vous allez rajouter une nouvelle application ainsi :

Bloc de code
languagexml
themeRDark
 <!-- Application DEUINFO de la carte étudiante européenne 
		nok A3 : ISO enbaled, 3 AES keys
		amks OB :  configuration changeable, free directory list access without master key
-->
<bean class="org.esupportail.nfctag.beans.DesfireApplication" p:desfireAppId="F58840" p:amks="0B" p:nok="A3" p:isoId="1000" p:isoName="A00000061404F58840">
	<property name="files">
		<util:list>
			<!-- ESCN File 
							communicationSettings 00 : communication plain text for clear access
							accessRights E000 : - read access clear 'E' 
	              								- write access '0' master key only
	              								- read/write access clear '0'
	             								- change acces rights '0' master key only
	              								- fileSize : 16bits -> 000010 -> 100000. 
			-->
			<bean class="org.esupportail.nfctag.beans.DesfireFile"
p:fileNumber="00" p:communicationSettings="00" p:accessRights="E000" p:isoId="1001"
p:tagWriteApi-ref="escnDeuInfoTagWriteEsupSgc" />

			<!-- Signature (71 ou 72 octets) - taille variable  -->
			<bean class="org.esupportail.nfctag.beans.DesfireFile"
p:fileNumber="01" p:communicationSettings="00" p:accessRights="E000" p:isoId="1002"
p:tagWriteApi-ref="signatureDeuInfoTagWriteEsupSgc" />
			<!-- Certificat - taille variable  -->
			<bean class="org.esupportail.nfctag.beans.DesfireFile"
p:fileNumber="02" p:communicationSettings="00" p:accessRights="E000" p:isoId="1003"
p:tagWriteApi-ref="certDeuInfoTagWriteEsupSgc"/>
		</util:list>
	</property>
	<property name="keys">
		<util:list>
			<!-- master key of deuInfo application : private app master key of the university -->
			<bean class="org.esupportail.nfctag.beans.DesfireKey" 
p:keyNo="00" p:keyVer="00" p:key="00000000000000000000000000000000" />
			<!-- deuinfo master key diversified with ESCN -->
			<bean class="org.esupportail.nfctag.beans.DesfireKey" 
p:keyNo="01" p:keyVer="00" p:desfireKeyService-ref="escnDeuInfoDiversifiedKeyService" />
			<!-- deuinfo master key diversified with CSN -->
			<bean class="org.esupportail.nfctag.beans.DesfireKey" 
p:keyNo="02" p:keyVer="00" p:desfireKeyService-ref="csnDeuInfoDiversifiedKeyService" />
		</util:list>
	</property>
</bean>

...

Pour que cela fonctionne vous devez en plus également ajouter 5 beans supplémentaires référencés dans cette configuration : 

Bloc de code
languagexml
themeRDark
    <bean id="escnDeuInfoTagWriteEsupSgc" class="org.esupportail.nfctag.service.api.impl.TagWriteRestWs">
		<property name="idFromCsnUrlTemplate" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/getEscDeuInfoEscn?csn={0}"/>
    </bean>
    
    <bean id="signatureDeuInfoTagWriteEsupSgc" class="org.esupportail.nfctag.service.api.impl.TagWriteRestWs">
		<property name="idFromCsnUrlTemplate" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/getEscDeuInfoSignature?csn={0}"/>
    </bean>
    
    <bean id="certDeuInfoTagWriteEsupSgc" class="org.esupportail.nfctag.service.api.impl.TagWriteRestWs">
		<property name="idFromCsnUrlTemplate" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/getEscDeuInfoCertificat?csn={0}"/>
    </bean>

    <bean id="csnDeuInfoDiversifiedKeyService" class="org.esupportail.nfctag.service.desfire.DesfireDiversificationService">
		<property name="baseKey" value="11111111111111111111111111111111"/>
    </bean>
    
    <bean id="escnDeuInfoDiversifiedKeyService" class="org.esupportail.nfctag.service.desfire.DesfireDiversificationService">
		<property name="baseKey" value="11111111111111111111111111111111"/>
		<property name="tagWriteApi">
			<bean class="org.esupportail.nfctag.service.api.impl.TagWriteRestWs">
				<property name="idFromCsnUrlTemplate" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/getEscDeuInfoEscn?csn={0}"/>
		    </bean>
		</property>
    </bean>

...

Pour la lecture/vérification de la DEUINFO d'une carte au travers d'esup-nfc-tag (desktop ou droid), au niveau d'esup-nfc-tag-server toujours on peut positionner les beans suivants : 

Bloc de code
languagexml
themeRDark
   <bean id="desfireDeuinfoReadConfig" class="org.esupportail.nfctag.service.api.impl.DesfireReadDeuinfoConfig">
   		<property name="baseKey" value="11111111111111111111111111111111"/>
   		<property name="description" value="DEUINFO"/>
   </bean>
   
   <bean id="iso7816DesfireDeuinfoReadConfig" class="org.esupportail.nfctag.service.api.impl.Iso7816ReadDeuinfoConfig">
   		<property name="description" value="Check Iso7816 DEUINFO"/>
   </bean>  

    <bean id="esupSgcDeuinfoExtApi" class="org.esupportail.nfctag.service.api.impl.AppliExtRestWs">
    	<property name="isTagableUrl" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/isTagableDeuinfo"/>
    	<property name="validateTagUrl" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/validateTagDeuinfo"/>
    	<property name="getLocationsUrl" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/locationsDeuinfo"/>
    	<property name="displayUrl" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/deuinfo"/>
    	<property name="description" value="DEUINFO"/>
    </bean>
        
    <bean id="tagIdCheckApiDeuinfoEsupSgc" class="org.esupportail.nfctag.service.api.impl.TagIdCheckRestWs">
		<property name="tagIdCheckUrl" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/tagIdCheckDeuinfo"/>
		<property name="idFromEppnInitUrl" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/idFromEppnInit"/>
		<property name="description" value="Deuinfo"/>
    </bean>

...

Pour ce faire, on peut passer les APDU suivants normalisés ISO 7816  : 

Bloc de code
languagetext
themeRDark
# select deuinfo app
00A4040009A00000061404F5884000
# select ESCN file
00A40000021001
# read
00B0000000
# select sign file
00A40000021002
# read
00B0000000
# select cert file
00A40000021003 
# read
00B0000000
# read next (cert > 256 bytes)
00B0010000
# read next (cert > 512 bytes)
00B0020000


Voici un exemple de ce que ça donne (depuis scriptor ici) : 

Bloc de code
languagebash
themeRDark
vincent@debian-i7:/tmp$ scriptor -r 'Identive Identive CLOUD 4500 F Dual Interface Reader [CLOUD 4700 F Contactless Reader] (53201322201041) 01 00'
Using given card reader: Identive Identive CLOUD 4500 F Dual Interface Reader [CLOUD 4700 F Contactless Reader] (53201322201041) 01 00
Using T=1 protocol
Reading commands from STDIN
00A4040009A00000061404F5884000
> 00 A4 04 00 09 A0 00 00 06 14 04 F5 88 40 00 
< 90 00 : Normal processing.
00A40000021001
> 00 A4 00 00 02 10 01 
< 90 00 : Normal processing.
00B0000000
> 00 B0 00 00 00 
< D8 8B 02 C1 89 4E 10 38 A7 11 00 19 99 46 59 82 
90 00 : Normal processing.
00A40000021002
> 00 A4 00 00 02 10 02 
< 90 00 : Normal processing.
00B0000000
> 00 B0 00 00 00 
< 30 45 02 20 79 DC F9 A1 C0 2C C5 1F 61 73 28 02 
E1 CF EB 65 6A 1B 9E 72 F4 6E E2 D7 12 8A B4 7B 
D2 E0 7F 2D 02 21 00 B3 83 1A BD 51 8F 17 36 A2 
AE 4A 31 07 1B 7F 75 FF C3 2F 3E E5 85 FD 9A F7 
E5 55 09 1D 5F 8F A0 90 00 : Normal processing.
00A40000021003
> 00 A4 00 00 02 10 03 
< 90 00 : Normal processing.
00B0000000
> 00 B0 00 00 00 
< 30 82 02 64 30 82 02 09 A0 03 02 01 02 02 02 10 
00 30 0A 06 08 2A 86 48 CE 3D 04 03 02 30 81 8E 
31 0B 30 09 06 03 55 04 06 13 02 46 52 31 0B 30 
09 06 03 55 04 08 0C 02 37 36 31 0E 30 0C 06 03 
55 04 07 0C 05 52 6F 75 65 6E 31 29 30 27 06 03 
55 04 0A 0C 20 55 6E 69 76 65 72 73 69 74 C3 83 
C2 A9 20 64 65 20 52 6F 75 65 6E 20 4E 6F 72 6D 
61 6E 64 69 65 31 16 30 14 06 03 55 04 03 0C 0D 
75 6E 69 76 2D 72 6F 75 65 6E 2E 66 72 31 1F 30 
1D 06 09 2A 86 48 86 F7 0D 01 09 01 16 10 73 69 
40 75 6E 69 76 2D 72 6F 75 65 6E 2E 66 72 30 1E 
17 0D 32 30 30 34 30 36 31 30 31 30 31 32 5A 17 
0D 33 30 30 34 30 34 31 30 31 30 31 32 5A 30 7E 
31 0B 30 09 06 03 55 04 06 13 02 46 52 31 0B 30 
09 06 03 55 04 08 0C 02 37 36 31 29 30 27 06 03 
55 04 0A 0C 20 55 6E 69 76 65 72 73 69 74 C3 83 
90 00 : Normal processing.
00B0010000
> 00 B0 01 00 00 
< C2 A9 20 64 65 20 52 6F 75 65 6E 20 4E 6F 72 6D 
61 6E 64 69 65 31 16 30 14 06 03 55 04 03 0C 0D 
75 6E 69 76 2D 72 6F 75 65 6E 2E 66 72 31 1F 30 
1D 06 09 2A 86 48 86 F7 0D 01 09 01 16 10 73 69 
40 75 6E 69 76 2D 72 6F 75 65 6E 2E 66 72 30 59 
30 13 06 07 2A 86 48 CE 3D 02 01 06 08 2A 86 48 
CE 3D 03 01 07 03 42 00 04 93 B6 D5 D9 B9 42 CF 
7E 6B 04 FB 65 B7 D9 A2 3E 9F FA 5F 88 9D 1A F2 
08 6A F1 4B 54 08 E6 60 DE 11 8D CA 00 DE 82 5A 
2A 62 3A FD 6F DF C0 15 D1 F9 80 94 77 7F 49 80 
F2 F1 0A 41 26 0B F6 AF A1 A3 66 30 64 30 1D 06 
03 55 1D 0E 04 16 04 14 26 B9 B2 78 0E 7F DC E1 
0A 67 11 1E 56 9A A7 DC 2B 92 38 9F 30 1F 06 03 
55 1D 23 04 18 30 16 80 14 23 65 6A 02 C5 64 E3 
8A 32 81 76 D5 94 9E 48 7A 27 DB 37 4E 30 12 06 
03 55 1D 13 01 01 FF 04 08 30 06 01 01 FF 02 01 
90 00 : Normal processing.
00B0020000
> 00 B0 02 00 00 
< 03 30 0E 06 03 55 1D 0F 01 01 FF 04 04 03 02 01 
86 30 0A 06 08 2A 86 48 CE 3D 04 03 02 03 49 00 
30 46 02 21 00 FC 0A 75 A8 A2 E1 3A 28 18 8D 71 
B4 70 B8 83 3A C3 02 1F EA C5 D7 C0 75 A4 43 60 
AC EA 5C C6 87 02 21 00 90 E9 87 E6 D0 5D 67 2C 
10 7F 73 75 CE 7F DF 73 A8 03 9C C6 2A FC F7 DA 
B2 67 5C 35 0A 87 80 88 90 00 : Normal processing.

...

Dit autrement, cela peut en fait "rendre compatible" une carte extérieure Desfire EV2 avec des applications sécurisées de l'établissement, applications telles que le contrôle d'accès ou  encore le paiement Izly.

Mise en oeuvre

Chargement des DAM keys

Pour que les cartes que vous éditez puissent effectivement héberger des applications d'établissements partenaires, il faut que celles-ci présentent les 3 "DAM keys" dans l'application Master (000000).

Pour cela, vous devez configurer l'écriture de ces clefs.

  1. Une clef de diversification propre à la carte est demandée par esup-nfc-tag-server auprès d'esup-sgc
  2. esup-sgc la génère cette clef aléatoirement et la persiste en base (afin de pouvoir la retrouver lors d'une éventuelle procédure d'écriture d'une DAM) ; chaque carte dispose de sa propre clef de diversification
  3. esup-nfc-tag-server calcule les clefs DAM diversifiées en utilisant cette clef de diversification avec comme entrée le CSN (...) de la carte (comme proposé au niveau des spécifications du projet ESC)
  4. esup-nfc-tag-serve encodent ces 2 clefs DAM dans la carte (application Master)
Configuration esup-nfc-tag-server

Pour écrire les damKeys, il faut dans le fichier applicationContext-desfire.xml au niveau de votre org.esupportail.nfctag.beans.DesfireTag représentant votre Tag à écrire ajouter une propriété damKeysTagWriteApi faisant référence à bean de type DamKeysTagWriteApi, ce brena étant lui-même à définir.

Bloc de code
languagexml
themeRDark
...
<bean id="damKeysTagWriteRestWs" class="org.esupportail.nfctag.service.api.impl.DamKeysTagWriteRestWs">
  <property name="createDamKeysFromCsnUrlTemplate" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/createDamDiversBaseKey?csn={0}"/>
  <property name="damKeysFromCsnUrlTemplate" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/getDamDiversBaseKey?csn={0}"/>
  <property name="resetDamKeysUrlTemplate" value="https://esup-sgc.univ-ville.fr/wsrest/nfc/resetDamDiversBaseKey?csn={0}"/>
</bean>
...
<bean id="desfireComueTagEsupSgc" class="org.esupportail.nfctag.beans.DesfireTag" p:formatBeforeWrite="false" p:keyStart="00000000000000000000000000000000" p:keyTypeStart="AES" p:keyFinish="00000000000000000000000000000000" p:keyTypeFinish="AES" p:keyVersionFinish="00" p:damKeysTagWriteApi-ref="damKeysTagWriteRestWs">
....
</bean>
...
Configuration esup-sgc

Le cardType envoyé à ESCR doit être revu.   En chargeant des DAM keys sur vos cartes, il doit maintenant passer à 4. 

Pour ce faire, vous pouvez paramétrer votre bean europeanStudentCardService (dans applicationContext-crous.xml) ainsi : 

Bloc de code
languagexml
themeRDark
	<bean id="europeanStudentCardService" class="org.esupportail.sgc.services.esc.ApiEscrService">
		<property name="enable" value="true"/>
		<property name="webUrl" value="https://api.europeanstudentcard.eu/v1" />
		<property name="key" value="clef-a-recuperer-auprès-d-escr" />
		<property name="restTemplate" ref="restTemplate" />
		<property name="countryCode" value="FR"/>
		<property name="picInstitutionCode" value="le-code-pic-de-letablissement"/>
		<!-- 
		Type of cards. Possibles values are :
		1 - passive card, with no electronic
		2 - Smartcard without European common data zone
		3 - Smartcard with European common data zone
		4 - Smartcard on which application may be installed by service providers
		 -->
 		<property name="cardType" value="2"/>
        <property name="cardTypes">
          <map>
             <entry key="2021-03-25 10:41:00" value="3"/>
			 <entry key="2021-07-07 16:25:00" value="4"/>
          </map>
        </property>
	</bean>


Création d'une application Mifare Desfire sur une carte d'un établissement partenaire

Info

L'implémentation correspondant à cette partie est en cours.

...