Skip to content

Repo switch #1355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 6 additions & 28 deletions src/main/java/org/myrobotlab/framework/repo/Repo.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,18 @@ protected Repo() {
// FIXME reduce down to maven central bintray & repo.myrobotlab.org
remotes = new ArrayList<RemoteRepo>();
remotes.add(new RemoteRepo("central", "https://repo.maven.apache.org/maven2", "the mother load"));
// remotes.add(new RemoteRepo("bintray", "https://jcenter.bintray.com",
// "the big kahuna"));
// remotes.add(new RemoteRepo("bintray2", "https://dl.bintray.com", "more
// big kahuna"));
// old repo in AWS EC2
// remotes.add(new RemoteRepo("myrobotlab", "https://repo.myrobotlab.org/artifactory/myrobotlab", "all other mrl deps"));

// mrl repo for all other missing deps - requires personal access token to read (what a pain)
// created a read only package token for this purpose
remotes.add(new RemoteRepo("myrobotlab", "https://repo.myrobotlab.org/artifactory/myrobotlab", "all other mrl deps"));

remotes.add(new RemoteRepo("sarxos", "https://oss.sonatype.org/content/repositories/snapshots", "for sarxos webcam"));

// DO NOT INCLUDE - messed up repo !
// remotes.add(new RemoteRepo("dcm4che", "http://www.dcm4che.org/maven2",
// "for
// jai_imageio")); - do not use
remotes.add(new RemoteRepo("eclipse-release", "https://repo.eclipse.org/content/groups/releases"));

// remotes.add(new RemoteRepo("jmonkey",
// "https://dl.bintray.com/jmonkeyengine/org.jmonkeyengine", "jmonkey
// simulator"));

remotes.add(new RemoteRepo("oss-snapshots-repo", "https://oss.sonatype.org/content/groups/public", "sphinx"));
// remotes.add(new RemoteRepo("alfresco",
// "https://artifacts.alfresco.com/nexus/content/repositories/public",
// "swinggui mxgraph"));
// remotes.add(new RemoteRepo("talend",
// "https://nexus.talanlabs.com/content/repositories/releases/", "swinggui
// mxgraph"));

// probably safe to drop this one - maven central should have it
// remotes.add(new RemoteRepo("marytts", "http://mary.dfki.de/repo", "some
// marytts voices"));

// This one is needed because of a transient dependency of solr
// org.restlet.jee .. not sure where
// remotes.add(new RemoteRepo("maven-restlet",
// "https://maven.restlet.talend.com", "Public online Restlet
// repository"));

// This is the repo for the Java Discord API for the Discord Bot service
// lives.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/myrobotlab/service/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,7 @@ synchronized static public void install(String serviceType, Boolean blocking) {
@Override
public void run() {
try {
// r.getRepo().setKey(Runtime.getSecurity().getRepoKey());
if (serviceType == null) {
r.getRepo().install();
} else {
Expand Down
73 changes: 71 additions & 2 deletions src/main/java/org/myrobotlab/service/Security.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Base64;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -28,6 +29,7 @@
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
Expand Down Expand Up @@ -142,15 +144,17 @@ public static void main(String[] args) throws Exception {
// LoggingFactory.init(Level.INFO);

Runtime.getInstance(args);

Security security = Runtime.getSecurity();
System.out.println(security.encrypt("repo-key"));
System.out.println(security.getRepoKey());

Runtime.start("gui", "SwingGui");
// Security security = Security.getInstance();
// initializeStore("im a rockin rocker");
Runtime.getSecurity().setKey("myKeyName", "XXDDLKERIOEJKLJ##$KJKJ#LJ@@");
String key = Runtime.getSecurity().getKey("myKeyName");
log.info("key is {}", key);

Security security = Runtime.getSecurity();

security.setKey("amazon.polly.user.key", "XXXXXXXXXXXXXX");
security.setKey("amazon.polly.user.secret", "XXXXXXXXXXXXXXXXXXXXXXXXXXXX");
Expand Down Expand Up @@ -221,6 +225,10 @@ public Security(String n, String id) {
public boolean addGroup(String groupId) {
return addGroup(groupId, false);
}

public String getRepoKey() {
return decrypt(encryptedRepoKey);
}

public boolean addGroup(String groupId, boolean defaultAccess) {
Group g = new Group();
Expand Down Expand Up @@ -784,5 +792,66 @@ public ServiceConfig apply(ServiceConfig c) {
public ServiceConfig getConfig() {
return config;
}

/**
* 16 byte initialization vector
*/
private String initVector = "myrobotlabrocks!";

/**
* At some point this could be replaced by the users key, but
* currently we only need this to decrypt repo reader personal access token
* to download dependency libraries from github, which SHOULD NOT require a
* PAT anyway
*/
private String key = "replcewthuserkey";

private String encryptedRepoKey = "yKPc6MH7zpRVE58Utji8uq26At64qn6fmDbXMhObcLHWVp451ONpXu6MHNUZj5Lp";

public String encrypt(String toEncrypt) {
return encrypt(key, initVector, toEncrypt);
}


public String encrypt(String key, String initVector, String toEncrypt) {
try {
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");

Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);

byte[] encrypted = cipher.doFinal(toEncrypt.getBytes());

return Base64.getEncoder().encodeToString(encrypted);
} catch (Exception e) {
e.printStackTrace();
}

return null;
}

public String decrypt(String encrypted) {
return decrypt(key, initVector, encrypted);
}

public String decrypt(String key, String initVector, String encrypted) {
try {
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");

Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);

byte[] original = cipher.doFinal(Base64.getDecoder().decode(encrypted));

return new String(original);
} catch (Exception e) {
e.printStackTrace();
}

return null;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ChessGameMeta extends MetaData {
*/
public ChessGameMeta() {
addCategory("game");
addDependency("ChessBoard", "ChessBoard", "1.0.0");
addDependency("ChessBoard", "chessboard", "1.0.0");
addDescription("Would you like to play a game?");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Deeplearning4jMeta() {
addDependency("org.deeplearning4j", "deeplearning4j-modelimport", dl4jVersion);

// the miniXCEPTION network / model for emotion detection on detected faces
addDependency("miniXCEPTION", "miniXCEPTION", "0.0", "zip");
addDependency("miniXCEPTION", "minixception", "0.0", "zip");

if (!cudaEnabled) {
// By default support native CPU execution.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/myrobotlab/service/meta/WiiDarMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WiiDarMeta extends MetaData {
public WiiDarMeta() {

addDescription("WiiDar.... who dar? WiiDar!");
addDependency("wiiusej", "wiiusej", "wiiusej");
addDependency("wiiusej", "wiiusej", "0.0.1");
addCategory("sensors");
// no longer have hardware for this ...
setAvailable(false);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/myrobotlab/service/meta/WiiMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public WiiMeta() {
addDescription("Wii mote control and sensor info");
addCategory("control", "sensors");

addDependency("wiiusej", "wiiusej", "wiiusej");
addDependency("wiiusej", "wiiusej", "0.0.1");
//

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<ivysettings>
<credentials host="maven.pkg.github.com" realm="GitHub Package Registry" username="supertick" passwd="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"/>
<settings defaultResolver="public"/>
<resolvers>
<chain name="public">
Expand Down