org.apache.jetspeed.services.ldap
Class LDAPService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.jetspeed.services.ldap.LDAPService
All Implemented Interfaces:
org.apache.turbine.services.Initable, org.apache.turbine.services.Service

public class LDAPService
extends org.apache.turbine.services.TurbineBaseService

Version:
$Id: LDAPService.java,v 1.7 2005/04/27 14:08:24 raphael Exp $
Author:
Ender KILICOGLU, Sami Leino

Field Summary
static int BASE
           
static int DEFAULT_LIMIT
           
static int DEFAULT_PORT
           
static int DEFAULT_SSLPORT
           
static int DEFAULT_TIMEOUT
           
static int DEFAULT_VERSION
           
static int ONE
           
static java.lang.String SERVICE_NAME
           
static int SUB
           
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Constructor Summary
LDAPService()
           
 
Method Summary
 boolean addAttribute(LDAPURL url, javax.naming.directory.Attribute at)
          Add Attribute Function add given attribute to given LDAPURL.
 boolean addEntry(LDAPURL url, javax.naming.directory.Attributes at)
          Add entry Function tries to add object with given LDAPURL and with given attributes.
 LDAPURL buildURL(java.lang.String DN)
          Build LDAPURL Function Build LDAPURL with given DN.
 boolean checkAndCloseContext(javax.naming.Context context)
           
 int compare(LDAPURL srcUrl, LDAPURL dstUrl)
          Compare Function Compare given LDAPURLs.
 javax.naming.directory.DirContext connect(LDAPURL url)
          Connection Function tries to connect given LDAPURL.
 boolean deleteAttribute(LDAPURL url, javax.naming.directory.Attribute at)
          Delete Atrribute Function Delete given attribute for given LDAPURL.
 boolean deleteAttrs(LDAPURL url, javax.naming.directory.Attributes ats)
          Delete Attributes Function Delete Attributes for given LDAPURL.
 boolean deleteEntry(LDAPURL url)
          Delete Entry Function Delete given LDAPURL.
 boolean deleteTree(LDAPURL url)
          Delete Tree Function Delete record with all child node LDAPURL.
 boolean disconnect()
          Disconnection Function tries to disconnect all connection.
 boolean exists(LDAPURL url)
          Query existense of an Object Function tries to locate given LDAPURL.
 LDAPURL findEntryName(LDAPURL url)
          Find Entry Name Function Return entry name for given LDAPURL.
 java.lang.String getName(java.lang.String dn)
          Return Name Function Return name for given DN.
 LDAPURL getReferralUrl(javax.naming.ReferralException e)
          Get Referral URL Function Return LDAPURL extracted from exception.
 int importEntry(LDAPURL url, java.lang.String dn, javax.naming.directory.Attributes entry, int type)
          Import Function Import given LDAPURL to another dn.
 void init()
          This is the late initialization method called by the Turbine Service framework
 void init(javax.servlet.ServletConfig conf)
          This is the early initialization method called by the Turbine Service framework
 javax.naming.Name parse(java.lang.String dn)
          Return Name Function Add Base DN to given DN.
 javax.naming.directory.Attributes read(LDAPURL url)
          Read Attributes Function Return attributes for given LDAPURL.
 java.lang.String removeAttrName(java.lang.String attrvalue)
          Get value Function Return value for attribute value pair.
 boolean renameEntry(LDAPURL url, java.lang.String newDN)
          Rename Entry Function Rename given LDAPURL with given DN.
 javax.naming.NamingEnumeration search(javax.naming.directory.DirContext ctx, java.lang.String dn, java.lang.String filter, java.lang.String[] attribs, int type)
          Search Function Search objects for given Base DN and filter.
 java.util.Vector search(LDAPURL url, java.lang.String filter, java.lang.String[] attribs, boolean subTreeScope)
          Search Function Search objects for given BaseURL and filter.
 boolean synchEntry(LDAPURL url, javax.naming.directory.Attributes ats)
          Sync Entry Function Sync given LDAPURL with given atrributes.
 boolean transfer(LDAPURL fromUrl, LDAPURL toUrl, boolean delete, boolean replace, boolean withChildren)
          Transfer Function Transfer given LDAPURL to other LDAPURL.
 boolean transferEntry(LDAPURL fromUrl, javax.naming.directory.Attributes ats, LDAPURL toUrl, boolean delete, boolean replace)
          Transfer with updates Function Transfer updated LDAPURL with given modification items to other LDAPURL.
 boolean transferEntry(LDAPURL fromUrl, LDAPURL toUrl, boolean delete, boolean replace)
          Transfer without updates Function Transfer LDAPURL to other LDAPURL.
 boolean updateAttribute(LDAPURL url, javax.naming.directory.Attribute at)
          Update Atribute Function Update an attribute for given LDAPURL.
 boolean updateEntry(LDAPURL url, javax.naming.directory.Attributes at)
          Update Atributes Function Update attributes for given LDAPURL.
 boolean updateEntry(LDAPURL url, javax.naming.directory.Attributes ats, boolean replace)
          Update Entry Function Update attributes for given LDAPURL.
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, shutdown
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, setInitableBroker
 

Field Detail

SERVICE_NAME

public static java.lang.String SERVICE_NAME

BASE

public static final int BASE
See Also:
Constant Field Values

ONE

public static final int ONE
See Also:
Constant Field Values

SUB

public static final int SUB
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_SSLPORT

public static final int DEFAULT_SSLPORT
See Also:
Constant Field Values

DEFAULT_LIMIT

public static final int DEFAULT_LIMIT
See Also:
Constant Field Values

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values

DEFAULT_VERSION

public static final int DEFAULT_VERSION
See Also:
Constant Field Values
Constructor Detail

LDAPService

public LDAPService()
Method Detail

connect

public javax.naming.directory.DirContext connect(LDAPURL url)
Connection Function tries to connect given LDAPURL.

Parameters:
url - LDAPURL which locate server to connect.
Returns:
DirContext connection context object.

disconnect

public boolean disconnect()
Disconnection Function tries to disconnect all connection.

Returns:
boolean true if success else false.

checkAndCloseContext

public boolean checkAndCloseContext(javax.naming.Context context)

deleteAttribute

public boolean deleteAttribute(LDAPURL url,
                               javax.naming.directory.Attribute at)
Delete Atrribute Function Delete given attribute for given LDAPURL.

Parameters:
url - object affected.
at - Atribute to delete
Returns:
boolean true if success else false.

addAttribute

public boolean addAttribute(LDAPURL url,
                            javax.naming.directory.Attribute at)
Add Attribute Function add given attribute to given LDAPURL.

Parameters:
url - object affected.
at - Atribute to add
Returns:
boolean true if success else false.

addEntry

public boolean addEntry(LDAPURL url,
                        javax.naming.directory.Attributes at)
Add entry Function tries to add object with given LDAPURL and with given attributes.

Parameters:
url - object to create.
at - Atributes to add
Returns:
boolean true if success else false.

exists

public boolean exists(LDAPURL url)
Query existense of an Object Function tries to locate given LDAPURL.

Parameters:
url - object affected.
Returns:
boolean true if exist else false.

compare

public int compare(LDAPURL srcUrl,
                   LDAPURL dstUrl)
Compare Function Compare given LDAPURLs.

Parameters:
srcUrl - object affected.
dstUrl - object affected.
Returns:
int 0 same host+DN, 1 same DN,2 child,3 no relation.

importEntry

public int importEntry(LDAPURL url,
                       java.lang.String dn,
                       javax.naming.directory.Attributes entry,
                       int type)
Import Function Import given LDAPURL to another dn.

Parameters:
url - object to import.
dn - Dn of new object.
entry - attributes.
type - 0 addnew, 1 update, 2 sync.
Returns:
int 1 success, 0 unknown type,-1 failure.

buildURL

public LDAPURL buildURL(java.lang.String DN)
Build LDAPURL Function Build LDAPURL with given DN.

Parameters:
DN - DN value for object.
Returns:
LDAPURL build with given DN.

read

public javax.naming.directory.Attributes read(LDAPURL url)
Read Attributes Function Return attributes for given LDAPURL.

Parameters:
url - object to read attributes.
Returns:
Attributes attributes for given url.

renameEntry

public boolean renameEntry(LDAPURL url,
                           java.lang.String newDN)
Rename Entry Function Rename given LDAPURL with given DN.

Parameters:
url - object to modify.
newDN - DN value for new object.
Returns:
boolean true if success else false.

synchEntry

public boolean synchEntry(LDAPURL url,
                          javax.naming.directory.Attributes ats)
Sync Entry Function Sync given LDAPURL with given atrributes.

Parameters:
url - object to sync.
ats - Modification items.
Returns:
boolean true if success else false.

deleteAttrs

public boolean deleteAttrs(LDAPURL url,
                           javax.naming.directory.Attributes ats)
Delete Attributes Function Delete Attributes for given LDAPURL.

Parameters:
url - object to modify.
ats - Attributes to delete.
Returns:
boolean true if success else false.

deleteEntry

public boolean deleteEntry(LDAPURL url)
Delete Entry Function Delete given LDAPURL.

Parameters:
url - object to delete.
Returns:
boolean true if success else false.

findEntryName

public LDAPURL findEntryName(LDAPURL url)
Find Entry Name Function Return entry name for given LDAPURL.

Parameters:
url - object to modify.
Returns:
LDAPURL real entry DN.

deleteTree

public boolean deleteTree(LDAPURL url)
Delete Tree Function Delete record with all child node LDAPURL.

Parameters:
url - object to modify.
Returns:
boolean true if success else false.

transfer

public boolean transfer(LDAPURL fromUrl,
                        LDAPURL toUrl,
                        boolean delete,
                        boolean replace,
                        boolean withChildren)
Transfer Function Transfer given LDAPURL to other LDAPURL.

Parameters:
fromUrl - object to transfer.
toUrl - target object.
delete - delete after transfer.
replace - replace if exist.
withChildren - transfer with childs.
Returns:
boolean true if success else false.

transferEntry

public boolean transferEntry(LDAPURL fromUrl,
                             javax.naming.directory.Attributes ats,
                             LDAPURL toUrl,
                             boolean delete,
                             boolean replace)
Transfer with updates Function Transfer updated LDAPURL with given modification items to other LDAPURL.

Parameters:
fromUrl - object to transfer.
toUrl - target object.
delete - delete after transfer.
replace - replace if exist.
ats - attributes to update.
Returns:
boolean true if success else false.

transferEntry

public boolean transferEntry(LDAPURL fromUrl,
                             LDAPURL toUrl,
                             boolean delete,
                             boolean replace)
Transfer without updates Function Transfer LDAPURL to other LDAPURL.

Parameters:
fromUrl - object to transfer.
toUrl - target object.
delete - delete after transfer.
replace - replace if exist.
Returns:
boolean true if success else false.

updateAttribute

public boolean updateAttribute(LDAPURL url,
                               javax.naming.directory.Attribute at)
Update Atribute Function Update an attribute for given LDAPURL.

Parameters:
url - object to update.
at - atrribute to update.
Returns:
boolean true if success else false.

updateEntry

public boolean updateEntry(LDAPURL url,
                           javax.naming.directory.Attributes at)
Update Atributes Function Update attributes for given LDAPURL.

Parameters:
url - object to update.
at - atrributes to update.
Returns:
boolean true if success else false.

updateEntry

public boolean updateEntry(LDAPURL url,
                           javax.naming.directory.Attributes ats,
                           boolean replace)
Update Entry Function Update attributes for given LDAPURL.

Parameters:
url - object to update.
ats - atrributes to update.
replace - replace if exist.
Returns:
boolean true if success else false.

search

public javax.naming.NamingEnumeration search(javax.naming.directory.DirContext ctx,
                                             java.lang.String dn,
                                             java.lang.String filter,
                                             java.lang.String[] attribs,
                                             int type)
                                      throws javax.naming.NamingException
Search Function Search objects for given Base DN and filter.

Parameters:
ctx - directory context.
dn - Base search DN.
filter - Search filter.
attribs - attributes to receive.
type - search scope 1 Subscope, else 0.
Returns:
NamingEnumeration Results.
Throws:
javax.naming.NamingException

search

public java.util.Vector search(LDAPURL url,
                               java.lang.String filter,
                               java.lang.String[] attribs,
                               boolean subTreeScope)
Search Function Search objects for given BaseURL and filter.

Parameters:
url - Base URL .
filter - Search filter.
attribs - attributes to receive.
subTreeScope - true subtree else false.
Returns:
Vector Results.

removeAttrName

public java.lang.String removeAttrName(java.lang.String attrvalue)
Get value Function Return value for attribute value pair.

Parameters:
attrvalue - input.
Returns:
String Value.

getName

public java.lang.String getName(java.lang.String dn)
Return Name Function Return name for given DN.

Parameters:
dn - DN.
Returns:
String Name.

parse

public javax.naming.Name parse(java.lang.String dn)
Return Name Function Add Base DN to given DN.

Parameters:
dn - full DN.
Returns:
Name Name for given DN.

getReferralUrl

public LDAPURL getReferralUrl(javax.naming.ReferralException e)
Get Referral URL Function Return LDAPURL extracted from exception.

Parameters:
e - Exception to extract.
Returns:
LDAPURL referrral URL.

init

public void init(javax.servlet.ServletConfig conf)
          throws org.apache.turbine.services.InitializationException
This is the early initialization method called by the Turbine Service framework

Parameters:
conf - The ServletConfig
Throws:
org.apache.turbine.services.InitializationException - if the service fails to initialize

init

public void init()
          throws org.apache.turbine.services.InitializationException
This is the late initialization method called by the Turbine Service framework

Throws:
org.apache.turbine.services.InitializationException - if the service fails to initialize


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.