001    /**
002     * Copyright (c) 2000-present 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 java.util.List;
018    
019    import javax.naming.Binding;
020    import javax.naming.directory.Attribute;
021    import javax.naming.directory.Attributes;
022    import javax.naming.directory.SearchResult;
023    import javax.naming.ldap.LdapContext;
024    
025    /**
026     * @author Edward C. Han
027     */
028    public interface PortalLDAP {
029    
030            public LdapContext getContext(long ldapServerId, long companyId)
031                    throws Exception;
032    
033            public LdapContext getContext(
034                            long companyId, String providerURL, String principal,
035                            String credentials)
036                    throws Exception;
037    
038            public Binding getGroup(long ldapServerId, long companyId, String groupName)
039                    throws Exception;
040    
041            public Attributes getGroupAttributes(
042                            long ldapServerId, long companyId, LdapContext ldapContext,
043                            String fullDistinguishedName)
044                    throws Exception;
045    
046            public Attributes getGroupAttributes(
047                            long ldapServerId, long companyId, LdapContext ldapContext,
048                            String fullDistinguishedName, boolean includeReferenceAttributes)
049                    throws Exception;
050    
051            public byte[] getGroups(
052                            long companyId, LdapContext ldapContext, byte[] cookie,
053                            int maxResults, String baseDN, String groupFilter,
054                            List<SearchResult> searchResults)
055                    throws Exception;
056    
057            public byte[] getGroups(
058                            long companyId, LdapContext ldapContext, byte[] cookie,
059                            int maxResults, String baseDN, String groupFilter,
060                            String[] attributeIds, List<SearchResult> searchResults)
061                    throws Exception;
062    
063            public byte[] getGroups(
064                            long ldapServerId, long companyId, LdapContext ldapContext,
065                            byte[] cookie, int maxResults, List<SearchResult> searchResults)
066                    throws Exception;
067    
068            public byte[] getGroups(
069                            long ldapServerId, long companyId, LdapContext ldapContext,
070                            byte[] cookie, int maxResults, String[] attributeIds,
071                            List<SearchResult> searchResults)
072                    throws Exception;
073    
074            public String getGroupsDN(long ldapServerId, long companyId)
075                    throws Exception;
076    
077            public long getLdapServerId(
078                            long companyId, String screenName, String emailAddress)
079                    throws Exception;
080    
081            public Attribute getMultivaluedAttribute(
082                            long companyId, LdapContext ldapContext, String baseDN,
083                            String filter, Attribute attribute)
084                    throws Exception;
085    
086            public String getNameInNamespace(
087                            long ldapServerId, long companyId, Binding binding)
088                    throws Exception;
089    
090            public Binding getUser(
091                            long ldapServerId, long companyId, String screenName,
092                            String emailAddress)
093                    throws Exception;
094    
095            public Binding getUser(
096                            long ldapServerId, long companyId, String screenName,
097                            String emailAddress, boolean checkOriginalEmail)
098                    throws Exception;
099    
100            public Attributes getUserAttributes(
101                            long ldapServerId, long companyId, LdapContext ldapContext,
102                            String fullDistinguishedName)
103                    throws Exception;
104    
105            public byte[] getUsers(
106                            long companyId, LdapContext ldapContext, byte[] cookie,
107                            int maxResults, String baseDN, String userFilter,
108                            List<SearchResult> searchResults)
109                    throws Exception;
110    
111            public byte[] getUsers(
112                            long companyId, LdapContext ldapContext, byte[] cookie,
113                            int maxResults, String baseDN, String userFilter,
114                            String[] attributeIds, List<SearchResult> searchResults)
115                    throws Exception;
116    
117            public byte[] getUsers(
118                            long ldapServerId, long companyId, LdapContext ldapContext,
119                            byte[] cookie, int maxResults, List<SearchResult> searchResults)
120                    throws Exception;
121    
122            public byte[] getUsers(
123                            long ldapServerId, long companyId, LdapContext ldapContext,
124                            byte[] cookie, int maxResults, String[] attributeIds,
125                            List<SearchResult> searchResults)
126                    throws Exception;
127    
128            public String getUsersDN(long ldapServerId, long companyId)
129                    throws Exception;
130    
131            public boolean hasUser(
132                            long ldapServerId, long companyId, String screenName,
133                            String emailAddress)
134                    throws Exception;
135    
136            public boolean isGroupMember(
137                            long ldapServerId, long companyId, String groupDN, String userDN)
138                    throws Exception;
139    
140            public boolean isUserGroupMember(
141                            long ldapServerId, long companyId, String groupDN, String userDN)
142                    throws Exception;
143    
144            public byte[] searchLDAP(
145                            long companyId, LdapContext ldapContext, byte[] cookie,
146                            int maxResults, String baseDN, String filter, String[] attributeIds,
147                            List<SearchResult> searchResults)
148                    throws Exception;
149    
150    }