Skip to content
Snippets Groups Projects
Commit af36089f authored by William Enright's avatar William Enright
Browse files

removed redundant methods from authentication module, refactored checkVersion...

removed redundant methods from authentication module, refactored checkVersion method for manifest file checking
parent 38553678
No related branches found
No related tags found
No related merge requests found
......@@ -172,4 +172,18 @@ public class UserAuthenticationModule implements AuthenticationModule {
return (RSAPublicKey) publicKey;
}
@Override
public char[] getOTP(String username) {
if(datastore.userExists(username)){
StatementList statementList = new StatementList();
StatementElement statementElement = new StatementElement("username","=",username,"");
statementList.addStatement(statementElement);
User user = datastore.getUserDao().getObjects(statementList).get(0);
return (user.getPassword()).toCharArray();
}
return new char[0];
}
}
......@@ -20,9 +20,5 @@ public interface AuthenticationModule {
boolean testModuleConfiguration(AuthenticationSourceType type, String configuration);
boolean createUser(AuthenticationSourceType type, String realm, NameServer nameServer, User user);
RSAPublicKey getAuthModulePubKey();
boolean updateReset(User user, int needsReset);
boolean userExists(User user);
boolean userNeedsReset(User user);
boolean setNewOneTimePassword(String username, String otp);
char[] getOTP(String username);
}
......@@ -21,45 +21,9 @@ public class LicenseUtils {
String resp = "";
File file = new File(jarPath);
JarFile jar = new JarFile(file);
// first get all directories,
// then make those directory on the destination Path
for (Enumeration<JarEntry> enums = jar.entries(); enums.hasMoreElements(); ) {
JarEntry entry = (JarEntry) enums.nextElement();
String fileName = destinationDir + File.separator + entry.getName();
File f = new File(fileName);
if (fileName.endsWith("/")) {
f.mkdirs();
}
}
//now create all files
for (Enumeration<JarEntry> enums = jar.entries(); enums.hasMoreElements(); ) {
JarEntry entry = (JarEntry) enums.nextElement();
if (entry.toString().contains("META-INF/MANIFEST.MF")) {
String fileName = destinationDir + File.separator + entry.getName();
File f = new File(fileName);
if (!fileName.endsWith("/")) {
InputStream is = jar.getInputStream(entry);
FileOutputStream fos = new FileOutputStream(f);
// write contents of 'is' to 'fos'
while (is.available() > 0) {
fos.write(is.read());
}
fos.close();
is.close();
}
}
}
String manifestPath = destinationDir + "/META-INF/MANIFEST.MF";
Manifest manifest = new Manifest(new URL("file:///" + manifestPath).openStream());
Manifest manifest = jar.getManifest();
resp = manifest.getMainAttributes().getValue("Implementation-Version");
System.out.println("Found version: " + resp);
return resp;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment