Fields Summary |
---|
static final int | RETRY_DELAYRetry delay. |
public static final String | NOTIFY_PROPMIDlet property for the install notify URL. |
public static final String | SUCCESS_MSGSuccess message for the suite provider. |
public static final String | INSUFFICIENT_MEM_MSGError message for the suite provider. |
public static final String | USER_CANCELLED_MSGError message for the suite provider. |
public static final String | JAR_SIZE_MISMATCH_MSGError message for the suite provider. |
public static final String | ATTRIBUTE_MISMATCH_MSGError message for the suite provider. |
public static final String | INVALID_JAD_MSGError message for the suite provider. |
public static final String | INVALID_JAR_MSGError message for the suite provider. |
public static final String | INCOMPATIBLE_MSGError message for the suite provider. |
public static final String | AUTHENTICATION_FAILURE_MSGError message for authentication failure. |
public static final String | AUTHORIZATION_FAILURE_MSGError message for authorization failure. |
public static final String | PUSH_REG_FAILURE_MSGError message for push registration failure. |
public static final String | DELETE_NOTIFICATION_MSGError message for push registration failure. |
public static final String | CONTENT_HANDLER_CONFLICTMessage to send when a content handler install fails. |
public static final String | INVALID_CONTENT_HANDLERMessage to send when a content handler install fails. |
Methods Summary |
---|
private static native void | addInstallNotification(int suiteId, java.lang.String url)Adds an element to the install notification list.
|
private static native void | fillDeleteNotificationListForRetry(com.sun.midp.installer.PendingNotification[] list)Retrieves the queued delete notification list from storage and
increments the retry count of every member of the list.
|
private static java.lang.String | formatAuthCredentials(java.lang.String username, java.lang.String password)Formats the username and password for HTTP basic authentication
according RFC 2617.
byte[] data = new byte[username.length() + password.length() + 1];
int j = 0;
for (int i = 0; i < username.length(); i++, j++) {
data[j] = (byte)username.charAt(i);
}
data[j] = (byte)':";
j++;
for (int i = 0; i < password.length(); i++, j++) {
data[j] = (byte)password.charAt(i);
}
return "Basic " + Base64.encode(data, 0, data.length);
|
private static synchronized com.sun.midp.installer.PendingNotification[] | getDeleteNotifications()Retrieves the queued delete notification list. Each element
in the array is a URL to send a delete notification to.
PendingNotification[] array =
new PendingNotification[getNumberOfDeleteNotifications()];
if (array.length > 0) {
for (int i = 0; i < array.length; i++) {
array[i] = new PendingNotification();
}
fillDeleteNotificationListForRetry(array);
}
return array;
|
private static native boolean | getInstallNotificationForRetry(int suiteId, com.sun.midp.installer.PendingNotification dest)Retrieves the URL of suite's install notification from storage and
increments the retry count of element.
|
private static native int | getNumberOfDeleteNotifications()Retrieves the number of URLs queued delete in the notification list.
|
public static void | postInstallMsgBackToProvider(java.lang.String message, com.sun.midp.midlet.MIDletSuite suite, java.lang.String proxyUsername, java.lang.String proxyPassword)Posts a status message back to the provider's URL in JAD.
This method will also retry ALL pending delete notifications.
String url;
MIDletSuite callingMidletSuite =
MIDletStateHandler.getMidletStateHandler().getMIDletSuite();
if (callingMidletSuite == null) {
throw new IllegalStateException("This method can't be called " +
"before a suite is started.");
}
callingMidletSuite.checkIfPermissionAllowed(Permissions.AMS);
// Now, send out install notifications
url = suite.getProperty(NOTIFY_PROP);
try {
postMsgBackToProvider(message, url, proxyUsername, proxyPassword);
} catch (Throwable t) {
if (message == SUCCESS_MSG) {
// Only queue successful install notifications for retry
addInstallNotification(suite.getID(), url);
}
}
|
private static void | postMsgBackToProvider(java.lang.String message, java.lang.String url, java.lang.String proxyUsername, java.lang.String proxyPassword)Posts a status message back to the provider's URL in JAD.
HttpConnection transaction;
if (url == null) {
return;
}
transaction = (HttpConnection)Connector.open(url, Connector.WRITE);
postMsgBackToProvider(message, transaction, proxyUsername,
proxyPassword);
|
private static void | postMsgBackToProvider(java.lang.String message, javax.microedition.io.HttpConnection transaction, java.lang.String proxyUsername, java.lang.String proxyPassword)Posts a status message back to the provider's URL in JAD.
OutputStream out;
try {
transaction.setRequestMethod(HttpConnection.POST);
if (proxyUsername != null && proxyPassword != null) {
transaction.setRequestProperty("Proxy-Authorization",
formatAuthCredentials(proxyUsername, proxyPassword));
}
out = transaction.openOutputStream();
try {
int responseCode;
out.write(message.getBytes());
responseCode = transaction.getResponseCode();
if (responseCode != HttpConnection.HTTP_OK) {
throw new IOException("Failed to notify " +
transaction.getURL() +
" HTTP response code: " + responseCode);
}
} finally {
out.close();
}
} finally {
transaction.close();
}
|
public static void | postQueuedDeleteMsgsBackToProvider(java.lang.String proxyUsername, java.lang.String proxyPassword)Posts all queued delete notification messages
PendingNotification[] deleteNotifyList;
deleteNotifyList = getDeleteNotifications();
for (int i = 0; i < deleteNotifyList.length; i++) {
try {
postMsgBackToProvider(DELETE_NOTIFICATION_MSG,
deleteNotifyList[i].url,
proxyUsername, proxyPassword);
removeDeleteNotification(deleteNotifyList[i].suiteId);
} catch (Throwable t) {
if (deleteNotifyList[i].retries >=
Constants.MAX_INSTALL_DELETE_NOTIFICATION_RETRIES) {
removeDeleteNotification(deleteNotifyList[i].suiteId);
}
}
}
|
private static native void | removeDeleteNotification(int suiteId)Removes the element from the delete notification list.
|
private static native void | removeInstallNotification(int suiteId)Removes the element from the install notification list.
|
public static void | retryInstallNotification(com.sun.midp.security.SecurityToken token, com.sun.midp.midlet.MIDletSuite suite)Retry the pending install status message for this suite only.
This method will also retry ALL pending delete notifications,
if the install notification was retried.
/*
* Delay any processing so that startup time is not effected.
*/
new Thread(new InstallRetryHandler(token, suite)).start();
|
static void | retryInstallNotificationInternal(com.sun.midp.security.SecurityToken token, com.sun.midp.midlet.MIDletSuite suite)Retry the pending install status message for this suite only.
This method will also retry ALL pending delete notifications,
if the install notification was retried.
PendingNotification notification = new PendingNotification();
token.checkIfPermissionAllowed(Permissions.AMS);
// Now, send out install notifications
if (suite.getProperty(NOTIFY_PROP) == null) {
return;
}
if (!getInstallNotificationForRetry(suite.getID(), notification)) {
return;
}
try {
Protocol httpConnection = new Protocol();
httpConnection.openPrim(token, notification.url);
postMsgBackToProvider(SUCCESS_MSG, httpConnection, null, null);
removeInstallNotification(notification.suiteId);
} catch (Throwable t) {
if (notification.retries >=
Constants.MAX_INSTALL_DELETE_NOTIFICATION_RETRIES) {
removeInstallNotification(notification.suiteId);
}
}
try {
// Send out delete notifications that have been queued, first
postQueuedDeleteMsgsBackToProvider(null, null);
} catch (Throwable t) {
// ignore
}
|