diff --git a/.idea/dhbw.iml b/.idea/dhbw.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/dhbw.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a818314 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..308782f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/aviation/.idea/vcs.xml b/.idea/vcs.xml similarity index 100% rename from aviation/.idea/vcs.xml rename to .idea/vcs.xml diff --git a/Kapselung/Kapselung.iml b/Kapselung/Kapselung.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Kapselung/Kapselung.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Kapselung/src/Password.java b/Kapselung/src/Password.java new file mode 100644 index 0000000..648be10 --- /dev/null +++ b/Kapselung/src/Password.java @@ -0,0 +1,43 @@ +import java.security.SecureRandom; +import java.util.Objects; + +public class Password { + private String password = ""; + + private String checkStr(String s) { + if (s.isEmpty()) { + return "None"; + } + return s; + } + + public Boolean assign(String newPassword) { + if (password.isEmpty()) { + password = newPassword; + return true; + } + else { + return false; + } + } + + public Boolean change(String oldPassword, String newPassword) { + if (Objects.equals(oldPassword, password) && !oldPassword.isEmpty() && !newPassword.isEmpty()) { + password = newPassword; + return true; + } + return false; + } + + public Boolean check(String check_password) { + // protection against timing attacks + SecureRandom rng = new SecureRandom(); + try { + Thread.sleep(50 + (rng.nextInt() % 10)); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + return password.equals(check_password); + + } +} \ No newline at end of file diff --git a/Kapselung/src/Player.java b/Kapselung/src/Player.java new file mode 100644 index 0000000..19a9170 --- /dev/null +++ b/Kapselung/src/Player.java @@ -0,0 +1,27 @@ +public class Player { + private String name; + private String item; + + private String checkStr(String s) { + if (s.isEmpty()) { + return "None"; + } + return s; + } + + public String getItem() { + return item; + } + + public void setItem(String item) { + this.item = checkStr(item); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = checkStr(name); + } +} \ No newline at end of file diff --git a/aviation/.idea/misc.xml b/aviation/.idea/misc.xml deleted file mode 100644 index 07115cd..0000000 --- a/aviation/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/aviation/.idea/modules.xml b/aviation/.idea/modules.xml deleted file mode 100644 index ebe0693..0000000 --- a/aviation/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/aviation/.idea/uiDesigner.xml b/aviation/.idea/uiDesigner.xml deleted file mode 100644 index 2b63946..0000000 --- a/aviation/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file