Since: API level 11
public class

ExchangeAccount

extends Object
implements Parcelable
java.lang.Object
   ↳ com.samsung.android.knox.accounts.ExchangeAccount

Deprecated in API level 27

Class Overview

This class contains all the account information for a given email (EAS) account. Some configuration value has dependency on Microsoft Exchange ActiveSync protocol version.

Since
API level 11
MDM 5.0

Summary

Constants
int SET_SMIME_CERTIFICATE_ALL SMIME certificate mode by encryption and signing
int SET_SMIME_CERTIFICATE_BY_ENCRYPTION SMIME certificate mode by encryption
int SET_SMIME_CERTIFICATE_BY_SIGNING SMIME certificate mode by signing
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public boolean acceptAllCertificates true to accept all certificates sent by the server
public String certificateAlias Authentication certificate alias to be set upon account creation (optional; can be null).
public byte[] certificateData Certificate binary (optional can be null)
public String certificatePassword Certificate password to extract information (optional; can be null)
public String certificateStorageName Credential storage name where certificateAlias shall be stored (optional; can be null).
public String displayName The display name of the account
public String easDomain Account domain
public String easUser The user of the account
public String emailAddress The email address corresponding to the account
public boolean emailNotificationVibrateAlways true to always vibrate on email notification
public boolean isDefault true to make this account the default
public boolean isNotify true to notify user on receiving new mail
public int offPeak Frequency to sync email during off-peak time Value -2 - Automatic push Value -1 - Never Value 5 - 5 minutes Value 10 - 10 minutes Value 15 - 15 minutes Value 30 - 30 minutes Value 60 - 1 hour Value 240 - 4 hours Value 720 - 12 hours
public int peakDays Peak days for sync schedule.
public int peakEndTime Peak end time in minutes.
public int peakStartTime Peak start time in minutes.
public int periodCalendar Number of previous days Calendar to sync Value 0 - All Value 4 - 2 weeks Value 5 - 1 month Value 6 - 3 months Value 7 - 6 months
public String protocolVersion Protocol version of Microsoft Exchange ActiveSync (EAS only)
public int retrivalSize Email retrieval size Value 0 - Headers only Value 1 - 0.5 KB Value 2 - 1 KB Value 3 - 2 KB Value 4 - 5 KB Value 5 - 10 KB Value 6 - 20 KB Value 7 - 50 KB Value 8 - 100 KB Value 9 - All
NOTE: Some ActiveSync protocol versions with EAS 2003 do not support value 9.
public int roamingSchedule 0 - Manual 1 - Use sync settings
public String senderName User name for outgoing messages
public String serverAddress The server address corresponding to this account
public String serverPassword The server password corresponding to this account
public String serverPathPrefix The server path Prefix corresponding to this account
public String signature Signature to use with the account
public int smimeCertificateMode Set certificate mode when account creation time.
public String smimeCertificatePassword SMIME certificate password when account creation time
public String smimeCertificatePath SMIME certificate path when account creation time
public int syncCalendar syncCalendar = true, then account syncs calendar information syncCalendar = false, then account does not sync calendar information
public int syncContacts syncContacts = true, then account syncs contacts information syncContacts = false ,then account does not sync contacts information
public int syncInterval Frequency to sync email during peak time Value -2 - Automatic push, Value -1 - Never, Value 5 - 5 minutes, Value 10 - 10 minutes, Value 15 - 15 minutes Value 30 - 30 minutes, Value 60 - 1 hour, Value 60 - 1 hour, Value 240 - 4 hours, Value 720 - 12 hours
public int syncLookback Number of previous days to sync email Value 1 - 1 day, Value 2 - 3 days, Value 3 - 1 week, Value 4 - 2 weeks, Value 5 - 1 month
public boolean useSSL true to use Secure Sockets Layer (SSL)
Public Constructors
ExchangeAccount(String emailAddress, String easUser, String easDomain, String serverAddress, String serverPassword)
Struct to add a new Microsoft Exchange account with base parameters.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final int SET_SMIME_CERTIFICATE_ALL

Since: API level 11

SMIME certificate mode by encryption and signing

Since
API level 11
MDM 5.0
Constant Value: 1 (0x00000001)

public static final int SET_SMIME_CERTIFICATE_BY_ENCRYPTION

Since: API level 20

SMIME certificate mode by encryption

Since
API level 20
MDM 5.7
Constant Value: 2 (0x00000002)

public static final int SET_SMIME_CERTIFICATE_BY_SIGNING

Since: API level 11

SMIME certificate mode by signing

Since
API level 11
MDM 5.0
Constant Value: 3 (0x00000003)

Fields

public boolean acceptAllCertificates

Since: API level 11

true to accept all certificates sent by the server

Since
API level 11
MDM 5.0

public String certificateAlias

Since: API level 20

Authentication certificate alias to be set upon account creation (optional; can be null). If not empty, takes precedence over certificate data from certificateData and certificatePassword.

If certificateStorageName is null, certificate must be installed either in Client Certificate Manager (CCM) or KEYSTORE_FOR_VPN_AND_APPS keystore. Please refer either to CCM APIs (KNOX Premium SDK) or installCertificateToKeystore(String, byte[], String, String, int) for further details on how to install a certificate to those keystores, respectively. In case same alias is present on both keystores, the certificate at CCM will be enforced, taking precedence over the one installed at VPN and APPS keystore.

Since
API level 20
MDM 5.7

public byte[] certificateData

Since: API level 11

Certificate binary (optional can be null)

Since
API level 11
MDM 5.0

public String certificatePassword

Since: API level 11

Certificate password to extract information (optional; can be null)

Since
API level 11
MDM 5.0

public String certificateStorageName

Since: API level 20

Credential storage name where certificateAlias shall be stored (optional; can be null). In order to see how to install certificates to credential storage, please refer to Universal Credential Manager (UCM) DEV guide. Leave it as null if certificate is installed either at Client Certificate Manager (CCM) or KEYSTORE_FOR_VPN_AND_APPS keystore.

Since
API level 20
MDM 5.7

public String displayName

Since: API level 11

The display name of the account

Since
API level 11
MDM 5.0

public String easDomain

Since: API level 11

Account domain

Since
API level 11
MDM 5.0

public String easUser

Since: API level 11

The user of the account

Since
API level 11
MDM 5.0

public String emailAddress

Since: API level 11

The email address corresponding to the account

Since
API level 11
MDM 5.0

public boolean emailNotificationVibrateAlways

Since: API level 11

true to always vibrate on email notification

Since
API level 11
MDM 5.0

public boolean isDefault

Since: API level 11

true to make this account the default

Since
API level 11
MDM 5.0

public boolean isNotify

Since: API level 11

true to notify user on receiving new mail

Since
API level 11
MDM 5.0

public int offPeak

Since: API level 11

Frequency to sync email during off-peak time Value -2 - Automatic push Value -1 - Never Value 5 - 5 minutes Value 10 - 10 minutes Value 15 - 15 minutes Value 30 - 30 minutes Value 60 - 1 hour Value 240 - 4 hours Value 720 - 12 hours

Since
API level 11
MDM 5.0

public int peakDays

Since: API level 11

Peak days for sync schedule. For example: 62 (0x3e) for Mon|Tue|Wed|Thu|Fri (0111110) 73 (0x49) for Sun|Wed|Sat (1001001)

Since
API level 11
MDM 5.0

public int peakEndTime

Since: API level 11

Peak end time in minutes. For example: 5PM 17hr x 60 = 1020 6PM 18hr x 60 = 1080

Since
API level 11
MDM 5.0

public int peakStartTime

Since: API level 11

Peak start time in minutes. For example: 8AM 8hr x 60 = 480 9AM 9hr x 60 = 540

Since
API level 11
MDM 5.0

public int periodCalendar

Since: API level 11

Number of previous days Calendar to sync Value 0 - All Value 4 - 2 weeks Value 5 - 1 month Value 6 - 3 months Value 7 - 6 months

Since
API level 11
MDM 5.0

public String protocolVersion

Since: API level 11

Protocol version of Microsoft Exchange ActiveSync (EAS only)

Since
API level 11
MDM 5.0

public int retrivalSize

Since: API level 11

Email retrieval size Value 0 - Headers only Value 1 - 0.5 KB Value 2 - 1 KB Value 3 - 2 KB Value 4 - 5 KB Value 5 - 10 KB Value 6 - 20 KB Value 7 - 50 KB Value 8 - 100 KB Value 9 - All
NOTE: Some ActiveSync protocol versions with EAS 2003 do not support value 9. Please see https://msdn.microsoft.com/en-us/library/gg675441(v=exchg.80).aspx for more details.

Since
API level 11
MDM 5.0

public int roamingSchedule

Since: API level 11

0 - Manual 1 - Use sync settings

Since
API level 11
MDM 5.0

public String senderName

Since: API level 11

User name for outgoing messages

Since
API level 11
MDM 5.0

public String serverAddress

Since: API level 11

The server address corresponding to this account

Since
API level 11
MDM 5.0

public String serverPassword

Since: API level 11

The server password corresponding to this account

Since
API level 11
MDM 5.0

public String serverPathPrefix

Since: API level 11

The server path Prefix corresponding to this account

Since
API level 11
MDM 5.0

public String signature

Since: API level 11

Signature to use with the account

Since
API level 11
MDM 5.0

public int smimeCertificateMode

Since: API level 20

Set certificate mode when account creation time. Possible values are:

Since
API level 20
MDM 5.7

public String smimeCertificatePassword

Since: API level 11

SMIME certificate password when account creation time

Since
API level 11
MDM 5.0

public String smimeCertificatePath

Since: API level 11

SMIME certificate path when account creation time

Since
API level 11
MDM 5.0

public int syncCalendar

Since: API level 11

syncCalendar = true, then account syncs calendar information syncCalendar = false, then account does not sync calendar information

Since
API level 11
MDM 5.0

public int syncContacts

Since: API level 11

syncContacts = true, then account syncs contacts information syncContacts = false ,then account does not sync contacts information

Since
API level 11
MDM 5.0

public int syncInterval

Since: API level 11

Frequency to sync email during peak time Value -2 - Automatic push, Value -1 - Never, Value 5 - 5 minutes, Value 10 - 10 minutes, Value 15 - 15 minutes Value 30 - 30 minutes, Value 60 - 1 hour, Value 60 - 1 hour, Value 240 - 4 hours, Value 720 - 12 hours

Since
API level 11
MDM 5.0

public int syncLookback

Since: API level 11

Number of previous days to sync email Value 1 - 1 day, Value 2 - 3 days, Value 3 - 1 week, Value 4 - 2 weeks, Value 5 - 1 month

Since
API level 11
MDM 5.0

public boolean useSSL

Since: API level 11

true to use Secure Sockets Layer (SSL)

Since
API level 11
MDM 5.0

Public Constructors

public ExchangeAccount (String emailAddress, String easUser, String easDomain, String serverAddress, String serverPassword)

Since: API level 11

Struct to add a new Microsoft Exchange account with base parameters.

Parameters
emailAddress Email address of the account
easUser User name of the account
easDomain Domain name of the account
serverAddress Address of the server (e.g., "mail.xyz.com")
serverPassword Password of the account

NOTE : All other settings values are set to default.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 ExchangeAccountPolicy  exchangeAccountPolicy = edm.getExchangeAccountPolicy();

  try {

     accountId =  exchangeAccountPolicy.addNewAccount(new ExchangeAccount(

                 "testeasid@easserver.com", "testeasid","easDomain", "easserver.com",

                 "Password@123"));

     if(accountId >= 0){

         Log.d(TAG,"Add a new exchange account with base parameters succeeded!");

         // Administrator needs to call sendAccountsChangedBroadcast() API

         // to notify about the Microsoft Exchange account addition.

         exchangeAccountPolicy.sendAccountsChangedBroadcast();

      }else{

          Log.d(TAG," Add a new exchange account with base parameters failed.");

      }

  } catch(SecurityException e) {

      Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 ExchangeAccountPolicy exchangeAccountPolicy = kcm.getExchangeAccountPolicy();

  try {

     accountId =  exchangeAccountPolicy.addNewAccount(new ExchangeAccount(

                 "testeasid@easserver.com", "testeasid","easDomain", "easserver.com",

                 "Password@123"));

     if(accountId >= 0){

         Log.d(TAG,"Add a new exchange account with base parameters succeeded!");

         // Administrator needs to call sendAccountsChangedBroadcast() API

         // to notify about the Microsoft Exchange account addition.

         exchangeAccountPolicy.sendAccountsChangedBroadcast();

      }else{

          Log.d(TAG," Add a new exchange account with base parameters failed.");

      }

  } catch(SecurityException e) {

      Log.w(TAG,"SecurityException: "+e);

  }

 
Multiuser Environment
User Scope
Since
API level 11
MDM 5.0