Examples of UserDetails


Examples of com.infoclinika.mssharing.model.helper.RestHelper.UserDetails

    private StoredObjectPaths storedObjectPaths;

    @ResponseBody
    @RequestMapping(value = "/authenticate", method = RequestMethod.POST)
    public AuthenticateDTO authenticate(@RequestBody UserNamePassDTO credentials) {
        final UserDetails userDetails = restHelper.getUserDetailsByEmail(credentials.username);
        if (userDetails == null
                || !passwordEncoder.matches(credentials.password, userDetails.passwordHash)
                || !userDetails.emailVerified) {
            return new AuthenticateDTO("", new UploadConfigDTO("", "", ""));
        }
View Full Code Here

Examples of com.jeecms.common.security.userdetails.UserDetails

    }
    // Check the user exists.
    // Defer lookup until after expiry time checked, to possibly avoid
    // expensive database call.

    UserDetails user = getUserDetailsService().loadUser(userId,
        cookieTokens[0]);

    // Check signature of token matches remaining details.
    // Must do this after user lookup, as we need the DAO-derived password.
    // If efficiency was a major issue, just add in a UserCache
    // implementation,
    // but recall that this method is usually only called once per
    // HttpSession - if the token is valid,
    // it will cause SecurityContextHolder population, whilst if invalid,
    // will cause the cookie to be cancelled.
    String expectedTokenSignature = makeTokenSignature(tokenExpiryTime,
        user.getUsername(), user.getPassword(), user.getId());

    if (!expectedTokenSignature.equals(cookieTokens[2])) {
      throw new InvalidCookieException(
          "Cookie token[2] contained signature '" + cookieTokens[2]
              + "' but expected '" + expectedTokenSignature + "'");
View Full Code Here

Examples of edu.stanford.bmir.protege.web.shared.user.UserDetails

    }

    @Override
    public GetCurrentUserInSessionResult execute(GetCurrentUserInSessionAction action, ExecutionContext executionContext) {
        UserId userId = executionContext.getUserId();
        final UserDetails userDetails;
        final Set<GroupId> groups = new HashSet<GroupId>();
        if(userId.isGuest()) {
            userDetails = UserDetails.getGuestUserDetails();
        }
        else {
View Full Code Here

Examples of es.udc.tfg.journals.model.userservice.UserDetails

  User user;
  Journal journal;

  @Before
  public void setUp() throws DuplicateInstanceException {
    user = userService.registerUser("userPassword", new UserDetails("name",
        "lastName", "user@udc.es", "user"));

    journal = journalService.createJournal(new Journal(
        "experimental research", "exp res",
        "http://www.blackwellpublishing.com/journal.asp?ref=0145-6008",
View Full Code Here

Examples of org.acegisecurity.userdetails.UserDetails

    Assert.isInstanceOf( UsernamePasswordAuthenticationToken.class, authentication, messages .getMessage(
              "AbstractUserDetailsAuthenticationProvider.onlySupports", "Only UsernamePasswordAuthenticationToken is supported"));
    // Determine username
    String username = (authentication.getPrincipal() == null) ? "NONE_PROVIDED" : authentication.getName();
    boolean cacheWasUsed = true;
    UserDetails user = this.getUserCache().getUserFromCache(username);

    if (user == null) {
      cacheWasUsed = false;
      try {
        user = retrieveUserCustom(username, (UsernamePasswordAuthenticationToken) authentication);
      } catch (UsernameNotFoundException notFound) {
        if (hideUserNotFoundExceptions) {
          throw new BadCredentialsException( messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
        } else {
          throw notFound;
        }
      }
      Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");
    }

    if (!user.isAccountNonLocked()) {
      throw new LockedException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.locked", "User account is locked"));
    }

    if (!user.isEnabled()) {
      if (authentication instanceof CustomUsernamePasswordAuthenticationToken) {
        throw new CustomAuthenticationException("该证书绑定帐号还未启用或者已禁用!", CustomAuthenticationException.CODE_CA, -1);
      } else {
        throw new DisabledException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.disabled", "User is disabled"));
      }
    }

    if (!user.isAccountNonExpired()) {
      throw new AccountExpiredException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.expired", "User account has expired"));
    }

    // This check must come here, as we don't want to tell users
    // about account status unless they presented the correct credentials
    try {
      additionalAuthenticationChecks(user, (UsernamePasswordAuthenticationToken) authentication);
    } catch (AuthenticationException exception) {
      // There was a problem, so try again after checking we're using
      // latest data
      cacheWasUsed = false;
      user = retrieveUserCustom(username, (UsernamePasswordAuthenticationToken) authentication);
      additionalAuthenticationChecks(user, (UsernamePasswordAuthenticationToken) authentication);
    }

    if (!user.isCredentialsNonExpired()) {
      throw new CredentialsExpiredException(messages .getMessage( "AbstractUserDetailsAuthenticationProvider.credentialsExpired", "User credentials have expired"));
    }

    if (!cacheWasUsed) {
      this.getUserCache().putUserInCache(user);
    }

    Object principalToReturn = user;

    if (isForcePrincipalAsString()) {
      principalToReturn = user.getUsername();
    }

    return createSuccessAuthentication(principalToReturn, authentication, user);
  }
View Full Code Here

Examples of org.acegisecurity.userdetails.UserDetails

    return createSuccessAuthentication(principalToReturn, authentication, user);
  }

  protected final UserDetails retrieveUserCustom(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
    UserDetails loadedUser;
    if (authentication instanceof CustomUsernamePasswordAuthenticationToken) {
      try {
        loadedUser = ((CustomJdbcDaoImpl) this.getUserDetailsService())
            .loadUserByCaid(authentication.getName());
      } catch (DataAccessException repositoryProblem) {
View Full Code Here

Examples of org.acegisecurity.userdetails.UserDetails

  public UserDetails loadUserByCaid(String caid) throws UsernameNotFoundException, DataAccessException {
    List users = usersByCaidMapping.execute(caid);
    if (users.size() == 0) {
      throw new CustomAuthenticationException("该证书未与登录帐号绑定!",CustomAuthenticationException.CODE_CA,-2);
    }
    UserDetails user = (UserDetails) users.get(0); // contains no
    // GrantedAuthority[]
    List dbAuths = customAuthoritiesByUsernameMapping.execute(new Object[]{user.getUsername(),user.getUsername(),user.getUsername()});

    addCustomAuthorities(user.getUsername(), dbAuths);

    if (dbAuths.size() == 0) {
      throw new CustomAuthenticationException("该帐号没有任何访问权限!",CustomAuthenticationException.CODE_CA,-3);
    }

    GrantedAuthority[] arrayAuths = (GrantedAuthority[]) dbAuths.toArray(new GrantedAuthority[dbAuths.size()]);
    String returnUsername = user.getUsername();

    // if (!usernameBasedPrimaryKey) {
    // returnUsername = username;
    // }

    return new User(returnUsername, user.getPassword(), user.isEnabled(),
        true, true, true, arrayAuths);
  }
View Full Code Here

Examples of org.acegisecurity.userdetails.UserDetails

  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
    List users = usersByUsernameMapping.execute(username);
    if (users.size() == 0)
      throw new UsernameNotFoundException("User not found");
    UserDetails user = (UserDetails) users.get(0);
    List dbAuths = this.customAuthoritiesByUsernameMapping.execute(new Object[]{user.getUsername(),user.getUsername(),user.getUsername()});
    addCustomAuthorities(user.getUsername(), dbAuths);
    //if (dbAuths.size() == 0)
    //  throw new UsernameNotFoundException("User has no GrantedAuthority");
    GrantedAuthority arrayAuths[] = (GrantedAuthority[]) (GrantedAuthority[]) dbAuths
        .toArray(new GrantedAuthority[dbAuths.size()]);
    String returnUsername = user.getUsername();
    if (!isUsernameBasedPrimaryKey())
      returnUsername = username;
    return new User(returnUsername, user.getPassword(), user.isEnabled(),
        true, true, true, arrayAuths);
  }
View Full Code Here

Examples of org.acegisecurity.userdetails.UserDetails

    protected Object mapRow(ResultSet rs, int rownum) throws SQLException {
      String username = rs.getString(1);
      String password = rs.getString(2);
      boolean enabled = rs.getBoolean(3);
      UserDetails user = new User(username,password,enabled,true,true,true,
          new GrantedAuthority[] { new GrantedAuthorityImpl("HOLDER") });
      return user;
    }
View Full Code Here

Examples of org.acegisecurity.userdetails.UserDetails

    public Authentication get() {
        Jenkins h = Jenkins.getInstance();
        Secret userName = Secret.decrypt(props.getProperty(getPropertyKey()));
        if (userName==null) return Jenkins.ANONYMOUS; // failed to decrypt
        try {
            UserDetails u = h.getSecurityRealm().loadUserByUsername(userName.getPlainText());
            return new UsernamePasswordAuthenticationToken(u.getUsername(), "", u.getAuthorities());
        } catch (AuthenticationException e) {
            return Jenkins.ANONYMOUS;
        } catch (DataAccessException e) {
            return Jenkins.ANONYMOUS;
        }
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.