Examples of UserContext


Examples of br.com.procempa.modus.services.UserContext

  public void testLogin() throws Exception {
    String password = "111";
    char[] charPassword = new char[password.length()];
    password.getChars(0, password.length(), charPassword, 0);

    UserContext uc = LoginServices.login("1", charPassword);
    assertEquals(uc.getUsuario().getRg(), "1");

    password = "invalidPassword";
    charPassword = new char[password.length()];
    password.getChars(0, password.length(), charPassword, 0);
   
    UserContext ucFalha = LoginServices.login("1", charPassword);
    assertNull(ucFalha);
  }
View Full Code Here

Examples of com.boco.bomc.vpn.domain.UserContext

   * @param password
   * @param smspasswd
   * @throws Exception
   */
  private void initSession(String username,String password,String smspasswd) throws Exception{
    UserContext currentUser = new UserContext(username,password,smspasswd);
    HttpSession session = ActionContext.getActionContext().getHttpServletRequest().getSession();
    Map<String,Object> acctMap = (Map<String,Object>)session.getAttribute("acctMap");
    if(acctMap==null)
      throw new Exception("�޷���SESSION�л�ȡ�û���ϢacctMap!");
    List<Map<String,Object>> subAccts = (List<Map<String,Object>>)acctMap.get("SUBACCTS");
    if(subAccts==null)
      throw new Exception("�޷���ȡ�û���¼��BOMC���˺��б���ϢSUBACCTS!");
    for(Map<String,Object> map:subAccts){
      logger.info("���ʺ�["+username+"]�¹�BOMC���˺���Ϣ--start��");
      logger.info("���˺�[APPACCTID]��"+map.get("APPACCTID"));
      logger.info("���˺�[NAME]��"+map.get("NAME"));
      logger.info("���˺�[LOCK]��"+map.get("LOCK"));
      logger.info("���ʺ�["+username+"]�¹�BOMC���˺���Ϣ--end��");
    }
    currentUser.setSubAcct(subAccts);
    session.setAttribute("SESSION_USER", currentUser);
  }
View Full Code Here

Examples of com.cloud.user.UserContext

        }
    }

    @Override
    public VirtualRouter destroyRouter(final long routerId) throws ResourceUnavailableException, ConcurrentOperationException {
        UserContext context = UserContext.current();
        User user = _accountMgr.getActiveUser(context.getCallerUserId());

        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Attempting to destroy router " + routerId);
        }

        DomainRouterVO router = _routerDao.findById(routerId);
        if (router == null) {
            return null;
        }

        _accountMgr.checkAccess(context.getCaller(), null, true, router);

        boolean result = _itMgr.expunge(router, user, _accountMgr.getAccount(router.getAccountId()));

        if (result) {
            return router;
View Full Code Here

Examples of com.cloud.user.UserContext

        });
    }

    @Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_STOP, eventDescription = "stopping router Vm", async = true)
    public VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
        UserContext context = UserContext.current();
        Account account = context.getCaller();

        // verify parameters
        DomainRouterVO router = _routerDao.findById(routerId);
        if (router == null) {
            throw new InvalidParameterValueException("Unable to find router by id " + routerId + ".");
View Full Code Here

Examples of com.cloud.user.UserContext

        }
    }

    //Ensure router status is update to date before execute this function. The function would try best to recover all routers except MASTER
    protected void recoverRedundantNetwork(DomainRouterVO masterRouter, DomainRouterVO backupRouter) {
        UserContext context = UserContext.current();
        context.setAccountId(1);                           
        if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
            HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
            HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
            if (masterHost.getStatus() == Status.Up && backupHost.getStatus() == Status.Up) {
                String title =  "Reboot " + backupRouter.getInstanceName() + " to ensure redundant virtual routers work";
View Full Code Here

Examples of com.cloud.user.UserContext

        }
        return response;
    }

    private String queueCommand(BaseCmd cmdObj, Map<String, String> params) {
        UserContext ctx = UserContext.current();
        Long callerUserId = ctx.getCallerUserId();
        Account caller = ctx.getCaller();
        if (cmdObj instanceof BaseAsyncCmd) {
            Long objectId = null;
            String objectEntityTable = null;
            if (cmdObj instanceof BaseAsyncCreateCmd) {
                BaseAsyncCreateCmd createCmd = (BaseAsyncCreateCmd) cmdObj;
                _dispatcher.dispatchCreateCmd(createCmd, params);
                objectId = createCmd.getEntityId();
                objectEntityTable = createCmd.getEntityTable();
                params.put("id", objectId.toString());
            } else {
                ApiDispatcher.setupParameters(cmdObj, params);
                ApiDispatcher.plugService(cmdObj);
            }

            BaseAsyncCmd asyncCmd = (BaseAsyncCmd) cmdObj;

            if (callerUserId != null) {
                params.put("ctxUserId", callerUserId.toString());
            }
            if (caller != null) {
                params.put("ctxAccountId", String.valueOf(caller.getId()));
            }

            long startEventId = ctx.getStartEventId();
            asyncCmd.setStartEventId(startEventId);

            // save the scheduled event
            Long eventId = EventUtils.saveScheduledEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId,
                    asyncCmd.getEntityOwnerId(), asyncCmd.getEventType(), asyncCmd.getEventDescription(),
                    startEventId);
            if (startEventId == 0) {
                // There was no create event before, set current event id as start eventId
                startEventId = eventId;
            }

            params.put("ctxStartEventId", String.valueOf(startEventId));

            ctx.setAccountId(asyncCmd.getEntityOwnerId());

            AsyncJobVO job = new AsyncJobVO();
            job.setInstanceId((objectId == null) ? asyncCmd.getInstanceId() : objectId);
            job.setInstanceType(asyncCmd.getInstanceType());
            job.setUserId(callerUserId);
View Full Code Here

Examples of com.cloud.user.UserContext

    public boolean handleSystemIpRelease(IpAddress ip) {
        boolean success = true;
        Long networkId = ip.getAssociatedWithNetworkId();
        if (networkId != null) {
            if (ip.getSystem()) {
                UserContext ctx = UserContext.current();
                if (!disassociatePublicIpAddress(ip.getId(), ctx.getCallerUserId(), ctx.getCaller())) {
                    s_logger.warn("Unable to release system ip address id=" + ip.getId());
                    success = false;
                } else {
                    s_logger.warn("Successfully released system ip address id=" + ip.getId());
                }
View Full Code Here

Examples of com.cloud.user.UserContext

        return false;
    }

    @Override
    public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
        UserContext context = UserContext.current();
        context.setAccountId(1);
        List<DomainRouterVO> routers = _routerDao.listIsolatedByHostId(host.getId());
        for (DomainRouterVO router : routers) {
            if (router.isStopPending()) {
                State state = router.getState();
                if (state != State.Stopped && state != State.Destroyed) {
View Full Code Here

Examples of com.cloud.user.UserContext


    @Override
    @ActionEvent(eventType = EventTypes.EVENT_PROJECT_DELETE, eventDescription = "deleting project", async = true)
    public boolean deleteProject(long projectId) {
        UserContext ctx = UserContext.current();

        ProjectVO project= getProject(projectId);
        //verify input parameters
        if (project == null) {
            throw new InvalidParameterValueException("Unable to find project by id " + projectId);
        }

        _accountMgr.checkAccess(ctx.getCaller(),AccessType.ModifyProject, true, _accountMgr.getAccount(project.getProjectAccountId()));

        return deleteProject(ctx.getCaller(), ctx.getCallerUserId(), project)
    }
View Full Code Here

Examples of com.cloud.user.UserContext

    @Override
    public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, StopAnswer answer) {
        //release elastic IP here if assigned
        IPAddressVO ip = _ipAddressDao.findByAssociatedVmId(profile.getId());
        if (ip != null && ip.getSystem()) {
            UserContext ctx = UserContext.current();
            try {
                _rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true);
            } catch (Exception ex) {
                s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex);
            }
        }
    }
View Full Code Here
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.