Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.User


        createUser(TEST_USER, TEST_PASSWORD);
    }

    @SuppressWarnings("unchecked")
    private User createUser(String username, String password) {
        User user = (User) m_userAdmin.createRole(username, Role.USER);
        if (user != null) {
            Dictionary properties = user.getProperties();
            if (properties != null) {
                properties.put("username", username);
            }
            else {
                m_log.log(LogService.LOG_ERROR, "Could not get properties for " + username);
            }

            Dictionary credentials = user.getCredentials();
            if (credentials != null) {
                credentials.put("password", password);
            }
            else {
                m_log.log(LogService.LOG_ERROR, "Could not get credentials for " + username);
View Full Code Here


        if (password == null) {
            // Invalid/no password given!
            return null;
        }

        User user = userAdmin.getUser(m_keyUsername, username);
        if (user == null || !user.hasCredential(m_keyPassword, hashPassword(password))) {
            // Invalid/unknown user!
            return null;
        }

        return user;
View Full Code Here

        if (credentials.length != 2) {
            // A colon should always be present!
            return null;
        }

        User user = getUser(userAdmin, credentials[0]);
        if (user == null || !user.hasCredential(m_keyPassword, credentials[1])) {
            // Invalid/unknown user!
            return null;
        }

        return user;
View Full Code Here

    public User authenticate(Object... context) {
        if (context == null || context.length == 0) {
            throw new IllegalArgumentException("Invalid context!");
        }

        User result = null;

        m_log.log(LogService.LOG_DEBUG, "Authenticating user for: " + context);

        final List<AuthenticationProcessor> processors = getProcessors(context);
       
        int size = processors.size();
        for (int i = 0; i < size; i++) {
            result = processors.get(i).authenticate(m_userAdmin, context);
            if (result != null) {
                m_log.log(LogService.LOG_DEBUG, "Authenticated user (" + context + ") as: " + result.getName());
                break;
            }
        }

        return result;
View Full Code Here

    private final AuditLogProcessTask m_task = new AuditLogProcessTask();
    private Object m_serviceReg = null;

    public void start() {
        // get user
        User user = m_userAdmin.getUser("username",username);

        // login at Repository admin
        try {
            URL url =  new URL(getConfigValue( ConfigItem.HOSTNAME) + getConfigValue( ConfigItem.ENDPOINT));
            String customerName = getConfigValue( ConfigItem.CUSTOMER_NAME);
View Full Code Here

    /**
     * @return <code>true</code> if the login succeeded, <code>false</code> otherwise.
     */
    private boolean loginAutomatically() {
        User user = m_userAdmin.getUser("username", m_userName);
        setUser(user);
        return login(user);
    }
View Full Code Here

    /**
     * Tests that a null certificate chain will yield null.
     */
    @Test(groups = { UNIT })
    public void testAuthenticateNoCertificateChainYieldsNull() {
        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 testAuthenticateEmptyCertificateChainYieldsNull() {
        when(m_servletRequest.getAttribute(ATTRIBUTE_X509_CERTIFICATE)).thenReturn(new X509Certificate[0]);

        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 = createExpiredCertificateChain("bob");
        PublicKey publickey = certificateChain[0].getPublicKey();

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

        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq("publickey"), eq(publickey.getEncoded()))).thenReturn(Boolean.TRUE);

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

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

        PublicKey publickey = certificateChain[0].getPublicKey();

        when(m_servletRequest.getAttribute(ATTRIBUTE_X509_CERTIFICATE)).thenReturn(
            createNotValidCertificateChain("bob"));

        User user = mock(User.class);
        when(user.getName()).thenReturn("bob");
        when(user.hasCredential(eq("publickey"), eq(publickey.getEncoded()))).thenReturn(Boolean.TRUE);

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

        User result = createAuthorizationProcessor().authenticate(m_userAdmin, m_servletRequest);
        assert result == null : "Did not expect a valid user to be returned!";
    }
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.