Getting started

  • Download the release and try out the sample swt application
  • The User Guid page contains a link to the full documentation.
  • Take a look at the source of the sample.

A sample of heracles.xml

The Heracles Project will be configured over a xml file. This file defines the servers and other important things for the Project.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE heracles PUBLIC "http://heracles.sourceforge.net/NS/DTD/" "heracles-config.dtd">

<heracles>
        <ldap-config>
                <domain name="bbz-sg.lan">
                        <principal>admin.heracles@BBZ-SG.LAN</principal>
                        <credential>---heracles---!</credential>
                        <provider>ldap://bbzsg1.bbz-sg.lan:389/  ldap://bbzsg2.bbz-sg.lan:389/</provider>
                        <searchBase>DC=BBZ-SG,DC=LAN</searchBase>
                        <emptyValues>no information</emptyValues>
                </domain>
                <domain name="hft-so.bbz-sg.lan">
                        <principal>admin.heracles@HFT-SO.BBZ-SG.LAN</principal>
                        <credential>---heracles---!</credential>
                        <provider>ldap://hftso1.hft-so.bbz-sg.lan:389/  ldap://hftso2.hft-so.bbz-sg.lan:389/</provider>
                        <searchBase>DC=HFT-SO,DC=BBZ-SG,DC=LAN</searchBase>
                        <emptyValues>no information</emptyValues>
                </domain>
        </ldap-config>

        <kerberos-config>
                <realm name="BBZ-SG.LAN">bbzsg1.bbz-sg.lan bbzsg2.bbz-sg.lan</realm>
                <realm name="HFT-SO.BBZ-SG.LAN">hftso1.hft-so.bbz-sg.lan hftso2.hft-so.bbz-sg.lan</realm>
        </kerberos-config>
</heracles>

A sample for a simple authenticaton

Some where in your application inlclude ...

Heracles heracles = Heracles.getHeracles();

try{
  heracles.authSimple(username, password);
  System.out.println("login success");
}catch(LoginException ex){
  System.out.println("login failed");
}catch(HeraclesException ex){
  System.out.println("login failed");
}

A sample for an advanced authenticaton

For more features and possibilities...such as an autorisation!

Heracles heracles = Heracles.getHeracles();
LdapUser ldapUser = heracles.authAdvanced(name, passwd);

String gruppe = "";             
                
Iterator iter = ldapUser.getLdapGroups().iterator();
while (iter.hasNext()) {
  LdapGroup ldapGroup = (LdapGroup) iter.next();
  if(ldapGroup.getName().equals("gg_admin")){
        gruppe=ldapGroup.getName();
  }
  if(ldapGroup.getName().equals("gg_mitarbeiter")){
        gruppe=ldapGroup.getName();
  }
}


// Prüfung der Berechtigung

if(gruppe.equals("gg_admin")){
  ..
  ..
}

ACEGI sample to use the Heracles Authentication Provider

Heracles works together with acegi security framework.

  <!-- = = = = = = = = AUTHENTICATION = = = = = = = -->
  <bean id="authenticationManager" 
      class="org.acegisecurity.providers.ProviderManager">
    <property name="providers">
      <list>
        <ref bean="heraclesAuthenticationProvider"/>
      </list>
    </property>
  </bean>

  <bean id="heraclesAuthenticationProvider" 
      class="net.sourceforge.heracles.acegi.HeraclesAuthenticationProvider">
  </bean>