Search in sources :

Example 1 with AuthI

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);
    }
}
Also used : InitialContext(javax.naming.InitialContext) Context(javax.naming.Context) AuthLobcderComponents(nl.uva.cs.lobcder.auth.AuthLobcderComponents) AuthI(nl.uva.cs.lobcder.auth.AuthI) InitialContext(javax.naming.InitialContext) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with AuthI

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;
}
Also used : MyPrincipal(nl.uva.cs.lobcder.auth.MyPrincipal) AuthI(nl.uva.cs.lobcder.auth.AuthI)

Aggregations

AuthI (nl.uva.cs.lobcder.auth.AuthI)2 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Context (javax.naming.Context)1 InitialContext (javax.naming.InitialContext)1 AuthLobcderComponents (nl.uva.cs.lobcder.auth.AuthLobcderComponents)1 MyPrincipal (nl.uva.cs.lobcder.auth.MyPrincipal)1