use of sun.security.action.GetBooleanAction in project jdk8u_jdk by JetBrains.
the class LDAPCertStore method createInitialDirContext.
/**
* Create InitialDirContext.
*
* @param server Server DNS name hosting LDAP service
* @param port Port at which server listens for requests
* @throws InvalidAlgorithmParameterException if creation fails
*/
private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException {
String url = "ldap://" + server + ":" + port;
Hashtable<String, Object> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, url);
// If property is set to true, disable application resource file lookup.
boolean disableAppResourceFiles = AccessController.doPrivileged(new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
if (disableAppResourceFiles) {
if (debug != null) {
debug.println("LDAPCertStore disabling app resource files");
}
env.put("com.sun.naming.disable.app.resource.files", "true");
}
try {
ctx = new InitialDirContext(env);
/*
* By default, follow referrals unless application has
* overridden property in an application resource file.
*/
Hashtable<?, ?> currentEnv = ctx.getEnvironment();
if (currentEnv.get(Context.REFERRAL) == null) {
ctx.addToEnvironment(Context.REFERRAL, "follow");
}
} catch (NamingException e) {
if (debug != null) {
debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException");
e.printStackTrace();
}
Exception ee = new InvalidAlgorithmParameterException("unable to create InitialDirContext using supplied parameters");
ee.initCause(e);
throw (InvalidAlgorithmParameterException) ee;
}
}
use of sun.security.action.GetBooleanAction in project jdk8u_jdk by JetBrains.
the class PipeWriter method main.
/**
* Main program to start the activation system. <br>
* The usage is as follows: rmid [-port num] [-log dir].
*/
public static void main(String[] args) {
boolean stop = false;
// already.
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
try {
int port = ActivationSystem.SYSTEM_PORT;
RMIServerSocketFactory ssf = null;
/*
* If rmid has an inherited channel (meaning that it was
* launched from inetd), set the server socket factory to
* return the inherited server socket.
**/
Channel inheritedChannel = AccessController.doPrivileged(new PrivilegedExceptionAction<Channel>() {
public Channel run() throws IOException {
return System.inheritedChannel();
}
});
if (inheritedChannel != null && inheritedChannel instanceof ServerSocketChannel) {
/*
* Redirect System.err output to a file.
*/
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
public Void run() throws IOException {
File file = Files.createTempFile("rmid-err", null).toFile();
PrintStream errStream = new PrintStream(new FileOutputStream(file));
System.setErr(errStream);
return null;
}
});
ServerSocket serverSocket = ((ServerSocketChannel) inheritedChannel).socket();
port = serverSocket.getLocalPort();
ssf = new ActivationServerSocketFactory(serverSocket);
System.err.println(new Date());
System.err.println(getTextResource("rmid.inherited.channel.info") + ": " + inheritedChannel);
}
String log = null;
List<String> childArgs = new ArrayList<>();
/*
* Parse arguments
*/
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-port")) {
if (ssf != null) {
bomb(getTextResource("rmid.syntax.port.badarg"));
}
if ((i + 1) < args.length) {
try {
port = Integer.parseInt(args[++i]);
} catch (NumberFormatException nfe) {
bomb(getTextResource("rmid.syntax.port.badnumber"));
}
} else {
bomb(getTextResource("rmid.syntax.port.missing"));
}
} else if (args[i].equals("-log")) {
if ((i + 1) < args.length) {
log = args[++i];
} else {
bomb(getTextResource("rmid.syntax.log.missing"));
}
} else if (args[i].equals("-stop")) {
stop = true;
} else if (args[i].startsWith("-C")) {
childArgs.add(args[i].substring(2));
} else {
bomb(MessageFormat.format(getTextResource("rmid.syntax.illegal.option"), args[i]));
}
}
if (log == null) {
if (ssf != null) {
bomb(getTextResource("rmid.syntax.log.required"));
} else {
log = "log";
}
}
debugExec = AccessController.doPrivileged(new GetBooleanAction("sun.rmi.server.activation.debugExec"));
/**
* Determine class name for activation exec policy (if any).
*/
String execPolicyClassName = AccessController.doPrivileged(new GetPropertyAction("sun.rmi.activation.execPolicy", null));
if (execPolicyClassName == null) {
if (!stop) {
DefaultExecPolicy.checkConfiguration();
}
execPolicyClassName = "default";
}
/**
* Initialize method for activation exec policy.
*/
if (!execPolicyClassName.equals("none")) {
if (execPolicyClassName.equals("") || execPolicyClassName.equals("default")) {
execPolicyClassName = DefaultExecPolicy.class.getName();
}
try {
Class<?> execPolicyClass = getRMIClass(execPolicyClassName);
execPolicy = execPolicyClass.newInstance();
execPolicyMethod = execPolicyClass.getMethod("checkExecCommand", ActivationGroupDesc.class, String[].class);
} catch (Exception e) {
if (debugExec) {
System.err.println(getTextResource("rmid.exec.policy.exception"));
e.printStackTrace();
}
bomb(getTextResource("rmid.exec.policy.invalid"));
}
}
if (stop == true) {
final int finalPort = port;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
System.setProperty("java.rmi.activation.port", Integer.toString(finalPort));
return null;
}
});
ActivationSystem system = ActivationGroup.getSystem();
system.shutdown();
System.exit(0);
}
/*
* Fix for 4173960: Create and initialize activation using
* a static method, startActivation, which will build the
* Activation state in two ways: if when rmid is run, no
* log file is found, the ActLogHandler.recover(...)
* method will create a new Activation instance.
* Alternatively, if a logfile is available, a serialized
* instance of activation will be read from the log's
* snapshot file. Log updates will be applied to this
* Activation object until rmid's state has been fully
* recovered. In either case, only one instance of
* Activation is created.
*/
startActivation(port, ssf, log, childArgs.toArray(new String[childArgs.size()]));
// prevent activator from exiting
while (true) {
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException e) {
}
}
} catch (Exception e) {
System.err.println(MessageFormat.format(getTextResource("rmid.unexpected.exception"), e));
e.printStackTrace();
}
System.exit(1);
}
use of sun.security.action.GetBooleanAction in project jdk8u_jdk by JetBrains.
the class XEmbedCanvasPeer method canvasFocusLost.
void canvasFocusLost(FocusEvent e) {
if (isXEmbedActive() && !e.isTemporary()) {
xembedLog.fine("Forwarding FOCUS_LOST");
int num = 0;
if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembed.testing"))) {
Component opp = e.getOppositeComponent();
try {
num = Integer.parseInt(opp.getName());
} catch (NumberFormatException nfe) {
}
}
xembed.sendMessage(xembed.handle, XEMBED_FOCUS_OUT, num, 0, 0);
}
}
Aggregations