forked from mami-project/KeyServer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from cne/develop
Develop
- Loading branch information
Showing
29 changed files
with
2,322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# KeyServer Change Log | ||
|
||
v0.1.3 | ||
-------------------------------------------------------------------------------- | ||
Features: | ||
- KeyServer accepts multiples connections (system default limited). | ||
- KeyServer log to a file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?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"> | ||
<name>KeyServer</name> | ||
<url>https://pdihub.hi.inet/cne/cne-keyserver</url> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>es.tid.keyserver</groupId> | ||
<artifactId>keyserver</artifactId> | ||
<version>v0.1.3</version> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.7</maven.compiler.source> | ||
<maven.compiler.target>1.7</maven.compiler.target> | ||
</properties> | ||
|
||
<developers> | ||
<developer> | ||
<id>jgm221</id> | ||
<name>Javier Gusano Martinez</name> | ||
<email>[email protected]</email> | ||
<properties> | ||
<active>true</active> | ||
</properties> | ||
</developer> | ||
<developer> | ||
<id>jgm1986</id> | ||
<name>Javier Gusano Martinez</name> | ||
<email>[email protected]</email> | ||
<properties> | ||
<active>true</active> | ||
</properties> | ||
</developer> | ||
<developer> | ||
<id>oscargdd</id> | ||
<name>Oscar Gonzalez de Dios</name> | ||
<email>[email protected]</email> | ||
<properties> | ||
<active>true</active> | ||
</properties> | ||
</developer> | ||
</developers> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>redis.clients</groupId> | ||
<artifactId>jedis</artifactId> | ||
<version>2.7.2</version> | ||
<type>jar</type> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.googlecode.json-simple</groupId> | ||
<artifactId>json-simple</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>1.10</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.12</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.1.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-core</artifactId> | ||
<version>1.1.3</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.6</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>keyserver/KeyServer</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<archive> | ||
<manifest> | ||
<mainClass>keyserver/KeyServer</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
126 changes: 126 additions & 0 deletions
126
KeyServer/src/main/java/es/tid/keyserver/config/ConfigFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* Copyright 2016. | ||
* | ||
* 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 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package es.tid.keyserver.config; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
import es.tid.keyserver.keyserver.CheckObject; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Class for use external configuration files. | ||
* @author <a href="mailto:[email protected]">Javier Gusano Martinez</a> | ||
*/ | ||
public class ConfigFile implements CheckObject{ | ||
/** | ||
* Logging object. | ||
*/ | ||
private static final org.slf4j.Logger logger = | ||
LoggerFactory.getLogger(ConfigFile.class); | ||
/** | ||
* Property object with configuration parameters. | ||
*/ | ||
private Properties configFile; | ||
/** | ||
* Flag for check if the object is correctly initialized. | ||
*/ | ||
boolean isInitializated = false; | ||
|
||
/** | ||
* Default class constructor. | ||
* @param fileRoute Contains the name and route to the external | ||
* configuration file. | ||
*/ | ||
public ConfigFile(String fileRoute){ | ||
File propertiesFile = new File(fileRoute); | ||
String fileLocation; | ||
if((propertiesFile.exists() && propertiesFile.canRead())){ | ||
fileLocation = fileRoute; | ||
} else { | ||
logger.warn("Can't access to the specified config file or " | ||
+ "doesn't exists: {}", fileRoute); | ||
System.out.print(" - New config file on default location..."); | ||
fileLocation = "general.properties"; | ||
newDefaultProperties(fileLocation); | ||
} | ||
configFile = new Properties(); | ||
// Load the config file parammeters. | ||
try { | ||
configFile.load(new FileInputStream(fileLocation)); | ||
this.isInitializated = true; | ||
} catch (IOException ex) { | ||
logger.error("Cannot load the configuration file for KeyServer."); | ||
logger.trace("Exceiption message: {}", ex.toString()); | ||
this.isInitializated = false; | ||
} | ||
} | ||
|
||
/** | ||
* This method is used to get a value from a configuration key. | ||
* @param param Label of the configuration parameter. | ||
* @return Value associated to the configuration parameter specified as | ||
* input. | ||
*/ | ||
public String getParameter(String param){ | ||
return configFile.getProperty(param); | ||
} | ||
|
||
/** | ||
* Method used to create a new configuration file on specific route with | ||
* default parameters. | ||
* @param fileLocation Route and name to the new configuration file. By | ||
* default use "general.properties" | ||
*/ | ||
private void newDefaultProperties(String fileLocation) { | ||
try { | ||
FileOutputStream newConfigFile = new FileOutputStream(fileLocation); | ||
Properties defaultParameters = new Properties(); | ||
// Default parammeters: | ||
defaultParameters.setProperty("serverAddress", "127.0.0.1"); | ||
defaultParameters.setProperty("serverPort", "443"); | ||
defaultParameters.setProperty("serverBacklog", "0"); | ||
defaultParameters.setProperty("serverKeyFile","HTTPS_keystore.ks"); | ||
defaultParameters.setProperty("serverKeyPass","123456"); | ||
defaultParameters.setProperty("dbAddress","127.0.0.1"); | ||
defaultParameters.setProperty("dbPort", "6379"); | ||
// Save parameters on file | ||
defaultParameters.store(newConfigFile, null); | ||
// Close config file. | ||
newConfigFile.close(); | ||
} catch (FileNotFoundException ex) { | ||
logger.error("Cannot create a new config file with default parameters."); | ||
logger.trace("Exceiption message: {}", ex.toString()); | ||
System.exit(-1); | ||
} catch (IOException ex) { | ||
logger.error("Cannot save a new config file with default parameters."); | ||
logger.trace("Exceiption message: {}", ex.toString()); | ||
System.exit(-1); | ||
} | ||
} | ||
|
||
/** | ||
* Return true if the object is correctly initialized or false if not. | ||
* @return Object initialization status. | ||
*/ | ||
@Override | ||
public boolean isCorrectlyInitialized() { | ||
return isInitializated; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
KeyServer/src/main/java/es/tid/keyserver/config/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* This package contains all necessary to load and manipulate external | ||
* configuration files for KeyServer. | ||
* <p> | ||
* The external configuration file contains all fields to determine how the | ||
* KeyServer tool will be run. | ||
* @since 0.1.0 | ||
*/ | ||
package es.tid.keyserver.config; |
Oops, something went wrong.