Department of Computer Science & Engineering

Slides:



Advertisements
Similar presentations
MIDP Mobile Information Device Profile Johnny Yau CIS 642 Prof. Insup Lee.
Advertisements

Thomas S. Messerges, Ezzat A. Dabbish Motorola Labs Shin Seung Uk.
J2ME Melih Sakarya Java Teknolojileri Derneği. JVM JAVA Kullanılan yerler  Windows-Linux-Unix-Solaris  PDA lar  Smart Cardlar  Cep Telefonları  Appletler.
Sony Ericsson1 Tapuchin The Project Capuchin Energizing User Experience.
Java 2D Training. Basic Tools Java SDK 1.4x Wireless Toolkit 2.x NetBeans IDE + mobility pack Global Code editor Text Comparer Tools Graphics Editor Sprite.
Using Multimedia on the Web Enhancing a Web Site with Sound, Video, and Applets.
CNIT 132 – Week 9 Multimedia. Working with Multimedia Bandwidth is a measure of the amount of data that can be sent through a communication pipeline each.
It provides a framework for embedded multimedia facilities in java enabled mobile devices.
J2ME Screen Hierarchy Displayable ScreenCanvas FormAlertListTextbox.
CP3397 ECommerce.
Pengantar Teknologi Mobile 12
Cryptography and Network Security
Secure Socket Layer.
Internet Security Protocols
An Introduction to Secure Sockets Layer (SSL). Overview Types of encryption SSL History Design Goals Protocol Problems Competing Technologies.
J2ME 25 July Overview  What is J2ME?  The CLDC and CDC configurations  MIDP and MIDlets  Development Tools  Demonstrations.
Writing Your First MIDlet Running JAVA on a Cell Phone Jon A. Batcheller January 27, 2004.
WAP Public Key Infrastructure CSCI – Independent Study Fall 2002 Jaleel Syed Presentation No 5.
16.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft® Windows® Server 2003 Active Directory Infrastructure.
70-293: MCSE Guide to Planning a Microsoft Windows Server 2003 Network, Enhanced Chapter 9: Planning and Managing Certificate Services.
Java Security Model Lab#1 I. Omaima Al-Matrafi. Safety features built into the JVM Type-safe reference casting Structured memory access (no pointer arithmetic)
LAB#2 JAVA SECURITY OVERVIEW Prepared by: I.Raniah Alghamdi.
Apr 22, 2003Mårten Trolin1 Agenda Course high-lights – Symmetric and asymmetric cryptography – Digital signatures and MACs – Certificates – Protocols Interactive.
Developing Software for Wireless Devices
11 Web Services Dr. Miguel A. Labrador Department of Computer Science & Engineering
Making Cell Phone Games An Overview Ray Ratelis Guild Software, Inc.
Developing J2ME Applications Mobile and Wireless Networks.
Cosc 4730 Phone Programming in Java An Introduction.
Java 2 Platform, Micro Edition (J2ME) By Xiaorong Wang.
Detecting Changes  ItemStateListener interface – detect changes in internal state of an Item  new selection made in a ChoiceGroup  adjusted value of.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. M I C R O S O F T ® Preparing for Electronic Distribution Lesson 14.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
An Introduction to the Java ME Project Jens A Andersson.
32.1 Chapter 32 Security in the Internet: IPSec, SSL/TLS, PGP, VPN, and Firewalls Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Exploring Microsoft Office Word 2007 Chapter 7 The Advanced User Robert Grauer, Keith Mulbery,
Mobile Applications with Java ME & BlackBerry. Overview Java ME –Networking –Databases Java ME and the BlackBerry –The BlackBerry wireless device –Converting.
Java Security Pingping Ma Nov 2 nd, Overview Platform Security Cryptography Authentication and Access Control Public Key Infrastructure (PKI)
Creating Multimedia Interaction with Windows Media Technologies 7.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 lcdui Rob Pooley
1. Chapter 25 Protecting and Preparing Documents.
CHAPTER TEN AUTHORING.
Cryptography and Network Security (CS435) Part Fourteen (Web Security)
Web Security : Secure Socket Layer Secure Electronic Transaction.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 13 lcdui and OXO Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 14 Various MIDlet examples Rob Pooley
Discovering Computers Fundamentals Fifth Edition Chapter 9 Database Management.
Module 9: Fundamentals of Securing Network Communication.
1 SSL - Secure Sockets Layer The Internet Engineering Task Force (IETF) standard called Transport Layer Security (TLS) is based on SSL.
BlackBerry Persistent Storage Models Persistent Storage APIs and Record Management System.
1. 2 Overview In Exchange security is managed by assigning permissions in Active Directory Exchange objects are secured with DACL and ACEs Permissions.
ELECTROINC COMMERCE TOOLS Chapter 6. Outline 6.0 Introduction 6.1 PUBLIC KEY INFRASTRUCTURE (PKI) AND CERTIFICATE AUTHORITIES (CAs) TRUST
Introduction to Interactive Media Interactive Media Tools: Authoring Applications.
Java Security Session 19. Java Security / 2 of 23 Objectives Discuss Java cryptography Explain the Java Security Model Discuss each of the components.
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
1 Session 4 Module 6: Digital signatures. Digital Signatures / Session4 / 2 of 18 Module 4, 5 - Review (1)  Java 2 security model provides a consistent.
1 Introduction to J2ME Outline MIDP Building J2ME Apps- Tool J2ME Wireless Toolkit Demo MIDlet Programming -- MIDlet Transition States -- Midlet Skeleton.
4.1 © 2004 Pearson Education, Inc. Exam Managing and Maintaining a Microsoft® Windows® Server 2003 Environment Lesson 12: Implementing Security.
Securing Web Applications Lesson 4B / Slide 1 of 34 J2EE Web Components Pre-assessment Questions 1. Identify the correct return type returned by the doStartTag()
CHAPTER 9 File Storage Shared Preferences SQLite.
CSE403: MIDlets and Ant1 MIDlets and Ant April 3, 2003 Shane Cantrell Zach Crisman.
Advance Computer Programming Market for Java ME The Java ME Platform – Java 2 Micro Edition (J2ME) combines a resource- constrained JVM and a set of Java.
Java N Amanquah.
Java for Mobile Devices
Chinese wall model in the internet Environment
Instructor Materials Chapter 5: Ensuring Integrity
Presentation transcript:

Department of Computer Science & Engineering Developing MIDlets Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador

Outline MIDlet life cycle Hello World example User interface classes and APIs Lists, text boxes, forms, alerts Media API Record Management Systems Security

MIDlets Java program compiled using the APIs included in the CLDC and MIDP specifications After compilation, several steps need to be done before using the MIDlet in a real device Debugged in emulators Passed through the offline preverifier Packaged Creates the Java Archive file (JAR) and Java Application Descriptor (JAD) file JAR file contains the manifest file Automatically generated by the jar tool Information about the MIDlet, such as name, vendor, version and configuration and profile utilized JAD file contains additional information, such as URL and size Very useful for the mobile decide to decide whether to download the MIDlet or not

Manifest and JAD Examples Manifest File Example JAD File Example Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.0 Created-By: 1.6.0_03-b05 (Sun Microsystems Inc.) MIDlet-2: CalculatorWebService, , edu.cse.usf.book.ws.CalculatorWebService MIDlet-1: TCPTest, , edu.cse.usf.book.TCPTest MIDlet-Vendor: Vendor MIDlet-Name: TCPTest MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-2.0 MIDlet-1: TCPTest, , edu.cse.usf.book.TCPTest MIDlet-2: CalculatorWebService, , edu.cse.usf.book.ws.CalculatorWebService MIDlet-Jar-Size: 12747 MIDlet-Jar-URL: TCPTest.jar MIDlet-Name: TCPTest MIDlet-Vendor: Vendor MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-2.0

New Application Instance MIDlets All MIDlets have the same life cycle Paused Active Destroyed destroyApp() pauseApp() startApp() New Application Instance End

A Hello World MIDlet Example import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloWorld extends MIDlet implements CommandListener{ private Command exitCommand; private TextBox tbox; // MIDlet constructor public HelloWorld() { // Create "Exit" Command exitCommand = new Command("Exit", Command.Exit, 1); // Create TextBox to display the output tbox = new TextBox ("Hello World MIDlet", "Hello, World!", 15, 0); // Include the Exit Command in the interface and set its Listener tbox.addCommand(exitCommand); tbox.setCommandListener(this); // Set the TextBox as the current screen Display.getDisplay(this).setCurrent(tbox); }

A Hello World MIDlet Example // The system calls this function to start the MIDlet protected void startApp() {} // The application is switched to the paused state protected void pauseApp() {} // The application is destroyed protected void destroyApp() {boolean force} // MIDlet destroys itself if user gives the Exit Command public void commandAction (Command c, Displayable d) { if (c==exitCommand) { destroyApp(false); notifyDestroyed{}; }

Hello World MIDlet

The User Interface Hierarchy of Classes The package javax.microedition.lcdui contains most of the classes and methods needed to design GUIs Display Displayable Command Canvas Screen List StringItem TextBox Alert Form Item CustomItem Spacer ChoiceGroup TextField ImageItem DateField Gauge 0 ... 1 0 ... n

The User Interface API Hierarchy of classes Display class at the top Manages the display and input devices of the system Contains methods to retrieve the properties of the device and to request the display of object Only one instance of Display per MIDlet Reference of that instance can be obtained by getDisplay() method Displayable object contains the UI objects that are shown in the display setCurrent() and getCurrent() utilized to set and retrieve the current Displayable The application changes the current Displayable based on user action Displayable object may have listener and command objects associated User uses these objects to interact with the UI When the user selects a command, the application is automatically notified The application may react changing the Displayable by another one

The User Interface API Commands provide users with a way to navigate through the Displayables of an application If a Displayable has no command associated with it, the user has no way to change the current Displayable All commands have a string label, priority, and command type Commands are added or removed using the addCommand() and removeCommand() methods Six command types: BACK, OK, CANCEL, HELP, EXIT, STOP Following example shows the implementation of three commands, two generic commands, save and delete, and one specific command, the exit command

Commands Example class ExampleCommand extends Screen implements CommandListener { Command save = new Command ("Save", Command.SCREEN, 2}; Command delete = new Command ("Delete", Command.SCREEN, 3}; Command exit = new Command ("Exit", Command.EXIT, 4}; MIDlet midlet; public ExampleCommand (MIDlet mymidlet) { midlet = mymidlet; setCommandListener(this); addCommand(save); addCommand(delete); addCommand(exit); } public void commandAction (Command c, Displayable d) { if (c == save) { \\ Save data else if (c == delete) { \\ Delete data else if (c == exit) { \\ Exit the application midlet.notifyDestroyed();

Lists, Text Boxes, Forms, and Alerts Displayable class has two subclasses: Canvas and Screen Canvas contains objects that allow the developer to have precise control of what is drawn on the display Screen contains high-level objects that implement complete user interface components such as lists, text boxes, and forms List class is a Screen that displays a list of choice elements Each element includes a string and may have an icon Lists can be implicit, exclusive, and multiple choice Append, delete, insert, set, getString, and getImage methods The type of list is selected using the interface class Choice TextBox class is a Screen that allows the user to input and edit text Application can set input constraints ANY, NUMERIC, DECIMAL, PHONENUMBER, URL, EMAILADDR A text box must have commands

Lists, Text Boxes, Forms, and Alerts Form is a Screen that may contain StringItems, ImageItems, DateFields, TextFields, Gauges, and ChoiceGroups Any of the subclasses of class Item Form can be manipulated using the insert, append, delete, set, get, size, and deteleAll methods Alerts are Screens that can inform the user about errors and other exceptions, or as short informational notes and reminders Alerts are displayed for certain amount of time using the setTimeout method, or modal, which requires the user input to close it ALARM, CONFIRMATION, ERROR, INFO, and WARNING types

List Example List list = new List (String title, int listType, String[ ] stringElements, Image[ ] imageElements); where listType can be IMPLICIT, EXCLUSIVE, or MULTIPLE; stringElements (imageElements) is the initial array of elements(images) e.g., List list = new List (``Email list'', Choice.IMPLICIT, ``labrador@cse.usf.edu, ajperez@cse.usf.edu, pedrow@cse.usf.edu'', null);

Alert Example Alert alert = new Alert (String title, String alertText, Image alertImage, AlertType.XXX); where XXX can be any of the alertType e.g., Alert alert = new Alert (``Warning'', ``Delete all?'', null, AlertType.WARNING);

The Media API Designed to support sound in resource-constrained devices Subset of the Mobile Media API, an optional package meant for Java ME devices with advanced sound and multimedia capabilities Supports tone generation and media flow control (audio playback) Implemented in two packages The javax.microedition.media package, which is a fully compatible subset of classes included in the Mobile Media API The javax.microedition.media.control package that defines specific control types that can be used with a Player Three main components Manager: used by the application to request Players Player: plays the media Wav, MP3, MIDI files and tone sequences Controls: implement the controls of the Player Start, stop, close

Creating a Player The createPlayer method of the Manager class can create a player in two different ways Player Manager.createPlayer (String url) where url specifies the protocol and content of the data as follows: <protocol>:<content location> e.g., Player p = Manager.createPlayer(``http://hello.wav'');

Creating a Player A player can also be created to playback media from an inputStream Start(), stop(), close() methods Player Manager.createPlayer (InputStream stream, String type); e.g., InputStream istream = getClass().getResourceAsStream(``hello.wav''); Player p = Manager.createPlayer(istream, ``audio/X-wav''); p.start(); Where type can be: Wave audio files (audio/x-wav), AU audio files (audio/basic), MP3 audio files(audio/mpeg), MIDI files (audio/midi), Tone sequences (audio/x-tone-seq)

Generating Tones The Manager class can also be used to generate tones Volume is a value from 0 to 100 Duration is the duration of the tone in milliseconds Note defines the tone of the note Number from 0 to 127 note = (12 x log2 (f/440)) + 69 Frequency 440 Hz corresponds to note 69, which is MIDI note A Manager.playTone (int note, int duration, int volume)

The Record Management System (RMS) Simple record-oriented database that allows MIDlets to persistently store data in the mobile device Included in the javax.microedition.rms package Uses the concept of record store, a collection of persistent records Records are arrays of bytes of different lengths and types within a record store Records are automatically identified by a recordID Monotonically increasing-by-one mechanism with no wrap around Adjacent records in a record store do not necessarily have subsequent record IDs Record stores are uniquely named using the name of the MIDlet suite plus the name of the record store MIDlet suites are identified using the attributes MIDlet-vendor and MIDlet-name of the application descriptor

The Record Management System (RMS) The RMS API does not include locking mechanisms but ensures that record store operations are atomic, synchronous, and serialized It is the programmer’s responsibility to coordinate access when multiple threads within the same MIDlet attempt to access the same record simultaneously No corruption of data guarantee but the serialization mechanism might give MIDlets access to the record in an undesired sequence Methods to manipulate record stores listRecordStores, deleteRecordStore, openRecordStore, closeRecordStore, getNumRecords, getSize, getSizeAvailable, getNextRecordID, getVersion, getLastModified Methods to manipulate records addRecord, deleteRecord, getRecordSize, getRecord, setRecord

Opening a New Record Store public void openRecStore(String recordStore_name) { try{ RecordStore rs = RecordStore.openRecordStore(recordStore_name,true); } catch(Exception e) System.err.println(e.toString());

Adding a New Record to a Record Store public void writeRecord(String str) { byte[] rec = str.getBytes(); try rs.addRecord(rec, 0, rec.length); } catch (Exception e) System.err.println(e.toString());

Security Security is guided by the following goals Confidentiality Disclosure of information only to authorized users or systems Encryption is a common mechanism to provide confidentiality Symmetric and Asymmetric encryption Integrity Data cannot be modified without proper authorization Achieved by cryptographic methods plus additional information Authenticity Making sure the message is authentic; it comes from the real source Digital signatures using asymmetric encryption Availability Making sure information is available when needed

MIDlet Security MIDP 1.0 specification used the sandbox model Run in a controlled and separate environment and do not interfere with each other MIDP 2.0 expands this model including the concepts of trusted MIDlet and protection domains Untrusted MIDlet suite is one whose authenticity and integrity of JAR file cannot be trusted by the device Executed in untrusted and restrictive domain MIDP 2.0 includes the mechanisms to identify and trust a MIDlet suite and the concept of protection domain for trusted MIDlets Protection domain is a set of permissions associated with a root certificate in the device A specific domain can be defined in the device using the public key of the domain entity, e.g., a software development company Then, a MIDlet signed by the company will be given access to all those resources included in the permissions of the domain

MIDlet Security Digital signatures and authentication methods are utilized to decide whether to trust or not a MIDlet suite Internet X.509 Public Key Infrastructure standard included in RFC 2459 and RFC 2437 “PKCS #1: RSA Cryptography Specifications, version 2.0” First, the MIDlet is signed; then, at download time, it is authenticated Entire process consists of the following steps Sender creates a signing certificate sending its Distinguished Name and public key to a Certificate Authority (CA) to obtain a RSA X.509 certificate Sender encodes and inserts certificate(s) in the JAD file Sender signs the JAR file with its private key to provide MIDlet integrity; however, it does not include the JAD file Receiver downloads the MIDlet, checks the JAD file and verifies signer certificates and JAR signature

MIDlet Security Receiver verifies signer certificates by looking at the CA in the JAD file and the root certificate authorities stored in the device If authentication fails, MIDlet is not installed Receiver verifies JAR signature Gets signer’s public key from the CA and uses this key, the signature included in the JAD file, and the digest included in the JAR file to verify it Certificates are used in MIDP 2.0 security for authentication Package javax.microedition.pki provides the Certificate interface getIssuer(), getNotAfter(), getNotBefore(), getSerialNumber(), getSigAlgName(), getSubject(), getType(), and getVersion() methods Networking security achieved by Secure Socket Layer (SSL) and the Transport Layer Security (TLS) protocols HttpsConnection and SecureConnection interfaces Method getSecurityInfo can be applied to an open connection to fill a SecurityInfo object Obtain protocol name and version, cipher suite, certificate of the connection