3131import org .springframework .core .ParameterizedTypeReference ;
3232import org .springframework .stereotype .Service ;
3333import org .springframework .web .client .RestClient ;
34+ import org .springframework .web .util .UriUtils ;
3435
36+ import java .nio .charset .StandardCharsets ;
3537import java .util .ArrayList ;
3638import java .util .HashMap ;
3739import java .util .List ;
@@ -100,7 +102,8 @@ public List<CoreAuthModule> getAvailableModuleList() {
100102 }
101103
102104 List <AuthChainDTO > getRealmAuthChains (String realm , String tokenId ) {
103- final String chainsUri = String .format ("/json/realms/%s/realm-config/authentication/chains?_queryFilter=true" , realm );
105+ final String chainsUri = String .format ("/json/realms/%s/realm-config/authentication/chains?_queryFilter=true" ,
106+ UriUtils .encodePath (realm , StandardCharsets .UTF_8 ));
104107 SearchResponseDTO <AuthChainDTO > authChainsResponse = openAMRestClient .get ().uri (chainsUri )
105108 .header (openAMConfig .tokenHeader (), tokenId )
106109 .retrieve ()
@@ -110,7 +113,8 @@ List<AuthChainDTO> getRealmAuthChains(String realm, String tokenId) {
110113 }
111114
112115 List <AuthModuleDTO > getRealmAuthModules (String realm , String tokenId ) {
113- final String modulesUri = String .format ("/json/realms/%s/realm-config/authentication/modules?_queryFilter=true" , realm );
116+ final String modulesUri = String .format ("/json/realms/%s/realm-config/authentication/modules?_queryFilter=true" ,
117+ UriUtils .encodePath (realm , StandardCharsets .UTF_8 ));
114118 SearchResponseDTO <AuthModuleDTO > modulesResponse = openAMRestClient .get ().uri (modulesUri )
115119 .header (openAMConfig .tokenHeader (), tokenId )
116120 .retrieve ()
@@ -121,7 +125,9 @@ List<AuthModuleDTO> getRealmAuthModules(String realm, String tokenId) {
121125
122126 Map <String , PropertySchemaDTO > getModuleSchema (String tokenId , String realm , String moduleType ) {
123127
124- String schemaUrl = String .format ( "/json/realms/%s/realm-config/authentication/modules/%s?_action=schema" , realm , moduleType );
128+ String schemaUrl = String .format ( "/json/realms/%s/realm-config/authentication/modules/%s?_action=schema" ,
129+ UriUtils .encodePath (realm , StandardCharsets .UTF_8 ),
130+ UriUtils .encodePath (moduleType , StandardCharsets .UTF_8 ));
125131 AuthModuleSchemaDTO authModuleSchemaDTO = openAMRestClient .post ().uri (schemaUrl )
126132 .header (openAMConfig .tokenHeader (), tokenId )
127133 .retrieve ()
@@ -131,7 +137,10 @@ Map<String, PropertySchemaDTO> getModuleSchema(String tokenId, String realm, Str
131137 }
132138
133139 Map <String , Object > getModuleSettings (String tokenId , String realm , String moduleId , String moduleType ) {
134- String settingsUrl = String .format ("/json/realms/%s/realm-config/authentication/modules/%s/%s" , realm , moduleType , moduleId );
140+ String settingsUrl = String .format ("/json/realms/%s/realm-config/authentication/modules/%s/%s" ,
141+ UriUtils .encodePath (realm , StandardCharsets .UTF_8 ),
142+ UriUtils .encodePath (moduleType , StandardCharsets .UTF_8 ),
143+ UriUtils .encodePath (moduleId , StandardCharsets .UTF_8 ));
135144
136145 return openAMRestClient .get ().uri (settingsUrl )
137146 .header (openAMConfig .tokenHeader (), tokenId )
0 commit comments