Search in sources :

Example 1 with XWikiAuthServiceImpl

use of com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl in project xwiki-platform by xwiki.

the class XWiki method getAuthService.

// added some log statements to make debugging easier - LBlaze 2005.06.02
public XWikiAuthService getAuthService() {
    synchronized (this.AUTH_SERVICE_LOCK) {
        if (this.authService == null) {
            LOGGER.info("Initializing AuthService...");
            String authClass = getConfiguration().getProperty("xwiki.authentication.authclass");
            if (StringUtils.isNotEmpty(authClass)) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Using custom AuthClass " + authClass + ".");
                }
            } else {
                if (isLDAP()) {
                    authClass = "com.xpn.xwiki.user.impl.LDAP.XWikiLDAPAuthServiceImpl";
                } else {
                    authClass = "com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl";
                }
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Using default AuthClass " + authClass + ".");
                }
            }
            try {
                // Get the current ClassLoader
                @SuppressWarnings("deprecation") ClassLoaderManager clManager = Utils.getComponent(ClassLoaderManager.class);
                ClassLoader classloader = null;
                if (clManager != null) {
                    classloader = clManager.getURLClassLoader("wiki:xwiki", false);
                }
                // Get the class
                if (classloader != null) {
                    this.authService = (XWikiAuthService) Class.forName(authClass, true, classloader).newInstance();
                } else {
                    this.authService = (XWikiAuthService) Class.forName(authClass).newInstance();
                }
                LOGGER.debug("Initialized AuthService using Relfection.");
            } catch (Exception e) {
                LOGGER.warn("Failed to initialize AuthService " + authClass + " using Reflection, trying default implementations using 'new'.", e);
                this.authService = new XWikiAuthServiceImpl();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Initialized AuthService " + this.authService.getClass().getName() + " using 'new'.");
                }
            }
        }
        return this.authService;
    }
}
Also used : XWikiAuthServiceImpl(com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl) ClassLoaderManager(org.xwiki.classloader.ClassLoaderManager) XWikiPageClassLoader(com.xpn.xwiki.render.groovy.XWikiPageClassLoader) ParseGroovyFromString(com.xpn.xwiki.internal.render.groovy.ParseGroovyFromString) IncludeServletAsString(com.xpn.xwiki.web.includeservletasstring.IncludeServletAsString) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) IOException(java.io.IOException) JobException(org.xwiki.job.JobException) ParseException(org.xwiki.rendering.parser.ParseException) QueryException(org.xwiki.query.QueryException) URIException(org.apache.commons.httpclient.URIException) InvocationTargetException(java.lang.reflect.InvocationTargetException) HibernateException(org.hibernate.HibernateException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) NamingException(javax.naming.NamingException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException)

Aggregations

ParseGroovyFromString (com.xpn.xwiki.internal.render.groovy.ParseGroovyFromString)1 XWikiPageClassLoader (com.xpn.xwiki.render.groovy.XWikiPageClassLoader)1 XWikiAuthServiceImpl (com.xpn.xwiki.user.impl.xwiki.XWikiAuthServiceImpl)1 IncludeServletAsString (com.xpn.xwiki.web.includeservletasstring.IncludeServletAsString)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 NamingException (javax.naming.NamingException)1 URIException (org.apache.commons.httpclient.URIException)1 HibernateException (org.hibernate.HibernateException)1 ClassLoaderManager (org.xwiki.classloader.ClassLoaderManager)1 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 JobException (org.xwiki.job.JobException)1 QueryException (org.xwiki.query.QueryException)1 ParseException (org.xwiki.rendering.parser.ParseException)1 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)1