]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Make VpnType#fromIdentifier null-safe
authorMarkus Pfeiffer <markus.pfeiffer@relution.io>
Tue, 21 Nov 2023 14:37:24 +0000 (15:37 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 21 Feb 2024 11:24:53 +0000 (12:24 +0100)
src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnType.java

index 1a666734bca6ebc8a5b3fc5d39215f6651e35727..0552a645f027fadd6110d633af73027af075fd55 100644 (file)
 package org.strongswan.android.data;
 
 import java.util.EnumSet;
+import java.util.Objects;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 
 public enum VpnType
 {
@@ -32,11 +36,19 @@ public enum VpnType
         */
        public enum VpnTypeFeature
        {
-               /** client certificate is required */
+               /**
+                * Client certificate is required
+                */
                CERTIFICATE,
-               /** username and password are required */
+
+               /**
+                * Username and password are required
+                */
                USER_PASS,
-               /** enable BYOD features */
+
+               /**
+                * Enable BYOD features
+                */
                BYOD;
        }
 
@@ -48,7 +60,6 @@ public enum VpnType
         *
         * @param id identifier used to store and transmit this specific type
         * @param features of the given VPN type
-        * @param certificate true if a client certificate is required
         */
        VpnType(String id, EnumSet<VpnTypeFeature> features)
        {
@@ -58,6 +69,7 @@ public enum VpnType
 
        /**
         * The identifier used to store this value in the database
+        *
         * @return identifier
         */
        public String getIdentifier()
@@ -81,11 +93,12 @@ public enum VpnType
         * @param identifier get the enum entry with this identifier
         * @return the enum entry, or the default if not found
         */
-       public static VpnType fromIdentifier(String identifier)
+       @NonNull
+       public static VpnType fromIdentifier(@Nullable String identifier)
        {
                for (VpnType type : VpnType.values())
                {
-                       if (identifier.equals(type.mIdentifier))
+                       if (Objects.equals(identifier, type.mIdentifier))
                        {
                                return type;
                        }