/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013-2015 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
def whereParams = []
// Define audit specific object classes
// Use the specified _pagedResultsCookie to query based on
// activitydate and auto-incrememnt id
where = " WHERE activitydate >= ? AND id > ? "
}
// Default to order by id
// Translate sortKeys to actual SQL columns
def orderByFieldMap = [
"__UID__" : "objectid",
"__NAME__": "objectid",
"timestamp" : "activitydate"
]
if (orderByFieldMap[field]) {
}
} else {
}
}
}
// Set LIMIT based on the specified _pageSize
// Set OFFSET based on the specified _pagedResultsOffset
}
}
// Keep track of lastActivitydate and lastId so we can
// use it for the next request when performing paging
//Need to handle the __UID__ and __NAME__ in queries
"__UID__" : "objectid",
"__NAME__": "objectid"
]
def whereTemplates = [
CONTAINS : '$left ${not ? "NOT " : ""}LIKE ?',
ENDSWITH : '$left ${not ? "NOT " : ""}LIKE ?',
STARTSWITH : '$left ${not ? "NOT " : ""}LIKE ?',
EQUALS : '${not ? "NOT " : ""} $left <=> ?',
GREATERTHAN : '$left ${not ? "<=" : ">"} ?',
GREATERTHANOREQUAL: '$left ${not ? "<" : ">="} ?',
LESSTHAN : '$left ${not ? ">=" : "<"} ?',
LESSTHANOREQUAL : '$left ${not ? ">" : "<="} ?'
];
// This closure function recurses through the (potentially complex) query
// object in order to build an equivalent SQL 'where' expression
queryParser = { queryObj ->
return "(" + queryParser(queryObj.right) + " " + queryObj.operation + " " + queryParser(queryObj.left) + ")";
} else {
}
} else {
}
}
}
}
switch ( objectClass ) {
case auditaccess:
handler {
attribute 'server',
)?.getObject()
attribute 'client',
)?.getObject()
attribute 'request',
)?.getObject()
attribute 'http',
field("queryParameters", JsonValueUtil.fromJsonString(dataCollector.http_request_queryparameters)?.getObject()),
)?.getObject()),
)?.getObject()),
)?.getObject()
attribute 'response',
)?.getObject()
}
}
}
SELECT * FROM auditaccess ${where} ${orderBy} ${limit}
"""
// process each row of the resultset
dataCollector = [
]
}
});
break
case auditauthentication:
handler {
attribute 'context',
attribute 'entries',
}
}
}
SELECT * FROM auditauthentication ${where} ${orderBy} ${limit}
"""
// process each row of the resultset
dataCollector = [
]
}
});
break
case auditactivity:
handler {
attribute 'changedfields',
}
}
}
SELECT * FROM auditactivity ${where} ${orderBy} ${limit}
"""
// process each row of the resultset
dataCollector = [
]
}
});
break
case auditrecon:
handler {
attribute 'messagedetail',
}
}
}
SELECT * FROM auditrecon ${where} ${orderBy} ${limit}
"""
// process each row of the resultset
dataCollector = [
]
}
});
break
case auditsync:
handler {
attribute 'messagedetail',
}
}
}
SELECT * FROM auditsync ${where} ${orderBy} ${limit}
"""
// process each row of the resultset
dataCollector = [
}
});
break
case auditconfig:
handler {
attribute 'changedfields',
}
}
}
SELECT * FROM auditconfig ${where} ${orderBy} ${limit}
"""
// process each row of the resultset
dataCollector = [
]
}
});
break
default:
}
// If _pageSize has not been specified or if a custom _sortyKey has been
// specified return the default SearchResult object. We do not support
// paging with arbitrary sort keys.
return new SearchResult();
}