org.apache.zookeeper.Environment Java Examples
The following examples show how to use
org.apache.zookeeper.Environment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegistrySecurity.java From hadoop with Apache License 2.0 | 6 votes |
/** * Resolve the context of an entry. This is an effective test of * JAAS setup, because it will relay detected problems up * @param context context name * @return the entry * @throws RuntimeException if there is no context entry found */ public static AppConfigurationEntry[] validateContext(String context) { if (context == null) { throw new RuntimeException("Null context argument"); } if (context.isEmpty()) { throw new RuntimeException("Empty context argument"); } javax.security.auth.login.Configuration configuration = javax.security.auth.login.Configuration.getConfiguration(); AppConfigurationEntry[] entries = configuration.getAppConfigurationEntry(context); if (entries == null) { throw new RuntimeException( String.format("Entry \"%s\" not found; " + "JAAS config = %s", context, describeProperty(Environment.JAAS_CONF_KEY) )); } return entries; }
Example #2
Source File: TestSecureLogins.java From hadoop with Apache License 2.0 | 6 votes |
@Test public void testClientLogin() throws Throwable { LoginContext client = login(ALICE_LOCALHOST, ALICE_CLIENT_CONTEXT, keytab_alice); try { logLoginDetails(ALICE_LOCALHOST, client); String confFilename = System.getProperty(Environment.JAAS_CONF_KEY); assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename); String config = FileUtils.readFileToString(new File(confFilename)); LOG.info("{}=\n{}", confFilename, config); RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT); } finally { client.logout(); } }
Example #3
Source File: TestSecureLogins.java From big-c with Apache License 2.0 | 6 votes |
@Test public void testClientLogin() throws Throwable { LoginContext client = login(ALICE_LOCALHOST, ALICE_CLIENT_CONTEXT, keytab_alice); try { logLoginDetails(ALICE_LOCALHOST, client); String confFilename = System.getProperty(Environment.JAAS_CONF_KEY); assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename); String config = FileUtils.readFileToString(new File(confFilename)); LOG.info("{}=\n{}", confFilename, config); RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT); } finally { client.logout(); } }
Example #4
Source File: RegistrySecurity.java From big-c with Apache License 2.0 | 6 votes |
/** * Resolve the context of an entry. This is an effective test of * JAAS setup, because it will relay detected problems up * @param context context name * @return the entry * @throws RuntimeException if there is no context entry found */ public static AppConfigurationEntry[] validateContext(String context) { if (context == null) { throw new RuntimeException("Null context argument"); } if (context.isEmpty()) { throw new RuntimeException("Empty context argument"); } javax.security.auth.login.Configuration configuration = javax.security.auth.login.Configuration.getConfiguration(); AppConfigurationEntry[] entries = configuration.getAppConfigurationEntry(context); if (entries == null) { throw new RuntimeException( String.format("Entry \"%s\" not found; " + "JAAS config = %s", context, describeProperty(Environment.JAAS_CONF_KEY) )); } return entries; }
Example #5
Source File: RegistrySecurity.java From hadoop with Apache License 2.0 | 5 votes |
/** * Bind the JVM JAS setting to the specified JAAS file. * * <b>Important:</b> once a file has been loaded the JVM doesn't pick up * changes * @param jaasFile the JAAS file */ public static void bindJVMtoJAASFile(File jaasFile) { String path = jaasFile.getAbsolutePath(); if (LOG.isDebugEnabled()) { LOG.debug("Binding {} to {}", Environment.JAAS_CONF_KEY, path); } System.setProperty(Environment.JAAS_CONF_KEY, path); }
Example #6
Source File: RegistrySecurity.java From hadoop with Apache License 2.0 | 5 votes |
/** * Build up low-level security diagnostics to aid debugging * @return a string to use in diagnostics */ public String buildSecurityDiagnostics() { StringBuilder builder = new StringBuilder(); builder.append(secureRegistry ? "secure registry; " : "insecure registry; "); builder.append("Curator service access policy: ").append(access); builder.append("; System ACLs: ").append(aclsToString(systemACLs)); builder.append("User: ").append(UgiInfo.fromCurrentUser()); builder.append("; Kerberos Realm: ").append(kerberosRealm); builder.append(describeProperty(Environment.JAAS_CONF_KEY)); String sasl = System.getProperty(PROP_ZK_ENABLE_SASL_CLIENT, DEFAULT_ZK_ENABLE_SASL_CLIENT); boolean saslEnabled = Boolean.valueOf(sasl); builder.append(describeProperty(PROP_ZK_ENABLE_SASL_CLIENT, DEFAULT_ZK_ENABLE_SASL_CLIENT)); if (saslEnabled) { builder.append("; JAAS Client Identity") .append("=") .append(jaasClientIdentity) .append("; "); builder.append(KEY_REGISTRY_CLIENT_JAAS_CONTEXT) .append("=") .append(jaasClientContext) .append("; "); builder.append(describeProperty(PROP_ZK_SASL_CLIENT_USERNAME)); builder.append(describeProperty(PROP_ZK_SASL_CLIENT_CONTEXT)); } builder.append(describeProperty(PROP_ZK_ALLOW_FAILED_SASL_CLIENTS, "(undefined but defaults to true)")); builder.append(describeProperty( PROP_ZK_SERVER_MAINTAIN_CONNECTION_DESPITE_SASL_FAILURE)); return builder.toString(); }
Example #7
Source File: TestSecureLogins.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testJaasFileSetup() throws Throwable { // the JVM has seemed inconsistent on setting up here assertNotNull("jaasFile", jaasFile); String confFilename = System.getProperty(Environment.JAAS_CONF_KEY); assertEquals(jaasFile.getAbsolutePath(), confFilename); }
Example #8
Source File: TestSecureLogins.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testJaasFileBinding() throws Throwable { // the JVM has seemed inconsistent on setting up here assertNotNull("jaasFile", jaasFile); RegistrySecurity.bindJVMtoJAASFile(jaasFile); String confFilename = System.getProperty(Environment.JAAS_CONF_KEY); assertEquals(jaasFile.getAbsolutePath(), confFilename); }
Example #9
Source File: TestSecureLogins.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testJaasFileBinding() throws Throwable { // the JVM has seemed inconsistent on setting up here assertNotNull("jaasFile", jaasFile); RegistrySecurity.bindJVMtoJAASFile(jaasFile); String confFilename = System.getProperty(Environment.JAAS_CONF_KEY); assertEquals(jaasFile.getAbsolutePath(), confFilename); }
Example #10
Source File: RegistrySecurity.java From big-c with Apache License 2.0 | 5 votes |
/** * Bind the JVM JAS setting to the specified JAAS file. * * <b>Important:</b> once a file has been loaded the JVM doesn't pick up * changes * @param jaasFile the JAAS file */ public static void bindJVMtoJAASFile(File jaasFile) { String path = jaasFile.getAbsolutePath(); if (LOG.isDebugEnabled()) { LOG.debug("Binding {} to {}", Environment.JAAS_CONF_KEY, path); } System.setProperty(Environment.JAAS_CONF_KEY, path); }
Example #11
Source File: TestSecureLogins.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testJaasFileSetup() throws Throwable { // the JVM has seemed inconsistent on setting up here assertNotNull("jaasFile", jaasFile); String confFilename = System.getProperty(Environment.JAAS_CONF_KEY); assertEquals(jaasFile.getAbsolutePath(), confFilename); }
Example #12
Source File: RegistrySecurity.java From big-c with Apache License 2.0 | 5 votes |
/** * Build up low-level security diagnostics to aid debugging * @return a string to use in diagnostics */ public String buildSecurityDiagnostics() { StringBuilder builder = new StringBuilder(); builder.append(secureRegistry ? "secure registry; " : "insecure registry; "); builder.append("Curator service access policy: ").append(access); builder.append("; System ACLs: ").append(aclsToString(systemACLs)); builder.append("User: ").append(UgiInfo.fromCurrentUser()); builder.append("; Kerberos Realm: ").append(kerberosRealm); builder.append(describeProperty(Environment.JAAS_CONF_KEY)); String sasl = System.getProperty(PROP_ZK_ENABLE_SASL_CLIENT, DEFAULT_ZK_ENABLE_SASL_CLIENT); boolean saslEnabled = Boolean.valueOf(sasl); builder.append(describeProperty(PROP_ZK_ENABLE_SASL_CLIENT, DEFAULT_ZK_ENABLE_SASL_CLIENT)); if (saslEnabled) { builder.append("; JAAS Client Identity") .append("=") .append(jaasClientIdentity) .append("; "); builder.append(KEY_REGISTRY_CLIENT_JAAS_CONTEXT) .append("=") .append(jaasClientContext) .append("; "); builder.append(describeProperty(PROP_ZK_SASL_CLIENT_USERNAME)); builder.append(describeProperty(PROP_ZK_SASL_CLIENT_CONTEXT)); } builder.append(describeProperty(PROP_ZK_ALLOW_FAILED_SASL_CLIENTS, "(undefined but defaults to true)")); builder.append(describeProperty( PROP_ZK_SERVER_MAINTAIN_CONNECTION_DESPITE_SASL_FAILURE)); return builder.toString(); }
Example #13
Source File: BaseSecurityTest.java From incubator-atlas with Apache License 2.0 | 4 votes |
protected void bindJVMtoJAASFile(File jaasFile) { String path = jaasFile.getAbsolutePath(); System.setProperty(Environment.JAAS_CONF_KEY, path); disableZookeeperSecurity(); }
Example #14
Source File: BaseSecurityTest.java From atlas with Apache License 2.0 | 4 votes |
protected void bindJVMtoJAASFile(File jaasFile) { String path = jaasFile.getAbsolutePath(); System.setProperty(Environment.JAAS_CONF_KEY, path); disableZookeeperSecurity(); }
Example #15
Source File: RegistrySecurity.java From big-c with Apache License 2.0 | 4 votes |
/** * Reset any system properties related to JAAS */ public static void clearJaasSystemProperties() { System.clearProperty(Environment.JAAS_CONF_KEY); }
Example #16
Source File: EnvironmentLogService.java From iotplatform with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { Environment.logEnv("IoTP server environment: ", log); }
Example #17
Source File: EnvironmentLogService.java From iotplatform with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { Environment.logEnv("environment: ", log); }
Example #18
Source File: RegistrySecurity.java From hadoop with Apache License 2.0 | 4 votes |
/** * Reset any system properties related to JAAS */ public static void clearJaasSystemProperties() { System.clearProperty(Environment.JAAS_CONF_KEY); }