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>
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");
}
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")){
..
..
}
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>