Search Results

Search found 23 results on 1 pages for 'mabuzer'.

Page 1/1 | 1 

  • Tomcat does save logged users during restart

    - by mabuzer
    How to force Tomcat to save logged users, so that the they kept logged in even after Tomcat has restarted? Right now the user has to login again everytime. Added the following lines into web-app context.xml: <Manager className="org.apache.catalina.session.PersistentManager"> <Store className="org.apache.catalina.session.FileStore"/> </Manager> but still I see login page after Tomcat restart, I use Tomcat 6.0.26 Update I managed to solve it like this: 1) Make my own extended version of FormAuthentication class: package com.alz.tomcat; import java.io.IOException; import java.security.Principal; import org.apache.catalina.Session; import org.apache.catalina.deploy.LoginConfig; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; import org.apache.catalina.authenticator.Constants; import org.apache.catalina.authenticator.FormAuthenticator; /** * * @author mabuzer */ public class Authenticator extends FormAuthenticator { @Override public boolean authenticate(Request request, Response response, LoginConfig config) throws IOException { String username = (String) request.getSession().getAttribute("USERNAME"); String password = (String) request.getSession().getAttribute("PASSWORD"); Principal principal = request.getUserPrincipal(); Session session = request.getSessionInternal(true); if (request.getUserPrincipal() == null && !isNull(username) && !isNull(password)) { principal = context.getRealm().authenticate(username, password); if (principal != null) { session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal); if (!matchRequest(request)) { register(request, response, principal, Constants.FORM_METHOD, username, password); return (true); } } return super.authenticate(request, response, config); } else { return super.authenticate(request, response, config); } } private boolean isNull(String str) { if (str == null || "".equals(str)) { return true; } else { return false; } } } 2) Have your own ContextConfig class: package com.alz.tomcat; import java.util.HashMap; import org.apache.catalina.Valve; /** * * @author [email protected] */ public class ContextConfig extends org.apache.catalina.startup.ContextConfig { public ContextConfig() { super(); // we need to append our authenticator setCustomAuthenticators(customAuthenticators); customAuthenticators = new HashMap(); customAuthenticators.put("Authenticator" , new Authenticator()); } } 3) Have a class extends LifeCycleListener to set replace default ContextConfig the one you made: package com.alz.tomcat; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.core.StandardHost; /** * * @author [email protected] */ public class LifeCycleListener implements org.apache.catalina.LifecycleListener { public void lifecycleEvent(LifecycleEvent lifeCycleEvent) { if (Lifecycle.BEFORE_START_EVENT.equals(lifeCycleEvent.getType())) { StandardHost aStandardHost = (StandardHost) lifeCycleEvent.getLifecycle(); aStandardHost.setConfigClass("com.alz.tomcat.ContextConfig"); } } } 4) Final step which is to add your LifeCycleListener to server.xml in Host tag like this: <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false"> <Listener className="com.alz.tomcat.LifeCycleListener"/> </Host>

    Read the article

  • JAXB alternatives?

    - by mabuzer
    What's the best alternative for JAXB, keep in mind alternative need to do Validating, Marshalling, UnMarshalling, also generate classes of given xsd file as JAXB currently does. thanks in advance...

    Read the article

  • Tomcat cache filter

    - by mabuzer
    How to have resource handler in tomcat, which simply check resource like js or css and append an ?[last-modified-date] to it's url, so we enable cache, and be sure that client-browser use right resource? thanks in advance...

    Read the article

  • MySQL create memory leak in Tomcat

    - by mabuzer
    I have set a JDBCRealm for web-app inside tomcat, and when I reload it I got this from tomcat: SEVERE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. I use tomcat 6.0.24, with MySQL Connector 5.1.10,,,

    Read the article

  • MySQL best usage in Tomcat?

    - by mabuzer
    Which one is better way of using MySQL in Tomcat : A) assign a DB connection for user as long as it's session is valid. [OR] B) open connection to DB, on every request come to server and when it's done close that. ?

    Read the article

  • Use my own authentication in tomcat

    - by mabuzer
    how can I force tomcat to use my own implementation of Authenticator, and not the existing one like [FORM, BASIC, DIGEST,, etc]. I know if I added my authentication class name in org.apache.catalina.startup.Authenticators.properties it would work,,, any help please... I need an alternative for this...

    Read the article

  • Tomcat does not persist Session during restart

    - by mabuzer
    How to force Tomcat to serialize Session so that the user is kept logged in when Tomcat has restarted? Right now the user has to login again everytime. Added the following lines into web-app context.xml: <Manager className="org.apache.catalina.session.PersistentManager"> <Store className="org.apache.catalina.session.FileStore"/> </Manager> but still I see login page after Tomcat restart, I use Tomcat 6.0.24

    Read the article

  • Tomcat does not persist UserPrinciple during restart

    - by mabuzer
    How to force Tomcat to serialize UserPrinciple so that the user is kept logged in when Tomcat has restarted? Right now the user has to login again everytime. Added the following lines into web-app context.xml: <Manager className="org.apache.catalina.session.PersistentManager"> <Store className="org.apache.catalina.session.FileStore"/> </Manager> but still I see login page after Tomcat restart, I use Tomcat 6.0.26

    Read the article

1