Package net.jumperz.app.MMonjaDB.eclipse

Source Code of net.jumperz.app.MMonjaDB.eclipse.MAuthCommand

package net.jumperz.app.MMonjaDB.eclipse;

import com.mongodb.DB;

import net.jumperz.app.MMonjaDBCore.MAbstractLogAgent;
import net.jumperz.app.MMonjaDBCore.MDataManager;
import net.jumperz.app.MMonjaDBCore.action.MAction;
import net.jumperz.util.*;

public class MAuthCommand
extends MAbstractLogAgent
implements MCommand
{
private String username;
private String passwd;
private MAction action;
private boolean isSuperuser;
//--------------------------------------------------------------------------------
public MAuthCommand( String _username, String _passwd, MAction _action, boolean _isSuperuser )
{
username = _username;
passwd = _passwd;
action = _action;
isSuperuser = _isSuperuser;
}
//--------------------------------------------------------------------------------
public void execute()
{
try
  {
  DB db;
  if( isSuperuser )
    {
    db = MDataManager.getInstance().getMongo().getDB( "admin" );
    }
  else
    {
    db = MDataManager.getInstance().getDB();
    }
 
  if( db.isAuthenticated() )
    {
    return;
    }
 
    //exec auth
  if( db.authenticate( username, passwd.toCharArray() ) )
    {
    MDataManager.getInstance().getActionThreadPool().addCommand( action );
    }
  else
    {
    info( "auth failed." );
    }
  }
catch( Exception e )
  {
  info( e );
  }
}
//--------------------------------------------------------------------------------
public void breakCommand()
{
}
//--------------------------------------------------------------------------------
}
TOP

Related Classes of net.jumperz.app.MMonjaDB.eclipse.MAuthCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.