org.openpermis.cert
Class LdapOperations

java.lang.Object
  extended by org.openpermis.cert.LdapOperations

public final class LdapOperations
extends Object

Utility class to read from and write to the ldap server holding the certificates used by the authorization framework.

Since:
0.9.0

Field Summary
static String ATTRIBUTE_CERTIFICATE_ATTRIBUTE
          The name of the attribute holding the attribute certificate.
static String NAME_ATTRIBUTE
          The name of the attribute holding the name.
 
Method Summary
static void addPmiUser(InitialLdapContext context, String ldapPath, String name, byte[] certificate)
          Adds a pmiUser object to an ldap.
static InitialLdapContext createInitialContext(String ldapUrl, String bindPrincipal, String bindPrincipalPassword)
          Creates a new InitialLdapContext.
static void editAttribute(InitialLdapContext context, String ldapPath, String attributeName, Object newValue)
          Changes the value of an attribute in an ldap.
static List<SearchResult> getSubtreeEntries(InitialLdapContext context, String ldapPath, String objectClass)
          Returns all entries of a sub-tree.
static void main(String[] args)
          Performs some editing on a test ldap for testing and demonstration purposes.
static void removeEntry(InitialLdapContext context, String ldapPath)
          Removes an entry from an ldap.
static Object retrieveAttribute(InitialLdapContext context, String ldapPath, String attributeName)
          Returns an attribute from an LDAP server as an Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_CERTIFICATE_ATTRIBUTE

public static final String ATTRIBUTE_CERTIFICATE_ATTRIBUTE
The name of the attribute holding the attribute certificate.

Constant Field Value:
"attributeCertificateAttribute"
Since:
0.9.0

NAME_ATTRIBUTE

public static final String NAME_ATTRIBUTE
The name of the attribute holding the name.

Constant Field Value:
"name"
Since:
0.9.0
Method Detail

createInitialContext

public static InitialLdapContext createInitialContext(String ldapUrl,
                                                      String bindPrincipal,
                                                      String bindPrincipalPassword)
                                               throws NamingException
Creates a new InitialLdapContext.

Parameters:
ldapUrl - the url of the lda server e.g. "ldap://localhost:1389".
bindPrincipal - the ldap administrator's common name e.g. "cn=Directory Manager".
bindPrincipalPassword - the ldap administrator's password.
Returns:
the newly created InitialLdapContext.
Throws:
NamingException - if a naming exception is encountered.
Since:
0.9.0

getSubtreeEntries

public static List<SearchResult> getSubtreeEntries(InitialLdapContext context,
                                                   String ldapPath,
                                                   String objectClass)
                                            throws NamingException
Returns all entries of a sub-tree.

Parameters:
context - the InitialLdapContext referencing the ldap to be read.
ldapPath - the path of the subtree root.
objectClass - class of the object that should be retrieved.
Returns:
a list of all subtree entries of the given class type.
Throws:
NamingException - if a naming exception is encountered.
Since:
0.9.0

retrieveAttribute

public static Object retrieveAttribute(InitialLdapContext context,
                                       String ldapPath,
                                       String attributeName)
                                throws NamingException
Returns an attribute from an LDAP server as an Object.

Parameters:
context - the InitialLdapContext referencing the ldap to be read.
ldapPath - the path of the ldap entry to be read.
Returns:
the attribute as an Object.
Throws:
NamingException - if a naming exception is encountered.
Since:
0.9.0

editAttribute

public static void editAttribute(InitialLdapContext context,
                                 String ldapPath,
                                 String attributeName,
                                 Object newValue)
                          throws NamingException
Changes the value of an attribute in an ldap.

Parameters:
context - the InitialLdapContext referencing the ldap to be edited.
ldapPath - the path of the ldap entry to be edited.
attributeName - the name of the attribute to be edited.
newValue - the new value of the attribute.
Throws:
NamingException - if a naming exception is encountered.
Since:
0.9.0

removeEntry

public static void removeEntry(InitialLdapContext context,
                               String ldapPath)
                        throws NamingException
Removes an entry from an ldap.

Parameters:
context - the InitialLdapContext referencing the ldap to be edited.
ldapPath - the path of the ldap entry to be removed.
Throws:
NamingException - if a naming exception is encountered.
Since:
0.9.0

addPmiUser

public static void addPmiUser(InitialLdapContext context,
                              String ldapPath,
                              String name,
                              byte[] certificate)
                       throws NamingException
Adds a pmiUser object to an ldap.

Parameters:
context - the InitialLdapContext referencing the ldap to be edited.
ldapPath - the path of the ldap entry to be added.
name - value of the 'name' attribute of the pmiUser object.
certificate - value of the 'certificate' attribute of the pmiUser object.
Throws:
NamingException - if a naming exception is encountered.
Since:
0.9.0

main

public static void main(String[] args)
                 throws NamingException
Performs some editing on a test ldap for testing and demonstration purposes.

Parameters:
args - not used.
Throws:
NamingException - if a naming exception is encountered.
Since:
0.9.0


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:16:59
Copyright (c) 2002-2007 Ergon Informatik AG