Commit 256832a0 authored by benjamin.ertl's avatar benjamin.ertl
Browse files

add comments

parent a583d6cc
......@@ -26,8 +26,15 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
/**
* Custom SSL context generation class.
*
* @author benjamin
*
*/
public final class CustomSSLContext {
// example cert
@SuppressWarnings("unused")
private static final String cert = "-----BEGIN CERTIFICATE-----\n"
+ "MIICNTCCAZ6gAwIBAgIES343gjANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJV"
......@@ -46,6 +53,13 @@ public final class CustomSSLContext {
private CustomSSLContext() {
}
/**
* Initializes a SSL context with the given certificate.
*
* @param cert
* the X.509 certificate for the context
* @return a {@link SSLContext}
*/
public static SSLContext initSslContextWithCertificate(String cert) {
SSLContext sslContext = null;
......@@ -92,6 +106,11 @@ public final class CustomSSLContext {
return sslContext;
}
/**
* Initializes an empty SSL context.
*
* @return a {@link SSLContext}
*/
public static SSLContext initEmptySslContext() {
SSLContext sslContext = null;
try {
......
......@@ -19,6 +19,12 @@ import javax.net.ssl.SSLContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Custom URL connection generation class.
*
* @author benjamin
*
*/
public final class CustomUrlConnection {
private static final Logger log = LoggerFactory.getLogger(CustomUrlConnection.class);
......@@ -26,6 +32,15 @@ public final class CustomUrlConnection {
private CustomUrlConnection() {
}
/**
* Initializes a HTTPS URL connection.
*
* @param checkCertificate
* enables certificate check
* @param url
* the URL to connect to
* @return a {@link HttpsURLConnection}
*/
public static HttpsURLConnection getSecureHttpConnection(boolean checkCertificate, String url) {
HttpsURLConnection urlConnection = null;
try {
......@@ -56,6 +71,13 @@ public final class CustomUrlConnection {
return urlConnection;
}
/**
* Initializes a HTTP URL connection.
*
* @param url
* the URL to connect to
* @return a {@link HttpURLConnection}
*/
public static HttpURLConnection getHttpConnection(String url) {
HttpURLConnection urlConnection = null;
try {
......
......@@ -22,6 +22,12 @@ import org.springframework.stereotype.Component;
import edu.kit.scc.dto.GroupDTO;
import edu.kit.scc.dto.UserDTO;
/**
* LDAP client implementation.
*
* @author benjamin
*
*/
@Component
public class LdapClient {
......@@ -82,21 +88,29 @@ public class LdapClient {
@Autowired
private LdapGroupDAO ldapGroup;
public void getLdapUsers() {
/**
* Gets all users from the LDAP server.
*
* @return a {@link List<UserDTO>} with the LDAP user information
*/
public List<UserDTO> 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("jsmith1");
for (int i = 0; i < userDetails.size(); i++)
log.info("Description {}", ((UserDTO) userDetails.get(i)).getDescription());
return userList;
}
public void getLdapGroups() {
/**
* Gets all groups from the LDAP server.
*
* @return a {@link List<GroupDTO>} with the LDAP group information
*/
public List<GroupDTO> 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());
return groupList;
}
}
......@@ -83,6 +83,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
/**
* SAML client implementation.
*
* @author benjamin
*
*/
public class SamlClient {
private static final Logger log = LoggerFactory.getLogger(SamlClient.class);
......
......@@ -25,8 +25,12 @@ public class LdapClientTests {
private LdapClient ldapClient;
@Test
public void ldapClientTest() {
public void getLdapGroupsTest() {
ldapClient.getLdapGroups();
}
@Test
public void getLdapUsersTest() {
ldapClient.getLdapUsers();
}
}
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