2 * Copyright (C) 2012-2017 Tobias Brunner
3 * Copyright (C) 2012 Giuliano Grassi
4 * Copyright (C) 2012 Ralf Sager
5 * HSR Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 package org
.strongswan
.android
.data
;
21 import java
.util
.UUID
;
23 public class VpnProfile
implements Cloneable
25 /* While storing this as EnumSet would be nicer this simplifies storing it in a database */
26 public static final int SPLIT_TUNNELING_BLOCK_IPV4
= 1;
27 public static final int SPLIT_TUNNELING_BLOCK_IPV6
= 2;
29 private String mName
, mGateway
, mUsername
, mPassword
, mCertificate
, mUserCertificate
;
30 private String mRemoteId
, mLocalId
, mExcludedSubnets
, mIncludedSubnets
, mSelectedApps
;
31 private Integer mMTU
, mPort
, mSplitTunneling
;
32 private SelectedAppsHandling mSelectedAppsHandling
= SelectedAppsHandling
.SELECTED_APPS_DISABLE
;
33 private VpnType mVpnType
;
35 private long mId
= -1;
37 public enum SelectedAppsHandling
39 SELECTED_APPS_DISABLE(0),
40 SELECTED_APPS_EXCLUDE(1),
41 SELECTED_APPS_ONLY(2);
43 private Integer mValue
;
45 SelectedAppsHandling(int value
)
50 public Integer
getValue()
58 this.mUUID
= UUID
.randomUUID();
66 public void setId(long id
)
71 public void setUUID(UUID uuid
)
81 public String
getName()
86 public void setName(String name
)
91 public String
getGateway()
96 public void setGateway(String gateway
)
98 this.mGateway
= gateway
;
101 public VpnType
getVpnType()
106 public void setVpnType(VpnType type
)
108 this.mVpnType
= type
;
111 public String
getUsername()
116 public void setUsername(String username
)
118 this.mUsername
= username
;
121 public String
getPassword()
126 public void setPassword(String password
)
128 this.mPassword
= password
;
131 public String
getCertificateAlias()
136 public void setCertificateAlias(String alias
)
138 this.mCertificate
= alias
;
141 public String
getUserCertificateAlias()
143 return mUserCertificate
;
146 public void setUserCertificateAlias(String alias
)
148 this.mUserCertificate
= alias
;
151 public String
getLocalId()
156 public void setLocalId(String localId
)
158 this.mLocalId
= localId
;
161 public String
getRemoteId()
166 public void setRemoteId(String remoteId
)
168 this.mRemoteId
= remoteId
;
171 public Integer
getMTU()
176 public void setMTU(Integer mtu
)
181 public Integer
getPort()
186 public void setPort(Integer port
)
191 public void setExcludedSubnets(String excludedSubnets
)
193 this.mExcludedSubnets
= excludedSubnets
;
196 public String
getExcludedSubnets()
198 return mExcludedSubnets
;
201 public void setIncludedSubnets(String includedSubnets
)
203 this.mIncludedSubnets
= includedSubnets
;
205 public String
getIncludedSubnets()
207 return mIncludedSubnets
;
210 public void setSelectedApps(String selectedApps
)
212 this.mSelectedApps
= selectedApps
;
215 public String
getSelectedApps()
217 return mSelectedApps
;
220 public void setSelectedAppsHandling(SelectedAppsHandling selectedAppsHandling
)
222 this.mSelectedAppsHandling
= selectedAppsHandling
;
225 public void setSelectedAppsHandling(Integer value
)
227 mSelectedAppsHandling
= SelectedAppsHandling
.SELECTED_APPS_DISABLE
;
228 for (SelectedAppsHandling handling
: SelectedAppsHandling
.values())
230 if (handling
.mValue
.equals(value
))
232 mSelectedAppsHandling
= handling
;
238 public SelectedAppsHandling
getSelectedAppsHandling()
240 return mSelectedAppsHandling
;
243 public Integer
getSplitTunneling()
245 return mSplitTunneling
;
248 public void setSplitTunneling(Integer splitTunneling
)
250 this.mSplitTunneling
= splitTunneling
;
254 public String
toString()
260 public boolean equals(Object o
)
262 if (o
!= null
&& o
instanceof VpnProfile
)
264 VpnProfile other
= (VpnProfile
)o
;
265 if (this.mUUID
!= null
&& other
.getUUID() != null
)
267 return this.mUUID
.equals(other
.getUUID());
269 return this.mId
== other
.getId();
275 public VpnProfile
clone()
279 return (VpnProfile
)super.clone();
281 catch (CloneNotSupportedException e
)
283 throw new AssertionError();