EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.ssh.jsch.config]

COVERAGE SUMMARY FOR SOURCE FILE [JschSshClientModule.java]

nameclass, %method, %block, %line, %
JschSshClientModule.java100% (2/2)83%  (5/6)69%  (59/86)80%  (13.6/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JschSshClientModule$Factory100% (1/1)75%  (3/4)60%  (41/68)71%  (8.6/12)
create (IPSocket, String, byte []): SshClient 0%   (0/1)0%   (0/18)0%   (0/3)
create (IPSocket, Credentials): SshClient 100% (1/1)55%  (11/20)55%  (0.6/1)
JschSshClientModule$Factory (BackoffLimitedRetryHandler, Injector): void 100% (1/1)100% (12/12)100% (5/5)
create (IPSocket, String, String): SshClient 100% (1/1)100% (18/18)100% (3/3)
     
class JschSshClientModule100% (1/1)100% (2/2)100% (18/18)100% (5/5)
JschSshClientModule (): void 100% (1/1)100% (3/3)100% (2/2)
configure (): void 100% (1/1)100% (15/15)100% (3/3)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.ssh.jsch.config;
20 
21import javax.inject.Named;
22 
23import org.jclouds.Constants;
24import org.jclouds.domain.Credentials;
25import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
26import org.jclouds.net.IPSocket;
27import org.jclouds.predicates.InetSocketAddressConnect;
28import org.jclouds.predicates.SocketOpen;
29import org.jclouds.ssh.ConfiguresSshClient;
30import org.jclouds.ssh.SshClient;
31import org.jclouds.ssh.jsch.JschSshClient;
32import org.jclouds.util.CredentialUtils;
33 
34import com.google.inject.AbstractModule;
35import com.google.inject.Inject;
36import com.google.inject.Injector;
37import com.google.inject.Scopes;
38 
39/**
40 * 
41 * @author Adrian Cole
42 */
43@ConfiguresSshClient
44public class JschSshClientModule extends AbstractModule {
45 
46   protected void configure() {
47      bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON);
48      bind(SocketOpen.class).to(InetSocketAddressConnect.class).in(Scopes.SINGLETON);
49   }
50 
51   private static class Factory implements SshClient.Factory {
52      @Named(Constants.PROPERTY_CONNECTION_TIMEOUT)
53      @Inject(optional = true)
54      int timeout = 60000;
55 
56      private final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
57      private final Injector injector;
58 
59      @SuppressWarnings("unused")
60      @Inject
61      public Factory(BackoffLimitedRetryHandler backoffLimitedRetryHandler, Injector injector) {
62         this.backoffLimitedRetryHandler = backoffLimitedRetryHandler;
63         this.injector = injector;
64      }
65 
66      public SshClient create(IPSocket socket, String username, String password) {
67         SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, username, password, null);
68         injector.injectMembers(client);// add logger
69         return client;
70      }
71 
72      public SshClient create(IPSocket socket, String username, byte[] privateKey) {
73         SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, username, null, privateKey);
74         injector.injectMembers(client);// add logger
75         return client;
76      }
77 
78      @Override
79      public SshClient create(IPSocket socket, Credentials credentials) {
80         return CredentialUtils.isPrivateKeyCredential(credentials) ? create(socket, credentials.identity,
81               credentials.credential.getBytes()) : create(socket, credentials.identity, credentials.credential);
82      }
83   }
84}

[all classes][org.jclouds.ssh.jsch.config]
EMMA 2.0.5312 (C) Vladimir Roubtsov