Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.Authorization


     * @throws IOException
     */
    @Test
    public void testGetImpliedRoles() throws IOException {
        User user1 = Mockito.mock(User.class);
        Authorization auth = Mockito.mock(Authorization.class);
        Mockito.when(user1.getType()).thenReturn(Role.USER);
        Mockito.when(auth.getRoles()).thenReturn(new String[] { "role1" });
        Mockito.when(userAdmin.getRole("role1")).thenReturn(user1);
        Mockito.when(userAdmin.getAuthorization(user1)).thenReturn(auth);
        String[] roles = mbean.getImpliedRoles("role1");
        Assert.assertArrayEquals(new String[] { "role1" }, roles);
    }
View Full Code Here


        Role role = userAdmin.getRole(username);
        if (role == null) {
            return null;
        }
        validateRoleType(role, Role.USER);
        Authorization auth = userAdmin.getAuthorization((User) role);
        if (auth == null) {
            return null;
        }

        return new AuthorizationData(auth).toCompositeData();
View Full Code Here

            throw new IOException("User name cannot be null");
        }
        Role role = userAdmin.getRole(username);
        if (role != null) {
            validateRoleType(role, Role.USER);
            Authorization auth = userAdmin.getAuthorization((User) role);
            if (auth != null) {
                return auth.getRoles();
            }
        }
        return null;
    }
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testGetAuthorization() throws IOException {
        Authorization auth = Mockito.mock(Authorization.class);
        User user = Mockito.mock(User.class);
        Mockito.when(user.getType()).thenReturn(Role.USER);
        Mockito.when(userAdmin.getAuthorization(user)).thenReturn(auth);
        Mockito.when(userAdmin.getRole("role1")).thenReturn(user);
        Mockito.when(auth.getName()).thenReturn("auth1");
        Mockito.when(auth.getRoles()).thenReturn(new String[]{"role1"});
        CompositeData data = mbean.getAuthorization("role1");
        Assert.assertNotNull(data);
        AuthorizationData authData = AuthorizationData.from(data);
        Assert.assertNotNull(authData);
        Assert.assertEquals("auth1", authData.getName());
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testGetImpliedRoles() throws IOException {
        User user1 = Mockito.mock(User.class);
        Authorization auth = Mockito.mock(Authorization.class);
        Mockito.when(user1.getType()).thenReturn(Role.USER);
        Mockito.when(auth.getRoles()).thenReturn(new String[] { "role1" });
        Mockito.when(userAdmin.getRole("role1")).thenReturn(user1);
        Mockito.when(userAdmin.getAuthorization(user1)).thenReturn(auth);
        String[] roles = mbean.getImpliedRoles("role1");
        Assert.assertArrayEquals(new String[] { "role1" }, roles);
    }
View Full Code Here

        Role role = userAdmin.getRole(user);
        if (role == null) {
            return null;
        }
        validateRoleType(role, Role.USER);
        Authorization auth = userAdmin.getAuthorization((User) role);
        if (auth == null) {
            return null;
        }

        return new AuthorizationData(auth).toCompositeData();
View Full Code Here

     */
    public String[] getImpliedRoles(String username) throws IOException {
        Role role = userAdmin.getRole(username);
        if (role != null) {
            validateRoleType(role, Role.USER);
            Authorization auth = userAdmin.getAuthorization((User) role);
            if (auth != null) {
                return auth.getRoles();
            }
        }
        return null;
    }
View Full Code Here

     *
     * @throws IOException
     */
    @Test
    public void testGetAuthorization() throws IOException {
        Authorization auth = Mockito.mock(Authorization.class);
        User user = Mockito.mock(User.class);
        Mockito.when(user.getType()).thenReturn(Role.USER);
        Mockito.when(userAdmin.getAuthorization(user)).thenReturn(auth);
        Mockito.when(userAdmin.getRole("role1")).thenReturn(user);
        Mockito.when(auth.getName()).thenReturn("auth1");
        Mockito.when(auth.getRoles()).thenReturn(new String[]{"role1"});
        CompositeData data = mbean.getAuthorization("role1");
        Assert.assertNotNull(data);
        AuthorizationData authData = AuthorizationData.from(data);
        Assert.assertNotNull(authData);
        Assert.assertEquals("auth1", authData.getName());
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testGetImpliedRoles() throws IOException {
        User user1 = Mockito.mock(User.class);
        Authorization auth = Mockito.mock(Authorization.class);
        Mockito.when(user1.getType()).thenReturn(Role.USER);
        Mockito.when(auth.getRoles()).thenReturn(new String[] { "role1" });
        Mockito.when(userAdmin.getRole("role1")).thenReturn(user1);
        Mockito.when(userAdmin.getAuthorization(user1)).thenReturn(auth);
        String[] roles = mbean.getImpliedRoles("role1");
        Assert.assertArrayEquals(new String[] { "role1" }, roles);
    }
View Full Code Here

TOP

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

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.