Search in sources :

Example 1 with XPageSignerSessionFactory

use of org.openntf.domino.xsp.session.XPageSignerSessionFactory in project org.openntf.domino by OpenNTF.

the class XotsDominoExecutor method initModule.

/**
 * Helper for WrappedCallable/WrappedRunnable
 *
 * @param ctx
 * @param mcl
 * @param wrapper
 * @throws ServletException
 */
static void initModule(final NotesContext ctx, final ClassLoader mcl, final Object wrappedObject) throws ServletException {
    if (mcl instanceof ModuleClassLoader) {
        URLClassLoader dcl = (URLClassLoader) ((ModuleClassLoader) mcl).getDynamicClassLoader();
        String className = wrappedObject.getClass().getName();
        String str = className.replace('.', '/') + ".class";
        URL url = dcl.findResource(str);
        if (url != null && url.getProtocol().startsWith("xspnsf")) {
            // Set up the "TopLevelXPageSigner == Signer of the runnable
            // As soon as we are in a xspnsf, we do not have a SessionFactory!
            ctx.setSignerSessionRights("WEB-INF/classes/" + str);
            // RPr: There is a bug: you can decide if you want to use "sessionAsSigner" or "sessionAsSignerFullAccess"
            // But you cannot use both simultaneously!
            Session signerSession = ctx.getSessionAsSigner(true);
            if (signerSession != null) {
                Factory.setSessionFactory(new XPageSignerSessionFactory(false), SessionType.SIGNER);
                Factory.setSessionFactory(new XPageSignerSessionFactory(true), SessionType.SIGNER_FULL_ACCESS);
            } else {
                // do not setup signer sessions if it is not properly signed!
                Factory.setSessionFactory(new InvalidSessionFactory(), SessionType.SIGNER);
                Factory.setSessionFactory(new InvalidSessionFactory(), SessionType.SIGNER_FULL_ACCESS);
            }
        } else {
            // The code is not part from an NSF, so it resides on the server
            Factory.setSessionFactory(new XPageNamedSessionFactory(Factory.getLocalServerName(), false), SessionType.SIGNER);
            Factory.setSessionFactory(new XPageNamedSessionFactory(Factory.getLocalServerName(), true), SessionType.SIGNER_FULL_ACCESS);
        }
    }
    Factory.setClassLoader(mcl);
}
Also used : InvalidSessionFactory(org.openntf.domino.xsp.session.InvalidSessionFactory) XPageNamedSessionFactory(org.openntf.domino.xsp.session.XPageNamedSessionFactory) ModuleClassLoader(com.ibm.domino.xsp.module.nsf.ModuleClassLoader) URLClassLoader(java.net.URLClassLoader) XPageSignerSessionFactory(org.openntf.domino.xsp.session.XPageSignerSessionFactory) URL(java.net.URL) Session(lotus.domino.Session)

Example 2 with XPageSignerSessionFactory

use of org.openntf.domino.xsp.session.XPageSignerSessionFactory in project org.openntf.domino by OpenNTF.

the class ODAFacesContextFactory method getFacesContext.

@Override
public FacesContext getFacesContext(final Object context, final Object request, final Object response, final Lifecycle lifecycle) throws FacesException {
    FacesContext ctx = _delegate.getFacesContext(context, request, response, lifecycle);
    Factory.initThread(ODAPlatform.getAppThreadConfig(null));
    Factory.setSessionFactory(new XPageCurrentSessionFactory(), SessionType.CURRENT);
    Factory.setSessionFactory(new XPageSignerSessionFactory(false), SessionType.SIGNER);
    Factory.setSessionFactory(new XPageSignerSessionFactory(true), SessionType.SIGNER_FULL_ACCESS);
    // TODO RPr: This is probably the wrong locale. See ViewHandler.calculateLocale
    Factory.setUserLocale(ctx.getExternalContext().getRequestLocale());
    Factory.setClassLoader(ctx.getContextClassLoader());
    if (ODAPlatform.isAppGodMode(null)) {
        ODAFacesContext localContext = new ODAFacesContext(ctx);
        attachListener(localContext);
        return localContext;
    } else {
        if (ctx instanceof FacesContextEx) {
            attachListener((FacesContextEx) ctx);
            return ctx;
        } else {
            DominoFacesContext localContext = new DominoFacesContext(ctx);
            attachListener(localContext);
            return localContext;
        }
    }
}
Also used : DominoFacesContext(com.ibm.xsp.domino.context.DominoFacesContext) FacesContext(javax.faces.context.FacesContext) XPageCurrentSessionFactory(org.openntf.domino.xsp.session.XPageCurrentSessionFactory) FacesContextEx(com.ibm.xsp.context.FacesContextEx) DominoFacesContext(com.ibm.xsp.domino.context.DominoFacesContext) XPageSignerSessionFactory(org.openntf.domino.xsp.session.XPageSignerSessionFactory)

Aggregations

XPageSignerSessionFactory (org.openntf.domino.xsp.session.XPageSignerSessionFactory)2 ModuleClassLoader (com.ibm.domino.xsp.module.nsf.ModuleClassLoader)1 FacesContextEx (com.ibm.xsp.context.FacesContextEx)1 DominoFacesContext (com.ibm.xsp.domino.context.DominoFacesContext)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 FacesContext (javax.faces.context.FacesContext)1 Session (lotus.domino.Session)1 InvalidSessionFactory (org.openntf.domino.xsp.session.InvalidSessionFactory)1 XPageCurrentSessionFactory (org.openntf.domino.xsp.session.XPageCurrentSessionFactory)1 XPageNamedSessionFactory (org.openntf.domino.xsp.session.XPageNamedSessionFactory)1