Oracle Java ME Embedded

Package com.oracle.meep.security

Provides classes necessary to create custom authentication and security policy providers as defined by MEEP specification.

See: Description

Package com.oracle.meep.security Description

Provides classes necessary to create custom authentication and security policy providers as defined by MEEP specification.

Class Overview

There are two main classes that should be used to create custom providers:

Building Providers

Authentication Provider

The purpose of the authentication provider is to verify an application or LIBlet and return the list of appropriate clients.

Custom authentication provider must extend AuthenticationProvider and implement the following abstract methods:

Authenticating Application

To authenticate applications and LIBlets custom authentication provider must implement AuthenticationProvider.authenticateApplication(com.oracle.meep.security.MIDletProperties, java.io.InputStream). This method should either return the list of clients to which an application/LIBlet is bound or report authentication error by throwing AuthenticationProviderException.

Application properties from JAD and/or manifest and application JAR file can be used for authentication purposes.

To access the list of clients defined by the security policy the following methods should be used:

Example

The following custom authentication provider selects clients depending on application vendor property.

 package com.company.security;
 
 import com.oracle.meep.security.AuthenticationProvider;
 import com.oracle.meep.security.AuthenticationProviderException;
 import com.oracle.meep.security.Client;
 import com.oracle.meep.security.MIDletProperties;
 import com.oracle.meep.security.Policy;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
 public class AuthProvider extends AuthenticationProvider {
     public List<Client> authenticateApplication(MIDletProperties props, InputStream in) throws AuthenticationProviderException {
         List<Client> result = new ArrayList<>();
         String vendor = props.getProperty("MIDlet-Vendor");
         
         switch (vendor) {
             case "Manufacturer":
                 result.add(Policy.getPolicy().getRootClient());
                 break;
             case "TrustedCompany":
                 result.add(Policy.getPolicy().getClient("clientA"));
                 result.add(Policy.getPolicy().getClient("clientB"));
                 break;
             case "UntrustedCompany":
                 result.add(Policy.getPolicy().getUntrustedClient());
                 break;
             default:
                 throw new AuthenticationProviderException(AuthenticationProviderException.ErrorCode.AUTHENTICATION_FAILURE);
         }
         
         return result;
     }
 
     public void initialize() {
     }    
 }
 
 

Security Policy Provider

The purpose of the security policy provider is to define the list of clients and their protection domains. Protection domain of a client is a set of permissions that can be granted to the application bound to this client.

Custom security policy provider must extend Policy and implement abstract method Policy.initialize(). This method is called by security framework and is responsible for security policy initialization. During initialization custom security policy provider must use helper methods to create the list of clients:

Example

The following custom security policy provider defines 2 clients with different protection domains and also specifies protection domain for virtual untrusted client.

 package com.company.security;
 
 import com.oracle.meep.security.Client;
 import com.oracle.meep.security.Policy;
 
 public class PolicyProvider extends Policy {
     public void initialize() {
         Client clientA = new Client("clientA");
         clientA.addPermissions(new javax.microedition.io.HttpProtocolPermission("http://locahost:80/"),
             new javax.microedition.io.SSLProtocolPermission("ssl://:*"));
         addClient(clientA);
         
         Client clientB = new Client("clientB");
         clientB.addPermissions(new javax.microedition.io.PushRegistryPermission("*", "static,dynamic,alarm"));
         addClient(clientB);
         
         getUntrustedClient().addPermissions(new javax.microedition.location.LocationPermission("location", "location"));
     }    
 }
 
 

Installing Providers

To install custom authentication and/or security policy providers the following steps should be made:

Example

security.providers.jar = appdb/providers.jar
On SDK this location will be expanded to C:\Users\<USER>\javame-sdk\8.0\work\EmbeddedDevice1\appdb\providers.jar

authentication.provider = com.company.security.AuthProvider

microedition.security.policy = com.company.security.PolicyProvider

Oracle Java ME Embedded

Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.