use of sun.security.krb5.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 sun.security.krb5.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 sun.security.krb5.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 sun.security.krb5.Config in project jdk8u_jdk by JetBrains.
the class Realm method parseCapaths.
/**
* Parses the [capaths] stanza of the configuration file for a
* list of realms to traverse to obtain credentials from the
* initiating realm cRealm to the target realm sRealm.
*
* For a given client realm C there is a tag C in [capaths] whose
* subtag S has a value which is a (possibly partial) path from C
* to S. When the path is partial, it contains only the tail of the
* full path. Values of other subtags will be used to build the full
* path. The value "." means a direct path from C to S. If realm S
* does not appear as a subtag, there is no path defined here.
*
* The implementation ignores all values which equals to C or S, or
* a "." in multiple values, or any duplicated realm names.
*
* When a path value has more than two realms, they can be specified
* with multiple key-value pairs each having a single value, but the
* order must not change.
*
* For example:
*
* [capaths]
* TIVOLI.COM = {
* IBM.COM = IBM_LDAPCENTRAL.COM MOONLITE.ORG
* IBM_LDAPCENTRAL.COM = LDAPCENTRAL.NET
* LDAPCENTRAL.NET = .
* }
*
* TIVOLI.COM has a direct path to LDAPCENTRAL.NET, which has a direct
* path to IBM_LDAPCENTRAL.COM. It also has a partial path to IBM.COM
* being "IBM_LDAPCENTRAL.COM MOONLITE.ORG". Merging these info together,
* a full path from TIVOLI.COM to IBM.COM will be
*
* TIVOLI.COM -> LDAPCENTRAL.NET -> IBM_LDAPCENTRAL.COM
* -> IBM_LDAPCENTRAL.COM -> MOONLITE.ORG
*
* Please note the sRealm IBM.COM does not appear in the path.
*
* @param cRealm the initiating realm
* @param sRealm the target realm, not the same as cRealm
* @returns array of realms including at least cRealm as the first
* element
* @throws KrbException if the config does not contain a sub-stanza
* for cRealm in [capaths] or the sub-stanza does not contain
* sRealm as a tag
*/
private static String[] parseCapaths(String cRealm, String sRealm) throws KrbException {
// This line could throw a KrbException
Config cfg = Config.getInstance();
if (!cfg.exists("capaths", cRealm, sRealm)) {
throw new KrbException("No conf");
}
LinkedList<String> path = new LinkedList<>();
String head = sRealm;
while (true) {
String value = cfg.getAll("capaths", cRealm, head);
if (value == null) {
break;
}
String[] more = value.split("\\s+");
boolean changed = false;
for (int i = more.length - 1; i >= 0; i--) {
if (path.contains(more[i]) || more[i].equals(".") || more[i].equals(cRealm) || more[i].equals(sRealm) || more[i].equals(head)) {
// Ignore invalid values
continue;
}
changed = true;
path.addFirst(more[i]);
}
if (!changed)
break;
head = path.getFirst();
}
path.addFirst(cRealm);
return path.toArray(new String[path.size()]);
}
use of sun.security.krb5.Config in project Payara by payara.
the class WebContainerImpl method setConfiguration.
// --------------------------------------------------------- Public Methods
public void setConfiguration(WebContainerConfig config) {
if (!initialized) {
init();
}
this.config = config;
final WebContainerConfig webConfig = config;
try {
VirtualServer vs = getVirtualServer(config.getVirtualServerId());
if (vs != null) {
((StandardHost) vs).setDefaultWebXmlLocation(config.getDefaultWebXml().getPath());
}
com.sun.enterprise.config.serverbeans.VirtualServer vsBean = httpService.getVirtualServerByName(config.getVirtualServerId());
if (vsBean != null) {
ConfigSupport.apply(new SingleConfigCode<com.sun.enterprise.config.serverbeans.VirtualServer>() {
public Object run(com.sun.enterprise.config.serverbeans.VirtualServer avs) throws PropertyVetoException, TransactionFailure {
avs.setId(webConfig.getVirtualServerId());
if (webConfig.getDocRootDir() != null) {
avs.setDocroot(webConfig.getDocRootDir().getAbsolutePath());
}
avs.setHosts(webConfig.getHostNames());
avs.setNetworkListeners(webConfig.getListenerName());
Property property = avs.createChild(Property.class);
property.setName("default-web-xml");
property.setValue(webConfig.getDefaultWebXml().getPath());
avs.getProperty().add(property);
return avs;
}
}, vsBean);
} else {
vs = createVirtualServer(config.getVirtualServerId(), config.getDocRootDir());
addVirtualServer(vs);
}
EmbeddedWebArchivist archivist = habitat.<EmbeddedWebArchivist>getService(EmbeddedWebArchivist.class);
archivist.setDefaultWebXml(config.getDefaultWebXml());
embedded.setDirectoryListing(config.getListings());
WebListener listener = getWebListener(config.getListenerName());
if (listener == null) {
listener = getWebListener(config.getPort());
if (listener == null) {
boolean found = false;
for (Map.Entry entry : webContainer.getConnectorMap().entrySet()) {
if (((WebConnector) entry.getValue()).getPort() == config.getPort()) {
found = true;
log.info("Port " + config.getPort() + " is already configured");
}
}
if (!found) {
listener = createWebListener(config.getListenerName(), HttpListener.class);
listener.setPort(config.getPort());
addWebListener(listener, config.getVirtualServerId());
}
}
} else {
if (listener.getPort() != config.getPort()) {
listener.setPort(config.getPort());
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations