Class Overview
This class provides APIs to set and get the device global proxy.
Summary
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public Methods
API to get the information about the Global proxy.
Returns
ProxyProperties
object describing the current Global Proxy, or
null
in case there is no Global Proxy set.
Usage
Administrator should call this API to retrieve a ProxyProperties object
containing all information about the Global Proxy current configured on the device.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
GlobalProxy globalProxy = edm.getGlobalProxy();
ProxyProperties proxyProperties;
try {
proxyProperties = globalProxy.getGlobalProxy();
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_GLOBALPROXY" permission which has a protection level
of signature. |
public
int
setGlobalProxy
(ProxyProperties properties)
Deprecated
in API level 35
API to set a Global Proxy on the device.
Parameters
properties
| ProxyProperties object with proxy information. Use
null to remove global proxy. |
Returns
1
if policy was successfully set; 0
otherwise.
Usage
Administrator will be able to set a Global Proxy on the device. Such proxy will work
both for Wifi and Data connections. This proxy may not be considered by some applications
(e.g. applications that directly open a socket with the final server), although it is used by
most of them. Applications might retry connections without using the global proxy whenever
the proxy is unreachable or the authentication fails.
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
GlobalProxy globalProxy = edm.getGlobalProxy();
try {
// 1. static proxy configuration
String hostName = "128.128.128.128";
int portNumber = 80;
List<String> exclusionList = new ArrayList<String>();
exclusionList.add("102.103.22.202");
exclusionList.add("www.samsung.com");
ProxyProperties staticProxy = new ProxyProperties();
staticProxy.setHostname(hostName);
staticProxy.setPortNumber(portNumber);
staticProxy.setExclusionList(exclusionList);
// optional, set up authentication for the given static proxy
staticProxy.setAuthConfigList(Arrays.asList(new AuthConfig[] {
new AuthConfig("user", "pass")
}));
int resultStatic = globalProxy.setGlobalProxy(staticProxy);
// 2. PAC proxy configuration
String pacFileUrl = "http://128.128.128.128/proxy.pac";
ProxyProperties automaticProxy = new ProxyProperties();
automaticProxy.setPacFileUrl(pacFileUrl);
// optional, set up authentication for the multiple proxies that could be returned in PAC file
automaticProxy.setAuthConfigList(Arrays.asList(new AuthConfig[] {
new AuthConfig("128.128.128.128", "3128", "user", "pass")
new AuthConfig("128.128.128.128", "3129", "user1", "pass1")
new AuthConfig("128.128.128.123", "3128", "user2", "pass2")
}));
int resultAutomatic = globalProxy.setGlobalProxy(automaticProxy);
} catch (SecurityException e) {
Log.w(TAG, "SecurityException: " + e);
}
|
Permission
The use of this API requires the caller to have the
"com.samsung.android.knox.permission.KNOX_SECURITY" permission which has a protection level
of signature. Moreover, this API also requires the caller to have the
"com.samsung.android.knox.permission.KNOX_GLOBALPROXY" permission which has a protection level
of signature. |