1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.ci.maven;
17
18 import org.apache.maven.settings.Server;
19 import org.codehaus.plexus.util.StringUtils;
20
21 import de.smartics.ci.maven.util.SettingsDecrypter;
22
23
24
25
26 public final class CiServer extends Server
27 {
28
29
30
31
32
33
34 private static final long serialVersionUID = 1L;
35
36
37
38
39 private final String url;
40
41
42
43
44
45
46
47
48
49
50 public CiServer(final Logger logger, final Server server, final String url,
51 final SettingsDecrypter settingsDecrypter)
52 {
53 checkParameter(logger, server, url);
54
55 this.url = url;
56
57 if (server != null)
58 {
59 this.setId(server.getId());
60 this.setUsername(server.getUsername());
61 final String decryptedPassword =
62 settingsDecrypter.decrypt(server.getPassword());
63 this.setPassword(decryptedPassword);
64 this.setPassphrase(server.getPassphrase());
65 this.setPrivateKey(server.getPrivateKey());
66
67 this.setDirectoryPermissions(server.getDirectoryPermissions());
68 this.setFilePermissions(server.getFilePermissions());
69 this.setConfiguration(server.getConfiguration());
70
71 this.setSourceLevel(server.getSourceLevel());
72 }
73 }
74
75 private void checkParameter(final Logger logger, final Server server,
76 final String url)
77 {
78 if (logger != null)
79 {
80 if (StringUtils.isBlank(url))
81 {
82 logger.warn("Ci-Server URL is null");
83 }
84 if (server == null || StringUtils.isBlank(server.getId())
85 || StringUtils.isBlank(server.getUsername())
86 || StringUtils.isBlank(server.getPassword()))
87 {
88 logger.warn("Server in settings is not correct id, username and "
89 + "password are needed (passphrase and private key are"
90 + " not supported right now).");
91 }
92 }
93 }
94
95
96
97
98
99
100 public String getUrl()
101 {
102 return url;
103 }
104 }