flex-messaging-opt-1.0

16:35:51.646 INFO  jd.cli.Main - Decompiling flex-messaging-opt-1.0.jar
package flex.management;

import flex.messaging.log.Log;
import flex.messaging.log.Logger;
import flex.messaging.util.ClassUtil;
import java.lang.reflect.Method;
import javax.management.MBeanServer;

public class WebSphereMBeanServerLocator
  implements MBeanServerLocator
{
  private static final int FAILED_TO_LOCATE_MBEAN_SERVER = 10427;
  private MBeanServer server;
  
  public synchronized MBeanServer getMBeanServer()
  {
    if (server == null)
    {
      Class adminServiceClass = ClassUtil.createClass("com.ibm.websphere.management.AdminServiceFactory");
      try
      {
        Method getMBeanFactoryMethod = adminServiceClass.getMethod("getMBeanFactory", new Class[0]);
        Object mbeanFactory = getMBeanFactoryMethod.invoke(null, new Object[0]);
        Method getMBeanServerMethod = mbeanFactory.getClass().getMethod("getMBeanServer", new Class[0]);
        server = ((MBeanServer)getMBeanServerMethod.invoke(mbeanFactory, new Object[0]));
      }
      catch (Exception e)
      {
        ManagementException me = new ManagementException();
        me.setMessage(10427, new Object[] { getClass().getName() });
        me.setRootCause(e);
        throw me;
      }
      if (Log.isDebug()) {
        Log.getLogger("Management.MBeanServer").debug("Using MBeanServer: " + server);
      }
    }
    return server;
  }
}

/* Location:
 * Qualified Name:     flex.management.WebSphereMBeanServerLocator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import flex.messaging.FlexContext;
import flex.messaging.util.PropertyStringResourceLoader;
import java.security.Principal;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jrun.security.JRunSecurityException;
import jrun.servlet.JRunServletContext;
import jrun.servlet.WebApplication;
import jrun.servlet.security.AuthenticatedUser;
import jrun.servlet.security.ServletUsers;
import jrun.servlet.security.WebAppSecurityService;
import jrun.servlet.session.Session;
import jrunx.kernel.JRun;

public class JRunLoginCommand
  extends AppServerLoginCommand
{
  private WebAppSecurityService appSecurity;
  private ServletUsers usersService;
  private static final int AUTH_FAILED = 10060;
  private static final int SEC_MANAGER_REQ_FOR_AUTH = 10061;
  private static final int NO_SEC_MANAGER = 20050;
  private static final int NO_SEC_SRVC_OR_USERS = 20051;
  
  public void start(ServletConfig servletConfig)
  {
    try
    {
      Class.forName("jrun.servlet.security.AuthenticatedUser");
      Class.forName("jrun.servlet.security.WebAppSecurityService");
      Class.forName("jrun.servlet.JRunServletContext");
    }
    catch (Throwable t)
    {
      SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
      
      se.setMessage(20050);
      throw se;
    }
    if (JRun.server != null) {
      try
      {
        ServletContext servletContext = servletConfig.getServletContext();
        String webAppName = ((JRunServletContext)servletContext).getWebApplication().getName();
        
        Set serviceMBeans = null;
        ObjectInstance mbean = null;
        
        ObjectName serviceName = new ObjectName("ServletEngineService." + webAppName + ":service=WebAppSecurityService");
        serviceMBeans = JRun.server.queryMBeans(serviceName, null);
        if (serviceMBeans != null)
        {
          Iterator iterator = serviceMBeans.iterator();
          if (iterator.hasNext()) {
            mbean = (ObjectInstance)iterator.next();
          }
        }
        if (mbean != null)
        {
          Object securityService = JRun.server.invoke(mbean.getObjectName(), "getWebAppSecurity", null, null);
          if ((securityService instanceof WebAppSecurityService)) {
            appSecurity = ((WebAppSecurityService)securityService);
          }
        }
        serviceName = new ObjectName("ServletEngineService:service=ServletUsersService");
        serviceMBeans = JRun.server.queryMBeans(serviceName, null);
        if (serviceMBeans != null)
        {
          Iterator iterator = serviceMBeans.iterator();
          if (iterator.hasNext()) {
            mbean = (ObjectInstance)iterator.next();
          }
        }
        if (mbean != null)
        {
          Object usersService = JRun.server.invoke(mbean.getObjectName(), "getServletUsers", null, null);
          if ((usersService instanceof ServletUsers)) {
            this.usersService = ((ServletUsers)usersService);
          }
        }
      }
      catch (MalformedObjectNameException ex)
      {
        SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
        
        se.setMessage(20051);
        se.setRootCause(ex);
        throw se;
      }
      catch (InstanceNotFoundException ex)
      {
        SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
        
        se.setMessage(20051);
        se.setRootCause(ex);
        throw se;
      }
      catch (MBeanException ex)
      {
        Exception e = ex.getTargetException();
        SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
        
        se.setMessage(20051);
        se.setRootCause(e);
        throw se;
      }
      catch (ReflectionException ex)
      {
        SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
        
        se.setMessage(20051);
        se.setRootCause(ex);
        throw se;
      }
      catch (NullPointerException npe)
      {
        SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
        
        se.setMessage(20051);
        se.setRootCause(npe);
        throw se;
      }
    }
  }
  
  public Principal doAuthentication(String username, Object credentials)
    throws SecurityException
  {
    if (appSecurity == null) {
      start(FlexContext.getServletConfig());
    }
    try
    {
      AuthenticatedUser user = null;
      String password = extractPassword(credentials);
      if (password != null)
      {
        HttpServletResponse response = FlexContext.getHttpResponse();
        if (response != null)
        {
          HttpServletRequest request = FlexContext.getHttpRequest();
          user = appSecurity.authenticate(username, password, request.getSession(true));
        }
        else
        {
          ServletContext servletContext = FlexContext.getServletConfig().getServletContext();
          WebApplication webApp = ((JRunServletContext)servletContext).getWebApplication();
          HttpSession tempSession = webApp.getSessionService().createSession("temp");
          user = appSecurity.authenticate(username, password, tempSession);
          tempSession.invalidate();
        }
        return user.getPrincipal();
      }
    }
    catch (Exception ex)
    {
      SecurityException se;
      SecurityException se;
      if ((ex instanceof SecurityException))
      {
        se = (SecurityException)ex;
      }
      else if ((ex instanceof MBeanException))
      {
        ex = ((MBeanException)ex).getTargetException();
        SecurityException se = new SecurityException();
        se.setMessage(10060);
        se.setRootCause(ex);
      }
      else if ((ex instanceof JRunSecurityException))
      {
        SecurityException se = new SecurityException();
        se.setMessage(10060);
        se.setRootCause(ex);
      }
      else
      {
        se = new SecurityException();
        se.setMessage(10061);
      }
      se.setCode("Client.Authentication");
      throw se;
    }
    return null;
  }
  
  public boolean doAuthorization(Principal principal, List roles)
    throws SecurityException
  {
    if (appSecurity == null) {
      start(FlexContext.getServletConfig());
    }
    boolean authorized = false;
    
    HttpServletResponse response = FlexContext.getHttpResponse();
    if (response != null)
    {
      HttpServletRequest request = FlexContext.getHttpRequest();
      authorized = doAuthorization(principal, roles, request);
    }
    else
    {
      for (int i = 0; i < roles.size(); i++)
      {
        String role = (String)roles.get(i);
        if (appSecurity.isPrincipalInRole(principal, role))
        {
          authorized = true;
          break;
        }
      }
    }
    return authorized;
  }
  
  public boolean logout(Principal principal)
    throws SecurityException
  {
    HttpServletResponse response = FlexContext.getHttpResponse();
    if (response != null) {
      try
      {
        ServletContext servletContext = FlexContext.getServletConfig().getServletContext();
        WebApplication webApp = ((JRunServletContext)servletContext).getWebApplication();
        HttpServletRequest request = FlexContext.getHttpRequest();
        
        HttpSession session = request.getSession();
        String sessionId = session.getId();
        AuthenticatedUser currentUser = usersService.getUser(sessionId, webApp);
        currentUser.logoff();
      }
      catch (NullPointerException npe) {}
    }
    return true;
  }
  
  public void stop()
  {
    usersService = null;
    appSecurity = null;
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.JRunLoginCommand
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import java.security.Principal;
import java.util.List;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import oracle.security.jazn.JAZNConfig;
import oracle.security.jazn.callback.JAZNCallbackHandler;

public class OracleLoginCommand
  extends AppServerLoginCommand
{
  public Principal doAuthentication(String username, Object credentials)
    throws SecurityException
  {
    OracleUser user;
    try
    {
      CallbackHandler callbackHandler = new JAZNCallbackHandler(JAZNConfig.getJAZNConfig(), null, username, extractPassword(credentials));
      
      LoginContext context = new LoginContext("oracle.security.jazn.oc4j.JAZNUserManager", callbackHandler);
      
      user = new OracleUser(context);
    }
    catch (LoginException loginException)
    {
      throw wrapLoginException(loginException);
    }
    return user;
  }
  
  public boolean doAuthorization(Principal principal, List roles)
    throws SecurityException
  {
    boolean result = false;
    if ((principal instanceof OracleUser))
    {
      OracleUser user = (OracleUser)principal;
      result = user.isMemberOf(roles);
    }
    return result;
  }
  
  public boolean logout(Principal principal)
    throws SecurityException
  {
    boolean result = false;
    if ((principal instanceof OracleUser))
    {
      OracleUser user = (OracleUser)principal;
      try
      {
        user.logout();
        result = true;
      }
      catch (LoginException loginException)
      {
        throw wrapLoginException(loginException);
      }
    }
    return result;
  }
  
  private SecurityException wrapLoginException(LoginException exception)
  {
    SecurityException result = new SecurityException();
    result.setRootCause(exception);
    return result;
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.OracleLoginCommand
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import java.security.Principal;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import oracle.security.jazn.realm.Realm;
import oracle.security.jazn.realm.RealmRole;
import oracle.security.jazn.realm.RealmUser;

public class OracleUser
  implements Principal
{
  private LoginContext context;
  private Subject subject;
  
  public OracleUser(LoginContext context)
    throws LoginException
  {
    this.context = context;
    context.logout();
    context.login();
    subject = context.getSubject();
  }
  
  public void logout()
    throws LoginException
  {
    context.logout();
  }
  
  private Principal userPrincipal()
  {
    Set possibleUsers = subject.getPrincipals(RealmUser.class);
    return (Principal)possibleUsers.iterator().next();
  }
  
  public boolean isMemberOf(List roleNames)
  {
    boolean result = false;
    Set possibleUsers = subject.getPrincipals(RealmRole.class);
    Iterator itr = possibleUsers.iterator();
    while (itr.hasNext())
    {
      RealmRole role = (RealmRole)itr.next();
      Realm realm = role.getRealm();
      String realmFullName = realm.getFullName();
      String roleSimpleName = role.getName();
      if ((realmFullName.length() > 0) && (roleSimpleName.startsWith(realmFullName))) {
        roleSimpleName = roleSimpleName.substring(realmFullName.length() + 1);
      }
      if (roleNames.contains(roleSimpleName))
      {
        result = true;
        break;
      }
    }
    return result;
  }
  
  public boolean equals(Object object)
  {
    boolean result = false;
    if (object == this)
    {
      result = true;
    }
    else if ((object instanceof OracleUser))
    {
      OracleUser other = (OracleUser)object;
      result = subject.equals(subject);
    }
    return result;
  }
  
  public String getName()
  {
    return userPrincipal().getName();
  }
  
  public int hashCode()
  {
    return subject.hashCode();
  }
  
  public String toString()
  {
    return subject.toString();
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.OracleUser
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import flex.messaging.FlexContext;
import flex.messaging.util.PropertyStringResourceLoader;
import java.security.Principal;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TomcatLoginCommand
  extends AppServerLoginCommand
{
  private static final int NO_VALVE = 20000;
  
  public Principal doAuthentication(String username, Object credentials)
    throws SecurityException
  {
    TomcatLogin login = TomcatLoginHolder.getLogin();
    if (login == null)
    {
      SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
      
      se.setMessage(20000);
      throw se;
    }
    String password = extractPassword(credentials);
    if (password != null)
    {
      HttpServletRequest request = FlexContext.getHttpRequest();
      return login.login(username, password, request);
    }
    return null;
  }
  
  public boolean doAuthorization(Principal principal, List roles)
    throws SecurityException
  {
    boolean authorized = false;
    
    HttpServletRequest request = FlexContext.getHttpRequest();
    HttpServletResponse response = FlexContext.getHttpResponse();
    if ((response != null) && (request != null) && (principal != null) && (principal.equals(request.getUserPrincipal())))
    {
      authorized = doAuthorization(principal, roles, request);
    }
    else
    {
      TomcatLogin login = TomcatLoginHolder.getLogin();
      if (login == null)
      {
        SecurityException se = new SecurityException(new PropertyStringResourceLoader("flex/messaging/vendors"));
        
        se.setMessage(20000);
        throw se;
      }
      authorized = login.authorize(principal, roles);
    }
    return authorized;
  }
  
  public boolean logout(Principal principal)
    throws SecurityException
  {
    HttpServletRequest request = FlexContext.getHttpRequest();
    HttpServletResponse response = FlexContext.getHttpResponse();
    if ((response != null) && (request != null))
    {
      TomcatLogin login = TomcatLoginHolder.getLogin();
      if (login != null) {
        return login.logout(request);
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.TomcatLoginCommand
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import com.ibm.ws.security.core.ContextManager;
import java.security.Principal;
import javax.security.auth.Subject;

class WebSphereLoginCommand$WSLCPrincipal
  implements Principal
{
  private String username;
  private ContextManager contextManager;
  private Subject subject;
  private final WebSphereLoginCommand this$0;
  
  public WebSphereLoginCommand$WSLCPrincipal(WebSphereLoginCommand paramWebSphereLoginCommand, String username, ContextManager contextManager, Subject subject)
  {
    this.username = username;
    this.contextManager = contextManager;
    this.subject = subject;
  }
  
  public String getName()
  {
    return username;
  }
  
  public ContextManager getContextManager()
  {
    return contextManager;
  }
  
  public Subject getSubject()
  {
    return subject;
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.WebSphereLoginCommand.WSLCPrincipal
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import com.ibm.websphere.security.UserRegistry;
import com.ibm.websphere.security.WSSecurityException;
import com.ibm.websphere.security.auth.WSLoginFailedException;
import com.ibm.ws.security.core.ContextManager;
import com.ibm.ws.security.core.ContextManagerFactory;
import flex.messaging.FlexContext;
import flex.messaging.log.Log;
import flex.messaging.log.Logger;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.security.auth.Subject;
import javax.servlet.http.HttpServletRequest;

public class WebSphereLoginCommand
  extends AppServerLoginCommand
{
  public Principal doAuthentication(String username, Object credentials)
  {
    Principal principal = null;
    try
    {
      String password = extractPassword(credentials);
      if (password != null)
      {
        ContextManager contextManager = ContextManagerFactory.getInstance();
        
        Subject subject = contextManager.login(contextManager.getDefaultRealm(), username, password);
        if (subject != null)
        {
          contextManager.setCallerSubject(subject);
          principal = new WSLCPrincipal(username, contextManager, subject);
        }
      }
    }
    catch (WSLoginFailedException wsLoginFailedException)
    {
      if (Log.isDebug()) {
        Log.getLogger("Security").debug("WebSphereLoginCommand#doAuthentication() failed: " + wsLoginFailedException.toString(), wsLoginFailedException);
      }
    }
    catch (WSSecurityException wsSecurityException)
    {
      if (Log.isDebug()) {
        Log.getLogger("Security").debug("WebSphereLoginCommand#doAuthentication() failed: " + wsSecurityException.toString(), wsSecurityException);
      }
    }
    if ((Log.isDebug()) && (principal != null)) {
      Log.getLogger("Security").debug("WebSphereLoginCommand#doAuthentication(). Principal: " + principal + ", Principal class: " + principal.getClass().getName() + ", Principal identity: " + System.identityHashCode(principal));
    }
    return principal;
  }
  
  public boolean doAuthorization(Principal principal, List roles)
  {
    if (principal == null) {
      return false;
    }
    if (Log.isDebug()) {
      Log.getLogger("Security").debug("WebSphereLoginCommand#doAuthorization(). Principal: " + principal + ", Principal class: " + principal.getClass().getName() + ", Principal identity: " + System.identityHashCode(principal));
    }
    HttpServletRequest request;
    Iterator iter;
    if ((principal instanceof WSLCPrincipal))
    {
      ContextManager contextManager = ((WSLCPrincipal)principal).getContextManager();
      UserRegistry registry = contextManager.getRegistry(contextManager.getDefaultRealm());
      try
      {
        List groups = new ArrayList(registry.getGroupsForUser(principal.getName()));
        
        groups.retainAll(roles);
        if (groups.size() > 0) {
          ContextManagerFactory.getInstance().setCallerSubject(((WSLCPrincipal)principal).getSubject());
        }
        return groups.size() > 0;
      }
      catch (Exception e) {}
    }
    else
    {
      request = FlexContext.getHttpRequest();
      for (iter = roles.iterator(); iter.hasNext();) {
        if (request.isUserInRole((String)iter.next())) {
          return true;
        }
      }
    }
    return false;
  }
  
  public boolean logout(Principal principal)
  {
    return true;
  }
  
  private class WSLCPrincipal
    implements Principal
  {
    private String username;
    private ContextManager contextManager;
    private Subject subject;
    
    public WSLCPrincipal(String username, ContextManager contextManager, Subject subject)
    {
      this.username = username;
      this.contextManager = contextManager;
      this.subject = subject;
    }
    
    public String getName()
    {
      return username;
    }
    
    public ContextManager getContextManager()
    {
      return contextManager;
    }
    
    public Subject getSubject()
    {
      return subject;
    }
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.WebSphereLoginCommand
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import java.security.Principal;
import javax.security.auth.Subject;
import weblogic.security.SubjectUtils;

class WeblogicLoginCommand$SubjectPrincipal
  implements Principal
{
  private Subject subject;
  private final WeblogicLoginCommand this$0;
  
  public WeblogicLoginCommand$SubjectPrincipal(WeblogicLoginCommand paramWeblogicLoginCommand, Subject subject)
  {
    this.subject = subject;
  }
  
  public String getName()
  {
    return SubjectUtils.getUserPrincipal(subject).getName();
  }
  
  public Subject getSubject()
  {
    return subject;
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.WeblogicLoginCommand.SubjectPrincipal
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.security;

import flex.messaging.FlexContext;
import java.security.Principal;
import java.util.Iterator;
import java.util.List;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import weblogic.security.SimpleCallbackHandler;
import weblogic.security.SubjectUtils;
import weblogic.security.services.Authentication;
import weblogic.servlet.security.ServletAuthentication;

public class WeblogicLoginCommand
  extends AppServerLoginCommand
{
  public Principal doAuthentication(String username, Object credentials)
  {
    Principal principal = null;
    
    String password = extractPassword(credentials);
    if (password != null)
    {
      HttpServletResponse response = FlexContext.getHttpResponse();
      if (response != null)
      {
        HttpServletRequest request = FlexContext.getHttpRequest();
        int result = 1;
        try
        {
          result = ServletAuthentication.login(username, password, request);
        }
        catch (LoginException e) {}catch (NoSuchMethodError noSuchMethodError)
        {
          result = ServletAuthentication.weak(username, password, request);
        }
        if (result != 1) {
          principal = getSubjectPrincipal(username, password);
        }
      }
      else
      {
        principal = getSubjectPrincipal(username, password);
      }
    }
    return principal;
  }
  
  private Principal getSubjectPrincipal(String username, String password)
  {
    Principal principal = null;
    
    SimpleCallbackHandler handler = new SimpleCallbackHandler(username, password);
    try
    {
      Subject subject = Authentication.login(handler);
      principal = new SubjectPrincipal(subject);
    }
    catch (LoginException e) {}
    return principal;
  }
  
  private boolean doSubjectGroupAuthorization(Principal principal, List roles)
  {
    boolean authorized = false;
    
    Subject subject = ((SubjectPrincipal)principal).getSubject();
    Iterator iter = roles.iterator();
    while (iter.hasNext())
    {
      String role = (String)iter.next();
      if (SubjectUtils.isUserInGroup(subject, role))
      {
        authorized = true;
        break;
      }
    }
    return authorized;
  }
  
  public boolean doAuthorization(Principal principal, List roles)
  {
    if (principal == null) {
      return false;
    }
    boolean authorized = false;
    
    HttpServletResponse response = FlexContext.getHttpResponse();
    if (response != null)
    {
      HttpServletRequest request = FlexContext.getHttpRequest();
      
      authorized = doAuthorization(principal, roles, request);
      if (!authorized) {
        authorized = doSubjectGroupAuthorization(principal, roles);
      }
    }
    else
    {
      authorized = doSubjectGroupAuthorization(principal, roles);
    }
    return authorized;
  }
  
  public boolean logout(Principal principal)
  {
    HttpServletResponse response = FlexContext.getHttpResponse();
    if (response != null)
    {
      HttpServletRequest request = FlexContext.getHttpRequest();
      ServletAuthentication.logout(request);
    }
    return true;
  }
  
  private class SubjectPrincipal
    implements Principal
  {
    private Subject subject;
    
    public SubjectPrincipal(Subject subject)
    {
      this.subject = subject;
    }
    
    public String getName()
    {
      return SubjectUtils.getUserPrincipal(subject).getName();
    }
    
    public Subject getSubject()
    {
      return subject;
    }
  }
}

/* Location:
 * Qualified Name:     flex.messaging.security.WeblogicLoginCommand
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.util.concurrent;

import com.ibm.websphere.asynchbeans.WorkEvent;
import com.ibm.websphere.asynchbeans.WorkException;
import com.ibm.websphere.asynchbeans.WorkListener;
import flex.messaging.log.Log;
import flex.messaging.log.Logger;

class AsynchBeansWorkManagerExecutor$1
  implements WorkListener
{
  private final AsynchBeansWorkManagerExecutor this$0;
  
  AsynchBeansWorkManagerExecutor$1(AsynchBeansWorkManagerExecutor paramAsynchBeansWorkManagerExecutor) {}
  
  public void workAccepted(WorkEvent event) {}
  
  public void workCompleted(WorkEvent event)
  {
    WorkException e = event.getException();
    if (e != null)
    {
      if (Log.isDebug()) {
        Log.getLogger("Executor").error("AsynchBeansWorkManager's WorkListener.workCompleted() callback invoked for failed execution.", e);
      }
      AsynchBeansWorkManagerExecutor.access$100(this$0, AsynchBeansWorkManagerExecutor.WorkCommandWrapper.access$000((AsynchBeansWorkManagerExecutor.WorkCommandWrapper)event.getWork()), e);
    }
  }
  
  public void workRejected(WorkEvent event)
  {
    WorkException e = event.getException();
    if (Log.isDebug()) {
      Log.getLogger("Executor").error("AsynchBeansWorkManager's WorkListener.workRejected() callback invoked. WorkException? " + e);
    }
    AsynchBeansWorkManagerExecutor.access$100(this$0, AsynchBeansWorkManagerExecutor.WorkCommandWrapper.access$000((AsynchBeansWorkManagerExecutor.WorkCommandWrapper)event.getWork()), e);
  }
  
  public void workStarted(WorkEvent event) {}
}

/* Location:
 * Qualified Name:     flex.messaging.util.concurrent.AsynchBeansWorkManagerExecutor.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.util.concurrent;

import com.ibm.websphere.asynchbeans.Work;

class AsynchBeansWorkManagerExecutor$WorkCommandWrapper
  implements Work
{
  private final Runnable command;
  private final AsynchBeansWorkManagerExecutor this$0;
  
  public AsynchBeansWorkManagerExecutor$WorkCommandWrapper(AsynchBeansWorkManagerExecutor paramAsynchBeansWorkManagerExecutor, Runnable command)
  {
    this.command = command;
  }
  
  public void run()
  {
    command.run();
  }
  
  public void release() {}
}

/* Location:
 * Qualified Name:     flex.messaging.util.concurrent.AsynchBeansWorkManagerExecutor.WorkCommandWrapper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package flex.messaging.util.concurrent;

import com.ibm.websphere.asynchbeans.Work;
import com.ibm.websphere.asynchbeans.WorkEvent;
import com.ibm.websphere.asynchbeans.WorkException;
import com.ibm.websphere.asynchbeans.WorkListener;
import com.ibm.websphere.asynchbeans.WorkManager;
import flex.messaging.config.ConfigurationException;
import flex.messaging.log.Log;
import flex.messaging.log.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class AsynchBeansWorkManagerExecutor
  implements Executor
{
  public AsynchBeansWorkManagerExecutor(String workManagerJNDIName)
  {
    try
    {
      InitialContext ic = new InitialContext();
      workManager = ((WorkManager)ic.lookup(workManagerJNDIName));
    }
    catch (NamingException ne)
    {
      ConfigurationException ce = new ConfigurationException();
      ce.setMessage(13600, new Object[] { workManagerJNDIName });
      ce.setRootCause(ne);
      throw ce;
    }
    workListener = new WorkListener()
    {
      public void workAccepted(WorkEvent event) {}
      
      public void workCompleted(WorkEvent event)
      {
        WorkException e = event.getException();
        if (e != null)
        {
          if (Log.isDebug()) {
            Log.getLogger("Executor").error("AsynchBeansWorkManager's WorkListener.workCompleted() callback invoked for failed execution.", e);
          }
          AsynchBeansWorkManagerExecutor.this.handleFailedExecution(getWorkcommand, e);
        }
      }
      
      public void workRejected(WorkEvent event)
      {
        WorkException e = event.getException();
        if (Log.isDebug()) {
          Log.getLogger("Executor").error("AsynchBeansWorkManager's WorkListener.workRejected() callback invoked. WorkException? " + e);
        }
        AsynchBeansWorkManagerExecutor.this.handleFailedExecution(getWorkcommand, e);
      }
      
      public void workStarted(WorkEvent event) {}
    };
  }
  
  private final Object lock = new Object();
  private final WorkManager workManager;
  private final WorkListener workListener;
  private FailedExecutionHandler failedExecutionHandler;
  
  /* Error */
  public FailedExecutionHandler getFailedExecutionHandler()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 4	flex/messaging/util/concurrent/AsynchBeansWorkManagerExecutor:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: getfield 18	flex/messaging/util/concurrent/AsynchBeansWorkManagerExecutor:failedExecutionHandler	Lflex/messaging/util/concurrent/FailedExecutionHandler;
    //   11: aload_1
    //   12: monitorexit
    //   13: areturn
    //   14: astore_2
    //   15: aload_1
    //   16: monitorexit
    //   17: aload_2
    //   18: athrow
    // Line number table:
    //   Java source line #139	-> byte code offset #0
    //   Java source line #141	-> byte code offset #7
    //   Java source line #142	-> byte code offset #14
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	19	0	this	AsynchBeansWorkManagerExecutor
    //   5	11	1	Ljava/lang/Object;	Object
    //   14	4	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	13	14	finally
    //   14	17	14	finally
  }
  
  public void setFailedExecutionHandler(FailedExecutionHandler value)
  {
    synchronized (lock)
    {
      failedExecutionHandler = value;
    }
  }
  
  public void execute(Runnable command)
  {
    try
    {
      workManager.startWork(new WorkCommandWrapper(command), Long.MAX_VALUE, workListener);
    }
    catch (WorkException e)
    {
      handleFailedExecution(command, e);
    }
  }
  
  private void handleFailedExecution(Runnable command, Exception e)
  {
    FailedExecutionHandler handler = getFailedExecutionHandler();
    if (handler != null) {
      handler.failedExecution(command, this, e);
    } else if (Log.isError()) {
      Log.getLogger("Executor").error("AsynchBeansWorkManager hit an Exception but no FailedExecutionHandler is registered to handle the error.", e);
    }
  }
  
  class WorkCommandWrapper
    implements Work
  {
    private final Runnable command;
    
    public WorkCommandWrapper(Runnable command)
    {
      this.command = command;
    }
    
    public void run()
    {
      command.run();
    }
    
    public void release() {}
  }
}

/* Location:
 * Qualified Name:     flex.messaging.util.concurrent.AsynchBeansWorkManagerExecutor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd