cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Vidyasree
Pilgrim

SecurityService class not found

Hi,

I am trying to check for admin rights in my installer. I used the code

import com.zerog.ia.api.pub.CustomCodeRule;
import com.installshield.wizard.service.security.*;

public class AdminRule extends CustomCodeRule {

public boolean evaluateRule() {
SecurityService service = (SecurityService)
ruleProxy.getService(SecurityService.class);
boolean isAdmin = false;
try{
isAdmin = service.isCurrentUserAdmin();
}catch(Throwable e){}

return isAdmin;
}
}
But the above code gave me 'com.installshield.wizard.service.security.SecurityService class not found' error. I tried using InstallerProxy as advisedin the help manual.(Calling Installshield MultiPlatform APIs in Install Anywhere).

public class AdminRule extends CustomCodeRule {

public boolean evaluateRule() {
InstallerProxy ip;
SecurityService service = (SecurityService)
ip.getService(SecurityService.class);
boolean isAdmin = false;
try{
isAdmin = service.isCurrentUserAdmin();
}catch(Throwable e){}

return isAdmin;
}
}

But still getting the error in Service class.

Thanks in advance

Regards,
Vidya
Labels (1)
0 Kudos
9 Replies
Highlighted
scarney
Pilgrim

Re: SecurityService class not found

Vidya,

I think you need to add:


import static com.zerog.ia.api.pub.CustomCodeRule.ruleProxy;


Vidyasree wrote:
Hi,

I am trying to check for admin rights in my installer. I used the code

import com.zerog.ia.api.pub.CustomCodeRule;
import com.installshield.wizard.service.security.*;

public class AdminRule extends CustomCodeRule {

public boolean evaluateRule() {
SecurityService service = (SecurityService)
ruleProxy.getService(SecurityService.class);
boolean isAdmin = false;
try{
isAdmin = service.isCurrentUserAdmin();
}catch(Throwable e){}

return isAdmin;
}
}
But the above code gave me 'com.installshield.wizard.service.security.SecurityService class not found' error. I tried using InstallerProxy as advisedin the help manual.(Calling Installshield MultiPlatform APIs in Install Anywhere).

public class AdminRule extends CustomCodeRule {

public boolean evaluateRule() {
InstallerProxy ip;
SecurityService service = (SecurityService)
ip.getService(SecurityService.class);
boolean isAdmin = false;
try{
isAdmin = service.isCurrentUserAdmin();
}catch(Throwable e){}

return isAdmin;
}
}

But still getting the error in Service class.

Thanks in advance

Regards,
Vidya
0 Kudos
Highlighted
scarney
Pilgrim

Got it working

In addition to the import static com.zerog.ia.api.pub.CustomCodeRule.ruleProxy, you need to configure the following jarfiles as dependencies of your class :

[LIST=1]
  • path\to\root\of\InstallAnywhereInstallation\resource\services\services.jar
  • path\to\root\of\InstallAnywhereInstallation\resource\services\ppk\windowsppk.jar


    With that, it works in my code. Thanx for the tip.

    --
    Sandy
  • 0 Kudos
    Highlighted
    scarney
    Pilgrim

    Netbeans question

    Now,

    I have another question. In my CustomCodeRule class, I want to test from Netbeans which easier than building an installer everytime I change something. So I have:


    public static void main( String[] args ) {
    MyCustomCodeRule test_ccr = new MyCustomCodeRule();
    test_ccr.evaluateRule();
    }


    I get an exception at this line in my checkAdmin() method:


    SecurityService sservice = (SecurityService) ruleProxy.getService( SecurityService.class);


    I presume there is some sort of setup that InstallAnywhere does. Is that something I can mimic outside of it. Being able to test these classes outside of IA would speed my development time up greatly.

    --
    Sandy
    0 Kudos
    Highlighted
    Vidyasree
    Pilgrim

    Re: SecurityService class not found

    Hi Sandy,

    May i know the steps u followed to make it working?

    I tried in eclipse and i have tried the two steps mentioned by you. but still the issue remains.:(






    scarney wrote:
    In addition to the import static com.zerog.ia.api.pub.CustomCodeRule.ruleProxy, you need to configure the following jarfiles as dependencies of your class :

    [LIST=1]
  • path\to\root\of\InstallAnywhereInstallation\resource\services\services.jar
  • path\to\root\of\InstallAnywhereInstallation\resource\services\ppk\windowsppk.jar


    With that, it works in my code. Thanx for the tip.

    --
    Sandy
  • 0 Kudos
    Highlighted
    scarney
    Pilgrim

    Getting Service working

    Vidya,

    In your java code, you also need to do import com.installshield.wizard.service.security.SecurityService;

    --
    Sandy
    0 Kudos
    Highlighted
    Vidyasree
    Pilgrim

    Re: SecurityService class not found

    Hi Sandy,

    I doubt my way of doing is wrong.

    Could you please tell me in steps for adding Execute custom code for checking admin rights?

    Regards,
    Vidhya


    scarney wrote:
    Vidya,

    In your java code, you also need to do import com.installshield.wizard.service.security.SecurityService;

    --
    Sandy
    0 Kudos
    Highlighted

    Re: SecurityService class not found

    Hi Vidya,

    Try this-

    import com.installshield.wizard.service.security.SecurityService;
    import com.zerog.ia.api.pub.CustomCodeRule;

    public class AdminRule extends CustomCodeRule {

    public boolean evaluateRule() {
    CustomCodeRule.setCustomCodeRuleProxy(ruleProxy);
    SecurityService service = (SecurityService) ruleProxy
    .getService(SecurityService.class);
    boolean isAdmin = false;
    try {
    isAdmin = service.isCurrentUserAdmin();
    } catch (Throwable e) {
    }

    return isAdmin;
    }
    }


    - Create a jar
    - In the project file,add this in your custom rule
    - Add dependency services.jar from $IA_HOME$\resource\services\services.jar
    - Under Project > JVM Settings, enable checkbox 'Add service support for custom code'

    Let me know if this works.

    Thanks,
    Ramya
    0 Kudos
    Highlighted
    Vidyasree
    Pilgrim

    Is it possible to get the final output as .msi file, instead of .exe format.?

    Is it possible to get the final output as .msi file, instead of .exe format in InstallAnyWhere ?
    0 Kudos
    pv7721
    Flexera beginner

    Re: SecurityService class not found

    AFAIK this is not possible, as IA is multi platform, whereas .msi is Windows specific.
    0 Kudos