本文整理汇总了Java中org.glyptodon.guacamole.protocol.GuacamoleConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java GuacamoleConfiguration类的具体用法?Java GuacamoleConfiguration怎么用?Java GuacamoleConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GuacamoleConfiguration类属于org.glyptodon.guacamole.protocol包,在下文中一共展示了GuacamoleConfiguration类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAuthorizedConfigurations
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
@Override
public Map<String, GuacamoleConfiguration> getAuthorizedConfigurations(Credentials credentials) throws GuacamoleException {
if (signatureVerifier == null) {
initFromProperties();
}
GuacamoleConfiguration config = getGuacamoleConfiguration(credentials.getRequest());
if (config == null) {
return null;
}
Map<String, GuacamoleConfiguration> configs = new HashMap<String, GuacamoleConfiguration>();
configs.put(config.getParameter("id"), config);
return configs;
}
示例2: parseConfigParams
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
private GuacamoleConfiguration parseConfigParams(HttpServletRequest request) {
GuacamoleConfiguration config = new GuacamoleConfiguration();
Map<String, String[]> params = request.getParameterMap();
for (String name : params.keySet()) {
String value = request.getParameter(name);
if (!name.startsWith(PARAM_PREFIX) || value == null || value.length() == 0) {
continue;
}
else if (name.equals(PARAM_PREFIX + "protocol")) {
config.setProtocol(request.getParameter(name));
}
else {
config.setParameter(name.substring(PARAM_PREFIX.length()), request.getParameter(name));
}
}
if (config.getProtocol() == null) config.setProtocol(defaultProtocol);
return config;
}
示例3: testSuccess
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
public void testSuccess() throws GuacamoleException {
HttpServletRequest request = getHttpServletRequest();
Credentials credentials = new Credentials();
credentials.setRequest(request);
TimeProviderInterface timeProvider = mock(TimeProviderInterface.class);
when(timeProvider.currentTimeMillis()).thenReturn(1373563683000L);
HmacAuthenticationProvider authProvider = new HmacAuthenticationProvider(timeProvider);
Map<String, GuacamoleConfiguration> configs = authProvider.getAuthorizedConfigurations(credentials);
assertNotNull(configs);
assertEquals(1, configs.size());
GuacamoleConfiguration config = configs.get(connectionId);
assertNotNull(config);
assertEquals("rdp", config.getProtocol());
}
示例4: testHostnameFailure
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
public void testHostnameFailure() throws GuacamoleException {
HttpServletRequest request = mockRequest(new HashMap<String, String>() {{
put(ID_PARAM, connectionId);
put("timestamp", "1373563683000");
put("guac.hostname", "10.2.3.5"); // changed hostname should invalidate signature
put("guac.protocol", "rdp");
put("guac.port", "3389");
// Test signature was generated with the following PHP snippet
// base64_encode(hash_hmac('sha1', '1373563683000rdphostname10.2.3.4port3389', 'secret', true));
put(SIGNATURE_PARAM, "6PHOr00TnhA10Ef9I4bLqeSXKYg=");
}});
Credentials credentials = new Credentials();
credentials.setRequest(request);
TimeProviderInterface timeProvider = mock(TimeProviderInterface.class);
when(timeProvider.currentTimeMillis()).thenReturn(1373563683000L);
HmacAuthenticationProvider authProvider = new HmacAuthenticationProvider(timeProvider);
Map<String, GuacamoleConfiguration> configs = authProvider.getAuthorizedConfigurations(credentials);
assertNull(configs);
}
示例5: testTimestampFresh
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
public void testTimestampFresh() throws Exception {
HttpServletRequest request = getHttpServletRequest();
Credentials credentials = new Credentials();
credentials.setRequest(request);
TimeProviderInterface timeProvider = mock(TimeProviderInterface.class);
when(timeProvider.currentTimeMillis()).thenReturn(1373563683000L + ONE_HOUR - 1l);
HmacAuthenticationProvider authProvider = new HmacAuthenticationProvider(timeProvider);
Map<String, GuacamoleConfiguration> configs = authProvider.getAuthorizedConfigurations(credentials);
assertNotNull(configs);
assertEquals(1, configs.size());
GuacamoleConfiguration config = configs.get(connectionId);
assertNotNull(config);
}
示例6: testTimestampStale
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
public void testTimestampStale() throws Exception {
HttpServletRequest request = getHttpServletRequest();
Credentials credentials = new Credentials();
credentials.setRequest(request);
TimeProviderInterface timeProvider = mock(TimeProviderInterface.class);
when(timeProvider.currentTimeMillis()).thenReturn(1373563683000L + ONE_HOUR);
HmacAuthenticationProvider authProvider = new HmacAuthenticationProvider(timeProvider);
Map<String, GuacamoleConfiguration> configs = authProvider.getAuthorizedConfigurations(credentials);
assertNull(configs);
// test that updateUserContext also returns null when the timestamp is stale
Map<String, GuacamoleConfiguration> dummyConfigs = new HashMap<String, GuacamoleConfiguration>();
dummyConfigs.put("dummy", new GuacamoleConfiguration());
SimpleUserContext context = new SimpleUserContext(dummyConfigs);
UserContext updatedUserContext = authProvider.updateUserContext(context, credentials);
assertNull(updatedUserContext);
}
示例7: updateUserContext
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
@Override
public UserContext updateUserContext(UserContext context, Credentials credentials) throws GuacamoleException {
HttpServletRequest request = credentials.getRequest();
GuacamoleConfiguration config = getGuacamoleConfiguration(request);
if (config == null) {
return null;
}
String id = config.getParameter("id");
SimpleConnectionDirectory connections = (SimpleConnectionDirectory) context.getRootConnectionGroup().getConnectionDirectory();
SimpleConnection connection = new SimpleConnection(id, id, config);
connections.putConnection(connection);
return context;
}
示例8: doConnect
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
@Override
protected GuacamoleTunnel doConnect(final HttpServletRequest request) throws GuacamoleException {
final HttpSession httpSession = request.getSession(true);
final String sessionId = readBody(request);
final LoginDialog credentials = (LoginDialog) request.getSession().getAttribute(sessionId);
credentials.createNewSession(request.getSession());
// guacd connection information
final String hostname = "192.168.178.32";
final String user = credentials.getUserName();
final String password = credentials.getPassword();
final int port = 4822;
// RDP connection information
final GuacamoleConfiguration config = new GuacamoleConfiguration();
// config.setProtocol("rdp");
// config.setParameter("security", "any");
// config.setParameter("ignore-cert", "true");
// config.setParameter("hostname", "192.168.178.24");
// config.setParameter("port", "3389");
// config.setParameter("username", "Administrator");
// config.setParameter("password", "1Nv3sdw1n.");
config.setProtocol("ssh");
config.setParameter("hostname", hostname);
config.setParameter("port", "22");
config.setParameter("username", user);
config.setParameter("password", password);
// Connect to guacd, proxying a connection to the VNC server above
final GuacamoleSocket socket = new ConfiguredGuacamoleSocket(new InetGuacamoleSocket(hostname, port), config);
// Create tunnel from now-configured socket
final GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
// Attach tunnel
final GuacamoleSession session = new GuacamoleSession(httpSession);
session.attachTunnel(tunnel);
return tunnel;
}
示例9: getGuacamoleConfiguration
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
private GuacamoleConfiguration getGuacamoleConfiguration(HttpServletRequest request) throws GuacamoleException {
if (signatureVerifier == null) {
initFromProperties();
}
String signature = request.getParameter(SIGNATURE_PARAM);
if (signature == null) {
return null;
}
signature = signature.replace(' ', '+');
String timestamp = request.getParameter(TIMESTAMP_PARAM);
if (!checkTimestamp(timestamp)) {
return null;
}
GuacamoleConfiguration config = parseConfigParams(request);
// Hostname is required!
if (config.getParameter("hostname") == null) {
return null;
}
// Hostname is required!
if (config.getProtocol() == null) {
return null;
}
StringBuilder message = new StringBuilder(timestamp)
.append(config.getProtocol());
for (String name : SIGNED_PARAMETERS) {
String value = config.getParameter(name);
if (value == null) {
continue;
}
message.append(name);
message.append(value);
}
if (!signatureVerifier.verifySignature(signature, message.toString())) {
return null;
}
String id = request.getParameter(ID_PARAM);
if (id == null) {
id = "DEFAULT";
} else {
// This should really use BasicGuacamoleTunnelServlet's IdentfierType, but it is private!
// Currently, the only prefixes are both 2 characters in length, but this could become invalid at some point.
// see: [email protected]:guacamole/src/main/java/org/glyptodon/guacamole/net/basic/BasicGuacamoleTunnelServlet.java:244-252
id = id.substring(2);
}
// This isn't normally part of the config, but it makes it much easier to return a single object
config.setParameter("id", id);
return config;
}
示例10: getAuthorizedConfigurations
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
@Override
public Map<String, GuacamoleConfiguration> getAuthorizedConfigurations(Credentials credentials)
throws GuacamoleException
{
Map<String, GuacamoleConfiguration> configs = new HashMap<String, GuacamoleConfiguration>();
/* Input credentials will be in the form of:
* -> username: <rig name>=<session user>
* -> password: <secret to allow retreival of Windows login details.
*/
String username = credentials.getUsername(), password = credentials.getPassword();
if (username == null || password == null) {
this.logger.debug("No credentials provided, no configurations being returned.");
return null;
}
int sep = username.indexOf(':');
if (sep < 0 || sep == username.length() - 1) {
this.logger.warn("Username has incorrect format");
return null;
}
String rigName = username.substring(0, sep), user = username.substring(sep + 1);
this.logger.info("Going to contact rig '" + rigName + "' for user '" + user + "'.");
Rig rig = this.rigsConfig.getRig(rigName);
if (rig == null) {
this.logger.warn("Rig '" + rigName + "' not found.");
return null;
}
/* Request rig configuration. */
try
{
RigRequest req = new RigRequest(rig);
if (req.getConfig(user, password)) {
configs.put(rig.name, req.getConnection());
this.requestValidated = System.currentTimeMillis();
this.logger.info("Loaded configuration for " + rigName);
credentials.getSession().setAttribute("sahara-user", user);
credentials.getSession().setAttribute("sahara-rig", rigName);
return configs;
} else {
this.logger.warn("No configuration loaded for " + rigName);
return null;
}
}
catch (Throwable e)
{
this.logger.error("Failed requesting rig client " + rigName + " error " + e.getClass().getSimpleName() +
":" + e.getMessage());
e.printStackTrace();
return null;
}
}
示例11: getConnection
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
public GuacamoleConfiguration getConnection() {
return this.config;
}