String auth = "Basic " + new BASE64Encoder().encode((username +
":" + pswd).getBytes());
mdsConn.setRequestProperty("Authorization", auth);
2. Locating Internal Push Recipients
Depending on the configuration of an organization’s
BlackBerry environment, it might be difficult to locate the recipient
for a push request. If the BES environment is configured with a single
BES domain and a central push server (see Figure 1),
the application can submit the push request to the central push server
and it will locate the recipient’s BES and deliver the data.
If the BES environment is configured with multiple BES domains or a single domain without a central push server, as shown in Figure 2,
the task is more difficult. In this scenario, the push application has
to maintain a list of all the valid MDS servers in the environment (in
a single domain or multiple domains, it doesn’t matter—the MDS server
is not aware of the other MDS servers) and push to each MDS server
until the server accepts the push request.
When the MDS server receives the push request, it
validates the user against the BES Configuration Database. MDS returns
a HTTP result code of 200 when it locates the user and accepts the
push. It returns an HTTP result code 403 if the email address or PIN
for the recipient cannot be located. The push application must loop
through each MDS server until it receives confirmation that the push
has been accepted before moving to the next push recipient.
When developers first learn about this
feature, their first inclination is to modify the table containing push
recipient information to include the MDS server information. When the
push application retrieves recipient information from the table, it
also retrieves the MDS server information. The problem with this
approach is that users sometimes switch BES. Because of this, as soon
as this table is created, it is out of date.