File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\os\windows\ManagedWindowsServiceAccount.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2012-, CloudBees, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.os.windows;
25
26 import hudson.Extension;
27 import hudson.ExtensionPoint;
28 import hudson.model.AbstractDescribableImpl;
29 import hudson.model.Descriptor;
30 import hudson.os.windows.ManagedWindowsServiceLauncher.AccountInfo;
31 import hudson.util.Secret;
32 import org.kohsuke.stapler.DataBoundConstructor;
33
34 /**
35 * Encapsulates how to login (a part of {@link ManagedWindowsServiceLauncher}).
36 *
37 * @author Kohsuke Kawaguchi
38 * @author Vincent Latombe
39 * @since 1.448
40 */
41 public abstract class ManagedWindowsServiceAccount extends AbstractDescribableImpl<ManagedWindowsServiceAccount> implements ExtensionPoint {
42 public abstract AccountInfo getAccount(ManagedWindowsServiceLauncher launcher);
43
44 /**
45 * Logs in with the local system user.
46 * This is the default.
47 */
48 public static final class LocalSystem extends ManagedWindowsServiceAccount {
49 @DataBoundConstructor
50 public LocalSystem() {}
51
52 @Override
53 public AccountInfo getAccount(ManagedWindowsServiceLauncher launcher) {
54 return null;
55 }
56
57 @Extension(ordinal=100)
58 public static class DescriptorImpl extends Descriptor<ManagedWindowsServiceAccount> {
59 @Override
60 public String getDisplayName() {
61 return "Use Local System User";
62 }
63 }
64 }
65
66 /**
67 * Logs in with the administrator user account supplied in {@link ManagedWindowsServiceLauncher}.
68 */
69 public static final class Administrator extends ManagedWindowsServiceAccount {
70 @DataBoundConstructor
71 public Administrator() {}
72
73 @Override
74 public AccountInfo getAccount(ManagedWindowsServiceLauncher launcher) {
75 return new AccountInfo(launcher.userName,Secret.toString(launcher.password));
76 }
77
78 @Extension
79 public static class DescriptorImpl extends Descriptor<ManagedWindowsServiceAccount> {
80 @Override
81 public String getDisplayName() {
82 return "Use Administrator account given above";
83 }
84 }
85 }
86
87 /**
88 * Logs in with a separate user.
89 */
90 public static final class AnotherUser extends ManagedWindowsServiceAccount {
91 public final String userName;
92 public final Secret password;
93
94 @DataBoundConstructor
95 public AnotherUser(String userName, Secret password) {
96 this.userName = userName;
97 this.password = password;
98 }
99
100 @Override
101 public AccountInfo getAccount(ManagedWindowsServiceLauncher launcher) {
102 return new AccountInfo(userName,Secret.toString(password));
103 }
104
105 @Extension
106 public static class DescriptorImpl extends Descriptor<ManagedWindowsServiceAccount> {
107 @Override
108 public String getDisplayName() {
109 return "Log on using a different account";
110 }
111 }
112 }
113
114 }
115