<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chirashi Security &#187; java</title>
	<atom:link href="http://chirashi.zenconsult.net/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://chirashi.zenconsult.net</link>
	<description>A blog with scattered thoughts on security</description>
	<lastBuildDate>Sun, 16 Oct 2011 17:26:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Emulating the BlackBerry Phone Call Log Field</title>
		<link>http://chirashi.zenconsult.net/2009/12/emulating-the-blackberry-phone-call-log-field/</link>
		<comments>http://chirashi.zenconsult.net/2009/12/emulating-the-blackberry-phone-call-log-field/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 13:54:27 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jde]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=433</guid>
		<description><![CDATA[While writing an application for the BlackBerry, I wanted to emulate the layout of the Phone Log.  Typically, this looks like a set of rows laid out in a two-column or multi-column format.  Since there was no available field to achieve this, I had to write my own.  The way I did it was to [...]]]></description>
			<content:encoded><![CDATA[<p>While writing an application for the BlackBerry, I wanted to emulate the layout of the Phone Log.  Typically, this looks like a set of rows laid out in a two-column or multi-column format.  Since there was no available field to achieve this, I had to write my own.  The way I did it was to override the drawListRow method in an ObjectListField.  One thing you can notice in your BlackBerry call log screen is that the last 10 characters are always reserved and never appear as an ellipsis.  The last 10 characters are usually formatted thusly:</p>
<p><strong>[Call Attribute: upto 4 characters][Date or Time: upto 6 characters]</strong></p>
<p>Some examples of these are:</p>
<pre><code>
(W) 9:58p
(W2)11:22p
(H) 01/09
</code></pre>
<p>You will see in example 2 above, that all 10 characters are used up.  After I figured this out, the rest was pretty straightforward.  Here is the source code to my Field called PhoneNumberListField.</p>
<pre lang="Java">import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ObjectListField;

public class PhoneNumberListField extends ObjectListField
{

	public PhoneNumberListField()
        {
     	    super();
        }

	public PhoneNumberListField(long style)
        {
     	    super(style);
        }

        public void drawListRow(ListField listField, Graphics graphics,
        		int index, int y, int width)
        {

        	String tmpCol1 = (String) this.get(listField, index);
        	String col1 = tmpCol1.substring(0, (tmpCol1.length() - 10));
        	String col2 = tmpCol1.substring(tmpCol1.length()-10);

        	int col2Size = this.getFont().getAdvance(col2);
                int col1Size = width - col2Size;

        	int col1Start = 0;
        	int col2Start = (width - col2Size);

        	graphics.drawText(col1, col1Start, y, DrawStyle.ELLIPSIS, col1Size);

        	graphics.drawText(col2, col2Start, y, DrawStyle.HDEFAULT, col2Size);

        }

}</pre>
<h3>How to implement</h3>
<p>You first create an array of Strings.  This array can contain phone numbers or a combination of First Name, Last Name together with the phone attribute like (W), (H) for Work and Home numbers respectively.  The last field will be the date or time.  I check the time of the call to see if it is older than 24 hours.  If it is, I use the date.  The format for the time is “<em>h:mma</em>” and for date it is “<em>MM/dd</em>”.  You can format these using SimpleDateFormat.</p>
<p>The full list of BlackBerry Attributes are represented as follows:</p>
<p>Home: (H)<br />
Work: (W)<br />
Mobile: (M)<br />
Pager: (P)<br />
Fax: (F)<br />
Other: (O)<br />
Work2: (W2)<br />
Home2: (H2)</p>
<p>The attribute constants can be found in the <a href="http://www.blackberry.com/developers/docs/4.6.0api/net/rim/blackberry/api/pdap/BlackBerryContact.html" target="_blank">BlackBerryContact Interface</a>.  A typical array of mine would look like this:</p>
<pre><code>
String[] numList = {“Sheran Gunasekera (W) 09/09”, “Scott Mosier (M) 9:39a”,
“Kevin Smith (M)10:39p”, “+12120031337     10:04p};</code></pre>
<p>Then, if I want to place this field on my MainScreen, I do this:</p>
<pre lang="Java">PhoneNumberListField numbers = new PhoneNumberListField();
numbers.setEmptyString(“*** No Calls Yet ***”, DrawStyle.HCENTER);
numbers.set(numList);
add(numbers);</pre>
<p>This is what it looks like:</p>
<div id="attachment_444" class="wp-caption alignnone" style="width: 310px"><a href="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/PhoneNumberListField.png"><img class="size-medium wp-image-444" title="PhoneNumberListField" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/12/PhoneNumberListField-300x200.png" alt="PhoneNumberListField" width="300" height="200" /></a><p class="wp-caption-text">PhoneNumberListField</p></div>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/12/emulating-the-blackberry-phone-call-log-field/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mice, Permissions and a Solution?</title>
		<link>http://chirashi.zenconsult.net/2009/11/mice-permissions-and-a-solution/</link>
		<comments>http://chirashi.zenconsult.net/2009/11/mice-permissions-and-a-solution/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 18:14:04 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Surveillance]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=394</guid>
		<description><![CDATA[The BlackBerry default application permissions should be one of the most important things to a BlackBerry Internet Service (BIS) user.  But how can these application permissions be monitored and checked for those times when they are changed (creating a potentially risky situation) and the user forgets to revert to its original setting?  This post will highlight a possible mechanism of checking for the most critical permissions.  There's also some sample program source code that users can download and play with.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-medium wp-image-399" style="padding: 0 7px 5px; 0" title="mice" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/mice-300x218.jpg" alt="mice" width="300" height="218" />What do mice do when its cold?  They sit around a candle.  What do they do when its really cold?  They light the candle.  In a sense, the same applies to the Default Application Permissions on your BlackBerry.  They are important, but without being set correctly and understood well, they’re very much like the unlit candle the mice sit around: lots of potential, but completely ineffectual.  The perils of not setting your application permissions correctly?  Here are a two:</p>
<ol>
<li>You don’t know if your “Input Simulation” permission is set to “Allow”.  If it is allowed, any application can make key-presses on your handheld as if they were you.  Potential: <a href="http://chirashi.zensay.com/2009/10/remote-listening-for-the-blackberry/">an application can answer your phone calls</a>.</li>
<li>You’re not sure your “Security Timer Reset” permission is set to “Allow”.  If it is, then any application can <a href="http://chirashi.zensay.com/2009/11/the-security-timer-reset-permission/">render your screen lockout useless</a>.</li>
</ol>
<p>I can almost hear you asking me, “Why tell me about it? You think I don’t know about this?” and the truth is, its an even split.  There are users out there that are blissfully unaware of things like Default Application Permissions.  The BlackBerry is going the way of the consumer, and fast.  With the rise in popularity of the <a href="http://en.wikipedia.org/wiki/BlackBerry_Internet_Service" target="_blank">BlackBerry Internet Service</a>, a user no longer needs to be a part of an large organization to reap the many benefits of a BlackBerry.  The flip side?  There is no <a href="http://en.wikipedia.org/wiki/BlackBerry_Enterprise_Server" target="_blank">enterprise security administrator</a> or policy to protect these users.  Thus when they decide to go with BIS, they take on the task of remaining secure.  For a second, leave these users out of the picture.  Pick the other half of the users who are aware.  Suppose they set some permissions and then forgot about them?  Maybe they allowed access based on an application requesting them to do so and they never set the permissions back.  What then?</p>
<p>I thought about this and came up with a solution of sorts.  Why not have a list of the most important security permissions and check them at a timed interval to see if they have been changed?  If they have, then send the user an alert.  Here’s the code I came up with:</p>
<pre lang="JAVA">package com.zensay.sectest;

import java.util.Timer;
import java.util.TimerTask;
import net.rim.device.api.applicationcontrol.ApplicationPermissions;
import net.rim.device.api.applicationcontrol.ApplicationPermissionsManager;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiEngine;
import net.rim.device.api.ui.component.Dialog;

public class Main extends Application
{
    public static void main(String args[])
    {
        Main app = new Main();
        app.enterEventDispatcher();
    }

    public Main()
    {
        TimerTask tm = new TimerTask()
        {
			public void run()
			{
				reqPerm();
			}
        };
    	Timer t = new Timer();
        t.schedule(tm,10000, 10000);
    }

    public void reqPerm()
	{
		ApplicationPermissionsManager apm = ApplicationPermissionsManager.getInstance();
		int input = apm.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);
		if(input == ApplicationPermissions.VALUE_ALLOW)
		{
			synchronized(Application.getEventLock())
			{
				UiEngine ui = Ui.getUiEngine();
				Screen screen = new Dialog(Dialog.D_OK, "Input Simulation is allowed!!",
						Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
				ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
			}
		}
	}
}</pre>
<p><img class="alignnone size-medium wp-image-406" title="perm_check" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/11/perm_check-188x300.jpg" alt="perm_check" width="188" height="300" /></p>
<p style="clear: both;">To explain it a little bit, the code (when compiled, signed and executed on your BlackBerry) will check your “Input Simulation” permission.  If it is set to “Allow” the application will pop open a message window and notify the user.  It does this every 10 seconds.  Its annoying as hell, but I think you get the general idea.  I tested this on my Bold and it works very well.  I’m thinking about making it an additional feature in Kisses; with a slightly longer timeout of course.  Its a feature I would find useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/11/mice-permissions-and-a-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing the JDE Plugin 5.0.0 for Eclipse</title>
		<link>http://chirashi.zenconsult.net/2009/11/installing-the-jde-plugin-5-0-0-for-eclipse/</link>
		<comments>http://chirashi.zenconsult.net/2009/11/installing-the-jde-plugin-5-0-0-for-eclipse/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 09:31:17 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[blackberry os 5.0.0]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jde]]></category>

		<guid isPermaLink="false">http://chirashi.zensay.com/?p=321</guid>
		<description><![CDATA[I wanted to try out the new Eclipse JDE plugin with OS 5.0.0 so I downloaded the ZIP file from the BlackBerry developer website and tried to install it on my Eclipse. Towards the very end of the installation, I received some error messages. They looked something like this: An error occurred while collecting items [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-269" style="margin: 5px;" title="topleft" src="http://chirashi.zenconsult.net/wp-content/uploads/2009/10/topleft.gif" alt="topleft" width="139" height="55" />I wanted to try out the new Eclipse JDE plugin with OS 5.0.0 so I downloaded the ZIP file from the BlackBerry developer website and tried to install it on my Eclipse.</p>
<p>Towards the very end of the installation, I received some error messages.  They looked something like this:</p>
<pre>An error occurred while collecting items to be installed
  No repository found containing: net.rim.eide/osgi.bundle/1.0.0.67
  No repository found containing: net.rim.eide.bootstrapper/osgi.bundle/1.0.0.67
  No repository found containing: net.rim.eide.preprocessing.hook/osgi.bundle/1.0.0.67</pre>
<p>Quite annoying since it took me a long time to download the JDE ZIP file thanks to a slow Internet connection.  After a little bit of digging, I figured out that the three components I was missing were indeed not in the ZIP file that I had downloaded.  So rather than downloading the whole new ZIP file again, I thought I&#8217;d try another approach.</p>
<p>I went into the Eclipse Software Updates menu: <em>Help-&gt;Software Updates</em> and added the update site &#8220;http://www.blackberry.com/go/eclipseUpdate&#8221;.  I then refreshed the repository and looked for Plugin verison 5.0.0, highlighted the relevant checkboxes and clicked install.  Sure enough, Eclipse dutifully fetched the three missing bundles from RIM&#8217;s update site and finished off my installation.  I&#8217;m <a href="http://chirashi.zensay.com/2009/10/blackberry-os-5-0-0-knows-what-you-install/">playing with OS 5.0</a> as I write this.</p>
]]></content:encoded>
			<wfw:commentRss>http://chirashi.zenconsult.net/2009/11/installing-the-jde-plugin-5-0-0-for-eclipse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

