Package uk.ac.bbsrc.tgac.miso.core.data.impl

Examples of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl


  }

  @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

      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

  public SystemAlert() {
    super(getDummySystemUser());
  }

  private static User getDummySystemUser() {
    User dummySystemUser = new UserImpl();
    dummySystemUser.setUserId(LimsUtils.SYSTEM_USER_ID);
    return dummySystemUser;
  }
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

          log.debug("Cache hit on map for User " + id);
          return (User)element.getObjectValue();
        }
      }

      User user = new UserImpl();
      user.setUserId(id);
      user.setActive(rs.getBoolean("active"));
      user.setAdmin(rs.getBoolean("admin"));
      user.setExternal(rs.getBoolean("external"));
      user.setFullName(rs.getString("fullName"));
      user.setInternal(rs.getBoolean("internal"));
      user.setLoginName(rs.getString("loginName"));
      user.setPassword(rs.getString("password"));
      user.setEmail(rs.getString("email"));

      try {
        Blob roleblob = rs.getBlob("roles");
        if (roleblob != null) {
          if (roleblob.length() > 0) {
            byte[] rbytes = roleblob.getBytes(1, (int)roleblob.length());
            String s1 = new String(rbytes);
            String[] roles = s1.split(",");
            user.setRoles(roles);
          }
        }
        if (!isLazy()) {
          user.setGroups(listGroupsByUserId(id));
        }
      }
      catch (IOException e) {
        e.printStackTrace();
      }
View Full Code Here

    this.securityManager = securityManager;
  }

  @RequestMapping(method = RequestMethod.GET)
  public ModelAndView setupForm(ModelMap model) throws IOException {
    model.put("user", new UserImpl());
    return new ModelAndView("/pages/registerUser.jsp", model);
  }
View Full Code Here

  public static User fromLdapUser(InetOrgPerson details) {
    // remember that this user has no userID!
    // upon persistence using the default MISO securityManager, this user is checked against the MISO SQL DB
    // by username. If a user already exists with that username that has been authed, then they must be the same
    // user and this user will inherit the already-persisted userID.
    UserImpl user = new UserImpl();

    user.setActive(details.isAccountNonExpired());
    user.setAdmin(details.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_ADMIN")));
    user.setExternal(details.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_EXTERNAL")));
    user.setInternal(details.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_INTERNAL")));
    user.setLoginName(details.getUsername());
    user.setPassword(details.getPassword());
    user.setFullName(details.getDisplayName());
    user.setEmail(details.getMail());

    List<String> roles = new ArrayList<String>();
    for (GrantedAuthority ga : details.getAuthorities()) {
      roles.add(ga.toString());
    }
    user.setRoles(roles.toArray(new String[0]));

    return user;
  }
View Full Code Here

TOP

Related Classes of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl

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.