File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\cli\src\main\java\hudson\cli\CliPort.java.html

1 package hudson.cli;
2
3 import org.apache.commons.codec.binary.Base64;
4
5 import java.net.InetSocketAddress;
6 import java.security.GeneralSecurityException;
7 import java.security.KeyFactory;
8 import java.security.PublicKey;
9 import java.security.spec.X509EncodedKeySpec;
10
11 /**
12 * @author Kohsuke Kawaguchi
13 */
14 final class CliPort {
15 /**
16 * The TCP endpoint to talk to.
17 */
18 final InetSocketAddress endpoint;
19
20 /**
21 * CLI protocol version. 1 and 2 are currently defined.
22 */
23 final int version;
24
25 /**
26 * Server instance identity. Can be null.
27 */
28 final String identity;
29
30 CliPort(InetSocketAddress endpoint, String identity, int version) {
31 this.endpoint = endpoint;
32 this.identity = identity;
33 this.version = version;
34 }
35
36 /**
37 * Gets the public part of the RSA key that represents the server identity.
38 */
39 public PublicKey getIdentity() throws GeneralSecurityException {
40 if (identity==null) return null;
41 byte[] image = Base64.decodeBase64(identity);
42 return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(image));
43 }
44 }
45