Search in sources :

Example 1 with UrlHandler

use of org.bedework.webdav.servlet.shared.UrlHandler in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method getInviteStatus.

@Override
public InviteType getInviteStatus(final CalDAVCollection col) throws WebdavException {
    try {
        InviteType inv = svci.getSharingHandler().getInviteStatus(unwrap(col));
        if (inv == null) {
            return null;
        }
        UrlHandler uh = getUrlHandler();
        for (UserType u : inv.getUsers()) {
            u.setHref(uh.prefix(u.getHref()));
        }
        return inv;
    } catch (CalFacadeForbidden cf) {
        throw new WebdavForbidden(cf.getMessage());
    } catch (WebdavException we) {
        throw we;
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : UrlHandler(org.bedework.webdav.servlet.shared.UrlHandler) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) InviteType(org.bedework.caldav.util.sharing.InviteType) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) CalFacadeForbidden(org.bedework.calfacade.exc.CalFacadeForbidden) UserType(org.bedework.caldav.util.sharing.UserType)

Example 2 with UrlHandler

use of org.bedework.webdav.servlet.shared.UrlHandler in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method init.

@Override
public String init(final HttpServletRequest req, final String account, final boolean service, final boolean calWs, final boolean synchWs, final boolean notifyWs, final boolean socketWs, final String opaqueData) throws WebdavException {
    try {
        this.calWs = calWs;
        this.synchWs = synchWs;
        final HttpReqInfo reqi = new HttpReqInfo(req);
        // In case we reinit
        principalInfo = null;
        if (req != null) {
            urlHandler = new UrlHandler(req, !calWs);
        } else {
            urlHandler = new UrlHandler("", null, true);
        }
        // final HttpSession session = req.getSession();
        // final ServletContext sc = session.getServletContext();
        // final String appName = sc.getInitParameter("bwappname");
        // if ((appName == null) || (appName.length() == 0)) {
        // throw new WebdavException("bwappname is not set in web.xml");
        // }
        // Notification service calling?
        final String id;
        final String notePr = reqi.notePr();
        if (notifyWs) {
            id = doNoteHeader(reqi.note(), notePr);
        } else if (socketWs) {
            final String tkn = reqi.socketToken();
            if ((tkn == null) || !tkn.equals(getSystemProperties().getSocketToken())) {
                throw new WebdavForbidden();
            }
            id = reqi.socketPr();
        } else {
            id = account;
        }
        doBedeworkExtensions(reqi.bedeworkExtensions());
        /* Find the mbean and get the config */
        // ObjectName mbeanName = new ObjectName(CalDAVConf.getServiceName(appName));
        // Call to set up ThreadLocal variables
        boolean publicAdmin = false;
        boolean adminCreateEprops = false;
        if (!notifyWs && (opaqueData != null)) {
            final String[] vals = opaqueData.split("\t");
            for (final String val : vals) {
                if (val.startsWith("public-admin=")) {
                    publicAdmin = Boolean.valueOf(val.substring(13));
                    continue;
                }
                if (val.startsWith("adminCreateEprops=")) {
                    adminCreateEprops = Boolean.valueOf(val.substring(18));
                }
            }
        }
        getSvci(id, reqi.runAs(), service, publicAdmin, reqi.clientId(), adminCreateEprops);
        authProperties = svci.getAuthProperties();
        sysProperties = configs.getSystemProperties();
        basicSysProperties = configs.getBasicSystemProperties();
        svci.postNotification(new HttpEvent(SysCode.CALDAV_IN));
        reqInTime = System.currentTimeMillis();
        currentPrincipal = svci.getUsersHandler().getUser(id);
        if (notifyWs && (notePr != null)) {
            final String principalToken = reqi.principalToken();
            if (principalToken == null) {
                throw new WebdavUnauthorized();
            }
            final BwPreferences prefs = svci.getPrefsHandler().get();
            if ((prefs == null) || (prefs.getNotificationToken() == null) || !principalToken.equals(prefs.getNotificationToken())) {
                throw new WebdavUnauthorized();
            }
        }
        return id;
    } catch (final WebdavException we) {
        throw we;
    } catch (final Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) UrlHandler(org.bedework.webdav.servlet.shared.UrlHandler) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) WebdavUnauthorized(org.bedework.webdav.servlet.shared.WebdavUnauthorized) HttpEvent(org.bedework.sysevents.events.HttpEvent)

Aggregations

UrlHandler (org.bedework.webdav.servlet.shared.UrlHandler)2 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)2 WebdavForbidden (org.bedework.webdav.servlet.shared.WebdavForbidden)2 InviteType (org.bedework.caldav.util.sharing.InviteType)1 UserType (org.bedework.caldav.util.sharing.UserType)1 CalFacadeForbidden (org.bedework.calfacade.exc.CalFacadeForbidden)1 BwPreferences (org.bedework.calfacade.svc.BwPreferences)1 HttpEvent (org.bedework.sysevents.events.HttpEvent)1 WebdavUnauthorized (org.bedework.webdav.servlet.shared.WebdavUnauthorized)1