boolean contains = false; for (User user : userdata) { // assuming userID is a number!! if(user.getUserId() == u.getUserId()) { contains = true; break; } }
@BindingAnnotation(UserBinder.UserBinderFactory.class) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.PARAMETER}) public @interface UserBinder { public static class UserBinderFactory implements BinderFactory { @Override public Binder build(Annotation annotation) { return new Binder<UserBinder, User>() { @Override public void bind(SQLStatement<?> q, UserBinder bind, User arg) { q.bind("userId", arg.getUserId()); q.bind("uuid", arg.getUuid()); q.bind("openId", arg.getOpenId()); q.bind("givenName", arg.getGivenName()); // etc. } }; } } }
/** * The FederatedStore at time of initialisation, can set the auths required * to allow users to use custom {@link StoreProperties} outside the * scope of the {@link uk.gov.gchq.gaffer.store.library.GraphLibrary}. * * @param user the user needing validation for custom property usage. * @return boolean permission */ public boolean isLimitedToLibraryProperties(final User user) { return (null != this.customPropertiesAuths) && Collections.disjoint(user.getOpAuths(), this.customPropertiesAuths); }
private boolean userContainsWithDataAuth(final User user) { return validateAuths(user.getDataAuths(), this.withDataAuth, true); }
public Accrual getAccruals(String accrualID) throws AccrualNotFoundException{ User user = (User) SecurityUtils.getSubject().getSession().getAttribute("userInfo"); String userid= user.getUserId(); String sql = Select * from db_acc where acc_id= accrualID and user_id=userid; }
private boolean userNotContainsWithoutDataAuth(final User user) { return !validateAuths(user.getDataAuths(), this.withoutDataAuth, false); }
private boolean isUserHasASharedAuth(final User user) { return !Collections.disjoint(user.getOpAuths(), this.graphAuths); }
private boolean isAuthorised(final User user, final List<String> auths) { if (null != auths && !auths.isEmpty()) { for (final String auth : auths) { if (user.getOpAuths().contains(auth)) { return true; } } } return false; }
import com.google.appengine.api.users.User; import com.google.appengine.api.NamespaceManager; ... @ApiMethod(name = "scores.insert") public Score insert(Score score, User user) throws OAuthRequestException, IOException { ... if (NamespaceManager.get() == null) { // Assuming there is a logged in user. String namespace = user.getUserId(); NamespaceManager.set(namespace); } ... }
private boolean userNotContainsWithoutOpAuth(final User user) { return !validateAuths(user.getOpAuths(), this.withoutOpAuth, false); }
public class UserIdConverter implements Formatter<User> { private final UserDao userDao; @Autowired public UserIdConverter(UserDao userDao) { this.userDao = userDao; } @Override public User parse(String userId, Locale locale) { return userDao.load(userId); } @Override public String print(User target, Locale locale) { return target.getUserId(); } }
private boolean userContainsWithOpAuth(final User user) { return validateAuths(user.getOpAuths(), this.withOpAuth, true); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof User)) { // this covers the null check return false; } User other = (User) obj; // this is now safe if ((this.getUserId() == null) && other.getUserId() != null) { return false } else if ((this.getUserId() != null) && !this.getUserId().equals(other.getUserId())) { return false; } return true; }
User currentUser = PortalUtil.getUser(portletRequest); long userId = currentUser.getUserId();
Map<User, String> userMap = new HashMap<User, String>(); for (User user : users) { userMap.put(user, calculateSililarity.calculate(sessionUser.getUserId(), user.getUserId())); } model.addAttribute("userMap", userMap);
UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); String userId = user.getUserId();
/** * Logs the operation chain and the user id. * * @param opChain the operation chain being executed * @param context the Context executing the operation chain */ @Override public void preExecute(final OperationChain<?> opChain, final Context context) { LOGGER.info("Running {} as {}", context.getOriginalOpChain(), context.getUser().getUserId()); }
@Override public <T> T onFailure(final T result, final OperationChain<?> opChain, final Context context, final Exception e) { LOGGER.warn("Failed to run {} as {}", context.getOriginalOpChain(), context.getUser().getUserId()); return result; } }