Search in sources :

Example 16 with Client

use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.

the class CleanerTimerTest method client_whichIsNotExpiredAndDeletable_MustNotBeRemoved.

@Test
public void client_whichIsNotExpiredAndDeletable_MustNotBeRemoved() throws StringEncrypter.EncryptionException {
    // 1. create client
    final Client client = createClient(true);
    clientService.persist(client);
    // 2. client is in persistence
    assertNotNull(clientService.getClient(client.getClientId()));
    // 3. clean up
    cleanerTimer.processImpl();
    cacheService.clear();
    // 4. client is in persistence (not removed)
    assertNotNull(clientService.getClient(client.getClientId()));
}
Also used : Client(org.gluu.oxauth.model.registration.Client) Test(org.testng.annotations.Test) BaseComponentTest(org.gluu.oxauth.BaseComponentTest)

Example 17 with Client

use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.

the class CacheGrantManual method testClient.

private static Client testClient() {
    Client client = new Client();
    client.setClientId(UUID.randomUUID().toString());
    return client;
}
Also used : MemcachedClient(net.spy.memcached.MemcachedClient) Client(org.gluu.oxauth.model.registration.Client)

Example 18 with Client

use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.

the class Manual method getGroupsFromClient.

@Test
public void getGroupsFromClient() {
    final Client client = MANAGER.find(Client.class, "inum=@!0000!0008!7652.0000,ou=clients,o=gluu");
    System.out.println(client);
}
Also used : Client(org.gluu.oxauth.model.registration.Client) Test(org.testng.annotations.Test)

Example 19 with Client

use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.

the class CleanUpClientTest method cleanUpClient.

@Test
@Parameters(value = "usedClients")
public void cleanUpClient(String usedClients) {
    Assert.assertNotNull(usedClients);
    List<String> usedClientsList = Arrays.asList(StringHelper.split(usedClients, ",", true, false));
    output("Used clients: " + usedClientsList);
    int clientsResultSetSize = 50;
    int countResults = 0;
    int countRemoved = 0;
    boolean existsMoreClients = true;
    while (existsMoreClients && countResults < 10000) {
        List<Client> clients = clientService.getAllClients(new String[] { "inum" }, clientsResultSetSize);
        existsMoreClients = clients.size() == clientsResultSetSize;
        countResults += clients.size();
        Assert.assertNotNull(clients);
        output("Found clients: " + clients.size());
        output("Total clients: " + countResults);
        for (Client client : clients) {
            String clientId = client.getClientId();
            if (!usedClientsList.contains(clientId)) {
                try {
                    clientService.remove(client);
                } catch (EntryPersistenceException ex) {
                    output("Failed to remove client: " + ex.getMessage());
                }
                countRemoved++;
            }
        }
    }
    output("Removed clients: " + countRemoved);
}
Also used : EntryPersistenceException(org.gluu.persist.exception.EntryPersistenceException) Client(org.gluu.oxauth.model.registration.Client) Parameters(org.testng.annotations.Parameters) BaseComponentTest(org.gluu.oxauth.BaseComponentTest) Test(org.testng.annotations.Test)

Example 20 with Client

use of org.gluu.oxauth.model.registration.Client in project oxAuth by GluuFederation.

the class RedirectionUriService method validatePostLogoutRedirectUri.

public String validatePostLogoutRedirectUri(String clientId, String postLogoutRedirectUri) {
    boolean isBlank = Util.isNullOrEmpty(postLogoutRedirectUri);
    Client client = clientService.getClient(clientId);
    if (client != null) {
        String[] postLogoutRedirectUris = client.getPostLogoutRedirectUris();
        log.debug("Validating post logout redirect URI: clientId = {}, postLogoutRedirectUri = {}", clientId, postLogoutRedirectUri);
        return validatePostLogoutRedirectUri(postLogoutRedirectUri, postLogoutRedirectUris);
    }
    if (!isBlank) {
        throw errorResponseFactory.createWebApplicationException(Response.Status.BAD_REQUEST, EndSessionErrorResponseType.POST_LOGOUT_URI_NOT_ASSOCIATED_WITH_CLIENT, "`post_logout_redirect_uri` is not added to associated client.");
    }
    return null;
}
Also used : Client(org.gluu.oxauth.model.registration.Client)

Aggregations

Client (org.gluu.oxauth.model.registration.Client)55 WebApplicationException (javax.ws.rs.WebApplicationException)15 Test (org.testng.annotations.Test)14 BaseComponentTest (org.gluu.oxauth.BaseComponentTest)12 InvalidJwtException (org.gluu.oxauth.model.exception.InvalidJwtException)10 OAuth2AuditLog (org.gluu.oxauth.model.audit.OAuth2AuditLog)8 JSONException (org.json.JSONException)8 Response (javax.ws.rs.core.Response)6 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)6 JSONObject (org.json.JSONObject)6 IOException (java.io.IOException)5 Date (java.util.Date)5 Jwt (org.gluu.oxauth.model.jwt.Jwt)5 SessionClient (org.gluu.oxauth.model.session.SessionClient)5 URI (java.net.URI)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 JwtAuthorizationRequest (org.gluu.oxauth.model.authorize.JwtAuthorizationRequest)4 ArrayList (java.util.ArrayList)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 Claim (org.gluu.oxauth.model.authorize.Claim)3