Commit dd2a57c8 authored by benjamin.ertl's avatar benjamin.ertl
Browse files

annotation app context

parent 5b9b3346
......@@ -110,6 +110,8 @@
<version>5.1</version>
</dependency>
<!-- SAML -->
<!-- Utils -->
<dependency>
<groupId>com.google.guava</groupId>
......
......@@ -5,12 +5,18 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import edu.kit.scc.dao.UserDAO;
import edu.kit.scc.dto.UserDTO;
......@@ -26,6 +32,28 @@ public class Main {
// "997fc6c123b3224b3ade247ea8376164";
// private static String accessToken = "88e3bd6a549e385926378129b330c";
@Bean
LdapContextSource contextSource() {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setUrl("ldap://192.168.122.202:10389");
ldapContextSource.setBase("o=sshService");
ldapContextSource.setUserDn("uid=admin,ou=system");
ldapContextSource.setPassword("secret");
return ldapContextSource;
}
@Bean
LdapTemplate ldapTemplate(LdapContextSource contextSource) {
return new LdapTemplate(contextSource);
}
@Bean
LDAPUserDAO ldapUser(LdapTemplate ldapTemplate) {
LDAPUserDAO ldapUserDAO = new LDAPUserDAO();
ldapUserDAO.setLdapTemplate(ldapTemplate);
return ldapUserDAO;
}
public static void main(String[] args) {
// OidcClient oidcClient = new OidcClient(clientId, clientSecret,
......@@ -53,7 +81,9 @@ public class Main {
// Resource resource = new ClassPathResource("springldap.xml");
// BeanFactory factory = new XmlBeanFactory(resource);
ApplicationContext ctx = new ClassPathXmlApplicationContext("springldap.xml");
// ApplicationContext ctx = new
// ClassPathXmlApplicationContext("springldap.xml");
ApplicationContext ctx = new AnnotationConfigApplicationContext(Main.class);
UserDAO ldapUser = (LDAPUserDAO) ctx.getBean("ldapUser");
List<UserDTO> userList = ldapUser.getAllUserNames();
for (int i = 0; i < userList.size(); i++)
......
package edu.kit.scc.saml;
public class SamlClient {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment