001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.security.ldap;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.model.User;
019    
020    import javax.naming.directory.Attributes;
021    import javax.naming.ldap.LdapContext;
022    
023    /**
024     * @author Edward Han
025     * @author Michael C. Han
026     * @author Brian Wing Shun Chan
027     * @author Raymond Aug??
028     */
029    public class PortalLDAPImporterUtil {
030    
031            public static PortalLDAPImporter getPortalLDAPImporter() {
032                    PortalRuntimePermission.checkGetBeanProperty(
033                            PortalLDAPImporterUtil.class);
034    
035                    return _portalLDAPImporter;
036            }
037    
038            public static void importFromLDAP() throws Exception {
039                    getPortalLDAPImporter().importFromLDAP();
040            }
041    
042            public static void importFromLDAP(long companyId) throws Exception {
043                    getPortalLDAPImporter().importFromLDAP(companyId);
044            }
045    
046            public static void importFromLDAP(long ldapServerId, long companyId)
047                    throws Exception {
048    
049                    getPortalLDAPImporter().importFromLDAP(ldapServerId, companyId);
050            }
051    
052            public static User importLDAPUser(
053                            long ldapServerId, long companyId, LdapContext ldapContext,
054                            Attributes attributes, String password)
055                    throws Exception {
056    
057                    return getPortalLDAPImporter().importLDAPUser(
058                            ldapServerId, companyId, ldapContext, attributes, password);
059            }
060    
061            public static User importLDAPUser(
062                            long ldapServerId, long companyId, String emailAddress,
063                            String screenName)
064                    throws Exception {
065    
066                    return getPortalLDAPImporter().importLDAPUser(
067                            ldapServerId, companyId, emailAddress, screenName);
068            }
069    
070            public static User importLDAPUser(
071                            long companyId, String emailAddress, String screenName)
072                    throws Exception {
073    
074                    return getPortalLDAPImporter().importLDAPUser(
075                            companyId, emailAddress, screenName);
076            }
077    
078            public static User importLDAPUserByScreenName(
079                            long companyId, String screenName)
080                    throws Exception {
081    
082                    return getPortalLDAPImporter().importLDAPUserByScreenName(
083                            companyId, screenName);
084            }
085    
086            public void setPortalLDAPImporter(PortalLDAPImporter portalLDAPImporter) {
087                    PortalRuntimePermission.checkSetBeanProperty(getClass());
088    
089                    _portalLDAPImporter = portalLDAPImporter;
090            }
091    
092            private static PortalLDAPImporter _portalLDAPImporter;
093    
094    }