Package com.eaglegenomics.simlims.core

Examples of com.eaglegenomics.simlims.core.User


  @RequestMapping(method = RequestMethod.POST)
  public String processSubmit(@ModelAttribute("plate") Plate<LinkedList<Plateable>, Plateable> plate,
                              ModelMap model,
                              SessionStatus session) throws IOException {
    try {
      User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName());
      if (!plate.userCanWrite(user)) {
        throw new SecurityException("Permission denied.");
      }
      requestManager.savePlate(plate);
      session.setComplete();
View Full Code Here


  }

  @RequestMapping("/myAccount")
  public ModelAndView myAccountMenu(ModelMap model) {
    try {
      User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName());
      String realName = user.getFullName();
      StringBuilder groups = new StringBuilder();
      for (String role : user.getRoles()) {
        groups.append(role.replaceAll("ROLE_", "") + "&nbsp;");
      }
      model.put("userRealName", realName);
      //model.put("apiKey", securityManager.getPrivateKey(user));
      model.put("apiKey", SignatureHelper.generatePrivateUserKey((user.getLoginName() + "::" + user.getPassword()).getBytes("UTF-8")));
      model.put("userGroups", groups.toString());
      return new ModelAndView("/pages/myAccount.jsp", model);
    }
    catch (IOException e) {
      e.printStackTrace();
View Full Code Here

  }

  @RequestMapping("/mainMenu")
  public ModelAndView mainMenu(ModelMap model) {
    try {
      User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName());
      Map<String, String> checks = MisoWebUtils.checkStorageDirectories((String) servletContext.getAttribute("miso.baseDirectory"));
      if (checks.keySet().contains("error")) {
        model.put("error", checks.get("error"));
      }
      if (Arrays.asList(user.getRoles()).contains("ROLE_EXTERNAL") && !Arrays.asList(user.getRoles()).contains("ROLE_INTERNAL")) {
        return new ModelAndView("/pages/external/externalMain.jsp", model);
      }
      else {
        return new ModelAndView("/pages/mainMenu.jsp", model);
      }
View Full Code Here

  @RequestMapping("/requests")
  public ModelAndView listRequests(
      @RequestParam(value = "projectId", required = true) long projectId,
      ModelMap model) throws IOException {
    try {
      User user = securityManager
          .getUserByLoginName(SecurityContextHolder.getContext()
              .getAuthentication().getName());
      Project project = requestManager.getProjectById(projectId);
      if (!project.userCanRead(user)) {
        throw new SecurityException("Permission denied.");
View Full Code Here

        try {
          if (rs.getLong("userId") == LimsUtils.SYSTEM_USER_ID) {
            a = new SystemAlert();
          }
          else {
            User u = securityManager.getUserById(rs.getLong("userId"));
            a = new DefaultAlert(u);
          }
          a.setAlertId(id);
          a.setAlertTitle(rs.getString("title"));
          a.setAlertText(rs.getString("text"));
View Full Code Here

  }

  @Override
  public void generateResponse(Event event) {
    log.info("Responding to event: " + event.getEventMessage() + ". Raising alert...");
    User u = new UserImpl();
    u.setFullName("Bar baz");
    Alert a = new MockAlert(u);
    a.setAlertText(a.getAlertText() + " ("+event.getEventMessage()+")");

    for (AlerterService as : alerterServices) {
      try {
View Full Code Here

  @Override
  public void generateResponse(Event event) {
    log.info("Responding to event: " + event.getEventMessage() + ". Raising alert...");

    User u = new UserImpl();
    u.setFullName("Foo bar");
    Alert a = new MockAlert(u);
    a.setAlertTitle("New alert for " + u.getFullName());
    a.setAlertText(a.getAlertText() + " ("+event.getEventMessage()+")");

    for (AlerterService as : alerterServices) {
      try {
        as.raiseAlert(a);
View Full Code Here

  @Test
  public void testImportBulkInputODS() {
    try {
      InputStream in = FormUtilsTests.class.getClassLoader().getResourceAsStream("test-bulk_input.ods");
      LimsUtils.writeFile(in, testSampleBulkInputOdsFile);
      User u = new UserImpl();
      u.setLoginName("testBulkImportUser");
      List<Sample> samples = FormUtils.importSampleInputSpreadsheet(testSampleBulkInputOdsFile, u, new MockFormTestRequestManager(), new DefaultLibraryNamingScheme());
      log.info("Imported :: " + LimsUtils.join(samples, " | "));
    }
    catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  @Test
  public void testImportBulkInputXLS() {
    try {
      InputStream in = FormUtilsTests.class.getClassLoader().getResourceAsStream("test-bulk_input.xlsx");
      LimsUtils.writeFile(in, testSampleBulkInputXlsFile);
      User u = new UserImpl();
      u.setLoginName("testBulkImportUser");
      List<Sample> samples = FormUtils.importSampleInputSpreadsheet(testSampleBulkInputXlsFile, u, new MockFormTestRequestManager(), new DefaultLibraryNamingScheme());
      log.info("Imported :: " + LimsUtils.join(samples, " | "));
    }
    catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  public JSONObject checkUser(HttpSession session, JSONObject json) {
    String username = json.getString("username");
    if (username != null && !username.equals("")) {
      if (SecurityContextHolder.getContext().getAuthentication().getName().equals(username)) {
        try {
          User user = securityManager.getUserByLoginName(username);
          if (user == null) {
            //user is authed, but doesn't exist in the LIMS DB. Save that user!
            User u = new UserImpl();
            Object o = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
            if (o instanceof UserDetails) {
              UserDetails details = (UserDetails) o;
              u.setLoginName(details.getUsername());
              u.setFullName(details.getUsername());
              u.setPassword(details.getPassword());
              u.setActive(true);

              if (details.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_ADMIN"))) {
                u.setAdmin(true);
              }

              if (details.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_INTERNAL"))) {
                u.setInternal(true);
                u.setRoles(new String[]{"ROLE_INTERNAL"});
              }
              else if (details.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_EXTERNAL"))) {
                u.setExternal(true);
                u.setRoles(new String[]{"ROLE_EXTERNAL"});
              }
              else {
                log.warn("Unrecognised roles");
              }

              if (details instanceof InetOrgPerson) {
                u.setFullName(((InetOrgPerson) details).getDisplayName());
                u.setEmail(((InetOrgPerson) details).getMail());
              }

              securityManager.saveUser(u);
            }
            else {
View Full Code Here

TOP

Related Classes of com.eaglegenomics.simlims.core.User

Copyright © 2018 www.massapicom. 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.