Last modified by Julien EYMERY on 2015/06/29 14:41

Show last authors
1 (((
2 == Problème ==
3 )))
4
5 Comment gérer l'authentification d'un service web via WS-SECURITY avec Adélia Studio ?
6 (((
7 == Solution ==
8 )))
9
10
11 l'authentification WS-SECURITY ne repose pas sur l'authentification HTTP classique par le container web. L'authentification se fait par un échange d'informations via la section <header> du message SOAP.
12
13 Pour assurer une authentification du service via un header WS-SECURITY, il existe à ce jour 2 possibilités :
14 (((
15 === Première possibilité ===
16 )))
17
18
19 Création manuelle du header "ws-security" pour l'authentification (via la directive *ENTETE_MSG_MEM ou *ENTETE_MSG_FILE de l'ordre SW_APPELER) [solution la plus simple]
20
21 L'en-tête à ajouter est le suivant :
22
23
24 {{code language="xml" language="xml"}}
25 <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
26 <wsse:UsernameToken wsu:Id="UsernameToken" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
27 <wsse:Username>user</wsse:Username>
28 <wsse:Password>password</wsse:Password>
29 </wsse:UsernameToken>
30 </wsse:Security>
31 {{/code}}
32
33
34
35 Par défaut, le password est du plain text (correspond au type PasswordText). Si le type doit être absolument renseigné, alors il faut écrire :
36
37
38 {{code language="none"}}
39 <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
40 {{/code}}
41
42
43
44 Pour un password de type DIGEST :
45
46
47 {{code language="none"}}
48 <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">AFFFHH==!</wsse:Password>
49 <wsse:Nonce>ksSedFljK</wsse:Nonce>
50 <wsu:Created>2013-09-13T15:34:43.000Z</wsu:Created>
51 {{/code}}
52
53 (((
54 === Deuxième possibilité ===
55 )))
56
57 Génération automatique du header WS-SECURITY avec une configuration du module RAMPART [solution plus compliquée à mettre en oeuvre; nécessite l'écriture en C d'une DLL spécifique].
58
59 La solution ci-dessous est non exhaustive mais indique la marche à suivre.
60
61
62 a. Déclarer, dans le fichier CfgWebServices.xml le module "rampart" avec une référence à un fichier "client-policy.xml" contenant la définition des éléments de sécurité :
63
64
65 {{code language="xml" language="xml"}}
66 <service><Module>
67    <Name>rampart</Name>
68    <Description>
69       <PolicyFile>client-policy.xml</PolicyFile>
70    </Description>
71 </Module>
72 </service>
73 {{/code}}
74
75
76
77 b. Ecriture du fichier client-policy.xml en question. Le clent-policy.xml devrait s'inspirer/se calquer à celui utiliser par le serveur.
78 Exemple dans le cas ou la police de sécurité semble requérir uniquement un userToken (user/password avec un mot de passe non chiffré).
79
80 [[client-policy_C.xml>>attach:client-policy_C.xml]]
81
82 [[client-policy_java.xml>>attach:client-policy_java.xml]]
83
84
85 c. Ecrire la DLL (ou classe) référencée dans le fichier client-policy.xml (cf. élément PasswordCallbackClass) et la déployer dans le dossier ad-hoc.
86 Cette DLL/Classe assure la gestion des mots de passe et s'appuie sur une interface RAMPART.
87
88 Exemples :
89
90 [[pwcb.c>>attach:pwcb.c]]
91
92 [[pwcb.java>>attach:pwcb.java]]
93
94 (((
95 === Références ===
96 )))
97
98
99 [[http://j2eesolution.blogspot.fr/2013/02/axis-2-username-token-authentication.html>>url:http://j2eesolution.blogspot.fr/2013/02/axis-2-username-token-authentication.html]]
100
101 [[http://wso2.com/library/240>>url:http://wso2.com/library/240]]
102
103 [[http://wso2.com/library/3733>>url:http://wso2.com/library/3733]]
104
105 [[http://axis.apache.org/axis2/java/rampart/>>url:http://axis.apache.org/axis2/java/rampart/]]
106
107 [[http://axis.apache.org/axis2/c/rampart/>>url:http://axis.apache.org/axis2/c/rampart/]]
108
109 [[(% style="line-height: 1.4285715;" %)https://www.oasis-open.org/committees/download.php/13392/wss-v1.1-spec-pr-UsernameTokenProfile-01.htm>>url:https://www.oasis-open.org/committees/download.php/13392/wss-v1.1-spec-pr-UsernameTokenProfile-01.htm]]
110 (((
111 == Articles connexes ==
112 )))
113
114 Les articles connexes apparaissent ici en fonction des étiquettes que vous avez sélectionnées. Cliquez pour modifier la macro et ajouter ou modifier des étiquettes.
115
116 {{liveData sort="doc.date:desc" source="liveTable" properties="doc.title,doc.date,doc.author" description="Recently updated" limit="5" filters="tag=authentification service" sourceParameters="translationPrefix=platform.index."}}{{/liveData}}
117