config support
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -11,12 +11,8 @@ repositories {
|
|||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
|
implementation 'org.yaml:snakeyaml:1.29'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
|
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
@ -1,20 +1,52 @@
|
|||||||
package de.vincentschweiger.calltoj;
|
package de.vincentschweiger.calltoj;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.*;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mo. 18/10/2021 17:32
|
* Mo. 18/10/2021 17:32
|
||||||
*
|
*
|
||||||
* @author cook1e
|
* @author cook1e
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public class CallToJ {
|
public class CallToJ {
|
||||||
private static String snom_webadmin_user = "admin";
|
private static final File configFile = new File(new File(System.getProperty("user.home")), ".callto.yaml");
|
||||||
private static String snom_webadmin_pw = "x7eff15";
|
|
||||||
private static String hostname_snom = "snom765-901777.getcom.de";
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
configFile.createNewFile();
|
||||||
|
FileOutputStream outputStream = new FileOutputStream(configFile);
|
||||||
|
InputStream inputStream = CallToJ.class.getResourceAsStream("/template.yaml");
|
||||||
|
if (inputStream != null) {
|
||||||
|
IOUtils.copy(inputStream, outputStream);
|
||||||
|
inputStream.close();
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "IN is null");
|
||||||
|
outputStream.close();
|
||||||
|
configFile.delete();
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
outputStream.close();
|
||||||
|
JOptionPane.showMessageDialog(null, "You have to configure CallToJ!\n See .callto.yaml in your home directory!");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
FileInputStream inputStream = new FileInputStream(configFile);
|
||||||
|
Map<String, Object> obj = yaml.load(inputStream);
|
||||||
|
|
||||||
|
String snom_webadmin_user = obj.get("user").toString();
|
||||||
|
String snom_webadmin_pw = obj.get("password").toString();
|
||||||
|
String hostname_snom = obj.get("hostname").toString();
|
||||||
|
|
||||||
public static void main(String[] args) throws java.io.IOException {
|
|
||||||
String number;
|
String number;
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
number = "015904183517";
|
number = "015904183517";
|
||||||
@ -37,5 +69,8 @@ public class CallToJ {
|
|||||||
connection.setDoOutput(false);
|
connection.setDoOutput(false);
|
||||||
connection.setRequestProperty("Authorization", "Basic " + encoding);
|
connection.setRequestProperty("Authorization", "Basic " + encoding);
|
||||||
connection.getResponseCode();
|
connection.getResponseCode();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
src/main/resources/template.yaml
Normal file
3
src/main/resources/template.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
user: USERNAME
|
||||||
|
password: PASSWORD
|
||||||
|
hostname: HOSTNAME
|
Reference in New Issue
Block a user