This discussion is archived
8 Replies Latest reply: Dec 4, 2009 5:19 AM by 807575 RSS

How to login to app server

807575 Newbie
Currently Being Moderated
Not having much luck trying to log into app server in Creator.
In the following code, I am trying to login admin user:

HTTPServletRequest request = (HttpServletRequest)this.this.getExternalContext().getRequest();
HTTPServletResponse request = (HTTPServletResponse)this.this.getExternalContext().getResponse();
com.sun.appserv.security.ProgrammaticLogin p = new com.sun.appserv.security.ProgrammaticLogin();
p.login("admin", "adminadmin", "file", request, response, true);

All I get is ClassCastException.

Any ideas??
  • 1. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    error in above code. Correct code is:

    HTTPServletRequest request = (HttpServletRequest)this.this.getExternalContext().getRequest();
    HTTPServletResponse response = (HTTPServletResponse)this.this.getExternalContext().getResponse();
    com.sun.appserv.security.ProgrammaticLogin p = new com.sun.appserv.security.ProgrammaticLogin();
    p.login("admin", "adminadmin", "file", request, response, true);
  • 2. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    I tried I didn't get the Class cast exception. Following is the code.
    HttpServletRequest request = (HttpServletRequest)getExternalContext().getRequest();
            HttpServletResponse response = (HttpServletResponse)getExternalContext().getResponse();
            try{
            com.sun.appserv.security.ProgrammaticLogin p = new com.sun.appserv.security.ProgrammaticLogin();
            p.login("admin", "adminadmin", "file", request, response, true);
            }catch(Exception exc){
                exc.printStackTrace();
            }
    But I got access denied exception

    [#|2004-08-02T14:02:34.182-0700|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.system.core.security|_ThreadID=13;|SEC1130: Code does not have permission to invoke programmatic login mechanism.|#]
    [#|2004-08-02T14:02:34.182-0700|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.system.stream.err|_ThreadID=13;|
    java.security.AccessControlException: access denied (com.sun.appserv.security.ProgrammaticLoginPermission login)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
    at java.security.AccessController.checkPermission(AccessController.java:401)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
    at com.sun.appserv.security.ProgrammaticLogin.checkLoginPermission(ProgrammaticLogin.java:341)
    at com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:167)
    at webapplication2.Page1.<init>(Page1.java:37)

    - Winston
  • 3. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    Perhaps the default security options for the app server do not allow this? Might be something to ask the app server folks?

    v
  • 4. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    Add the following line:

    grant {
    permission java.security.AllPermission;
    };

    at the end of the server.policy file:

    \Sun\Creator\SunAppServer8\domains\creator\config\server.policy

    THIS IS FOR DEVELOPMENT ONLY!!!
    Remove the above line for production
  • 5. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    I ran into a similar issue when trying to use Hibernate - it wanted access to my system properties and was denied all access.

    Perhaps this should be an FAQ, or there should be a link to a guide - I was a bit surprised to see it so restrictive by default (esp for a "newbie" setup) and no instructions or help anywhere.
  • 6. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    We can look into that - it's almost more of a server issue than a Creator issue.... the concern is that the server folks want this to be used w/caution due to the security issues. The defaults are set per the app server defaults - I'll try to find out where this is doc'd by them.

    Val
  • 7. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    By the way, here's the security chapter of the
    developer guide:

    http://docs.sun.com/source/817-6087/dgsecure.html

    I'm also going to suggest a link to the app server doc from our docs section...

    v
  • 8. Re: How to login to app server
    807575 Newbie
    Currently Being Moderated
    w3apps wrote:
    Add the following line:

    grant {
    permission java.security.AllPermission;
    };

    at the end of the server.policy file:

    \Sun\Creator\SunAppServer8\domains\creator\config\server.policy

    THIS IS FOR DEVELOPMENT ONLY!!!
    Remove the above line for production
    But if I remove it (AllPermission), how can I make it work in production?

    I tried the link in the end of this thread and then I tried this;
    grant codeBase "file:${com.sun.aas.installRoot}/lib/myjar-security.jar" { 
      permission java.security.AllPermission 
      "login"; 
    };
    I still get the message: “Code does not have permission to invoke programmatic login mechanism.”

    I don't know what to do! :(