* Authenticates users against a static list of username/password pairs.
* Each username/password may be associated with multiple configurations.
* This list is stored in an XML file which is reread if modified.
- *
+ *
* @author Michael Jumper, Michal Kotas
*/
public class BasicFileAuthenticationProvider implements AuthenticationProvider {
private Logger logger = LoggerFactory.getLogger(BasicFileAuthenticationProvider.class);
-
+
private long mappingTime;
private Map<String, AuthInfo> mapping;
throw new GuacamoleException("Missing \"basic-user-mapping\" parameter required for basic login.");
logger.info("Reading user mapping file: {}", mapFile);
-
+
// Parse document
try {
// If no mapping available, report as such
if (mapping == null)
throw new GuacamoleException("User mapping could not be read.");
-
+
// Validate and return info for given user and pass
AuthInfo info = mapping.get(credentials.getUsername());
if (info != null && info.validate(credentials.getUsername(), credentials.getPassword()))
}
break;
-
+
case CONNECTION:
if (localName.equals("connection")) {
return;
}
- break;
+ break;
case PROTOCOL:
currentConnection = attributes.getValue("name");
if (currentConnection == null)
throw new SAXException("Attribute \"name\" required for connection tag.");
-
+
// Next state
state = State.CONNECTION;
return;
// Associate protocol with default connection
currentConnection = "DEFAULT";
-
+
// Next state
state = State.DEFAULT_CONNECTION_PROTOCOL;
return;
// Associate parameter with default connection
currentConnection = "DEFAULT";
-
+
currentParameter = attributes.getValue("name");
if (currentParameter == null)
throw new SAXException("Attribute \"name\" required for param tag.");
}
break;
-
+
case CONNECTION:
if (localName.equals("protocol")) {
return;
}
- break;
+ break;
}
public void characters(char[] ch, int start, int length) throws SAXException {
String str = new String(ch, start, length);
-
+
switch (state) {
case PROTOCOL:
current.getConfiguration(currentConnection)
.setParameter(currentParameter, str);
return;
-
+
}
if (str.trim().length() != 0)