if (user == null) {
LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
"Person not found in connector user database: " + gsaName +
" using " + ncs.getUsernameType() + " username type");
for (String docId : docIds) {
authorized.add(new AuthorizationResponse(false, docId));
}
} else {
LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
"Authorizing documents for user " + gsaName +
" using " + ncs.getUsernameType() + " username type");
ArrayList<String> userGroups = new ArrayList<String>(user.getGroups());
LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
"Groups for " + gsaName + " are: " + userGroups);
NotesSession ns = null;
try {
ns = ncs.createNotesSession();
NotesDatabase cdb =
ns.getDatabase(ncs.getServer(), ncs.getDatabase());
NotesView securityView = cdb.getView(NCCONST.VIEWSECURITY);
for (String docId : docIds) {
NotesViewNavigator secVN = null;
NotesDocument dbdoc = null;
try {
// Extract the database and UNID from the URL
String repId = getRepIdFromDocId(docId);
String unid = getUNIDFromDocId(docId);
LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
"Authorizing document: " + repId + " : " + unid);
// Get the category from the security view for this
// database. The first document in the category is
// ALWAYS the database document.
secVN = securityView.createViewNavFromCategory(repId);
dbdoc = secVN.getFirstDocument().getDocument();
boolean dballow =
checkDatabaseAccess(dbdoc, user);
// Only check document level security if we are
// allowed at the database level. Assume we have
// access to the document unless proven
// otherwise...
boolean docallow = true;
if (dballow) {
Collection<String> readers =
ncs.getNotesDocumentManager()
.getDocumentReaders(unid, repId);
if (readers.size() > 0) {
docallow = checkDocumentReaders(user, readers, repId);
} else {
LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD,
"No document level security for " + unid);
}
}
boolean allow = docallow && dballow;
LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
"Final auth decision is " + allow + " " + unid);
authorized.add(new AuthorizationResponse(allow, docId));
} catch (Throwable t) {
LOGGER.logp(Level.WARNING, CLASS_NAME, METHOD,
"Failed to complete check for: " + docId, t);
authorized.add(new AuthorizationResponse(
AuthorizationResponse.Status.INDETERMINATE, docId));
} finally {
Util.recycle(dbdoc);
Util.recycle(secVN);
// Log timing for each document.
if (LOGGER.isLoggable(Level.FINER)) {
elapsedTimeMillis = System.currentTimeMillis() - startTime;
LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
"ElapsedAuthorizationResponseTime: " + elapsedTimeMillis
+ " Documents authorized: " + authorized.size());
}
}
}
} finally {
ncs.closeNotesSession(ns);
}
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, CLASS_NAME, e);
}
if (LOGGER.isLoggable(Level.FINER)) {
for (int i = 0; i < authorized.size(); i++) {
AuthorizationResponse ar = authorized.get(i);
LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
"AuthorizationResponse: " + ar.getDocid() + " : " + ar.isValid());
}
}
// Get elapsed time in milliseconds
elapsedTimeMillis = System.currentTimeMillis() - startTime;
LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,