Skip to content
Snippets Groups Projects
Commit 05912848 authored by George Peppard's avatar George Peppard
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
# Created by https://www.toptal.com/developers/gitignore/api/intellij+all,maven
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all,maven
### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
### Maven Patch ###
# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# End of https://www.toptal.com/developers/gitignore/api/intellij+all,maven
\ No newline at end of file
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gpeppard</groupId>
<artifactId>ecs-user-fetcher</artifactId>
<version>1.0-SNAPSHOT</version>
<name>ecs-user-fetcher</name>
<url>https://git.soton.ac.uk/gjp1g21/sc-web-scraper</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.17</maven.compiler.source>
<maven.compiler.target>1.17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-all</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.gpeppard.ecsuserfetcher;
/**
* A single instance of the program.
*
* @author George Peppard <gjp1g21@soton.ac.uk>
*/
public class EcsUserFetcher {
private final String ldapUsername;
private final String ldapPassword;
private final String query;
private final boolean detailed;
/**
* Constructs a new instance of SCWebScraper.
*
* We do not want everything to be static so instead, we use this object instead to hold (or
* call) the majority of program code.
*
* @param ldapUsername the LDAP username of the user accessing the data
* @param ldapPassword the LDAP password of the user accessing the data
* @param query the username of the user to search the database for
* @param detailed whether detailed output is returned, or just the user's full name
*/
public EcsUserFetcher(String ldapUsername, String ldapPassword, String query, boolean detailed) {
this.ldapUsername = ldapUsername;
this.ldapPassword = ldapPassword;
this.query = query;
this.detailed = detailed;
}
/**
* Run the application.
*/
public void run() {
}
}
package com.gpeppard.ecsuserfetcher;
import org.apache.commons.cli.*;
/**
* Main application class.
*
* @author George Peppard <gjp1g21@soton.ac.uk>
*/
public class Main {
/**
* Main program method. Handles parsing of options and determining where to route request.
*
* @param args CLI arguments
*/
public static void main(String[] args) {
CommandLineParser parser = new DefaultParser();
try {
CommandLine line = parser.parse(getCliOptions(), args);
if (line.hasOption("?")) {
showHelp();
} else {
bootstrap(line);
}
} catch (ParseException e) {
System.err.println("Argument parsing error: " + e.getMessage());
System.err.println("For help, run the program with the -? or --help arguments.");
}
}
/**
* Bootstraps an instance of EcsUserFetcher from which further logic can be executed, and checks for required args.
*
* To run the program, -u (LDAP username) and -p (LDAP password) are required. A query is also required which can
* be no longer than one word (as it is a username, and usernames cannot have spaces).
*
* @param cli the instance of {@code CommandLine} containing arguments
*/
private static void bootstrap(CommandLine cli) {
if (cli.hasOption("u") && cli.hasOption("p")) {
if (cli.getArgs().length == 1) {
EcsUserFetcher ecsUserFetcher = new EcsUserFetcher(
cli.getOptionValue("u"),
cli.getOptionValue("p"),
cli.getArgs()[0],
cli.hasOption("d")
);
ecsUserFetcher.run();
} else {
System.err.println("missing query, for help run with -? or --help");
}
} else {
System.err.println("-u and -p parameters are required, for help run with -? or --help");
}
}
/**
* Gets the valid CLI options that can be used with the program.
*
* @return the Options instance used by the program.
*/
private static Options getCliOptions() {
Option help = new Option("?", "help", false, "print this message");
Option detailed =
new Option(
"d",
"detailed",
false,
"whether detailed output is returned, or just the user's full name");
Option ldapUsername =
Option.builder("u")
.argName("username")
.hasArg()
.desc("fully qualified LDAP username to connect to the server")
.longOpt("ldap-username")
.build();
Option ldapPassword =
Option.builder("p")
.argName("password")
.hasArg()
.desc("LDAP password to connect to the server")
.longOpt("ldap-password")
.build();
Options options = new Options();
options.addOption(help);
options.addOption(detailed);
options.addOption(ldapUsername);
options.addOption(ldapPassword);
return options;
}
/** Outputs the help message to the command line. */
private static void showHelp() {
Options options = getCliOptions();
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("[options] [username]", options);
}
}
package com.gpeppard.ecsuserfetcher.models;
public class User {
}
package com.gpeppard;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment