Lines 47-54
Link Here
|
47 |
import java.io.IOException; |
47 |
import java.io.IOException; |
48 |
import java.io.InputStream; |
48 |
import java.io.InputStream; |
49 |
import java.io.UnsupportedEncodingException; |
49 |
import java.io.UnsupportedEncodingException; |
50 |
import java.net.MalformedURLException; |
|
|
51 |
import java.net.URL; |
52 |
import java.nio.charset.Charset; |
50 |
import java.nio.charset.Charset; |
53 |
import java.util.List; |
51 |
import java.util.List; |
54 |
import java.util.concurrent.Callable; |
52 |
import java.util.concurrent.Callable; |
Lines 57-68
Link Here
|
57 |
import java.util.logging.Logger; |
55 |
import java.util.logging.Logger; |
58 |
import java.util.regex.Pattern; |
56 |
import java.util.regex.Pattern; |
59 |
import javax.swing.SwingUtilities; |
57 |
import javax.swing.SwingUtilities; |
|
|
58 |
import org.netbeans.api.keyring.Keyring; |
60 |
import org.netbeans.api.project.FileOwnerQuery; |
59 |
import org.netbeans.api.project.FileOwnerQuery; |
61 |
import org.netbeans.api.project.Project; |
60 |
import org.netbeans.api.project.Project; |
62 |
import org.netbeans.api.project.ProjectUtils; |
61 |
import org.netbeans.api.project.ProjectUtils; |
63 |
import org.netbeans.api.server.ServerInstance; |
62 |
import org.netbeans.api.server.ServerInstance; |
64 |
import org.netbeans.libs.oracle.cloud.sdkwrapper.api.ApplicationManager; |
63 |
import org.netbeans.libs.oracle.cloud.sdkwrapper.api.ApplicationManager; |
65 |
import org.netbeans.libs.oracle.cloud.sdkwrapper.api.ApplicationManagerConnectionFactory; |
|
|
66 |
import org.netbeans.libs.oracle.cloud.api.CloudSDKHelper; |
64 |
import org.netbeans.libs.oracle.cloud.api.CloudSDKHelper; |
67 |
import org.netbeans.libs.oracle.cloud.sdkwrapper.exception.ManagerException; |
65 |
import org.netbeans.libs.oracle.cloud.sdkwrapper.exception.ManagerException; |
68 |
import org.netbeans.libs.oracle.cloud.sdkwrapper.model.*; |
66 |
import org.netbeans.libs.oracle.cloud.sdkwrapper.model.*; |
Lines 94-101
Link Here
|
94 |
private static final Logger LOG = Logger.getLogger(OracleInstance.class.getSimpleName()); |
92 |
private static final Logger LOG = Logger.getLogger(OracleInstance.class.getSimpleName()); |
95 |
|
93 |
|
96 |
private final String name; |
94 |
private final String name; |
|
|
95 |
|
96 |
/* GuardedBy(this) */ |
97 |
private boolean userLoaded; |
98 |
|
99 |
/* GuardedBy(this) */ |
97 |
private String user; |
100 |
private String user; |
|
|
101 |
|
102 |
/* GuardedBy(this) */ |
103 |
private boolean passwordLoaded; |
104 |
|
105 |
/* GuardedBy(this) */ |
98 |
private String password; |
106 |
private String password; |
|
|
107 |
|
99 |
private String adminURL; |
108 |
private String adminURL; |
100 |
private String identityDomain; |
109 |
private String identityDomain; |
101 |
private String javaServiceName; |
110 |
private String javaServiceName; |
Lines 109-122
Link Here
|
109 |
|
118 |
|
110 |
/* GuardedBy(this) */ |
119 |
/* GuardedBy(this) */ |
111 |
private OracleJ2EEInstance j2eeInstance; |
120 |
private OracleJ2EEInstance j2eeInstance; |
|
|
121 |
|
122 |
public OracleInstance(String name, String user, String password, String adminURL, String identityDomain, |
123 |
String javaServiceName, String dbServiceName, String onPremiseServerInstanceId, |
124 |
String sdkFolder) { |
125 |
this(name, adminURL, identityDomain, javaServiceName, dbServiceName, onPremiseServerInstanceId, sdkFolder); |
126 |
this.userLoaded = true; |
127 |
this.user = user; |
128 |
this.passwordLoaded = true; |
129 |
this.password = password; |
130 |
} |
112 |
|
131 |
|
113 |
public OracleInstance(String name, String user, String password, |
132 |
public OracleInstance(String name, String adminURL, String identityDomain, |
114 |
String adminURL, String identityDomain, |
|
|
115 |
String javaServiceName, String dbServiceName, String onPremiseServerInstanceId, |
133 |
String javaServiceName, String dbServiceName, String onPremiseServerInstanceId, |
116 |
String sdkFolder) { |
134 |
String sdkFolder) { |
117 |
this.name = name; |
135 |
this.name = name; |
118 |
this.user = user; |
|
|
119 |
this.password = password; |
120 |
this.adminURL = adminURL; |
136 |
this.adminURL = adminURL; |
121 |
this.identityDomain = identityDomain; |
137 |
this.identityDomain = identityDomain; |
122 |
this.javaServiceName = javaServiceName; |
138 |
this.javaServiceName = javaServiceName; |
Lines 138-148
Link Here
|
138 |
} |
154 |
} |
139 |
|
155 |
|
140 |
public String getPassword() { |
156 |
public String getPassword() { |
141 |
return password; |
157 |
synchronized (this) { |
|
|
158 |
if (passwordLoaded) { |
159 |
return password; |
160 |
} |
161 |
} |
162 |
|
163 |
return loadCredentials().getPassword(); |
142 |
} |
164 |
} |
143 |
|
165 |
|
144 |
public String getUser() { |
166 |
public String getUser() { |
145 |
return user; |
167 |
synchronized (this) { |
|
|
168 |
if (userLoaded) { |
169 |
return user; |
170 |
} |
171 |
} |
172 |
|
173 |
return loadCredentials().getUsername(); |
146 |
} |
174 |
} |
147 |
|
175 |
|
148 |
public String getAdminURL() { |
176 |
public String getAdminURL() { |
Lines 189-196
Link Here
|
189 |
} |
217 |
} |
190 |
|
218 |
|
191 |
public void setPassword(String password) { |
219 |
public void setPassword(String password) { |
192 |
this.password = password; |
|
|
193 |
synchronized (this) { |
220 |
synchronized (this) { |
|
|
221 |
this.password = password; |
222 |
this.passwordLoaded = true; |
194 |
if (j2eeInstance != null) { |
223 |
if (j2eeInstance != null) { |
195 |
j2eeInstance.getInstanceProperties().setProperty( |
224 |
j2eeInstance.getInstanceProperties().setProperty( |
196 |
InstanceProperties.PASSWORD_ATTR, password); |
225 |
InstanceProperties.PASSWORD_ATTR, password); |
Lines 200-207
Link Here
|
200 |
} |
229 |
} |
201 |
|
230 |
|
202 |
public void setUser(String user) { |
231 |
public void setUser(String user) { |
203 |
this.user = user; |
|
|
204 |
synchronized (this) { |
232 |
synchronized (this) { |
|
|
233 |
this.user = user; |
234 |
this.userLoaded = true; |
205 |
if (j2eeInstance != null) { |
235 |
if (j2eeInstance != null) { |
206 |
j2eeInstance.getInstanceProperties().setProperty( |
236 |
j2eeInstance.getInstanceProperties().setProperty( |
207 |
InstanceProperties.USERNAME_ATTR, user); |
237 |
InstanceProperties.USERNAME_ATTR, user); |
Lines 234-246
Link Here
|
234 |
} |
264 |
} |
235 |
} |
265 |
} |
236 |
|
266 |
|
|
|
267 |
private Credentials loadCredentials() { |
268 |
char ch[] = Keyring.read(OracleInstanceManager.PREFIX |
269 |
+ OracleInstanceManager.USERNAME + "." + name); |
270 |
if (ch == null) { |
271 |
LOG.log(Level.WARNING, "no username found for "+name); |
272 |
ch = new char[]{' '}; |
273 |
} |
274 |
String userName = new String(ch); |
275 |
assert userName != null : "username is missing for "+name; // NOI18N |
276 |
|
277 |
ch = Keyring.read(OracleInstanceManager.PREFIX |
278 |
+ OracleInstanceManager.PASSWORD + "." + name); |
279 |
if (ch == null) { |
280 |
LOG.log(Level.WARNING, "no password found for "+name); |
281 |
ch = new char[]{' '}; |
282 |
} |
283 |
String passwd = new String(ch); |
284 |
assert passwd != null : "password is missing for "+name; // NOI18N |
285 |
|
286 |
synchronized (this) { |
287 |
if (!userLoaded) { |
288 |
userLoaded = true; |
289 |
user = userName; |
290 |
} |
291 |
if (!passwordLoaded) { |
292 |
passwordLoaded = true; |
293 |
password = passwd; |
294 |
} |
295 |
return new Credentials(user, password); |
296 |
} |
297 |
} |
298 |
|
237 |
private synchronized void resetCache() { |
299 |
private synchronized void resetCache() { |
238 |
platform = null; |
300 |
platform = null; |
239 |
} |
301 |
} |
240 |
|
302 |
|
241 |
public synchronized ApplicationManager getApplicationManager() { |
303 |
public synchronized ApplicationManager getApplicationManager() { |
242 |
if (platform == null) { |
304 |
if (platform == null) { |
243 |
platform = createApplicationManager(adminURL, user, password, sdkFolder); |
305 |
platform = createApplicationManager(adminURL, getUser(), getPassword(), sdkFolder); |
244 |
} |
306 |
} |
245 |
return platform; |
307 |
return platform; |
246 |
} |
308 |
} |
Lines 529-532
Link Here
|
529 |
return sb.toString(); |
591 |
return sb.toString(); |
530 |
} |
592 |
} |
531 |
|
593 |
|
|
|
594 |
private static class Credentials { |
595 |
|
596 |
private final String username; |
597 |
|
598 |
private final String password; |
599 |
|
600 |
public Credentials(String username, String password) { |
601 |
this.username = username; |
602 |
this.password = password; |
603 |
} |
604 |
|
605 |
public String getUsername() { |
606 |
return username; |
607 |
} |
608 |
|
609 |
public String getPassword() { |
610 |
return password; |
611 |
} |
612 |
} |
613 |
|
532 |
} |
614 |
} |