use of org.glassfish.appclient.client.acc.config.TargetServer in project Payara by payara.
the class TargetServerHelper method selectEndpointsFromConfig.
private static List<TargetServer> selectEndpointsFromConfig(ClientContainer cc) {
/*
* Scan the property elements in the configuration for useful information.
*/
/*
* If the configuration specifies the "ssl" property then add a
* child security element to each TargetServer created for the
* target-server elements.
*/
boolean isGlobalSSL = false;
for (Property p : cc.getProperty()) {
/* if (p.getName().equals(GlassFishORBManager.IIOP_ENDPOINTS_PROPERTY)) {
endpointPropertySetting = p.getValue();
} else {
*/
if (p.getName().equals(SSL_PROPERTY_NAME)) {
isGlobalSSL = Boolean.parseBoolean(p.getValue());
}
// }
}
List<TargetServer> endpoints = new ArrayList<TargetServer>();
/*
* Start the target list with those specified in the configuration.
*/
endpoints.addAll(cc.getTargetServer());
/*
* For all target servers assembled so far, if one does not have a
* user-specified security child but the global SSL property was set
* then add a security child.
*/
for (TargetServer ts : endpoints) {
/*
* If the user selected SSL by setting that property in the
* config then add a security child, because the AppClientContainer
* expects each TargetServer object to declare its own
* security needs explicitly.
*
* Note that if the user already defined a security element for the
* target server we don't override it.
*/
if (isGlobalSSL && ts.getSecurity() == null) {
Security sec = new Security();
ts.setSecurity(sec);
}
}
return endpoints;
}
use of org.glassfish.appclient.client.acc.config.TargetServer in project Payara by payara.
the class AppClientSecurityInfoImpl method setSSLData.
private void setSSLData(List<TargetServer> tServers) {
try {
// Set the SSL related properties for ORB
TargetServer tServer = tServers.get(0);
// TargetServer is required.
// temp solution to target-server+ change in DTD
// assuming that multiple servers can be specified but only 1st
// first one will be used.
Security security = tServer.getSecurity();
if (security == null) {
_logger.fine("No Security input set in ClientContainer.xml");
// do nothing
return;
}
Ssl ssl = security.getSsl();
if (ssl == null) {
_logger.fine("No SSL input set in ClientContainer.xml");
// do nothing
return;
}
// XXX do not use NSS in this release
// CertDb certDB = security.getCertDb();
sslUtils.setAppclientSsl(convert(ssl));
this.appClientSSLUtil.setAppClientSSL(convert(ssl));
} catch (Exception ex) {
}
}
use of org.glassfish.appclient.client.acc.config.TargetServer in project Payara by payara.
the class XMLTest method testReadSampleXML.
@Test
public void testReadSampleXML() throws Exception {
System.out.println("testReadSampleXML");
for (String sampleXMLPath : SAMPLE_XML_PATH) {
System.out.println(" Testing with " + sampleXMLPath);
ClientContainer cc = readConfig(sampleXMLPath);
List<TargetServer> servers = cc.getTargetServer();
assertTrue("target servers did not read correctly from " + sampleXMLPath, servers.get(0).getAddress().equals(FIRST_HOST) && servers.get(0).getPort().equals(FIRST_PORT) && servers.get(1).getAddress().equals(SECOND_HOST) && servers.get(1).getPort() == SECOND_PORT);
}
}
use of org.glassfish.appclient.client.acc.config.TargetServer in project Payara by payara.
the class AppClientFacade method prepareACC.
public static void prepareACC(String agentArgsText, Instrumentation inst) throws UserError, MalformedURLException, URISyntaxException, JAXBException, FileNotFoundException, ParserConfigurationException, SAXException, IOException, Exception {
int minor = JDK.getMinor();
int major = JDK.getMajor();
if (major < 9) {
if (minor < 6) {
throw new UserError(localStrings.getLocalString(stringsAnchor, "main.badVersion", "Current Java version {0} is too low; {1} or later required", new Object[] { System.getProperty("java.version"), "1.6" }));
}
}
/*
* Analyze the agent argument string.
*/
AgentArguments agentArgs = AgentArguments.newInstance(agentArgsText);
/*
* The agent arguments that correspond to the ones that we want to
* pass to the ACC are the ones with the "arg=" keyword prefix. These
* will include arguments with meaning to the ACC (-textauth for example)
* as well as arguments to be passed on to the client's main method.
*/
appClientCommandArgs = AppclientCommandArguments.newInstance(agentArgs.namedValues("arg"));
if (appClientCommandArgs.isUsage()) {
usage(0);
} else if (appClientCommandArgs.isHelp()) {
help();
}
/*
* Examine the agent arguments for settings about how to launch the
* client.
*/
launchInfo = CommandLaunchInfo.newInstance(agentArgs);
if (launchInfo.getClientLaunchType() == ClientLaunchType.UNKNOWN) {
usage(1);
}
/*
* Handle the legacy env. variable APPCPATH.
*/
ACCClassLoader loader = initClassLoader((inst == null));
Thread.currentThread().setContextClassLoader(loader);
isJWS = Boolean.getBoolean("appclient.is.jws");
/*
* The installRoot property will be set by the ServerEnvironment
* initialization using the ACC start-up context. That happens during
* the ACCModulesManager warm-up.
*/
/*
* Load the ACC configuration XML file.
*/
ClientContainer clientContainer = readConfig(appClientCommandArgs.getConfigFilePath(), loader);
/*
* Decide what target servers to use. This combines any
* specified on the command line with any in the config file's
* target-server elements as well as any set in the properties
* of the config file.
*/
final TargetServer[] targetServers = TargetServerHelper.targetServers(clientContainer, appClientCommandArgs.getTargetServer());
/*
* Get the builder. Doing so correctly involves merging
* the configuration file data with some of the command line and
* agent arguments.
*/
final AppClientContainer.Builder builder = createBuilder(targetServers, clientContainer, appClientCommandArgs);
/*
* Create the ACC. Again, precisely how we create it depends on some
* of the command line arguments and agent arguments.
*/
final AppClientContainer newACC = createContainer(builder, launchInfo, appClientCommandArgs);
/*
* Because the JMV might invoke the client's main class, the agent
* needs to prepare the container. (This is done as part of the
* AppClientContainer.start() processing in the public API.
*/
newACC.prepare(inst);
acc = newACC;
}
use of org.glassfish.appclient.client.acc.config.TargetServer in project Payara by payara.
the class AppClientContainerBuilder method prepareIIOP.
/**
* Prepares the client ORB to bootstrap into the server ORB(s) specified
* by the TargetServer objects.
* @param targetServers the TargetServer endpoints to which the client ORB can try to connect
* @param containerProperties Properties, if specified, which might indicate that SSL is to be used
* @return ORB-related properties to define host and port for bootstrapping
*/
private void prepareIIOP(final TargetServer[] targetServers, Properties containerProperties) {
if (targetServers.length == 0) {
throw new IllegalArgumentException();
}
final StringBuilder sb = new StringBuilder();
for (TargetServer ts : targetServers) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(ts.getAddress()).append(":").append(ts.getPort());
}
/*
* If the user has explicitly defined the ORB-related properties, do
* not override those settings.
*/
if (targetServers.length == 1) {
defineIfNotDefined(GlassFishORBHelper.OMG_ORB_INIT_HOST_PROPERTY, targetServers[0].getAddress());
defineIfNotDefined(GlassFishORBHelper.OMG_ORB_INIT_PORT_PROPERTY, Integer.toString(targetServers[0].getPort()));
} else {
/*
* Currently, set a system property to specify multiple endpoints.
*/
defineIfNotDefined(ENDPOINTS_PROPERTY_NAME, sb.toString());
}
if (isSSLRequired(targetServers, containerProperties)) {
orbHelper.setCSIv2Prop(GlassFishORBHelper.ORB_SSL_CLIENT_REQUIRED, "true");
}
logger.log(Level.CONFIG, "Using endpoint address(es): {0}", sb.toString());
}
Aggregations