Search in sources :

Example 31 with Properties

use of org.apache.felix.utils.properties.Properties in project karaf by apache.

the class LdapLoginModuleTest method testBadPassword.

@Test
public void testBadPassword() throws Exception {
    Properties options = ldapLoginModuleOptions();
    LDAPLoginModule module = new LDAPLoginModule();
    Subject subject = new Subject();
    module.initialize(subject, new NamePasswordCallbackHandler("admin", "blahblah"), null, options);
    assertEquals("Precondition", 0, subject.getPrincipals().size());
    try {
        module.login();
        fail("Should have thrown LoginException");
    } catch (LoginException e) {
        assertTrue(e.getMessage().startsWith("Authentication failed"));
    }
}
Also used : NamePasswordCallbackHandler(org.apache.karaf.jaas.modules.NamePasswordCallbackHandler) LoginException(javax.security.auth.login.LoginException) Properties(org.apache.felix.utils.properties.Properties) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Example 32 with Properties

use of org.apache.felix.utils.properties.Properties in project karaf by apache.

the class BaseJDBCLockIntegrationTest method setUpTestSuite.

@BeforeClass
public static void setUpTestSuite() {
    Properties properties = new Properties();
    properties.put("karaf.bootstrap.log", "target/karaf.log");
    BootstrapLogManager.setProperties(properties);
}
Also used : Properties(org.apache.felix.utils.properties.Properties) BeforeClass(org.junit.BeforeClass)

Example 33 with Properties

use of org.apache.felix.utils.properties.Properties in project karaf by apache.

the class Main method readBundlesFromStartupProperties.

public List<BundleInfo> readBundlesFromStartupProperties(File startupPropsFile) {
    Properties startupProps = PropertiesLoader.loadPropertiesOrFail(startupPropsFile);
    List<BundleInfo> bundeList = new ArrayList<>();
    for (String key : startupProps.keySet()) {
        try {
            BundleInfo bi = new BundleInfo();
            bi.uri = new URI(key);
            String startlevelSt = startupProps.getProperty(key).trim();
            bi.startLevel = new Integer(startlevelSt);
            bundeList.add(bi);
        } catch (Exception e) {
            throw new RuntimeException("Error loading startup bundle list from " + startupPropsFile + " at " + key, e);
        }
    }
    return bundeList;
}
Also used : ArrayList(java.util.ArrayList) Properties(org.apache.felix.utils.properties.Properties) URI(java.net.URI) BundleException(org.osgi.framework.BundleException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 34 with Properties

use of org.apache.felix.utils.properties.Properties in project karaf by apache.

the class BootstrapLogManagerTest method testGetLogManagerFromPaxLoggingConfig.

@Test
public void testGetLogManagerFromPaxLoggingConfig() {
    new File("target/test.log").delete();
    Properties configProps = getConfigProperties();
    BootstrapLogManager.setProperties(configProps, "src/test/resources/org.ops4j.pax.logging.cfg");
    Handler handler = BootstrapLogManager.getDefaultHandler();
    Assert.assertNotNull(handler);
    assertExists("target/test.log");
}
Also used : Handler(java.util.logging.Handler) Properties(org.apache.felix.utils.properties.Properties) File(java.io.File) Test(org.junit.Test)

Example 35 with Properties

use of org.apache.felix.utils.properties.Properties in project karaf by apache.

the class BootstrapLogManagerTest method getConfigProperties.

private Properties getConfigProperties() {
    Properties configProps = new Properties();
    configProps.put("karaf.data", "target");
    return configProps;
}
Also used : Properties(org.apache.felix.utils.properties.Properties)

Aggregations

Properties (org.apache.felix.utils.properties.Properties)64 File (java.io.File)26 Test (org.junit.Test)22 IOException (java.io.IOException)21 Subject (javax.security.auth.Subject)21 NamePasswordCallbackHandler (org.apache.karaf.jaas.modules.NamePasswordCallbackHandler)21 RolePrincipal (org.apache.karaf.jaas.boot.principal.RolePrincipal)16 UserPrincipal (org.apache.karaf.jaas.boot.principal.UserPrincipal)16 Principal (java.security.Principal)12 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 GroupPrincipal (org.apache.karaf.jaas.boot.principal.GroupPrincipal)6 Map (java.util.Map)5 AbstractKerberosITest (org.apache.directory.server.kerberos.kdc.AbstractKerberosITest)5 FileInputStream (java.io.FileInputStream)4 MalformedURLException (java.net.MalformedURLException)4 URL (java.net.URL)4 LinkedHashMap (java.util.LinkedHashMap)4 TreeMap (java.util.TreeMap)4 FailedLoginException (javax.security.auth.login.FailedLoginException)4