Package org.jboss.errai.security.shared.api.identity

Examples of org.jboss.errai.security.shared.api.identity.User$StandardUserProperties


  @Inject private DataSyncEjb dataSyncEjb;
  @Inject private AuthenticationService service;

  @Override
  public <X> List<SyncResponse<X>> coldSync(SyncableDataSet<X> dataSet, List<SyncRequestOperation<X>> remoteResults) {
    User currentUser = service.getUser();
    System.out.println("DataSyncServiceImpl.currentUser is " + currentUser);
    if (currentUser == null) {
      throw new IllegalStateException("Nobody is logged in!");
    }

    if (dataSet.getQueryName().equals("allItemsForUser")) {
      // the userId that comes from the client can be tampered with and that is why we override it here
      // the server state is more secure.
      dataSet.getParameters().put("userId", currentUser.getIdentifier());
    }
    else {
      throw new IllegalArgumentException("You don't have permission to sync dataset");
    }
    return dataSyncEjb.coldSync(dataSet, remoteResults);
View Full Code Here


  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof User))
      return false;

    final User user = (User) obj;

    return getIdentifier().equals(user.getIdentifier());
  }
View Full Code Here

  @PostConstruct
  private void maybeLoadStoredCache() {
    logger.debug("PostConstruct invoked.");
    if (!isValid()) {
      logger.debug("Checking for user in local storage.");
      final User storedUser = userStorageHandler.getUser();

      if (storedUser != null) {
        setActiveUser(storedUser, false);
      }
    }
View Full Code Here

  private void setActiveUser(User user, boolean localStorage) {
    logger.debug("Setting active user: " + String.valueOf(user));
    valid = true;
    activeUser = user;
    if (localStorage) {
      final User toPersist = (!user.equals(User.ANONYMOUS)) ? user : null;
      userStorageHandler.setUser(toPersist);
    }
  }
View Full Code Here

  @PostConstruct
  public void init() {
    StyleBindingsRegistry.get().addStyleBinding(this, RestrictedAccess.class, new AnnotationStyleBindingExecutor() {
      @Override
      public void invokeBinding(final Element element, final Annotation annotation) {
        final User user = userCache.getUser();
        if (User.ANONYMOUS.equals(userCache.getUser()) || !user.hasAllRoles(((RestrictedAccess) annotation).roles())) {
          element.addClassName(RestrictedAccess.CSS_CLASS_NAME);
        }
        else {
          element.removeClassName(RestrictedAccess.CSS_CLASS_NAME);
        }
View Full Code Here

    @Override
    public User getUser() {
      try {
        final String json = Cookies.getCookie(UserCookieEncoder.USER_COOKIE_NAME);
        if (json != null) {
          User user = UserCookieEncoder.fromCookieValue(json);
          logger.debug("Found " + user + " in cookie cache!");
          return user;
        }
        else {
          return null;
View Full Code Here

    if (result != Identity.AuthenticationResult.SUCCESS) {
      throw new FailedAuthenticationException();
    }

    final User user = createUser((org.picketlink.idm.model.basic.User) identity.getAccount(), getRolesOfCurrentUser());
    return user;
  }
View Full Code Here

   * @param picketLinkUser the user returned by picketLink
   * @param roles The roles the given user has.
   * @return our user
   */
  private User createUser(org.picketlink.idm.model.basic.User picketLinkUser, Set<? extends Role> roles) {
    User user = new UserImpl(picketLinkUser.getLoginName(), roles, translatePicketLinkAttributes(picketLinkUser));
    return user;
  }
View Full Code Here

    this.roleExtractor = roleExtractor;
  }

  @AroundInvoke
  public Object aroundInvoke(InvocationContext context) throws Exception {
    final User user = authenticationService.getUser();
    final Collection<RestrictedAccess> annotations = getRestrictedAccessAnnotations(context.getTarget().getClass(),
            context.getMethod());
    final Set<Role> roles = AnnotationUtils.mergeRoles(roleExtractor, annotations);

    if (User.ANONYMOUS.equals(user)) {
      throw new UnauthenticatedException();
    }
    else if (!user.getRoles().containsAll(roles)) {
      throw new UnauthorizedException();
    }
    else {
      return context.proceed();
    }
View Full Code Here

    this.roleExtractor = roleExtractor;
  }

  @AroundInvoke
  public Object aroundInvoke(InvocationContext context) throws Exception {
    final User user = authenticationService.getUser();
    final Collection<RestrictedAccess> annotations = getRestrictedAccessAnnotations(context.getTarget().getClass(),
            context.getMethod());
    final Set<Role> roles = AnnotationUtils.mergeRoles(roleExtractor, annotations);

    if (User.ANONYMOUS.equals(user)) {
      throw new UnauthenticatedException();
    }
    else if (!user.getRoles().containsAll(roles)) {
      throw new UnauthorizedException();
    }
    else {
      return context.proceed();
    }
View Full Code Here

TOP

Related Classes of org.jboss.errai.security.shared.api.identity.User$StandardUserProperties

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.