Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.User


    public void testAuthenticateKnownUserYieldsValidResult() {
        X509Certificate[] certChain = createValidCertificateChain("bob");

        when(m_servletRequest.getAttribute(ATTRIBUTE_X509_CERTIFICATE)).thenReturn(certChain);

        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");

        when(m_userAdmin.getUser(eq("username"), eq("bob"))).thenReturn(user);

        User result = createAuthorizationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result != null : "Expected a valid user to be returned!";

        assert "bob".equals(user.getName()) : "Expected bob to be returned as user!";
    }
View Full Code Here


        X509Certificate[] certChain = createValidCertificateChainWithDN("cn=Alice,dc=acme,dc=corp", "cn=Fido,ou=dev,dc=acme,dc=corp", "cn=Bob,ou=dev,dc=acme,dc=corp");

        when(m_servletRequest.getAttribute(ATTRIBUTE_X509_CERTIFICATE)).thenReturn(certChain);

        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");

        when(m_userAdmin.getUser(eq(lookupKey), eq("CN=Bob,OU=dev,DC=acme,DC=corp"))).thenReturn(user);

        User result = processor.authenticate(m_userAdmin, m_servletRequest);
        assert result != null : "Expected a valid user to be returned!";

        assert "bob".equals(user.getName()) : "Expected bob to be returned as user!";
    }
View Full Code Here

    @Test(groups = { UNIT })
    public void testAuthenticateMissingCipherSuiteHeaderYieldsNull() {
        when(m_servletRequest.getAttribute(ATTRIBUTE_CIPHER_SUITE)).thenReturn(null);
        when(m_servletRequest.getAttribute(ATTRIBUTE_X509_CERTIFICATE)).thenReturn(createValidCertificateChain("bob"));

        User result = createAuthorizationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Did not expect a valid user to be returned!";
    }
View Full Code Here

     */
    @Test(groups = { UNIT })
    public void testAuthenticateUnknownUserYieldsNull() {
        when(m_servletRequest.getAttribute(ATTRIBUTE_X509_CERTIFICATE)).thenReturn(createValidCertificateChain("bob"));

        User result = createAuthorizationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Did not expect a valid user to be returned!";
    }
View Full Code Here

        X509Certificate[] certificateChain = createValidCertificateChain("alice");

        // Test whether we can use the new properties...
        when(m_servletRequest.getAttribute(ATTRIBUTE_X509_CERTIFICATE)).thenReturn(certificateChain);

        User user = mock(User.class);
        when(user.getName()).thenReturn("alice");

        when(m_userAdmin.getUser(eq(lookupKey), eq("alice"))).thenReturn(user);

        User result = processor.authenticate(m_userAdmin, m_servletRequest);
        assert result != null : "Expected a valid user to be returned!";

        assert "alice".equals(user.getName()) : "Expected alice to be returned as user!";
    }
View Full Code Here

   * @throws IOException
   * @throws InterruptedException
   * @throws InvalidSyntaxException
   */
  private void setUpTestCase() throws Exception {
    User user = new MockUser();
    String customer = "customer-" + Long.toHexString(System.currentTimeMillis());

        startRepositoryService();

        addRepository("storeInstance", customer, "store", true);
View Full Code Here

     * @param request the request to obtain the credentials from, cannot be <code>null</code>.
     * @return <code>true</code> if the authentication was successful, <code>false</code> otherwise.
     */
    private boolean authenticate(HttpServletRequest request) {
        if (m_useAuth) {
            User user = m_authService.authenticate(request);
            if (user == null) {
                m_log.log(LogService.LOG_INFO, "Authentication failure!");
            }
            return (user != null);
        }
View Full Code Here

        }
        Role newRole = m_useradmin.createRole(username, Role.USER);
        if (newRole == null) {
            throw new UserAlreadyExistsException(username);
        }
        User newUser = (User) newRole;
        newUser.getProperties().put("username", username);
        newUser.getCredentials().put("password", password);
        group.addMember(newUser);
    }
View Full Code Here

            throw new UserAlreadyExistsException(newUsername);
        }
        if (getUser(newUsername) != null) {
            throw new UserAlreadyExistsException(newUsername);
        }
        User user = getUser(oldUsername);
        if (user == null) {
            throw new UserNotFoundException(oldUsername);
        }
        String group = getGroup(user).getName();
        if (group == null) {
View Full Code Here

        String username = userDTO.getUsername();
        String password = userDTO.getPassword();
        if (username == null || password == null || "".equals(password)) {
            throw new IllegalArgumentException("Username or Password cannot be null or \"\" ");
        }
        User user = getUser(username);
        if (user == null) {
            throw new UserNotFoundException(username);

        }
        user.getCredentials().put("password", password);
    }
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.