use of lotus.domino.Database in project openliberty-domino by OpenNTF.
the class AdminNSFProxyConfigProvider method createConfiguration.
@SuppressWarnings("unchecked")
@Override
public ReverseProxyConfig createConfiguration() {
ReverseProxyConfig result = new ReverseProxyConfig();
RuntimeConfigurationProvider runtimeConfig = OpenLibertyUtil.findRequiredExtension(RuntimeConfigurationProvider.class);
result.dominoHostName = runtimeConfig.getDominoHostName();
result.dominoHttpPort = runtimeConfig.getDominoPort();
result.dominoHttps = runtimeConfig.isDominoHttps();
try {
DominoThreadFactory.getExecutor().submit(() -> {
try {
Session session = NotesFactory.createSession();
try {
Database adminNsf = AdminNSFUtil.getAdminDatabase(session);
Document config = AdminNSFUtil.getConfigurationDocument(adminNsf);
// Load the main config
boolean connectorHeaders = runtimeConfig.isUseDominoConnectorHeaders();
readConfigurationDocument(result, config, connectorHeaders);
if (!result.isGlobalEnabled()) {
return;
}
Collection<String> namesList = AdminNSFUtil.getCurrentServerNamesList();
// Look for proxy-enabled webapps
View targetsView = adminNsf.getView(VIEW_REVERSEPROXYTARGETS);
targetsView.setAutoUpdate(false);
targetsView.refresh();
ViewNavigator nav = targetsView.createViewNav();
nav.setEntryOptions(ViewNavigator.VN_ENTRYOPT_NOCOUNTDATA);
ViewEntry entry = nav.getFirst();
while (entry != null) {
Vector<?> columnValues = entry.getColumnValues();
List<String> dominoServers;
Object dominoServersObj = columnValues.get(4);
if (dominoServersObj instanceof String) {
dominoServers = Arrays.asList((String) dominoServersObj);
} else {
dominoServers = (List<String>) dominoServersObj;
}
boolean shouldRun = AdminNSFUtil.isNamesListMatch(namesList, dominoServers);
if (shouldRun) {
// Format: http://localhost:80
String baseUri = (String) columnValues.get(1);
// $NON-NLS-1$
boolean useXForwardedFor = "Y".equals(columnValues.get(2));
// $NON-NLS-1$
boolean useWsHeaders = "Y".equals(columnValues.get(3));
// Now read the children to build targets
ViewEntry childEntry = nav.getChild(entry);
while (childEntry != null) {
Vector<?> childValues = childEntry.getColumnValues();
// Format: foo
String contextPath = (String) childValues.get(0);
// $NON-NLS-1$
URI uri = URI.create(baseUri + "/" + contextPath);
ReverseProxyTarget target = new ReverseProxyTarget(uri, useXForwardedFor, useWsHeaders);
result.addTarget(contextPath, target);
childEntry.recycle(childValues);
ViewEntry tempChild = childEntry;
childEntry = nav.getNextSibling(childEntry);
tempChild.recycle();
}
}
entry.recycle(columnValues);
ViewEntry tempEntry = entry;
entry = nav.getNextSibling(entry);
tempEntry.recycle();
}
} finally {
session.recycle();
}
return;
} catch (Throwable e) {
e.printStackTrace(OpenLibertyLog.instance.out);
throw new RuntimeException(e);
}
}).get();
if (result.isGlobalEnabled()) {
// Determine the local server port from the server doc
DominoThreadFactory.getExecutor().submit(() -> {
try {
Session session = NotesFactory.createSession();
try {
String serverName = session.getUserName();
// $NON-NLS-1$ //$NON-NLS-2$
Database names = session.getDatabase("", "names.nsf");
// $NON-NLS-1$
View servers = names.getView("$Servers");
Document serverDoc = servers.getDocumentByKey(serverName);
// Mirror Domino's maximum entity size
// $NON-NLS-1$
long maxEntitySize = serverDoc.getItemValueInteger("HTTP_MaxContentLength");
if (maxEntitySize == 0) {
maxEntitySize = Long.MAX_VALUE;
}
result.maxEntitySize = maxEntitySize;
} finally {
session.recycle();
}
} catch (Exception e) {
e.printStackTrace(OpenLibertyLog.instance.out);
throw new RuntimeException(e);
}
}).get();
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace(OpenLibertyLog.instance.out);
throw new RuntimeException(e);
}
return result;
}
use of lotus.domino.Database in project openliberty-domino by OpenNTF.
the class IdentityServlet method checkPassword.
private String checkPassword(String userSecurityName, String password) throws NotesException, IOException {
Session session = NotesFactory.createSession();
try {
// $NON-NLS-1$ //$NON-NLS-2$
Database names = session.getDatabase("", "names.nsf");
Document tempDoc = names.createDocument();
// $NON-NLS-1$
tempDoc.replaceItemValue("Username", userSecurityName);
// $NON-NLS-1$
tempDoc.replaceItemValue("Password", password);
// $NON-NLS-1$
session.evaluate(" @SetField('HashPassword'; @NameLookup([NoCache]:[Exhaustive]; Username; 'HTTPPassword')[1]) ", tempDoc);
// TODO look up against other password variants, or find real way to do this
// $NON-NLS-1$
List<?> result = session.evaluate(" @VerifyPassword(Password; HashPassword) ", tempDoc);
if (!result.isEmpty() && Double.valueOf(1).equals(result.get(0))) {
// $NON-NLS-1$
return (String) session.evaluate(" @NameLookup([NoCache]:[Exhaustive]; Username; 'FullName') ", tempDoc).get(0);
} else {
// $NON-NLS-1$
return "";
}
} catch (Throwable t) {
t.printStackTrace();
throw t;
} finally {
session.recycle();
}
}
use of lotus.domino.Database in project openliberty-domino by OpenNTF.
the class IdentityServlet method isValidGroup.
public String isValidGroup(String groupSecurityName) throws NotesException {
Session session = NotesFactory.createSession();
try {
// $NON-NLS-1$ //$NON-NLS-2$
Database names = session.getDatabase("", "names.nsf");
Document tempDoc = names.createDocument();
// $NON-NLS-1$
tempDoc.replaceItemValue("GroupName", groupSecurityName);
// $NON-NLS-1$
List<?> result = session.evaluate(" @Trim(@NameLookup([NoCache]:[Exhaustive]; GroupName; 'ListName')) ", tempDoc);
return String.valueOf(!result.isEmpty());
} finally {
session.recycle();
}
}
use of lotus.domino.Database in project openliberty-domino by OpenNTF.
the class IdentityServlet method getUserSecurityName.
private String getUserSecurityName(String uniqueUserId) throws NotesException {
Session session = NotesFactory.createSession();
try {
// $NON-NLS-1$ //$NON-NLS-2$
Database names = session.getDatabase("", "names.nsf");
Document tempDoc = names.createDocument();
// $NON-NLS-1$
tempDoc.replaceItemValue("Username", uniqueUserId);
// $NON-NLS-1$
List<?> result = session.evaluate(" @Trim(@NameLookup([NoCache]:[Exhaustive]; Username; 'FullName')) ", tempDoc);
if (!result.isEmpty()) {
return (String) result.get(0);
} else {
// $NON-NLS-1$
return "";
}
} finally {
session.recycle();
}
}
use of lotus.domino.Database in project openliberty-domino by OpenNTF.
the class IdentityServlet method getUniqueUserId.
private String getUniqueUserId(String userSecurityName) throws NotesException {
Session session = NotesFactory.createSession();
try {
// $NON-NLS-1$ //$NON-NLS-2$
Database names = session.getDatabase("", "names.nsf");
Document tempDoc = names.createDocument();
// $NON-NLS-1$
tempDoc.replaceItemValue("Username", userSecurityName);
// $NON-NLS-1$
List<?> result = session.evaluate(" @Trim(@NameLookup([NoCache]:[Exhaustive]; Username; 'ShortName')) ", tempDoc);
if (!result.isEmpty()) {
return (String) result.get(0);
} else {
// $NON-NLS-1$
return "";
}
} finally {
session.recycle();
}
}
Aggregations