summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/com/wireguard/config/Profile.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/src/main/java/com/wireguard/config/Profile.java b/app/src/main/java/com/wireguard/config/Profile.java
index e04cab3e..a0388427 100644
--- a/app/src/main/java/com/wireguard/config/Profile.java
+++ b/app/src/main/java/com/wireguard/config/Profile.java
@@ -32,15 +32,15 @@ public class Profile extends BaseObservable implements Copyable<Profile>, Observ
public Profile(String name) {
super();
+ if (!isNameValid(name))
+ throw new IllegalArgumentException();
this.name = name;
}
private Profile(Profile original)
throws IOException {
this(original.getName());
- final byte configBytes[] = original.toString().getBytes(StandardCharsets.UTF_8);
- final ByteArrayInputStream configStream = new ByteArrayInputStream(configBytes);
- parseFrom(configStream);
+ parseFrom(original);
}
public Profile copy() {
@@ -90,6 +90,13 @@ public class Profile extends BaseObservable implements Copyable<Profile>, Observ
}
}
+ public void parseFrom(Profile profile)
+ throws IOException {
+ final byte configBytes[] = profile.toString().getBytes(StandardCharsets.UTF_8);
+ final ByteArrayInputStream configStream = new ByteArrayInputStream(configBytes);
+ parseFrom(configStream);
+ }
+
public void setIsConnected(boolean isConnected) {
this.isConnected = isConnected;
notifyPropertyChanged(BR.isConnected);