Skip to content

Commit

Permalink
version 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclefevre committed Nov 9, 2020
1 parent 3b6eb6c commit edd6eb7
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 101 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

__... in 5 minutes.__

![](./www/react-logo.png) ![](./www/spring-boot-logo.png) ![](./www/adb-logo.png) ![](./www/graalvm-logo.png) ![](./www/ords-logo.png) ![](./www/nodejs-logo.png) ![](./www/maven-logo.png)
![](./www/react-logo.png) ![](./www/spring-boot-logo.png) ![](./www/adb-logo.png) ![](./www/graalvm-logo.png) ![](./www/ords-logo.png) ![](./www/nodejs-logo.png)

# 30 seconds installation steps

Expand All @@ -20,21 +20,21 @@ __... in 5 minutes.__
[![DRAGON Stack - React Frontend / Autonomous Backend](https://img.youtube.com/vi/X-10r-zji9E/0.jpg)](https://www.youtube.com/watch?v=X-10r-zji9E)

## Download
The latest stable release is v2.0.3.
The latest stable release is v2.0.4.

### Linux and [Oracle Cloud Infrastructure Cloud Shell](https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/cloudshellintro.htm):
```
rm -f ./dragon-linux-x86_64-2.0.3
wget https://github.com/loiclefevre/dragon/releases/download/v2.0.3/dragon-linux-x86_64-2.0.3
rm -f ./dragon-linux-x86_64-2.0.4
wget https://github.com/loiclefevre/dragon/releases/download/v2.0.4/dragon-linux-x86_64-2.0.4
chmod +x dragon-linux-*
```
### Windows:
```
powershell wget https://github.com/loiclefevre/dragon/releases/download/v2.0.3/dragon-windows-x86_64-2.0.3.exe -OutFile dragon-windows-x86_64-2.0.3.exe
powershell wget https://github.com/loiclefevre/dragon/releases/download/v2.0.4/dragon-windows-x86_64-2.0.4.exe -OutFile dragon-windows-x86_64-2.0.4.exe
```
### MAC OS:
```
curl -L -O https://github.com/loiclefevre/dragon/releases/download/v2.0.3/dragon-osx-x86_64-2.0.3
curl -L -O https://github.com/loiclefevre/dragon/releases/download/v2.0.4/dragon-osx-x86_64-2.0.4
chmod +x dragon-osx-*
```

Expand Down Expand Up @@ -125,32 +125,32 @@ Example from OCI Cloud Shell (Linux):

Linux and OCI Cloud Shell:
```
$ ./dragon-linux-x86_64-2.0.3
$ ./dragon-linux-x86_64-2.0.4
```

To load JSON data as well as provisioning (Linux and OCI Cloud Shell):
```
$ ./dragon-linux-x86_64-2.0.3 -loadjson
$ ./dragon-linux-x86_64-2.0.4 -loadjson
```

To load JSON data as well as provisioning and finally create a React application (Linux and OCI Cloud Shell):
```
$ ./dragon-linux-x86_64-2.0.3 -loadjson -create-react-app myfrontend
$ ./dragon-linux-x86_64-2.0.4 -loadjson -create-react-app myfrontend
```

Windows:
```
> dragon-windows-x86_64-2.0.3.exe
> dragon-windows-x86_64-2.0.4.exe
```

MAC OS:
```
$ ./dragon-osx-x86_64-2.0.3
$ ./dragon-osx-x86_64-2.0.4
```

To destroy your database (Linux and OCI Cloud Shell):
```
$ ./dragon-linux-x86_64-2.0.3 -destroy
$ ./dragon-linux-x86_64-2.0.4 -destroy
```

## Stacks
Expand Down
40 changes: 7 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>ST4</artifactId>
Expand Down Expand Up @@ -150,48 +156,16 @@
<buildArgs>
--no-fallback
-H:+ReportExceptionStackTraces
-H:+TraceClassInitialization
--allow-incomplete-classpath
--report-unsupported-elements-at-runtime
--enable-all-security-services
-H:EnableURLProtocols=https
-H:ConfigurationFileDirectories=../src/main/resources/META-INF/native-image
-H:+TraceClassInitialization
--initialize-at-build-time=sun.instrument.InstrumentationImpl
</buildArgs>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.8-1</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/javagen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
-->
</plugins>
</build>
</project>
25 changes: 17 additions & 8 deletions src/main/java/com/oracle/dragon/util/Console.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.oracle.dragon.util;

import java.awt.*;
import java.time.Duration;

/**
Expand All @@ -14,6 +13,16 @@ public class Console {

public final static int MAX_COLUMNS = 80;

public static class Color {
public final int r,g,b;

public Color(int r, int g, int b) {
this.r = r;
this.g = g;
this.b = b;
}
}

// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#screen-colors
public enum Style {
ANSI_RESET("\u001B[0m"),
Expand Down Expand Up @@ -129,21 +138,21 @@ public static void printGradient(Color from, Color to, String msg, boolean brigh

final int length = msg.length();

int r = from.getRed();
int g = from.getGreen();
int b = from.getBlue();
int r = from.r;
int g = from.g;
int b = from.b;

double rd = r;
double gd = g;
double bd = b;

final double rInc = (to.getRed() - from.getRed()) / (double)length;
final double gInc = (to.getGreen() - from.getGreen()) / (double)length;
final double bInc = (to.getBlue() - from.getBlue()) / (double)length;
final double rInc = (to.r - from.r) / (double)length;
final double gInc = (to.g - from.g) / (double)length;
final double bInc = (to.b - from.b) / (double)length;

for (int i = 0; i < length; i++) {
if (i == length - 1) {
s.append(String.format("\u001B[38;2;%d;%d;%dm", to.getRed(), to.getGreen(), to.getBlue()));
s.append(String.format("\u001B[38;2;%d;%d;%dm", to.r, to.g, to.b));
} else {
s.append(String.format("\u001B[38;2;%d;%d;%dm", r, g, b));
rd += rInc;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/oracle/dragon/util/DSSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.oracle.dragon.stacks.StackType;
import com.oracle.dragon.util.exception.*;

import java.awt.*;
import java.io.*;
import java.net.*;
import java.net.http.HttpClient;
Expand Down Expand Up @@ -243,7 +242,7 @@ enum LicenseType {

private static void banner() {
if (ENABLE_COLORS && platform == Platform.Windows && !vscode) {
printGradient(new Color(199,52,46), Color.yellow, String.format("DRAGON Stack manager v%s", VERSION), true, true);
printGradient(new Console.Color(199,52,46), new Console.Color(255,255,0), String.format("DRAGON Stack manager v%s", VERSION), true, true);
} else {
print(String.format("%sDRAGON Stack manager v%s", Style.ANSI_TITLE, VERSION));
}
Expand Down Expand Up @@ -423,7 +422,7 @@ public static void printlnConfigurationTemplate(final boolean hasToCreateKeys, f
section.print("pending");

try {
keys = KeysUtil.createKeys(passPhrase);
keys = new KeysUtil().createKeys(passPhrase);
section.printlnOK("Upload the Public Key");
println("Please upload this " + ANSI_YELLOW + "public" + ANSI_RESET + " key to your Oracle Cloud Infrastructure user's API Keys:");
println();
Expand Down
51 changes: 10 additions & 41 deletions src/main/java/com/oracle/dragon/util/KeysUtil.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
package com.oracle.dragon.util;

import com.oracle.dragon.model.Keys;
import com.oracle.svm.core.annotate.AutomaticFeature;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
import org.bouncycastle.openssl.jcajce.JcePEMEncryptorBuilder;
import org.graalvm.nativeimage.hosted.Feature;
import org.graalvm.nativeimage.hosted.RuntimeClassInitialization;

import javax.crypto.*;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.InvalidParameterSpecException;
import java.security.spec.RSAKeyGenParameterSpec;
import java.util.Base64;
import java.util.Random;

public final class KeysUtil {
public static Keys createKeys(final String passPhrase) throws Exception {
@AutomaticFeature
public final class KeysUtil implements Feature {
@Override
public void afterRegistration(AfterRegistrationAccess access) {
RuntimeClassInitialization.initializeAtBuildTime("org.bouncycastle");
// see https://www.bouncycastle.org/fips-java/BCFipsIn100.pdf
Security.addProvider(new BouncyCastleProvider());
}

public Keys createKeys(final String passPhrase) throws Exception {
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "BC");
kpg.initialize(new RSAKeyGenParameterSpec(2048, RSAKeyGenParameterSpec.F4));
final KeyPair kp = kpg.generateKeyPair();
Expand Down Expand Up @@ -94,37 +96,4 @@ private static String chunk(String encoded, int maxColumns) {

return s.toString();
}

private static byte[] encryptWithPassPhrase(byte[] encodedprivkey, String passPhrase) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidParameterSpecException, IOException {
// We must use a PasswordBasedEncryption algorithm in order to encrypt the private key, you may use any common algorithm supported by openssl, you can check them in the openssl documentation http://www.openssl.org/docs/apps/pkcs8.html
String MYPBEALG = "PBEWithSHA1AndDESede";

final int count = 10000 + new Random().nextInt(1000);// hash iteration count
final SecureRandom random = new SecureRandom();
final byte[] salt = new byte[8];
random.nextBytes(salt);

// Create PBE parameter set
final PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, count);
final PBEKeySpec pbeKeySpec = new PBEKeySpec(passPhrase.toCharArray());
final SecretKeyFactory keyFac = SecretKeyFactory.getInstance(MYPBEALG);
final SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

final Cipher pbeCipher = Cipher.getInstance(MYPBEALG);

// Initialize PBE Cipher with key and parameters
pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);

// Encrypt the encoded Private Key with the PBE key
byte[] ciphertext = pbeCipher.doFinal(encodedprivkey);

// Now construct PKCS #8 EncryptedPrivateKeyInfo object
AlgorithmParameters algparms = AlgorithmParameters.getInstance(MYPBEALG);
algparms.init(pbeParamSpec);
EncryptedPrivateKeyInfo encinfo = new EncryptedPrivateKeyInfo(algparms, ciphertext);

// and here we have it! a DER encoded PKCS#8 encrypted key!
return encinfo.getEncoded();
}

}
8 changes: 4 additions & 4 deletions src/main/resources/META-INF/native-image/reflect-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,10 @@
{
"name":"org.glassfish.jersey.internal.util.collection.ConcurrentHashMapV8",
"fields":[
{"name":"baseCount", "allowUnsafeAccess":true},
{"name":"cellsBusy", "allowUnsafeAccess":true},
{"name":"sizeCtl", "allowUnsafeAccess":true},
{"name":"transferIndex", "allowUnsafeAccess":true},
{"name":"baseCount", "allowUnsafeAccess":true},
{"name":"cellsBusy", "allowUnsafeAccess":true},
{"name":"sizeCtl", "allowUnsafeAccess":true},
{"name":"transferIndex", "allowUnsafeAccess":true},
{"name":"transferOrigin", "allowUnsafeAccess":true}
]
},
Expand Down
Binary file modified www/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed www/maven-logo.png
Binary file not shown.

0 comments on commit edd6eb7

Please sign in to comment.