当前位置: 首页>>代码示例>>Java>>正文


Java GuacamoleConfiguration类代码示例

本文整理汇总了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;
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:17,代码来源:HmacAuthenticationProvider.java

示例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;
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:23,代码来源:HmacAuthenticationProvider.java

示例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());
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:19,代码来源:HmacAuthenticationProviderTest.java

示例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);
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:24,代码来源:HmacAuthenticationProviderTest.java

示例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);
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:18,代码来源:HmacAuthenticationProviderTest.java

示例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);
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:21,代码来源:HmacAuthenticationProviderTest.java

示例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;
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:14,代码来源:HmacAuthenticationProvider.java

示例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;
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:43,代码来源:GuacamoleServlet.java

示例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;
}
 
开发者ID:grncdr,项目名称:guacamole-auth-hmac,代码行数:57,代码来源:HmacAuthenticationProvider.java

示例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;
    }
}
 
开发者ID:sahara-labs,项目名称:rig-client-commons,代码行数:57,代码来源:SaharaProvider.java

示例11: getConnection

import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; //导入依赖的package包/类
public GuacamoleConfiguration getConnection() {
    return this.config;
}
 
开发者ID:sahara-labs,项目名称:rig-client-commons,代码行数:4,代码来源:RigRequest.java


注:本文中的org.glyptodon.guacamole.protocol.GuacamoleConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。