BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-27-2008, 01:01 PM   #1 (permalink)
New Member
 
Join Date: May 2008
Model: 8130
PIN: N/A
Carrier: Verizon
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Check the IT Policy settings programmatically?

Please Login to Remove!

Hi,

I have an application that needs specific permissions. I can check the permission settings for the device, but I also need to check to see if the IT Policy allows it (or includes the item).

Is there any way to do this programmatically? I know there's the ITPolicy class, but I can't figure out what the variables represent.

Thanks!
Offline  
Old 08-28-2008, 04:41 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

When dealing with an ITPolicy the first thing you need to do is add a GlobalEventListener to your application so you can catch any policy changes and handle them accordingly. The event will have a GUID so you compare this with the ITPolicy change GUID:

if (guid == ITPolicy.GUID_IT_POLICY_CHANGED) {
//handle policy change
}

This area of the API is well documented, a policy with type boolean is handled like so:

boolean allowedit = ITPolicy.getBoolean("myNameSpace myApplication Allow Edit", false);

The false is the default to use if no value is found. Similarly a policy can be a string:

String myURL = ITPolicy.getString("myNameSpace myApplication URL");

i'll blog about this with full examples if i get any free time over the next couple of weeks.
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 08-28-2008, 09:14 AM   #3 (permalink)
New Member
 
Join Date: May 2008
Model: 8130
PIN: N/A
Carrier: Verizon
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. It seems that this would be more to check when the IT Policy changes though, like you're listening for changes. Is there a way to simply check a specific IT Policy item?

In pseudo-code:

//on program start

if ( ITPolicy.getSetting("Allow Resetting of Idle Timer") == false ) {
errorMessage.send( "Your IT Policy is too restrictive to run this application.")
}
Offline  
Old 08-28-2008, 09:27 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

of course that's fine, just run it when the application starts up... all the info is in the javadoc:

/docs/api/net/rim/device/api/itpolicy/ITPolicy.html
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 08-28-2008, 10:04 AM   #5 (permalink)
New Member
 
Join Date: May 2008
Model: 8130
PIN: N/A
Carrier: Verizon
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Alright thanks. It says that the getBoolean method has the form "(int id, boolean defaultValue)", where id is "the parameter ID". What form does this take? If I want to check to see if the BES server has the "Allow Resetting of Idle Timer" set to True, what would this cryptic parameter ID be?

Thanks again!!
Offline  
Old 08-28-2008, 11:18 AM   #6 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess the method that takes an int is for retrieving a Rim ITPolicy where the id can be retrieved from a static parameter. Not sure.

If you're checking a custom BES policy you'd use the method that takes a string:

boolean allowreset = ITPolicy.getBoolean("Allow Resetting of Idle Timer", false);
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 08-28-2008, 11:45 AM   #7 (permalink)
New Member
 
Join Date: May 2008
Model: 8130
PIN: N/A
Carrier: Verizon
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried to find the setting of the IT Policy "Allow Resetting of Idle Timer", but I can't seem to get the string of the format it wants. I've tried:

ITPolicy.getInteger("ALLOW_RESET_IDLE_TIMER", -1);
ITPolicy.getInteger("Allow resetting of idle timer", -1);
ITPolicy.getInteger("Allow Resetting of Idle Timer", -1);

None of these work, they end up returning the '-1' as the 'not found' value.

Any idea on the format? Thanks!!
Offline  
Old 09-05-2008, 07:37 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2006
Location: Boston
Model: 8900
Carrier: AT&T
Posts: 98
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

So if you use

String value = ITPolicy.getString( string_name_of_it_policy );

"value" will come back as "null" if the policy does not exist - this removes the possibility of getting a "default" value back and provides some assurance that the value of the policy isn't actually set to the default.

You may be using an incorrect string for the name of the IT policy. Your best bet is to go to the BES that governs the devices you're using and find out precisely the spelling of the string that the IT Policy you're looking for has as its "name". The "name" must match exactly (spelling, spacing, and case). In addition, the policy must be "assigned" - a device doesn't receive a new policy just because it gets created on the BES.

Cheers,

karl
__________________
Karl G. Kowalski
---------------
Owns a RAZR
Develops for BlackBerry
So next phone will be........an iPhone 3G!

Last edited by holy3daps : 09-05-2008 at 07:40 AM.
Offline  
Old 11-07-2008, 11:20 AM   #9 (permalink)
New Member
 
ahremsee's Avatar
 
Join Date: Oct 2007
Model: 8310
OS: 4.2.2.181
PIN: N/A
Carrier: o2
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quick Question.
Do we have any way of testing Custom IT Policies on a Device Simulator?

Regards
Rob Clarke
Offline  
Old 05-10-2009, 05:10 PM   #10 (permalink)
New Member
 
Join Date: Mar 2009
Model: 8330
PIN: N/A
Carrier: AT&T
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Smile See: public static boolean canResetIdleTime()

Quote:
Originally Posted by atsikouras View Post
In pseudo-code:

//on program start

if ( ITPolicy.getSetting("Allow Resetting of Idle Timer") == false ) {
errorMessage.send( "Your IT Policy is too restrictive to run this application.")
}
I have a possible answer for your specific example case here, though not the general case you inquired about in the OP.

from:
www DOTTO blackberry DOTTO com/developers/docs/4.3.0api/net/rim/device/api/system/DeviceInfo.html

BlackBerry JDE 4.3.0 API Specification: Class DeviceInfo

Method Detail
canResetIdleTime

public static boolean canResetIdleTime()

Checks whether or not the calling application can reset the device's idle timer.

All of the following conditions must be satisfied in order for an application to be able to reset the device's idle timer:

* IT Policy ALLOW_RESET_IDLE_TIMER must be true. The default is false for BES users, true for BIS.
* All modules on the call stack must be authorized by the RIM Runtime (RRT) key (RRT_SIGNER_ID).
* All modules on the call stack must pass the PERMISSION_IDLE_TIMER application control check.

Returns: true if the calling application can reset the device's idle timer; false otherwise.
Since: JDE 4.3.0
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.