edu.ucsb.nceas.metacat

## Class AuthLdap

- java.lang.Object
- - edu.ucsb.nceas.metacat.AuthLdap

- All Implemented Interfaces:
    AuthInterface

      public class AuthLdap
      extends java.lang.Object
      implements AuthInterface

  An implementation of the AuthInterface interface that allows Metacat to use the LDAP protocol for directory services. The LDAP authentication service is used to determine if a user is authenticated, and whether they are a member of a particular group.

- - ### Field Summary

    - ### Fields inherited from interface edu.ucsb.nceas.metacat.AuthInterface

      `GROUPDESINDEX, GROUPNAMEINDEX, USERCNINDEX, USERDNINDEX, USEREMAILINDEX, USERINFOCNINDEX, USERINFOEMAILINDEX, USERINFOORGANIDEX, USERORGINDEX, USERORGUNITINDEX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AuthLdap()` Construct an AuthLdap

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `authenticate(java.lang.String user, java.lang.String password)` Determine if a user/password are valid according to the authentication service.
    `java.util.HashMap<java.lang.String,java.util.Vector<java.lang.String>>` | `getAttributes(java.lang.String foruser)` Get attributes describing a user or group
    `java.util.HashMap<java.lang.String,java.util.Vector<java.lang.String>>` | `getAttributes(java.lang.String user, java.lang.String password, java.lang.String foruser)` Get attributes describing a user or group
    `java.lang.String[][]` | `getGroups(java.lang.String user, java.lang.String password)` Get all groups from the authentication service
    `java.lang.String[][]` | `getGroups(java.lang.String user, java.lang.String password, java.lang.String foruser)` Get the groups for a particular user from the authentication service
    `java.lang.String` | `getPrincipals(java.lang.String user, java.lang.String password)` Get all groups and users from authentication scheme.
    `java.lang.String[]` | `getUserInfo(java.lang.String user, java.lang.String password)` Get all users from the authentication service
    `java.lang.String[][]` | `getUsers(java.lang.String user, java.lang.String password)` Get all users from the authentication service
    `java.lang.String[]` | `getUsers(java.lang.String user, java.lang.String password, java.lang.String group)` Get the users for a particular group from the authentication service
    `static void` | `main(java.lang.String[] args)` Test method for the class
    `static int` | `searchUser(java.lang.String user, java.lang.String[][] userGroup)` Method for getting index of user DN in User info array

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AuthLdap

          public AuthLdap()
                   throws java.lang.InstantiationException

      Construct an AuthLdap
      Throws:
        `java.lang.InstantiationException`

  - ### Method Detail

    - #### authenticate

          public boolean authenticate(java.lang.String user,
                                      java.lang.String password)
                               throws java.net.ConnectException

      Determine if a user/password are valid according to the authentication service.
      Specified by:
        `authenticate` in interface `AuthInterface`
      Parameters:
        `user` - the name of the principal to authenticate
        `password` - the password to use for authentication
      Throws:
        `java.net.ConnectException`

    - #### getUsers

          public java.lang.String[][] getUsers(java.lang.String user,
                                               java.lang.String password)
                                        throws java.net.ConnectException

      Get all users from the authentication service
      Specified by:
        `getUsers` in interface `AuthInterface`
      Parameters:
        `user` - the user for authenticating against the service
        `password` - the password for authenticating against the service
      Throws:
        `java.net.ConnectException`

    - #### getUserInfo

          public java.lang.String[] getUserInfo(java.lang.String user,
                                                java.lang.String password)
                                         throws java.net.ConnectException

      Get all users from the authentication service
      Specified by:
        `getUserInfo` in interface `AuthInterface`
      Parameters:
        `user` - the user for authenticating against the service
        `password` - the password for authenticating against the service
      Throws:
        `java.net.ConnectException`

    - #### getUsers

          public java.lang.String[] getUsers(java.lang.String user,
                                             java.lang.String password,
                                             java.lang.String group)
                                      throws java.net.ConnectException

      Get the users for a particular group from the authentication service
      Specified by:
        `getUsers` in interface `AuthInterface`
      Parameters:
        `user` - the user for authenticating against the service
        `password` - the password for authenticating against the service
        `group` - the group whose user list should be returned
      Throws:
        `java.net.ConnectException`

    - #### getGroups

          public java.lang.String[][] getGroups(java.lang.String user,
                                                java.lang.String password)
                                         throws java.net.ConnectException

      Get all groups from the authentication service
      Specified by:
        `getGroups` in interface `AuthInterface`
      Parameters:
        `user` - the user for authenticating against the service
        `password` - the password for authenticating against the service
      Throws:
        `java.net.ConnectException`

    - #### getGroups

          public java.lang.String[][] getGroups(java.lang.String user,
                                                java.lang.String password,
                                                java.lang.String foruser)
                                         throws java.net.ConnectException

      Get the groups for a particular user from the authentication service
      Specified by:
        `getGroups` in interface `AuthInterface`
      Parameters:
        `user` - the user for authenticating against the service
        `password` - the password for authenticating against the service
        `foruser` - the user whose group list should be returned
      Throws:
        `java.net.ConnectException`

    - #### getAttributes

          public java.util.HashMap<java.lang.String,java.util.Vector<java.lang.String>> getAttributes(java.lang.String foruser)
                                                                                               throws java.net.ConnectException

      Get attributes describing a user or group
      Specified by:
        `getAttributes` in interface `AuthInterface`
      Parameters:
        `foruser` - the user for which the attribute list is requested
      Throws:
        `java.net.ConnectException`

    - #### getAttributes

          public java.util.HashMap<java.lang.String,java.util.Vector<java.lang.String>> getAttributes(java.lang.String user,
                                                                                                      java.lang.String password,
                                                                                                      java.lang.String foruser)
                                                                                               throws java.net.ConnectException

      Get attributes describing a user or group
      Specified by:
        `getAttributes` in interface `AuthInterface`
      Parameters:
        `user` - the user for authenticating against the service
        `password` - the password for authenticating against the service
        `foruser` - the user whose attributes should be returned
      Throws:
        `java.net.ConnectException`

    - #### getPrincipals

          public java.lang.String getPrincipals(java.lang.String user,
                                                java.lang.String password)
                                         throws java.net.ConnectException

      Get all groups and users from authentication scheme. The output is formatted in XML.
      Specified by:
        `getPrincipals` in interface `AuthInterface`
      Parameters:
        `user` - the user which requests the information
        `password` - the user's password
      Throws:
        `java.net.ConnectException`

    - #### searchUser

          public static int searchUser(java.lang.String user,
                                       java.lang.String[][] userGroup)

      Method for getting index of user DN in User info array

    - #### main

          public static void main(java.lang.String[] args)

      Test method for the class

Copyright © 2023 Regents of the University of California. All Rights Reserved.