use of org.apache.felix.utils.properties.Properties in project ddf by codice.
the class SystemPropertiesAdmin method writeOutUsersDotPropertiesFile.
/*
* Writes user property data to the relevant file after replacing the default hostname where
* necessary.
*/
private void writeOutUsersDotPropertiesFile(File userPropertiesFile) {
try {
Properties usersDotProperties = new Properties(userPropertiesFile);
if (!usersDotProperties.isEmpty()) {
String oldHostValue = usersDotProperties.getProperty(oldHostName);
if (oldHostValue != null) {
usersDotProperties.remove(oldHostName);
usersDotProperties.setProperty(System.getProperty(SystemBaseUrl.HOST), oldHostValue);
usersDotProperties.save();
}
}
} catch (IOException e) {
LOGGER.warn("Exception while writing to users.properties file.", e);
}
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class GSSAPILdapLoginModuleTest method testPasswordFailure.
@Test(expected = LoginException.class)
public void testPasswordFailure() throws Exception {
Properties options = ldapLoginModuleOptions();
GSSAPILdapLoginModule module = new GSSAPILdapLoginModule();
Subject subject = new Subject();
module.initialize(subject, new NamePasswordCallbackHandler("hnelson", "secret0"), null, options);
assertEquals("Precondition", 0, subject.getPrincipals().size());
assertTrue(module.login());
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class GSSAPILdapLoginModuleTest method testUserNotFound.
@Test(expected = LoginException.class)
public void testUserNotFound() throws Exception {
Properties options = ldapLoginModuleOptions();
GSSAPILdapLoginModule module = new GSSAPILdapLoginModule();
Subject subject = new Subject();
module.initialize(subject, new NamePasswordCallbackHandler("test", "test"), null, options);
assertEquals("Precondition", 0, subject.getPrincipals().size());
assertFalse(module.login());
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class LDAPPubkeyLoginModuleTest method testNonAdminLogin.
@Test
public void testNonAdminLogin() throws Exception {
Properties options = ldapLoginModuleOptions();
LDAPPubkeyLoginModule module = new LDAPPubkeyLoginModule();
Subject subject = new Subject();
Path pubkeyFile = srcTestResourcePath("org/apache/karaf/jaas/modules/ldap/ldaptest.cheese.id_rsa");
module.initialize(subject, new NamePubkeyCallbackHandler("cheese", pubkeyFile), null, options);
assertEquals("Precondition", 0, subject.getPrincipals().size());
assertTrue(module.login());
assertTrue(module.commit());
assertEquals(1, subject.getPrincipals().size());
assertThat(names(subject.getPrincipals(UserPrincipal.class)), containsInAnyOrder("cheese"));
assertThat(names(subject.getPrincipals(RolePrincipal.class)), Matchers.empty());
assertTrue(module.logout());
assertEquals("Principals should be gone as the user has logged out", 0, subject.getPrincipals().size());
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class LdapCacheTest method testAdminLogin.
@Test
public void testAdminLogin() throws Exception {
Properties options = ldapLoginModuleOptions();
LDAPLoginModule module = new LDAPLoginModule();
CallbackHandler cb = new NamePasswordCallbackHandler("admin", "admin123");
Subject subject = new Subject();
module.initialize(subject, cb, null, options);
assertEquals("Precondition", 0, subject.getPrincipals().size());
assertTrue(module.login());
assertTrue(module.commit());
assertEquals(2, subject.getPrincipals().size());
assertThat(names(subject.getPrincipals(UserPrincipal.class)), containsInAnyOrder("admin"));
assertThat(names(subject.getPrincipals(RolePrincipal.class)), containsInAnyOrder("admin"));
assertTrue(module.logout());
assertEquals("Principals should be gone as the user has logged out", 0, subject.getPrincipals().size());
LDAPCache ldapCache = new LDAPCache(new LDAPOptions(options));
DirContext context = ldapCache.open();
addUserToGroup(context, "cn=admin,ou=people,dc=example,dc=com", "another");
ldapCache.close();
Thread.sleep(100);
module = new LDAPLoginModule();
subject = new Subject();
module.initialize(subject, cb, null, options);
assertEquals("Precondition", 0, subject.getPrincipals().size());
assertTrue(module.login());
assertTrue(module.commit());
assertEquals("Postcondition", 3, subject.getPrincipals().size());
}
Aggregations