/** * Construct a callback handler configured with the specified values. * Note that if the <code>JAASRealm</code> instance specifies digested passwords, * the <code>password</code> parameter will be pre-digested here. * * @param realm Our associated JAASRealm instance * @param username Username to be authenticated with * @param password Password to be authenticated with */ public JAASCallbackHandler(JAASRealm realm, String username, String password) { super(); this.realm = realm; this.username = username; if (realm.hasMessageDigest()) { this.password = realm.digest(password); } else { this.password = password; } }
/** * @return the <code>Principal</code> associated with the given user name. */ @Override protected Principal getPrincipal(String username) { return authenticate(username, new JAASCallbackHandler(this, username, null, null, null, null, null, null, null, HttpServletRequest.CLIENT_CERT_AUTH)); }
/** * Prepare for the beginning of active use of the public methods of this * component and implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { // These need to be called after loading configuration, in case // useContextClassLoader appears after them in xml config parseClassNames(userClassNames, userClasses); parseClassNames(roleClassNames, roleClasses); super.startInternal(); }
JAASRealm realm = new JAASRealm(); realm.setUserClassNames(userClassNames); realm.setRoleClassNames(roleClassNames); if("true".equals(useContextClassLoader) || "TRUE".equals(useContextClassLoader)){ realm.setUseContextClassLoader(true); } else { realm.setUseContextClassLoader(false); ObjectName oname = realm.getObjectName();
this.username = username; if (realm.hasMessageDigest()) { this.password = realm.getCredentialHandler().mutate(password);
if (isUseContextClassLoader()) { ocl=Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); return (null); } finally { if( isUseContextClassLoader()) { Thread.currentThread().setContextClassLoader(ocl); Principal principal = createPrincipal(username, subject); if (principal == null) { log.debug(sm.getString("jaasRealm.authenticateFailure", username));
if (!isUseContextClassLoader()) { ocl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( Configuration config = getConfig(); loginContext = new LoginContext( appName, null, callbackHandler, config); return null; } finally { if(!isUseContextClassLoader()) { Thread.currentThread().setContextClassLoader(ocl); Principal principal = createPrincipal(username, subject, loginContext); if (principal == null) { log.debug(sm.getString("jaasRealm.authenticateFailure", username));
public void setContainer(Container container) { super.setContainer(container); if( appName==null ) { String name=container.getName(); name = makeLegalForJAAS(name); appName=name; log.info("Set JAAS app name " + appName); } }
if (realm.getContainer().getLogger().isTraceEnabled()) realm.getContainer().getLogger().trace(sm.getString("jaasCallback.username", username)); ((NameCallback) callbacks[i]).setName(username); } else if (callbacks[i] instanceof PasswordCallback) {
if (isUseContextClassLoader()) loader = Thread.currentThread().getContextClassLoader();
Principal principal = createPrincipal(username, subject); if (principal == null) { if (log.isLoggable(Level.FINE)) {
/** Provide a default in case no explicit configuration is set * * @return configured realm, or a JAAS realm by default */ public Realm getRealm() { Realm configured=super.getRealm(); // If no set realm has been called - default to JAAS // This can be overriden at engine, context and host level if( configured==null ) { configured=new JAASRealm(); this.setRealm( configured ); } return configured; }
if (!isUseContextClassLoader()) { ocl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( return (null); } finally { if(!isUseContextClassLoader()) { Thread.currentThread().setContextClassLoader(ocl); Principal principal = createPrincipal(username, subject, loginContext); if (principal == null) { log.debug(sm.getString("jaasRealm.authenticateFailure", username));
if (!isUseContextClassLoader()) { ocl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( Configuration config = getConfig(); loginContext = new LoginContext( appName, null, callbackHandler, config); return (null); } finally { if(!isUseContextClassLoader()) { Thread.currentThread().setContextClassLoader(ocl); Principal principal = createPrincipal(username, subject, loginContext); if (principal == null) { log.debug(sm.getString("jaasRealm.authenticateFailure", username));
@Override public void setContainer(Container container) { super.setContainer(container); if( appName==null ) { String name = container.getName(); if (!name.startsWith("/")) { name = "/" + name; } name = makeLegalForJAAS(name); appName=name; log.info("Set JAAS app name " + appName); } }
if (realm.getContainer().getLogger().isTraceEnabled()) realm.getContainer().getLogger().trace(sm.getString("jaasCallback.username", username)); ((NameCallback) callbacks[i]).setName(username); } else if (callbacks[i] instanceof PasswordCallback) {
if (isUseContextClassLoader()) loader = Thread.currentThread().getContextClassLoader();
this.username = username; if (realm.hasMessageDigest()) { this.password = realm.getCredentialHandler().mutate(password);
/** Provide a default in case no explicit configuration is set * * @return configured realm, or a JAAS realm by default */ public Realm getRealm() { Realm configured=super.getRealm(); // If no set realm has been called - default to JAAS // This can be overridden at engine, context and host level if( configured==null ) { configured=new JAASRealm(); this.setRealm( configured ); } return configured; }
if (!isUseContextClassLoader()) { ocl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( return (null); } finally { if(!isUseContextClassLoader()) { Thread.currentThread().setContextClassLoader(ocl); Principal principal = createPrincipal(username, subject, loginContext); if (principal == null) { log.debug(sm.getString("jaasRealm.authenticateFailure", username));