Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.User


*/
public class PopupMessageAction implements MessageAction {
    public static final String NAME = "PopupMessageAction";

    public void handle(Event event) {
        final User user = (User) event.getProperty(USER);
        final String description = (String) event.getProperty(DESCRIPTION);
        final String shortDescription = (String) event.getProperty(SHORT_DESCRIPTION);

        Thread t = new Thread("Notification") {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(null,
                    "<html><table><tr><td>To: </td><td>" + user.getName() + " " + (String) user.getProperties().get("email") + "</td></tr>" +
                    "<tr><td>Subject: </td><td>" + shortDescription + "</td></tr>" +
                    "<tr><td valign='top'>Message: </td><td>" + description.replaceAll("\n", "<p>")
                );
            }
        };
View Full Code Here


    /**
     * Tests that changing the credentials of a user-role yields an event.
     */
    public void testAddUserCredentialsYieldsEvent() throws Exception {
        final User role = (User) m_repository.addRole("testUser", Role.USER);
        assertNotNull(role);
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getCredentials().put("key", "value");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    /**
     * Tests that changing the credentials of a user-role yields an event.
     */
    public void testChangeUserCredentialsYieldsEvent() throws Exception {
        final User role = (User) m_repository.addRole("testUser", Role.USER);
        role.getCredentials().put("key", "value1");
        assertNotNull(role);
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getCredentials().put("key", "value2");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    /**
     * Tests that changing the credentials of a user-role yields an event.
     */
    public void testRemoveUserCredentialsYieldsEvent() throws Exception {
        final User role = (User) m_repository.addRole("testUser", Role.USER);
        role.getCredentials().put("key", "value");
        assertNotNull(role);
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getCredentials().remove("key");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

     * Tests whether adding a new credential to a user causes an event to be emitted to the {@link RoleRepository}.
     */
    public void testAddUserCredentialYieldsEventOk() throws Exception {
        m_latch = new CountDownLatch(1);
       
        final User role = (User) m_roleRepository.addRole("john.doe", Role.USER);
       
        new Thread(new Runnable() {
            public void run() {
                role.getCredentials().put("key", "value");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    /**
     * Tests whether changing an existing credential for a user causes an event to be emitted to the {@link RoleRepository}.
     */
    public void testChangeUserCredentialYieldsEventOk() throws Exception {
        final User role = (User) m_roleRepository.addRole("john.doe", Role.USER);
        role.getCredentials().put("key", "value");
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getCredentials().put("key", "other-value");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    /**
     * Tests whether removing a credential from a user causes an event to be emitted to the {@link RoleRepository}.
     */
    public void testRemoveUserCredentialYieldsEventOk() throws Exception {
        final User role = (User) m_roleRepository.addRole("john.doe", Role.USER);
        role.getCredentials().put("key", "value");
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getCredentials().remove("key");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

        Group children = createGroup("Children");
        Group adults = createGroup("Adults");
        Group residents = createGroup("Residents");
       
        // Users
        User elmer = RoleFactory.createUser("Elmer");
        User fudd = RoleFactory.createUser("Fudd");
        User marvin = RoleFactory.createUser("Marvin");
        User pepe = RoleFactory.createUser("Pepe");
        User daffy =RoleFactory.createUser("Daffy");
        User foghorn = RoleFactory.createUser("Foghorn");
       
        // Not explicitly mentioned; but needed to comply with the semantics
        alarmSystemControl.addRequiredMember(m_anyone);
        internetAccess.addRequiredMember(m_anyone);
        temperatureControl.addRequiredMember(m_anyone);
View Full Code Here

        voters.addRequiredMember(citizens);
        voters.addRequiredMember(adults);
        voters.addMember(m_anyone);
       
        // Elmer belongs to the citizens and adults...
        User elmer = createUser("elmer");
        citizens.addMember(elmer);
        adults.addMember(elmer);
       
        // Pepe belongs to the citizens, but is not an adult...
        User pepe = createUser("pepe");
        citizens.addMember(pepe);
       
        // Bugs is an adult, but is not a citizen...
        User bugs = createUser("bugs");
        adults.addMember(bugs);
       
        // Daffy is not an adult, neither a citizen...
        User daffy = createUser("daffy");
       
        AuthorizationImpl auth;

        auth = new AuthorizationImpl(elmer, m_roleRepository);
        assertTrue(auth.hasRole("adult"));
View Full Code Here

        voters.addRequiredMember(citizens);
        voters.addRequiredMember(adults);
        voters.addMember(m_anyone);
       
        // Elmer belongs to the citizens and adults...
        User elmer = createUser("elmer");
        citizens.addMember(elmer);
        adults.addMember(elmer);
       
        // Pepe belongs to the citizens, but is not an adult...
        User pepe = createUser("pepe");
        citizens.addMember(pepe);
       
        // Bugs is an adult, but is not a citizen...
        User bugs = createUser("bugs");
        adults.addMember(bugs);

        // Daffy is not an adult, neither a citizen...
        User daffy = createUser("daffy");

        // Donald is not an adult, neither a citizen...
        User donald = RoleFactory.createUser("donald");
       
        AuthorizationImpl auth;

        auth = new AuthorizationImpl(elmer, m_roleRepository);
        assertSameRoles(new String[]{ "elmer", "adult", "citizen", "voter" }, auth.getRoles());
View Full Code Here

TOP

Related Classes of org.osgi.service.useradmin.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.