Search in sources :

Example 1 with UmaAuditEntry

use of org.forgerock.openam.sm.datalayer.impl.uma.UmaAuditEntry in project OpenAM by OpenRock.

the class AuditHistory method queryCollection.

@Override
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) {
    AMIdentity identity = getIdentity(context);
    Set<UmaAuditEntry> history;
    try {
        if (request.getQueryFilter().toString().equals("true")) {
            history = auditLogger.getEntireHistory(identity);
        } else {
            history = auditLogger.getHistory(identity, request);
        }
    } catch (ServerException e) {
        return new InternalServerErrorException(e).asPromise();
    }
    List<ResourceResponse> results = new ArrayList<>();
    for (UmaAuditEntry entry : history) {
        JsonValue result = entry.asJson();
        results.add(newResourceResponse(entry.getId(), String.valueOf(result.hashCode()), result));
    }
    QueryResponsePresentation.enableDeprecatedRemainingQueryResponse(request);
    return QueryResponsePresentation.perform(handler, request, results);
}
Also used : ServerException(org.forgerock.openam.sm.datalayer.store.ServerException) Responses.newResourceResponse(org.forgerock.json.resource.Responses.newResourceResponse) ResourceResponse(org.forgerock.json.resource.ResourceResponse) AMIdentity(com.sun.identity.idm.AMIdentity) ArrayList(java.util.ArrayList) JsonValue(org.forgerock.json.JsonValue) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) UmaAuditEntry(org.forgerock.openam.sm.datalayer.impl.uma.UmaAuditEntry)

Example 2 with UmaAuditEntry

use of org.forgerock.openam.sm.datalayer.impl.uma.UmaAuditEntry in project OpenAM by OpenRock.

the class UmaAuditLogger method log.

public void log(String resourceSetId, String resourceSetName, AMIdentity resourceOwner, UmaAuditType message, String requestingPartyId) {
    final UmaAuditEntry umaAuditEntry;
    try {
        umaAuditEntry = new UmaAuditEntry(resourceSetId, resourceSetName, resourceOwner.getUniversalId(), message.toString(), requestingPartyId);
        delegate.create(umaAuditEntry);
    } catch (ServerException e) {
        logger.warning("Error writing to UMA audit log", e);
    }
}
Also used : ServerException(org.forgerock.openam.sm.datalayer.store.ServerException) UmaAuditEntry(org.forgerock.openam.sm.datalayer.impl.uma.UmaAuditEntry)

Aggregations

UmaAuditEntry (org.forgerock.openam.sm.datalayer.impl.uma.UmaAuditEntry)2 ServerException (org.forgerock.openam.sm.datalayer.store.ServerException)2 AMIdentity (com.sun.identity.idm.AMIdentity)1 ArrayList (java.util.ArrayList)1 JsonValue (org.forgerock.json.JsonValue)1 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)1 ResourceResponse (org.forgerock.json.resource.ResourceResponse)1 Responses.newResourceResponse (org.forgerock.json.resource.Responses.newResourceResponse)1