org.wildfly.security.manager.WildFlySecurityManager.getPropertyPrivileged()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.wildfly.security.manager.WildFlySecurityManager.getPropertyPrivileged()方法的一些代码示例,展示了WildFlySecurityManager.getPropertyPrivileged()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WildFlySecurityManager.getPropertyPrivileged()方法的具体详情如下:
包路径:org.wildfly.security.manager.WildFlySecurityManager
类名称:WildFlySecurityManager
方法名:getPropertyPrivileged

WildFlySecurityManager.getPropertyPrivileged介绍

[英]Get a property, doing a faster permission check that skips having to execute a privileged action frame.
[中]获取一个属性,进行更快的权限检查,从而避免执行特权操作框架。

代码示例

代码示例来源:origin: wildfly/wildfly

private static String getProperty(final String name) {
  return WildFlySecurityManager.getPropertyPrivileged(name, null);
}

代码示例来源:origin: wildfly/wildfly

public WebParsingDeploymentProcessor() {
  String property = WildFlySecurityManager.getPropertyPrivileged(XMLSchemaValidator.PROPERTY_SCHEMA_VALIDATION, "false");
  this.schemaValidation = Boolean.parseBoolean(property);
}

代码示例来源:origin: wildfly/wildfly

private static boolean checkForPresence(final String key, final String value) {
  final String tmp = WildFlySecurityManager.getPropertyPrivileged(key, value);
  try {
    return tmp != null && tmp.trim().toLowerCase(Locale.ENGLISH).startsWith(value);
  } catch (Throwable t) {
    return false;
  }
}

代码示例来源:origin: wildfly/wildfly

private static int getMajorJavaVersion() {
    int major = 8;
    String version = WildFlySecurityManager.getPropertyPrivileged("java.specification.version", null);
    if (version != null) {
      Matcher matcher = Pattern.compile("^(?:1\\.)?(\\d+)$").matcher(version);
      if (matcher.find()) {
        major = Integer.valueOf(matcher.group(1));
      }
    }
    return major;
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * Initialize the naming components required by {@link javax.naming.spi.NamingManager}.
 */
public static void initializeNamingManager() {
  // Setup naming environment
  final String property = WildFlySecurityManager.getPropertyPrivileged(Context.URL_PKG_PREFIXES, null);
  if(property == null || property.isEmpty()) {
    WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES);
  } else if(!Arrays.asList(property.split(":")).contains(PACKAGE_PREFIXES)) {
    WildFlySecurityManager.setPropertyPrivileged(Context.URL_PKG_PREFIXES, PACKAGE_PREFIXES + ":" + property);
  }
  try {
    //If we are reusing the JVM. e.g. in tests we should not set this again
    if (!NamingManager.hasInitialContextFactoryBuilder())
      NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder());
  } catch (NamingException e) {
    ROOT_LOGGER.failedToSet(e, "InitialContextFactoryBuilder");
  }
}

代码示例来源:origin: wildfly/wildfly

private HttpHandler configureRootHandler() {
  AccessLogService logService = accessLogService;
  HttpHandler rootHandler = pathHandler;
  ArrayList<UndertowFilter> filters = new ArrayList<>(this.filters);
  //handle options * requests
  rootHandler = new OptionsHandler(rootHandler);
  //handle requests that use the Expect: 100-continue header
  rootHandler = Handlers.httpContinueRead(rootHandler);
  rootHandler = LocationService.configureHandlerChain(rootHandler, filters);
  if (logService != null) {
    rootHandler = logService.configureAccessLogHandler(rootHandler);
  }
  // handle .well-known requests from ACME certificate authorities
  String path = WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", ".");
  Path base;
  try {
    base = Paths.get(path).normalize().toRealPath();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  final int cacheBufferSize = 1024;
  final int cacheBuffers = 1024;
  PathResourceManager resourceManager = new PathResourceManager(base, cacheBufferSize * cacheBuffers, true, false);
  rootHandler = new AcmeResourceHandler(resourceManager, rootHandler);
  GateHandlerWrapper gateHandlerWrapper = this.gateHandlerWrapper;
  if(gateHandlerWrapper != null) {
    rootHandler = gateHandlerWrapper.wrap(rootHandler);
  }
  return rootHandler;
}

代码示例来源:origin: wildfly/wildfly

private PolicyConfigurationFactory getPolicyConfigurationFactory() throws ModuleLoadException, ClassNotFoundException, PolicyContextException {
  String module = WildFlySecurityManager.getPropertyPrivileged(JACC_MODULE, null);
  final ClassLoader originalClassLoader;
  final ClassLoader jaccClassLoader;
  if (module != null) {
    jaccClassLoader = SecurityActions.getModuleClassLoader(module);
    originalClassLoader = SecurityActions.setThreadContextClassLoader(jaccClassLoader);
  } else {
    jaccClassLoader = null;
    originalClassLoader = null;
  }
  try {
    return PolicyConfigurationFactory.getPolicyConfigurationFactory();
  } finally {
    if (originalClassLoader != null) {
      SecurityActions.setThreadContextClassLoader(originalClassLoader);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
  final String jndiName = DatabaseDataStoreResourceDefinition.DATASOURCE_JNDI_NAME.resolveModelAttribute(context, model).asString();
  final ModelNode dataBaseValue = DatabaseDataStoreResourceDefinition.DATABASE.resolveModelAttribute(context, model);
  final String database;
  if(dataBaseValue.isDefined()) {
    database = dataBaseValue.asString();
  } else {
    database = null;
  }
  final String partition = DatabaseDataStoreResourceDefinition.PARTITION.resolveModelAttribute(context, model).asString();
  final String name = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue();
  int refreshInterval = DatabaseDataStoreResourceDefinition.REFRESH_INTERVAL.resolveModelAttribute(context, model).asInt();
  boolean allowExecution = DatabaseDataStoreResourceDefinition.ALLOW_EXECUTION.resolveModelAttribute(context, model).asBoolean();
  final String nodeName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null);
  final DatabaseTimerPersistence databaseTimerPersistence = new DatabaseTimerPersistence(database, partition, nodeName, refreshInterval, allowExecution);
  final ServiceName serviceName = TimerPersistence.SERVICE_NAME.append(name);
  context.getServiceTarget().addService(serviceName, databaseTimerPersistence)
      .addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, databaseTimerPersistence.getModuleLoader())
      .addDependency(ContextNames.bindInfoFor(jndiName).getBinderServiceName(), ManagedReferenceFactory.class, databaseTimerPersistence.getDataSourceInjectedValue())
      .addDependency(TimerServiceDeploymentProcessor.TIMER_SERVICE_NAME, java.util.Timer.class, databaseTimerPersistence.getTimerInjectedValue())
      .install();
}

代码示例来源:origin: wildfly/wildfly

String module = WildFlySecurityManager.getPropertyPrivileged(JACC_MODULE, null);
String provider = WildFlySecurityManager.getPropertyPrivileged(JACC_POLICY_PROVIDER, "org.jboss.security.jacc.DelegatingPolicy");
Class<?> providerClass = loadClass(module, provider);
try {

代码示例来源:origin: org.wildfly.core/wildfly-controller

@Override
protected boolean requiresRuntime(OperationContext context) {
  //TODO Gigantic HACK to disable the runtime part of this for the core model testing.
  //The core model testing currently uses RunningMode.ADMIN_ONLY, but in the real world
  //the http interface needs to be enabled even when that happens.
  //I don't want to wire up all the services unless I can avoid it, so for now the tests set this system property
  return WildFlySecurityManager.getPropertyPrivileged("jboss.as.test.disable.runtime", null) == null;
}

代码示例来源:origin: org.wildfly.core/wildfly-cli

private CliConfigImpl() {
  defaultControllerProtocol = "remote+http";
  historyEnabled = true;
  historyFileName = ".jboss-cli-history";
  historyFileDir = WildFlySecurityManager.getPropertyPrivileged("user.home", null);
  historyMaxSize = 500;
  connectionTimeout = 5000;
}

代码示例来源:origin: org.wildfly/wildfly-server

@Override
protected boolean requiresRuntime(OperationContext context) {
  //TODO Gigantic HACK to disable the runtime part of this for the core model testing.
  //The core model testing currently uses RunningMode.ADMIN_ONLY, but in the real world
  //the http interface needs to be enabled even when that happens.
  //I don't want to wire up all the services unless I can avoid it, so for now the tests set this system property
  if (WildFlySecurityManager.getPropertyPrivileged("jboss.as.test.disable.runtime", null) != null) {
    return false;
  }
  return true;
}

代码示例来源:origin: org.wildfly.core/wildfly-controller

private int getInteger(final String name, final int defaultValue) {
  final String val = WildFlySecurityManager.getPropertyPrivileged(name, null);
  try {
    return val == null ? defaultValue : Integer.parseInt(val);
  } catch (NumberFormatException ignored) {
    return defaultValue;
  }
}

代码示例来源:origin: org.wildfly.core/wildfly-process-controller

private String getBindAddress() {
  if (bindAddress != null) {
    return bindAddress;
  } else {
    boolean v4Stack = Boolean.valueOf(WildFlySecurityManager.getPropertyPrivileged(CommandLineConstants.PREFER_IPV4_STACK, "false"));
    boolean useV6 = !v4Stack && Boolean.valueOf(WildFlySecurityManager.getPropertyPrivileged(CommandLineConstants.PREFER_IPV6_ADDRESSES, "false"));
    return useV6 ? "::1" : "127.0.0.1";
  }
}

代码示例来源:origin: org.wildfly/wildfly-controller

private int getInteger(final String name, final int defaultValue) {
  final String val = WildFlySecurityManager.getPropertyPrivileged(name, null);
  try {
    return val == null ? defaultValue : Integer.parseInt(val);
  } catch (NumberFormatException ignored) {
    return defaultValue;
  }
}

代码示例来源:origin: org.wildfly.core/wildfly-cli

EnvironmentRestorer(final String... propertyKeys) {
  this.propertiesToReset = new HashMap<>();
  for (String key : propertyKeys) {
    final String value = WildFlySecurityManager.getPropertyPrivileged(key, null);
    propertiesToReset.put(key, value);
  }
  propertiesToReset.put("jboss.home.dir", WildFlySecurityManager.getPropertyPrivileged("jboss.home.dir", null));
  propertiesToReset.put("org.jboss.boot.log.file", WildFlySecurityManager.getPropertyPrivileged("org.jboss.boot.log.file", null));
}

代码示例来源:origin: org.wildfly.core/wildfly-host-controller

private static String usageNote() {
  boolean isWindows = (WildFlySecurityManager.getPropertyPrivileged("os.name", null)).toLowerCase(Locale.ENGLISH).contains("windows");
  String command = isWindows ? "domain" : "domain.sh";
  return HostControllerLogger.ROOT_LOGGER.usageNote(command);
}

代码示例来源:origin: org.jboss.migration/jboss-server-migration-wildfly10.0

private void setSystemProperty(final String name, final Object value) {
  if (value != null) {
    final String currentValue = WildFlySecurityManager.getPropertyPrivileged(name, null);
    WildFlySecurityManager.setPropertyPrivileged(name, value.toString());
    propertiesToReset.put(name, currentValue);
  }
}

代码示例来源:origin: org.wildfly/wildfly-server

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model,
               ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
  final ServiceTarget serviceTarget = context.getServiceTarget();
  final ServiceName endpointName = ManagementRemotingServices.MANAGEMENT_ENDPOINT;
  final String hostName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null);
  NativeManagementServices.installRemotingServicesIfNotInstalled(serviceTarget, hostName, verificationHandler, newControllers, context.getServiceRegistry(false));
  installNativeManagementConnector(context, model, endpointName, serviceTarget, verificationHandler, newControllers);
}

代码示例来源:origin: org.wildfly.core/wildfly-host-controller

private ConfigurationFile getStandardDomainConfigurationFile() {
  final String defaultDomainConfig = WildFlySecurityManager.getPropertyPrivileged(HostControllerEnvironment.JBOSS_DOMAIN_DEFAULT_CONFIG, "domain.xml");
  final String initialDomainConfig = environment.getInitialDomainConfig();
  return new ConfigurationFile(environment.getDomainConfigurationDir(), defaultDomainConfig,
      initialDomainConfig == null ? environment.getDomainConfig() : initialDomainConfig, environment.getDomainConfigurationFileInteractionPolicy(), false);
}

相关文章

微信公众号

最新文章

更多