Search in sources :

Example 6 with OxAuthSectorIdentifier

use of org.gluu.oxtrust.model.OxAuthSectorIdentifier in project oxTrust by GluuFederation.

the class SectorIdentifierWebResourceTest method searchSectorIdentifierTest.

@Test
public void searchSectorIdentifierTest() {
    String searchPattern = "unknow";
    String SEARCH_QUERY = "?" + ApiConstants.SEARCH_PATTERN + "=" + searchPattern + "&size=5";
    HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.SECTORS + ApiConstants.SEARCH + SEARCH_QUERY);
    HttpResponse response = handle(request);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    try {
        OxAuthSectorIdentifier[] resources = mapper.readValue(EntityUtils.toString(entity), OxAuthSectorIdentifier[].class);
        Assert.assertTrue(resources.length >= 0);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) OxAuthSectorIdentifier(org.gluu.oxtrust.model.OxAuthSectorIdentifier) HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with OxAuthSectorIdentifier

use of org.gluu.oxtrust.model.OxAuthSectorIdentifier in project oxTrust by GluuFederation.

the class SectorIdentifierService method generateIdForNewSectorIdentifier.

/**
 * Generate new oxId for sector identifier
 *
 * @return New oxId for sector identifier
 * @throws Exception
 */
public String generateIdForNewSectorIdentifier() {
    OxAuthSectorIdentifier sectorIdentifier = new OxAuthSectorIdentifier();
    String newId = null;
    String newDn = null;
    do {
        newId = generateIdForNewSectorIdentifierImpl();
        newDn = getDnForSectorIdentifier(newId);
        sectorIdentifier.setDn(newDn);
    } while (persistenceEntryManager.contains(newDn, OxAuthSectorIdentifier.class));
    return newId;
}
Also used : OxAuthSectorIdentifier(org.gluu.oxtrust.model.OxAuthSectorIdentifier)

Example 8 with OxAuthSectorIdentifier

use of org.gluu.oxtrust.model.OxAuthSectorIdentifier in project oxTrust by GluuFederation.

the class SectorIdentifierService method searchSectorIdentifiers.

/**
 * Search sector identifiers by pattern
 *
 * @param pattern
 *            Pattern
 * @param sizeLimit
 *            Maximum count of results
 * @return List of sector identifiers
 */
public List<OxAuthSectorIdentifier> searchSectorIdentifiers(String pattern, int sizeLimit) {
    String[] targetArray = new String[] { pattern };
    Filter searchFilter = Filter.createSubstringFilter(OxTrustConstants.oxId, null, targetArray, null);
    List<OxAuthSectorIdentifier> result = persistenceEntryManager.findEntries(getDnForSectorIdentifier(null), OxAuthSectorIdentifier.class, searchFilter, sizeLimit);
    return result;
}
Also used : OxAuthSectorIdentifier(org.gluu.oxtrust.model.OxAuthSectorIdentifier) Filter(org.gluu.search.filter.Filter)

Example 9 with OxAuthSectorIdentifier

use of org.gluu.oxtrust.model.OxAuthSectorIdentifier in project oxTrust by GluuFederation.

the class SectorIdentifierService method generateInumForNewSectorIdentifier.

/**
     * Generate new inum for sector identifier
     *
     * @return New inum for sector identifier
     * @throws Exception
     */
public String generateInumForNewSectorIdentifier() throws Exception {
    OxAuthSectorIdentifier sectorIdentifier = new OxAuthSectorIdentifier();
    String newInum = null;
    do {
        newInum = generateInumForNewSectorIdentifierImpl();
        String newDn = getDnForSectorIdentifier(newInum);
        sectorIdentifier.setDn(newDn);
    } while (ldapEntryManager.contains(sectorIdentifier));
    return newInum;
}
Also used : OxAuthSectorIdentifier(org.gluu.oxtrust.model.OxAuthSectorIdentifier)

Example 10 with OxAuthSectorIdentifier

use of org.gluu.oxtrust.model.OxAuthSectorIdentifier in project oxTrust by GluuFederation.

the class UpdateSectorIdentifierAction method add.

public String add() throws Exception {
    if (this.sectorIdentifier != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = false;
    this.sectorIdentifier = new OxAuthSectorIdentifier();
    try {
        this.loginUris = getNonEmptyStringList(sectorIdentifier.getRedirectUris());
        if (sectorIdentifier.getClientIds() != null && sectorIdentifier.getClientIds().size() > 0)
            this.loginUris.addAll(clientRedirectUriList(sectorIdentifier.getClientIds()));
        this.clientDisplayNameEntries = loadClientDisplayNameEntries();
    } catch (BaseMappingException ex) {
        log.error("Failed to load login Uris", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new sector identifier");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) OxAuthSectorIdentifier(org.gluu.oxtrust.model.OxAuthSectorIdentifier)

Aggregations

OxAuthSectorIdentifier (org.gluu.oxtrust.model.OxAuthSectorIdentifier)11 IOException (java.io.IOException)4 HttpEntity (org.apache.http.HttpEntity)4 HttpResponse (org.apache.http.HttpResponse)4 ParseException (org.apache.http.ParseException)4 Test (org.junit.Test)4 HttpGet (org.apache.http.client.methods.HttpGet)2 HttpPost (org.apache.http.client.methods.HttpPost)2 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)2 ByteArrayEntity (org.apache.http.entity.ByteArrayEntity)2 Filter (org.gluu.search.filter.Filter)2 HttpPut (org.apache.http.client.methods.HttpPut)1 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)1