Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
benjamin.ertl
aai-identity-harmonization
Commits
a583d6cc
Commit
a583d6cc
authored
Jan 21, 2016
by
benjamin.ertl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init test + license
parent
d4169efa
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
442 additions
and
126 deletions
+442
-126
pom.xml
pom.xml
+4
-0
src/main/java/edu/kit/scc/Application.java
src/main/java/edu/kit/scc/Application.java
+8
-0
src/main/java/edu/kit/scc/RestServiceController.java
src/main/java/edu/kit/scc/RestServiceController.java
+8
-0
src/main/java/edu/kit/scc/dao/GroupDAO.java
src/main/java/edu/kit/scc/dao/GroupDAO.java
+25
-0
src/main/java/edu/kit/scc/dao/UserDAO.java
src/main/java/edu/kit/scc/dao/UserDAO.java
+10
-2
src/main/java/edu/kit/scc/dto/GroupDTO.java
src/main/java/edu/kit/scc/dto/GroupDTO.java
+37
-0
src/main/java/edu/kit/scc/dto/UserDTO.java
src/main/java/edu/kit/scc/dto/UserDTO.java
+25
-0
src/main/java/edu/kit/scc/http/CustomSSLContext.java
src/main/java/edu/kit/scc/http/CustomSSLContext.java
+8
-0
src/main/java/edu/kit/scc/http/CustomUrlConnection.java
src/main/java/edu/kit/scc/http/CustomUrlConnection.java
+8
-0
src/main/java/edu/kit/scc/http/HttpClient.java
src/main/java/edu/kit/scc/http/HttpClient.java
+8
-0
src/main/java/edu/kit/scc/http/HttpResponse.java
src/main/java/edu/kit/scc/http/HttpResponse.java
+8
-0
src/main/java/edu/kit/scc/http/NullHostNameVerifier.java
src/main/java/edu/kit/scc/http/NullHostNameVerifier.java
+8
-0
src/main/java/edu/kit/scc/ldap/GroupAttributeMapper.java
src/main/java/edu/kit/scc/ldap/GroupAttributeMapper.java
+33
-0
src/main/java/edu/kit/scc/ldap/LdapClient.java
src/main/java/edu/kit/scc/ldap/LdapClient.java
+45
-14
src/main/java/edu/kit/scc/ldap/LdapGroupDAO.java
src/main/java/edu/kit/scc/ldap/LdapGroupDAO.java
+113
-0
src/main/java/edu/kit/scc/ldap/LdapUserDAO.java
src/main/java/edu/kit/scc/ldap/LdapUserDAO.java
+25
-13
src/main/java/edu/kit/scc/ldap/UserAttributeMapper.java
src/main/java/edu/kit/scc/ldap/UserAttributeMapper.java
+11
-0
src/main/java/edu/kit/scc/oidc/OidcClient.java
src/main/java/edu/kit/scc/oidc/OidcClient.java
+8
-0
src/main/java/edu/kit/scc/saml/AttributeRepository.java
src/main/java/edu/kit/scc/saml/AttributeRepository.java
+0
-10
src/main/java/edu/kit/scc/saml/GetAttributeRequest.java
src/main/java/edu/kit/scc/saml/GetAttributeRequest.java
+0
-10
src/main/java/edu/kit/scc/saml/GetAttributeResponse.java
src/main/java/edu/kit/scc/saml/GetAttributeResponse.java
+0
-10
src/main/java/edu/kit/scc/saml/HttpSignableSoapClient.java
src/main/java/edu/kit/scc/saml/HttpSignableSoapClient.java
+0
-65
src/main/java/edu/kit/scc/saml/SamlClient.java
src/main/java/edu/kit/scc/saml/SamlClient.java
+10
-2
src/main/java/edu/kit/scc/scim/ScimClient.java
src/main/java/edu/kit/scc/scim/ScimClient.java
+8
-0
src/test/java/edu/kit/scc/test/LdapClientTests.java
src/test/java/edu/kit/scc/test/LdapClientTests.java
+32
-0
No files found.
pom.xml
View file @
a583d6cc
...
...
@@ -85,5 +85,9 @@
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/java/edu/kit/scc/Application.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc
;
import
org.slf4j.Logger
;
...
...
src/main/java/edu/kit/scc/RestServiceController.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc
;
import
java.text.ParseException
;
...
...
src/main/java/edu/kit/scc/dao/GroupDAO.java
0 → 100644
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.dao
;
import
java.util.List
;
import
edu.kit.scc.dto.GroupDTO
;
public
interface
GroupDAO
{
public
List
<
GroupDTO
>
getAllGroups
();
public
List
<
GroupDTO
>
getGroupDetails
(
String
commonName
);
public
void
insertGroup
(
GroupDTO
groupDTO
);
public
void
updateGroup
(
GroupDTO
groupDTO
);
public
void
deleteGroup
(
GroupDTO
groupDTO
);
}
src/main/java/edu/kit/scc/dao/UserDAO.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.dao
;
import
java.util.List
;
...
...
@@ -5,9 +13,9 @@ import java.util.List;
import
edu.kit.scc.dto.UserDTO
;
public
interface
UserDAO
{
public
List
<
UserDTO
>
getAllUser
Name
s
();
public
List
<
UserDTO
>
getAllUsers
();
public
List
<
UserDTO
>
getUserDetails
(
String
commonName
,
String
lastName
);
public
List
<
UserDTO
>
getUserDetails
(
String
uid
);
public
void
insertUser
(
UserDTO
userDTO
);
...
...
src/main/java/edu/kit/scc/dto/GroupDTO.java
0 → 100644
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.dto
;
public
class
GroupDTO
{
String
commonName
;
int
gidNumber
;
public
String
getCommonName
()
{
return
commonName
;
}
public
void
setCommonName
(
String
commonName
)
{
this
.
commonName
=
commonName
;
}
public
int
getGidNumber
()
{
return
gidNumber
;
}
public
void
setGidNumber
(
int
gidNumber
)
{
this
.
gidNumber
=
gidNumber
;
}
@Override
public
String
toString
()
{
return
"GroupDTO ["
+
(
commonName
!=
null
?
"commonName="
+
commonName
+
", "
:
""
)
+
"gidNumber="
+
gidNumber
+
"]"
;
}
}
src/main/java/edu/kit/scc/dto/UserDTO.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.dto
;
public
class
UserDTO
{
...
...
@@ -5,6 +13,15 @@ public class UserDTO {
String
commonName
;
String
lastName
;
String
description
;
String
uid
;
public
String
getUid
()
{
return
uid
;
}
public
void
setUid
(
String
uid
)
{
this
.
uid
=
uid
;
}
public
String
getCommonName
()
{
return
commonName
;
...
...
@@ -29,4 +46,12 @@ public class UserDTO {
public
void
setLastName
(
String
lastName
)
{
this
.
lastName
=
lastName
;
}
@Override
public
String
toString
()
{
return
"UserDTO ["
+
(
commonName
!=
null
?
"commonName="
+
commonName
+
", "
:
""
)
+
(
lastName
!=
null
?
"lastName="
+
lastName
+
", "
:
""
)
+
(
description
!=
null
?
"description="
+
description
+
", "
:
""
)
+
(
uid
!=
null
?
"uid="
+
uid
:
""
)
+
"]"
;
}
}
\ No newline at end of file
src/main/java/edu/kit/scc/http/CustomSSLContext.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.http
;
import
java.io.ByteArrayInputStream
;
...
...
src/main/java/edu/kit/scc/http/CustomUrlConnection.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.http
;
import
java.io.IOException
;
...
...
src/main/java/edu/kit/scc/http/HttpClient.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.http
;
import
java.io.IOException
;
...
...
src/main/java/edu/kit/scc/http/HttpResponse.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.http
;
public
class
HttpResponse
{
...
...
src/main/java/edu/kit/scc/http/NullHostNameVerifier.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.http
;
import
javax.net.ssl.HostnameVerifier
;
...
...
src/main/java/edu/kit/scc/ldap/GroupAttributeMapper.java
0 → 100644
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.ldap
;
import
javax.naming.NamingException
;
import
javax.naming.directory.Attribute
;
import
javax.naming.directory.Attributes
;
import
org.springframework.ldap.core.AttributesMapper
;
import
edu.kit.scc.dto.GroupDTO
;
public
class
GroupAttributeMapper
implements
AttributesMapper
<
GroupDTO
>
{
@Override
public
GroupDTO
mapFromAttributes
(
Attributes
attributes
)
throws
NamingException
{
GroupDTO
groupDTO
=
new
GroupDTO
();
String
commonName
=
(
String
)
attributes
.
get
(
"cn"
).
get
();
if
(
commonName
!=
null
)
groupDTO
.
setCommonName
(
commonName
);
Attribute
gidNumber
=
attributes
.
get
(
"gidNumber"
);
if
(
gidNumber
!=
null
)
groupDTO
.
setGidNumber
(
Integer
.
valueOf
((
String
)
gidNumber
.
get
()));
return
groupDTO
;
}
}
src/main/java/edu/kit/scc/ldap/LdapClient.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.ldap
;
import
java.util.List
;
...
...
@@ -11,6 +19,7 @@ import org.springframework.ldap.core.LdapTemplate;
import
org.springframework.ldap.core.support.LdapContextSource
;
import
org.springframework.stereotype.Component
;
import
edu.kit.scc.dto.GroupDTO
;
import
edu.kit.scc.dto.UserDTO
;
@Component
...
...
@@ -22,10 +31,16 @@ public class LdapClient {
private
String
url
;
@Value
(
"${ldap.searchBase}"
)
private
String
base
;
private
String
searchBase
;
@Value
(
"${ldap.userBase}"
)
private
String
userBase
;
@Value
(
"${ldap.groupBase}"
)
private
String
groupBase
;
@Value
(
"${ldap.bindDn}"
)
private
String
d
n
;
private
String
bindD
n
;
@Value
(
"${ldap.bindPassword}"
)
private
String
password
;
...
...
@@ -34,8 +49,8 @@ public class LdapClient {
LdapContextSource
contextSource
()
{
LdapContextSource
ldapContextSource
=
new
LdapContextSource
();
ldapContextSource
.
setUrl
(
url
);
ldapContextSource
.
setBase
(
b
ase
);
ldapContextSource
.
setUserDn
(
d
n
);
ldapContextSource
.
setBase
(
searchB
ase
);
ldapContextSource
.
setUserDn
(
bindD
n
);
ldapContextSource
.
setPassword
(
password
);
return
ldapContextSource
;
}
...
...
@@ -46,26 +61,42 @@ public class LdapClient {
}
@Bean
L
DAP
UserDAO
ldapUser
(
LdapTemplate
ldapTemplate
)
{
L
DAP
UserDAO
ldapUserDAO
=
new
L
DAP
UserDAO
();
L
dap
UserDAO
ldapUser
(
LdapTemplate
ldapTemplate
)
{
L
dap
UserDAO
ldapUserDAO
=
new
L
dap
UserDAO
();
ldapUserDAO
.
setLdapTemplate
(
ldapTemplate
);
ldapUserDAO
.
setUserBase
(
userBase
);
return
ldapUserDAO
;
}
@Bean
LdapGroupDAO
ldapGroup
(
LdapTemplate
ldapTemplate
)
{
LdapGroupDAO
ldapGroupDAO
=
new
LdapGroupDAO
();
ldapGroupDAO
.
setLdapTemplate
(
ldapTemplate
);
ldapGroupDAO
.
setGroupBase
(
groupBase
);
return
ldapGroupDAO
;
}
@Autowired
private
L
DAP
UserDAO
ldapUser
;
private
L
dap
UserDAO
ldapUser
;
public
void
getLdapUser
()
{
List
<
UserDTO
>
userList
=
ldapUser
.
getAllUserNames
();
@Autowired
private
LdapGroupDAO
ldapGroup
;
public
void
getLdapUsers
()
{
List
<
UserDTO
>
userList
=
ldapUser
.
getAllUsers
();
for
(
int
i
=
0
;
i
<
userList
.
size
();
i
++)
log
.
info
(
"User name {}"
,
((
UserDTO
)
userList
.
get
(
i
)).
getCommonName
());
List
<
UserDTO
>
userDetails
=
ldapUser
.
getUserDetails
(
"
John Smith"
,
"S
mith"
);
List
<
UserDTO
>
userDetails
=
ldapUser
.
getUserDetails
(
"
js
mith
1
"
);
for
(
int
i
=
0
;
i
<
userDetails
.
size
();
i
++)
log
.
info
(
"Description {}"
,
((
UserDTO
)
userDetails
.
get
(
i
)).
getDescription
());
}
UserDTO
newUser
=
new
UserDTO
();
newUser
.
setCommonName
(
"me"
);
newUser
.
setLastName
(
"too"
);
ldapUser
.
insertUser
(
newUser
);
public
void
getLdapGroups
()
{
List
<
GroupDTO
>
groupList
=
ldapGroup
.
getAllGroups
();
for
(
int
i
=
0
;
i
<
groupList
.
size
();
i
++)
log
.
info
(
"Gropu name {}"
,
((
GroupDTO
)
groupList
.
get
(
i
)).
getCommonName
());
List
<
GroupDTO
>
groupDetails
=
ldapGroup
.
getGroupDetails
(
"user"
);
for
(
int
i
=
0
;
i
<
groupDetails
.
size
();
i
++)
log
.
info
(
"GidNumber {}"
,
((
GroupDTO
)
groupDetails
.
get
(
i
)).
getGidNumber
());
}
}
src/main/java/edu/kit/scc/ldap/LdapGroupDAO.java
0 → 100644
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.ldap
;
import
java.util.List
;
import
javax.naming.InvalidNameException
;
import
javax.naming.directory.Attributes
;
import
javax.naming.directory.BasicAttribute
;
import
javax.naming.directory.BasicAttributes
;
import
javax.naming.ldap.LdapName
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.ldap.core.LdapTemplate
;
import
org.springframework.ldap.filter.AndFilter
;
import
org.springframework.ldap.filter.EqualsFilter
;
import
org.springframework.ldap.support.LdapUtils
;
import
edu.kit.scc.dao.GroupDAO
;
import
edu.kit.scc.dto.GroupDTO
;
public
class
LdapGroupDAO
implements
GroupDAO
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
LdapGroupDAO
.
class
);
private
LdapTemplate
ldapTemplate
;
private
String
groupBase
;
public
void
setLdapTemplate
(
LdapTemplate
ldapTemplate
)
{
this
.
ldapTemplate
=
ldapTemplate
;
}
public
void
setGroupBase
(
String
groupBase
)
{
this
.
groupBase
=
groupBase
;
}
@Override
public
List
<
GroupDTO
>
getAllGroups
()
{
return
ldapTemplate
.
search
(
groupBase
,
"(objectclass=posixGroup)"
,
new
GroupAttributeMapper
());
}
@Override
public
List
<
GroupDTO
>
getGroupDetails
(
String
commonName
)
{
AndFilter
andFilter
=
new
AndFilter
();
andFilter
.
and
(
new
EqualsFilter
(
"objectclass"
,
"posixGroup"
)).
and
(
new
EqualsFilter
(
"cn"
,
commonName
));
log
.
debug
(
"LDAP query {}"
,
andFilter
.
encode
());
return
ldapTemplate
.
search
(
groupBase
,
andFilter
.
encode
(),
new
GroupAttributeMapper
());
}
@Override
public
void
insertGroup
(
GroupDTO
groupDTO
)
{
BasicAttribute
posixGroupBasicAttribute
=
new
BasicAttribute
(
"objectclass"
);
posixGroupBasicAttribute
.
add
(
"posixGroup"
);
Attributes
posixGroupAttributes
=
new
BasicAttributes
();
posixGroupAttributes
.
put
(
posixGroupBasicAttribute
);
posixGroupAttributes
.
put
(
"cn"
,
groupDTO
.
getCommonName
());
posixGroupAttributes
.
put
(
"gidNumber"
,
groupDTO
.
getGidNumber
());
LdapName
newGroupDN
=
LdapUtils
.
emptyLdapName
();
try
{
newGroupDN
=
new
LdapName
(
groupBase
);
newGroupDN
.
add
(
"cn="
+
groupDTO
.
getCommonName
());
log
.
debug
(
newGroupDN
.
toString
());
// ldapTemplate.bind(newUserDN, null, personAttributes);
}
catch
(
InvalidNameException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
updateGroup
(
GroupDTO
groupDTO
)
{
BasicAttribute
posixGroupBasicAttribute
=
new
BasicAttribute
(
"objectclass"
);
posixGroupBasicAttribute
.
add
(
"posixGroup"
);
Attributes
posixGroupAttributes
=
new
BasicAttributes
();
posixGroupAttributes
.
put
(
posixGroupBasicAttribute
);
posixGroupAttributes
.
put
(
"cn"
,
groupDTO
.
getCommonName
());
posixGroupAttributes
.
put
(
"gidNumber"
,
groupDTO
.
getGidNumber
());
LdapName
newGroupDN
=
LdapUtils
.
emptyLdapName
();
try
{
newGroupDN
=
new
LdapName
(
groupBase
);
newGroupDN
.
add
(
"cn="
+
groupDTO
.
getCommonName
());
log
.
debug
(
newGroupDN
.
toString
());
// ldapTemplate.bind(newUserDN, null, personAttributes);
}
catch
(
InvalidNameException
e
)
{
e
.
printStackTrace
();
}
}
@Override
public
void
deleteGroup
(
GroupDTO
groupDTO
)
{
LdapName
newGroupDN
=
LdapUtils
.
emptyLdapName
();
try
{
newGroupDN
=
new
LdapName
(
groupBase
);
newGroupDN
.
add
(
"cn="
+
groupDTO
.
getCommonName
());
log
.
debug
(
newGroupDN
.
toString
());
// ldapTemplate.unbind(newUserDN);
}
catch
(
InvalidNameException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/edu/kit/scc/ldap/L
DAP
UserDAO.java
→
src/main/java/edu/kit/scc/ldap/L
dap
UserDAO.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.ldap
;
import
java.util.List
;
...
...
@@ -18,26 +26,31 @@ import org.springframework.ldap.support.LdapUtils;
import
edu.kit.scc.dao.UserDAO
;
import
edu.kit.scc.dto.UserDTO
;
public
class
L
DAP
UserDAO
implements
UserDAO
{
public
class
L
dap
UserDAO
implements
UserDAO
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
L
DAP
UserDAO
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
L
dap
UserDAO
.
class
);
private
LdapTemplate
ldapTemplate
;
private
String
userBase
;
public
void
setLdapTemplate
(
LdapTemplate
ldapTemplate
)
{
this
.
ldapTemplate
=
ldapTemplate
;
}
public
void
setUserBase
(
String
userBase
)
{
this
.
userBase
=
userBase
;
}
@Override
public
List
<
UserDTO
>
getAllUser
Name
s
()
{
return
ldapTemplate
.
search
(
""
,
"(objectclass=person)"
,
new
UserAttributeMapper
());
public
List
<
UserDTO
>
getAllUsers
()
{
return
ldapTemplate
.
search
(
userBase
,
"(objectclass=person)"
,
new
UserAttributeMapper
());
}
@Override
public
List
<
UserDTO
>
getUserDetails
(
String
commonName
,
String
lastName
)
{
public
List
<
UserDTO
>
getUserDetails
(
String
uid
)
{
AndFilter
andFilter
=
new
AndFilter
();
andFilter
.
and
(
new
EqualsFilter
(
"objectclass"
,
"person"
)).
and
(
new
EqualsFilter
(
"cn"
,
commonName
))
.
and
(
new
EqualsFilter
(
"sn"
,
lastName
));
andFilter
.
and
(
new
EqualsFilter
(
"objectclass"
,
"person"
)).
and
(
new
EqualsFilter
(
"uid"
,
uid
));
log
.
debug
(
"LDAP query {}"
,
andFilter
.
encode
());
return
ldapTemplate
.
search
(
""
,
andFilter
.
encode
(),
new
UserAttributeMapper
());
...
...
@@ -45,7 +58,6 @@ public class LDAPUserDAO implements UserDAO {
@Override
public
void
insertUser
(
UserDTO
userDTO
)
{
BasicAttribute
personBasicAttribute
=
new
BasicAttribute
(
"objectclass"
);
personBasicAttribute
.
add
(
"person"
);
...
...
@@ -54,11 +66,12 @@ public class LDAPUserDAO implements UserDAO {
personAttributes
.
put
(
"cn"
,
userDTO
.
getCommonName
());
personAttributes
.
put
(
"sn"
,
userDTO
.
getLastName
());
personAttributes
.
put
(
"description"
,
userDTO
.
getDescription
());
personAttributes
.
put
(
"uid"
,
userDTO
.
getUid
());
LdapName
newUserDN
=
LdapUtils
.
emptyLdapName
();
try
{
newUserDN
=
new
LdapName
(
"o=sshService"
);
newUserDN
.
add
(
"uid="
+
userDTO
.
get
CommonName
());
newUserDN
=
new
LdapName
(
userBase
);
newUserDN
.
add
(
"uid="
+
userDTO
.
get
Uid
());
log
.
debug
(
newUserDN
.
toString
());
// ldapTemplate.bind(newUserDN, null, personAttributes);
}
catch
(
InvalidNameException
e
)
{
...
...
@@ -80,7 +93,7 @@ public class LDAPUserDAO implements UserDAO {
LdapName
newUserDN
=
LdapUtils
.
emptyLdapName
();
try
{
newUserDN
=
new
LdapName
(
"o=sshService"
);
newUserDN
=
new
LdapName
(
userBase
);
newUserDN
.
add
(
"uid="
+
userDTO
.
getCommonName
());
log
.
debug
(
newUserDN
.
toString
());
// ldapTemplate.rebind(newUserDN, null, personAttributes);
...
...
@@ -94,7 +107,7 @@ public class LDAPUserDAO implements UserDAO {
public
void
deleteUser
(
UserDTO
userDTO
)
{
LdapName
newUserDN
=
LdapUtils
.
emptyLdapName
();
try
{
newUserDN
=
new
LdapName
(
"o=sshService"
);
newUserDN
=
new
LdapName
(
userBase
);
newUserDN
.
add
(
"uid="
+
userDTO
.
getCommonName
());
log
.
debug
(
newUserDN
.
toString
());
// ldapTemplate.unbind(newUserDN);
...
...
@@ -103,5 +116,4 @@ public class LDAPUserDAO implements UserDAO {
e
.
printStackTrace
();
}
}
}
src/main/java/edu/kit/scc/ldap/UserAttributeMapper.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
*/
package
edu.kit.scc.ldap
;
import
javax.naming.NamingException
;
...
...
@@ -13,6 +21,9 @@ public class UserAttributeMapper implements AttributesMapper<UserDTO> {
@Override
public
UserDTO
mapFromAttributes
(
Attributes
attributes
)
throws
NamingException
{
UserDTO
userDTO
=
new
UserDTO
();
String
uid
=
(
String
)
attributes
.
get
(
"uid"
).
get
();
if
(
uid
!=
null
)
userDTO
.
setUid
(
uid
);
String
commonName
=
(
String
)
attributes
.
get
(
"cn"
).
get
();
if
(
commonName
!=
null
)
userDTO
.
setCommonName
(
commonName
);
...
...
src/main/java/edu/kit/scc/oidc/OidcClient.java
View file @
a583d6cc
/* Copyright 2016 Karlsruhe Institute of Technology (KIT)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.