Changeset 520b4a3 in guacamole
- Timestamp:
- 04/18/12 15:02:23 (13 months ago)
- Branches:
- master, guacamole-debian-parent, rpm, unstable, unstable-websocket
- Children:
- 7545277
- Parents:
- 729e196
- git-author:
- Michal Kotas <miko@…> (04/18/12 15:01:34)
- git-committer:
- Michael Jumper <zhangmaike@…> (04/18/12 15:02:23)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/example/user-mapping.xml
r0c279c6 r520b4a3 3 3 <!-- Per-user authentication and config information --> 4 4 <authorize username="USERNAME" password="PASSWORD"> 5 <protocol>vnc</protocol> 6 <param name="hostname">localhost</param> 7 <param name="port">5900</param> 8 <param name="password">VNCPASS</param> 5 6 <!-- Single authorized connection --> 7 <remote-server servername="localhost"> 8 <protocol>vnc</protocol> 9 <param name="hostname">localhost</param> 10 <param name="port">5900</param> 11 <param name="password">VNCPASS</param> 12 </remote-server> 13 9 14 </authorize> 10 15 … … 15 20 password="319f4d26e3c536b5dd871bb2c52e3178" 16 21 encoding="md5"> 17 <protocol>vnc</protocol> 18 <param name="hostname">localhost</param> 19 <param name="port">5901</param> 20 <param name="password">VNCPASS</param> 21 </authorize> 22 23 <!-- First authorized connection --> 24 <remote-server servername="localhost"> 25 <protocol>vnc</protocol> 26 <param name="hostname">localhost</param> 27 <param name="port">5901</param> 28 <param name="password">VNCPASS</param> 29 </remote-server> 30 31 <!-- Second authorized connection --> 32 <remote-server servername="otherhost"> 33 <protocol>vnc</protocol> 34 <param name="hostname">otherhost</param> 35 <param name="port">5900</param> 36 <param name="password">VNCPASS</param> 37 </remote-server> 38 39 </authorize> 22 40 23 41 </user-mapping> -
src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java
rc5c5631 r520b4a3 47 47 /** 48 48 * Authenticates users against a static list of username/password pairs. 49 * Each username/password may be associated with exactly one configuration.49 * Each username/password may be associated with multiple configurations. 50 50 * This list is stored in an XML file which is reread if modified. 51 51 * 52 * @author Michael Jumper 52 * This is modified version of BasicFileAuthenticationProvider written by Michael Jumper. 53 * 54 * @author Michal Kotas 53 55 */ 54 56 public class BasicFileAuthenticationProvider implements AuthenticationProvider { … … 137 139 AuthInfo info = mapping.get(credentials.getUsername()); 138 140 if (info != null && info.validate(credentials.getUsername(), credentials.getPassword())) { 139 Map<String, GuacamoleConfiguration> configs = new HashMap<String, GuacamoleConfiguration>(); 140 configs.put("DEFAULT", info.getConfiguration()); 141 142 //Map<String, GuacamoleConfiguration> configs = new HashMap<String, GuacamoleConfiguration>(); 143 //configs.put("DEFAULT", info.getConfiguration()); 144 //return configs; 145 146 Map<String, GuacamoleConfiguration> configs = info.getConfigurations(); 141 147 return configs; 142 148 } … … 158 164 private Encoding auth_encoding; 159 165 160 private GuacamoleConfiguration config;166 private Map<String, GuacamoleConfiguration> configs; 161 167 162 168 public AuthInfo(String auth_username, String auth_password, Encoding auth_encoding) { … … 165 171 this.auth_encoding = auth_encoding; 166 172 167 config = new GuacamoleConfiguration();173 configs = new HashMap<String, GuacamoleConfiguration>(); 168 174 } 169 175 … … 221 227 } 222 228 223 public GuacamoleConfiguration getConfiguration() { 224 return config; 229 public GuacamoleConfiguration getConfiguration(String name) { 230 //return configs; 231 return configs.get(name); 232 } 233 public Map<String, GuacamoleConfiguration> getConfigurations() { 234 return configs; 235 } 236 public void addConfiguration(String name) { 237 configs.put(name, new GuacamoleConfiguration()); 225 238 } 226 239 227 240 } 228 229 241 230 242 private static class BasicUserMappingContentHandler extends DefaultHandler { … … 239 251 ROOT, 240 252 USER_MAPPING, 253 REMOTE_SERVER, 241 254 AUTH_INFO, 242 255 PROTOCOL, … … 248 261 private AuthInfo current = null; 249 262 private String currentParameter = null; 263 private String currentRemoteServer = null; 250 264 251 265 @Override … … 254 268 switch (state) { 255 269 256 case USER_MAPPING: 257 258 if (localName.equals("user-mapping")) { 259 state = State.END; 260 return; 261 } 262 263 break; 264 265 case AUTH_INFO: 266 267 if (localName.equals("authorize")) { 268 269 // Finalize mapping for this user 270 authMapping.put( 271 current.auth_username, 272 current 273 ); 274 275 state = State.USER_MAPPING; 276 return; 277 } 278 279 break; 280 281 case PROTOCOL: 282 283 if (localName.equals("protocol")) { 284 state = State.AUTH_INFO; 285 return; 286 } 287 288 break; 289 290 case PARAMETER: 291 292 if (localName.equals("param")) { 293 state = State.AUTH_INFO; 294 return; 295 } 296 297 break; 298 299 } 270 case USER_MAPPING: 271 272 if (localName.equals("user-mapping")) { 273 state = State.END; 274 return; 275 } 276 277 break; 278 279 case AUTH_INFO: 280 281 if (localName.equals("authorize")) { 282 283 // Finalize mapping for this user 284 authMapping.put( 285 current.auth_username, 286 current 287 ); 288 289 state = State.USER_MAPPING; 290 return; 291 } 292 293 break; 294 295 case REMOTE_SERVER: 296 297 if (localName.equals("remote-server")) { 298 state = State.AUTH_INFO; 299 return; 300 } 301 302 break; 303 304 case PROTOCOL: 305 306 if (localName.equals("protocol")) { 307 state = State.REMOTE_SERVER; 308 return; 309 } 310 311 break; 312 313 case PARAMETER: 314 315 if (localName.equals("param")) { 316 state = State.REMOTE_SERVER; 317 return; 318 } 319 320 break; 321 322 } 300 323 301 324 throw new SAXException("Tag not yet complete: " + localName); … … 318 341 break; 319 342 320 // Only <authorize> tags allowed in main document321 343 case USER_MAPPING: 322 344 … … 350 372 case AUTH_INFO: 351 373 374 if (localName.equals("remote-server")) { 375 376 currentRemoteServer = attributes.getValue("servername"); 377 if (currentRemoteServer == null) 378 throw new SAXException("Attribute \"servername\" required for param tag."); 379 380 current.addConfiguration(currentRemoteServer); 381 382 // Next state 383 state = State.REMOTE_SERVER; 384 return; 385 } 386 387 break; 388 389 case REMOTE_SERVER: 390 352 391 if (localName.equals("protocol")) { 353 392 // Next state … … 367 406 } 368 407 369 break; 408 break; 370 409 371 410 } … … 379 418 380 419 String str = new String(ch, start, length); 420 381 421 switch (state) { 382 422 383 423 case PROTOCOL: 384 current.getConfiguration( )385 .setProtocol(str);424 current.getConfiguration(currentRemoteServer) 425 .setProtocol(str); 386 426 return; 387 427 388 428 case PARAMETER: 389 current.getConfiguration( )429 current.getConfiguration(currentRemoteServer) 390 430 .setParameter(currentParameter, str); 391 431 return;
Note: See TracChangeset
for help on using the changeset viewer.
