Changeset 2b76b5f in guacamole


Ignore:
Timestamp:
04/18/12 15:31:20 (13 months ago)
Author:
zhangmaike
Branches:
master, guacamole-debian-parent, rpm, unstable, unstable-websocket
Children:
923a46a
Parents:
42c8e94
git-author:
Michael Jumper <zhangmaike@…> (04/18/12 15:31:20)
git-committer:
Michael Jumper <zhangmaike@…> (04/18/12 15:31:20)
Message:

Code cleanup, add backwards compatibility.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/example/user-mapping.xml

    r7545277 r2b76b5f  
    33    <!-- Per-user authentication and config information --> 
    44    <authorize username="USERNAME" password="PASSWORD"> 
    5  
    6         <!-- Single authorized connection --> 
    7                 <connection name="localhost"> 
    8             <protocol>vnc</protocol> 
    9             <param name="hostname">localhost</param> 
    10             <param name="port">5900</param> 
    11             <param name="password">VNCPASS</param> 
    12         </connection> 
    13  
     5        <protocol>vnc</protocol> 
     6        <param name="hostname">localhost</param> 
     7        <param name="port">5900</param> 
     8        <param name="password">VNCPASS</param> 
    149    </authorize> 
    1510 
  • src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java

    r42c8e94 r2b76b5f  
    5050 * This list is stored in an XML file which is reread if modified. 
    5151 *  
    52  * This is modified version of BasicFileAuthenticationProvider written by Michael Jumper. 
    53  *  
    54  * @author Michal Kotas 
     52 * @author Michael Jumper, Michal Kotas 
    5553 */ 
    5654public class BasicFileAuthenticationProvider implements AuthenticationProvider { 
     
    138136        // Validate and return info for given user and pass 
    139137        AuthInfo info = mapping.get(credentials.getUsername()); 
    140         if (info != null && info.validate(credentials.getUsername(), credentials.getPassword())) { 
    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();           
    147             return configs; 
    148         } 
     138        if (info != null && info.validate(credentials.getUsername(), credentials.getPassword())) 
     139            return info.getConfigurations(); 
    149140 
    150141        // Unauthorized 
     
    228219 
    229220        public GuacamoleConfiguration getConfiguration(String name) { 
    230             //return configs; 
    231             return configs.get(name); 
    232         } 
     221 
     222            // Create new configuration if not already in map 
     223            GuacamoleConfiguration config = configs.get(name); 
     224            if (config == null) { 
     225                config = new GuacamoleConfiguration(); 
     226                configs.put(name, config); 
     227            } 
     228 
     229            return config; 
     230 
     231        } 
     232 
    233233        public Map<String, GuacamoleConfiguration> getConfigurations() { 
    234234            return configs; 
    235         } 
    236         public void addConfiguration(String name) { 
    237             configs.put(name, new GuacamoleConfiguration()); 
    238235        } 
    239236 
     
    251248            ROOT, 
    252249            USER_MAPPING, 
     250 
     251            /* Username/password pair */ 
     252            AUTH_INFO, 
     253 
     254            /* Connection configuration information */ 
    253255            CONNECTION, 
    254             AUTH_INFO, 
    255256            PROTOCOL, 
    256257            PARAMETER, 
     258 
     259            /* Configuration information associated with default connection */ 
     260            DEFAULT_CONNECTION_PROTOCOL, 
     261            DEFAULT_CONNECTION_PARAMETER, 
     262 
    257263            END; 
    258264        } 
     
    315321                    if (localName.equals("param")) { 
    316322                        state = State.CONNECTION; 
     323                        return; 
     324                    } 
     325 
     326                    break; 
     327 
     328                case DEFAULT_CONNECTION_PROTOCOL: 
     329 
     330                    if (localName.equals("protocol")) { 
     331                        state = State.AUTH_INFO; 
     332                        return; 
     333                    } 
     334 
     335                    break; 
     336 
     337                case DEFAULT_CONNECTION_PARAMETER: 
     338 
     339                    if (localName.equals("param")) { 
     340                        state = State.AUTH_INFO; 
    317341                        return; 
    318342                    } 
     
    378402                            throw new SAXException("Attribute \"name\" required for connection tag."); 
    379403                         
    380                         current.addConfiguration(currentConnection); 
     404                        // Next state 
     405                        state = State.CONNECTION; 
     406                        return; 
     407                    } 
     408 
     409                    if (localName.equals("protocol")) { 
     410 
     411                        // Associate protocol with default connection 
     412                        currentConnection = "DEFAULT"; 
    381413                         
    382414                        // Next state 
    383                         state = State.CONNECTION; 
     415                        state = State.DEFAULT_CONNECTION_PROTOCOL; 
     416                        return; 
     417                    } 
     418 
     419                    if (localName.equals("param")) { 
     420 
     421                        // Associate parameter with default connection 
     422                        currentConnection = "DEFAULT"; 
     423                         
     424                        currentParameter = attributes.getValue("name"); 
     425                        if (currentParameter == null) 
     426                            throw new SAXException("Attribute \"name\" required for param tag."); 
     427 
     428                        // Next state 
     429                        state = State.DEFAULT_CONNECTION_PARAMETER; 
    384430                        return; 
    385431                    } 
Note: See TracChangeset for help on using the changeset viewer.