• javac : cannot find symbol , PrincipalAdapter

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #897  by skowit
 
Hello.
Now I used OpenKM login with LDAP ,I need to use User&group List (Full LDAP Integration).
I tried to create a new java file,It\'s implements PrincipalAdapter class.
My new java file , In getUsers and getRoles functions connect TO LDAP instead from file.
when i compiled java file. found the error this message :

UsersRolesPrincipalAdapterPKG.java:14: cannot find symbol
symbol: class PrincipalAdapter
public class UsersRolesPrincipalAdapterPKG implements PrincipalAdapter

How to debug this error,
thank you for the help

Ps, I\'am not good at english
 #903  by skowit
 
My Source code..
Code: Select all
package es.git.openkm.core;

import java.io.*;

import java.util.*;
import javax.naming.*;
import javax.naming.Context;
import javax.naming.directory.*;
import javax.naming.NamingException;
import java.util.Collection;


import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

public class UsersRolesPrincipalAdapterPKG implements PrincipalAdapter
{
  private static Logger log = LoggerFactory.getLogger(UsersRolesPrincipalAdapterPKG.class);


    public Collection getUsers() throws PrincipalAdapterException
    { 
      log.debug(\"getUsers()\");
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,
         \"com.sun.jndi.ldap.LdapCtxFactory\");
      env.put(Context.PROVIDER_URL,
         \"ldap://xxx.xxx.xxx.xxx:389\");
      env.put(Context.SECURITY_PRINCIPAL, \"cn=Manager,dc=example,dc=com\");
      env.put(Context.SECURITY_CREDENTIALS, \"mypassword\");

      DirContext ctx;
      try {
         ctx = new InitialDirContext(env);
      } catch (NamingException e) {
         throw new RuntimeException(e);
      }

      LinkedList list = new LinkedList();
      NamingEnumeration results = null;
      try {
         SearchControls controls =
            new SearchControls();
         controls.setSearchScope(
            SearchControls.SUBTREE_SCOPE);
         results = ctx.search(
            \"ou=employee,dc=example,dc=com\", \"(objectclass=person)\", controls);

         while (results.hasMore()) {
            SearchResult searchResult =
               (SearchResult) results.next();
            Attributes attributes =
               searchResult.getAttributes();
            Attribute attr = attributes.get(\"uid\");
            String uid = (String) attr.get();
            list.add(uid);
         }
      } catch (NameNotFoundException e) {
         // The base context was not found.
         // Just clean up and exit.
      } catch (NamingException e) {
         throw new RuntimeException(e);
      } finally {
         if (results != null) {
            try {
               results.close();
            } catch (Exception e) {
               // Never mind this.
            }
         }
         if (ctx != null) {
            try {
               ctx.close();
            } catch (Exception e) {
               // Never mind this.
            }
         }
      }
      log.debug(\"getUsers: \"+list);	
      return list;
   }

    public Collection getRoles() throws PrincipalAdapterException 
    { 
      log.debug(\"getRoles()\");
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,
         \"com.sun.jndi.ldap.LdapCtxFactory\");
      env.put(Context.PROVIDER_URL,
         \"ldap://xxx.xxx.xxx.xxx:389\");
      env.put(Context.SECURITY_PRINCIPAL, \"cn=Manager,dc=example,dc=com\");
      env.put(Context.SECURITY_CREDENTIALS, \"mypassword\");

      DirContext ctx;
      try {
         ctx = new InitialDirContext(env);
      } catch (NamingException e) {
         throw new RuntimeException(e);
      }

      LinkedList list = new LinkedList();
      NamingEnumeration results = null;
      try {
         SearchControls controls =
            new SearchControls();
         controls.setSearchScope(
            SearchControls.SUBTREE_SCOPE);
         results = ctx.search(
            \"ou=roles,dc=example,dc=com\", \"(objectclass=group)\", controls);

         while (results.hasMore()) {
            SearchResult searchResult =
               (SearchResult) results.next();
            Attributes attributes =
               searchResult.getAttributes();
            Attribute attr = attributes.get(\"cn\");
            String cn = (String) attr.get();
            list.add(cn);
         }
      } catch (NameNotFoundException e) {
         // The base context was not found.
         // Just clean up and exit.
      } catch (NamingException e) {
         throw new RuntimeException(e);
      } finally {
         if (results != null) {
            try {
               results.close();
            } catch (Exception e) {
               // Never mind this.
            }
         }
         if (ctx != null) {
            try {
               ctx.close();
            } catch (Exception e) {
               // Never mind this.
            }
         }
      }
      log.debug(\"getRoles: \"+list);
      return list;
   }
}
 #911  by jllort
 
You\'ve missed some imports ?

Because if your class is on package es.git.openkm.core; ( file writen ) then you need some imports

import es.git.openkm.core.principal.PrincipalAdapter;
import es.git.openkm.core.principal.PrincipalAdapterException;

and you must implement the method getMails

public Collection<String> getMails(Collection<String> users)
throws PrincipalAdapterException {
// TODO Auto-generated method stub
return null;
}

Without it your code can compile correctly.

Have you take a look about actual developer guide, if not look it please, because I think it\'s not possible jboss-ide ( eclipse ) don\'t detects problems.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.