use of nl.uva.cs.lobcder.auth.AuthI in project lobcder by skoulouzis.
the class MyMiltonConfigurator method build.
// public MyMiltonConfigurator() {
// super();
// try {
// // Attempt to use Enterprise edition build if available
// Class builderClass = Class.forName("nl.uva.cs.webdav.HttpManagerBuilderExt");
// builder = (HttpManagerBuilder) builderClass.newInstance();
// log.log(Level.INFO, "Using enterprise builder: {0}", builder.getClass());
// } catch (InstantiationException | IllegalAccessException | ClassNotFoundException ex) {
// log.info("Couldnt instantiate enterprise builder, DAV level 2 and beyond features will not be available");
// builder = new HttpManagerBuilder();
// }
// Class handlerHelper = Class.forName("io.milton.http.HandlerHelper");
// if (handlerHelper != null) {
// throw new RuntimeException("HandlerHelper is not an instance of io.milton.http.HandlerHelper");
// }
// builder = new HttpManagerBuilderExt();
// }
@Override
protected void build() {
builder.setEnableCompression(false);
builder.setEnableOptionsAuth(true);
builder.setEnableBasicAuth(true);
super.build();
try {
Context ctx = new InitialContext();
if (ctx == null) {
throw new Exception("JNDI could not create InitalContext ");
}
Context envContext = (Context) ctx.lookup("java:/comp/env");
catalogue = (JDBCatalogue) envContext.lookup("bean/JDBCatalog");
catalogue.startSweep();
// workerAuth = (AuthLobcderComponents) envContext.lookup("bean/authWorker");
List<String> workers = PropertiesHelper.getWorkers();
if (workers != null && workers.size() > 0) {
workerAuth = new AuthLobcderComponents();
}
webDataResourceFactory = (WebDataResourceFactory) builder.getMainResourceFactory();
webDataResourceFactory.setCatalogue(catalogue);
List<AuthI> authList = SingletonesHelper.getInstance().getAuth();
// if(workerAuth!=null){
// authList.add(workerAuth);
// }
webDataResourceFactory.setAuthList(authList);
// / webDataResourceFactory.setAuth1(authRemote);
// webDataResourceFactory.setAuth2(localDbAuth);
// webDataResourceFactory.setAuth3(workerAuth);
// loadOptimizers(envContext);
} catch (Exception e) {
Logger.getLogger(MyMiltonConfigurator.class.getName()).log(Level.SEVERE, null, e);
}
}
use of nl.uva.cs.lobcder.auth.AuthI in project lobcder by skoulouzis.
the class WebDataResource method authenticate.
@Override
public Object authenticate(String user, String password) {
String token = password;
MyPrincipal principal = null;
for (AuthI a : authList) {
principal = a.checkToken(user, token);
if (principal != null) {
break;
}
}
// }
if (principal != null) {
principalHolder.set(principal);
// Logger.getLogger(WebDataResource.class.getName()).log(Level.FINE, "getUserId: {0}", principal.getUserId());
// Logger.getLogger(WebDataResource.class.getName()).log(Level.FINE, "getRolesStr: {0}", principal.getRolesStr());
String msg = "From: " + fromAddress + " user: " + principal.getUserId() + " password: XXXX";
Logger.getLogger(WebDataResource.class.getName()).log(Level.INFO, msg);
}
try {
getCatalogue().updateAccessTime(getLogicalData().getUid());
} catch (SQLException ex) {
Logger.getLogger(WebDataResource.class.getName()).log(Level.SEVERE, null, ex);
}
return principal;
}
Aggregations