Example usage for org.apache.http.auth BasicUserPrincipal BasicUserPrincipal

List of usage examples for org.apache.http.auth BasicUserPrincipal BasicUserPrincipal

Introduction

In this page you can find the example usage for org.apache.http.auth BasicUserPrincipal BasicUserPrincipal.

Prototype

public BasicUserPrincipal(final String username) 

Source Link

Usage

From source file:ch.cyberduck.core.ssl.CertificateStoreX509KeyManagerTest.java

@Test
public void testChooseClientAliasNotfound() throws Exception {
    final X509KeyManager m = new CertificateStoreX509KeyManager(new DisabledCertificateStore()).init();
    assertNull(m.chooseClientAlias(new String[] { "RSA", "DSA" },
            new Principal[] { new BasicUserPrincipal("user") }, new Socket("test.cyberduck.ch", 443)));
}

From source file:com.nesscomputing.tinyhttp.HttpFetcherCredentialsProvider.java

@Override
public Credentials getCredentials(final AuthScope authScope) {
    return new Credentials() {

        @Override//from  w ww . ja v a 2s .c  o m
        public Principal getUserPrincipal() {
            return new BasicUserPrincipal(login);
        }

        @Override
        public String getPassword() {
            return pw;
        }
    };
}

From source file:com.nesscomputing.httpclient.factory.httpclient4.InternalCredentialsProvider.java

@Override
public Credentials getCredentials(final AuthScope authScope) {
    for (final HttpClientAuthProvider authProvider : authProviders) {
        if (authProvider.acceptRequest(authScope.getScheme(), authScope.getHost(), authScope.getPort(),
                authScope.getRealm())) {
            return new Credentials() {

                @Override/*  w w  w .j a v  a  2s .  co m*/
                public Principal getUserPrincipal() {
                    return new BasicUserPrincipal(authProvider.getUser());
                }

                @Override
                public String getPassword() {
                    return authProvider.getPassword();
                }

            };
        }
    }
    return null;
}

From source file:securitytools.nessus.NessusCredentials.java

/**
 * Constructs a new Credentials object with the specified username and
 * password.//from  w  ww. j  ava2s  .  c  o m
 *
 * @param username The username credential.
 * @param password The password credential.
 */
public NessusCredentials(String username, String password) {
    if (username == null) {
        throw new IllegalArgumentException("Username cannot be null.");
    }
    if (password == null) {
        throw new IllegalArgumentException("Password cannot be null.");
    }

    this.principal = new BasicUserPrincipal(username);
    this.password = password;
}

From source file:securitytools.veracode.VeracodeCredentials.java

/**
 * Constructs a new Credentials object with the specified username and
 * password.//  ww w. j a v a 2  s. com
 *
 * @param username The username credential.
 * @param password The password credential.
 */
public VeracodeCredentials(String username, String password) {
    if (username == null) {
        throw new IllegalArgumentException("Username cannot be null.");
    }
    if (password == null) {
        throw new IllegalArgumentException("Password cannot be null.");
    }

    this.principal = new BasicUserPrincipal(username);
    this.password = password;
}

From source file:org.fcrepo.integration.kernel.modeshape.FedoraSessionImplIT.java

@Test
public void testGetIdExceptionWithUserIdNonURI() throws RepositoryException {
    when(request.getRemoteUser()).thenReturn(FEDORA_USER);
    when(request.getUserPrincipal()).thenReturn(new BasicUserPrincipal(FEDORA_USER));
    when(request.isUserInRole(eq("admin"))).thenReturn(true);

    final ServletCredentials credentials = new ServletCredentials(request);
    final FedoraSession session = repo.login(credentials);

    // should be the default local user agent URI
    assertEquals("User agent URI invalid.",
            URI.create(FedoraSessionUserUtil.DEFAULT_USER_AGENT_BASE_URI + FEDORA_USER), session.getUserURI());
}

From source file:net.tralfamadore.security.CurrentUserInfoTest.java

@Test
public void testPrincipalCurrentUserInfo() {
    final String userName = "testUser";
    final Principal principal = new BasicUserPrincipal(userName);
    new NonStrictExpectations() {
        {/*w w w .  j a v a2s.c  o m*/
            FacesContext.getCurrentInstance();
            result = facesContext;
            facesContext.getExternalContext();
            result = externalContext;
            externalContext.getUserPrincipal();
            result = principal;
        }
    };

    CurrentUserInfo currentUserInfo = new PrincipalCurrentUserInfo();
    assertEquals(userName, currentUserInfo.getCurrentUser());

    new Verifications() {
        {
            externalContext.getUserPrincipal();
            times = 1;
        }
    };
}

From source file:nl.esciencecenter.octopus.webservice.mac.MacCredentialTest.java

@Test
public void testGetUserPrincipal() {
    assertThat(cred.getUserPrincipal()).isEqualTo(new BasicUserPrincipal("id"));
}

From source file:nl.esciencecenter.octopus.webservice.mac.MacCredential.java

public Principal getUserPrincipal() {
    return new BasicUserPrincipal(id);
}

From source file:org.fcrepo.auth.integration.ContainerRolesPrincipalProviderIT.java

@Test
public void testEmptyPrincipalProvider() throws RepositoryException {
    when(request.getRemoteUser()).thenReturn("fred");
    when(request.getUserPrincipal()).thenReturn(new BasicUserPrincipal("fred"));
    when(request.isUserInRole(Mockito.eq(ServletContainerAuthenticationProvider.FEDORA_USER_ROLE)))
            .thenReturn(true);/*from   w  ww  .j a v  a2s.co m*/
    Mockito.reset(fad);
    when(fad.hasPermission(any(Session.class), any(Path.class), any(String[].class))).thenReturn(true);

    final ServletCredentials credentials = new ServletCredentials(request);
    final FedoraSession session = repo.login(credentials);
    final Session jcrSession = getJcrSession(session);
    final Privilege[] rootPrivs = jcrSession.getAccessControlManager().getPrivileges("/");
    for (final Privilege p : rootPrivs) {
        logger.debug("got priv: " + p.getName());
    }
    final ContainerService os = new ContainerServiceImpl();
    os.findOrCreate(session, "/myobject");
    verify(fad, atLeastOnce()).hasPermission(any(Session.class), any(Path.class), any(String[].class));
}