use of org.jvnet.hk2.config in project jdk8u_jdk by JetBrains.
the class Semicolon method main.
public static void main(String[] args) throws Throwable {
System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/comments.conf");
Config config = Config.getInstance();
config.get("section", "value");
}
use of org.jvnet.hk2.config in project jdk8u_jdk by JetBrains.
the class ConfigWithQuotations method main.
public static void main(String[] args) throws Exception {
// This config file is generated using Kerberos.app on a Mac
System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/edu.mit.Kerberos");
Config config = Config.getInstance();
System.out.println(config);
if (!config.getDefaultRealm().equals("MAC.LOCAL")) {
throw new Exception("Realm error");
}
if (!config.getKDCList("MAC.LOCAL").equals("kdc.mac.local:88")) {
throw new Exception("KDC error");
}
}
use of org.jvnet.hk2.config in project jdk8u_jdk by JetBrains.
the class KDCOptions method setDefault.
private void setDefault() {
try {
Config config = Config.getInstance();
// If key not present, returns Integer.MIN_VALUE, which is
// almost all zero.
int options = config.getIntValue("libdefaults", "kdc_default_options");
if ((options & KDC_OPT_RENEWABLE_OK) == KDC_OPT_RENEWABLE_OK) {
set(RENEWABLE_OK, true);
} else {
if (config.getBooleanValue("libdefaults", "renewable")) {
set(RENEWABLE_OK, true);
}
}
if ((options & KDC_OPT_PROXIABLE) == KDC_OPT_PROXIABLE) {
set(PROXIABLE, true);
} else {
if (config.getBooleanValue("libdefaults", "proxiable")) {
set(PROXIABLE, true);
}
}
if ((options & KDC_OPT_FORWARDABLE) == KDC_OPT_FORWARDABLE) {
set(FORWARDABLE, true);
} else {
if (config.getBooleanValue("libdefaults", "forwardable")) {
set(FORWARDABLE, true);
}
}
} catch (KrbException e) {
if (DEBUG) {
System.out.println("Exception in getting default values for " + "KDC Options from the configuration ");
e.printStackTrace();
}
}
}
use of org.jvnet.hk2.config in project Payara by payara.
the class BaseRequestTracingNotifierConfigurer method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport actionReport = context.getActionReport();
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}
Config config = targetUtil.getConfig(target);
final RequestTracingServiceConfiguration configuration = config.getExtensionByType(RequestTracingServiceConfiguration.class);
ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
notifierClass = (Class<C>) genericSuperclass.getActualTypeArguments()[0];
C c = configuration.getNotifierByType(notifierClass);
try {
if (c == null) {
ConfigSupport.apply(new SingleConfigCode<RequestTracingServiceConfiguration>() {
@Override
public Object run(final RequestTracingServiceConfiguration configurationProxy) throws PropertyVetoException, TransactionFailure {
C c = configurationProxy.createChild(notifierClass);
applyValues(c);
configurationProxy.getNotifierList().add(c);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return configurationProxy;
}
}, configuration);
} else {
ConfigSupport.apply(new SingleConfigCode<C>() {
public Object run(C cProxy) throws PropertyVetoException, TransactionFailure {
applyValues(cProxy);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return cProxy;
}
}, c);
}
if (dynamic) {
if (server.isDas()) {
if (targetUtil.getConfig(target).isDas()) {
configureDynamically();
}
} else {
configureDynamically();
}
}
} catch (TransactionFailure ex) {
logger.log(Level.WARNING, "Exception during command ", ex);
actionReport.setMessage(ex.getCause().getMessage());
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
}
use of org.jvnet.hk2.config in project Payara by payara.
the class BaseNotificationConfigurer method execute.
@Override
public void execute(final AdminCommandContext context) {
final ActionReport actionReport = context.getActionReport();
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}
Config configuration = targetUtil.getConfig(target);
final NotificationServiceConfiguration notificationServiceConfiguration = configuration.getExtensionByType(NotificationServiceConfiguration.class);
ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
notifierConfigurationClass = (Class<C>) genericSuperclass.getActualTypeArguments()[0];
C c = notificationServiceConfiguration.getNotifierConfigurationByType(notifierConfigurationClass);
try {
if (c == null) {
ConfigSupport.apply(new SingleConfigCode<NotificationServiceConfiguration>() {
@Override
public Object run(final NotificationServiceConfiguration notificationServiceConfigurationProxy) throws PropertyVetoException, TransactionFailure {
C c = notificationServiceConfigurationProxy.createChild(notifierConfigurationClass);
applyValues(c);
notificationServiceConfigurationProxy.getNotifierConfigurationList().add(c);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
ParameterMap params = new ParameterMap();
params.add("enabled", Boolean.TRUE.toString());
params.add("dynamic", Boolean.TRUE.toString());
params.add("target", target);
ActionReport healthCheckSubReport = actionReport.addSubActionsReport();
CommandRunner.CommandInvocation healthCheckCommandInvocation = commandRunner.getCommandInvocation(getHealthCheckNotifierCommandName(), healthCheckSubReport, context.getSubject());
healthCheckCommandInvocation.parameters(params);
healthCheckCommandInvocation.execute();
if (healthCheckSubReport.hasFailures()) {
logger.log(Level.SEVERE, "Error occurred while configuring notifier with command: " + getHealthCheckNotifierCommandName());
}
ActionReport requestTracingSubReport = actionReport.addSubActionsReport();
CommandRunner.CommandInvocation requestTracingCommandInvocation = commandRunner.getCommandInvocation(getRequestTracingNotifierCommandName(), requestTracingSubReport, context.getSubject());
requestTracingCommandInvocation.parameters(params);
requestTracingCommandInvocation.execute();
if (requestTracingSubReport.hasFailures()) {
logger.log(Level.SEVERE, "Error occurred while configuring notifier with command: " + getRequestTracingNotifierCommandName());
}
return notificationServiceConfigurationProxy;
}
}, notificationServiceConfiguration);
} else {
ConfigSupport.apply(new SingleConfigCode<C>() {
public Object run(C cProxy) throws PropertyVetoException, TransactionFailure {
applyValues(cProxy);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return cProxy;
}
}, c);
}
if (dynamic) {
if (server.isDas()) {
if (targetUtil.getConfig(target).isDas()) {
configureDynamically();
}
} else {
configureDynamically();
}
}
} catch (TransactionFailure ex) {
logger.log(Level.WARNING, "Exception during command ", ex);
actionReport.setMessage(ex.getCause().getMessage());
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
}
Aggregations