author | Stephen Talley <stephen.talley@oracle.com> |
Thu, 03 Feb 2011 14:10:29 -0500 | |
changeset 647 | ddbb04508ea4 |
parent 534 | ac38af60b488 |
permissions | -rw-r--r-- |
534
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
1 |
/* |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
2 |
* CDDL HEADER START |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
3 |
* |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
4 |
* The contents of this file are subject to the terms of the |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
6 |
* You may not use this file except in compliance with the License. |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
7 |
* |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
9 |
* or http://www.opensolaris.org/os/licensing. |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
10 |
* See the License for the specific language governing permissions |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
11 |
* and limitations under the License. |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
12 |
* |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
18 |
* |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
19 |
* CDDL HEADER END |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
20 |
*/ |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
21 |
|
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
22 |
/* |
647
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
23 |
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. |
534
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
24 |
*/ |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
25 |
|
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
26 |
package org.opensolaris.os.rad.jmx; |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
27 |
|
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
28 |
import java.io.IOException; |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
29 |
import java.net.MalformedURLException; |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
30 |
import java.util.Map; |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
31 |
import javax.management.remote.JMXServiceURL; |
647
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
32 |
import org.opensolaris.os.rad.*; |
534
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
33 |
|
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
34 |
class RadJMXSSHConnector extends RadJMXConnector { |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
35 |
|
647
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
36 |
// |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
37 |
// Instance data |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
38 |
// |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
39 |
|
534
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
40 |
private String host_; |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
41 |
private String user_; |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
42 |
|
647
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
43 |
// |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
44 |
// Constructors |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
45 |
// |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
46 |
|
534
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
47 |
RadJMXSSHConnector(JMXServiceURL url, Map<String, ?> env) |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
48 |
throws MalformedURLException { |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
49 |
|
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
50 |
super(url, env); |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
51 |
host_ = url.getHost(); |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
52 |
|
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
53 |
/* |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
54 |
* JMX Service URLs don't permit user@host syntax, so we interpret |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
55 |
* a URL's path (following the initial /) as the user name. |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
56 |
*/ |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
57 |
String path = url.getURLPath(); |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
58 |
user_ = (path.length() < 2 || path.charAt(0) != '/') ? null : |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
59 |
path.substring(1); |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
60 |
} |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
61 |
|
647
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
62 |
// |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
63 |
// RadJMXConnector methods |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
64 |
// |
ddbb04508ea4
17819 nit roundup
Stephen Talley <stephen.talley@oracle.com>
parents:
534
diff
changeset
|
65 |
|
534
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
66 |
@Override |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
67 |
Transport getTransport(Map<String, ?> env) throws IOException { |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
68 |
return new SSHTransport(host_, user_); |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
69 |
} |
ac38af60b488
16483 remove netcat dependency
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
70 |
} |