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

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


  @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();
        final Set<Role> extractedRoles = roleExtractor.extractAllRoles((RestrictedAccess) annotation);
       
        if (User.ANONYMOUS.equals(userCache.getUser()) || !user.getRoles().containsAll(extractedRoles)) {
          element.addClassName(RestrictedAccess.CSS_CLASS_NAME);
        }
        else {
          element.removeClassName(RestrictedAccess.CSS_CLASS_NAME);
        }
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

    @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

    this.authenticationService = authenticationService;
  }

  @AroundInvoke
  public Object aroundInvoke(InvocationContext context) throws Exception {
    final User user = authenticationService.getUser();
    final Collection<RestrictedAccess> annotations = getRestrictedAccessAnnotations(context.getTarget().getClass(),
            context.getMethod());
    final String[] roles = AnnotationUtils.mergeRoles(annotations.toArray(new RestrictedAccess[annotations.size()]));

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

    if (identity.login() != Identity.AuthenticationResult.SUCCESS) {
      throw new AuthenticationException();
    }

    final User user = createUser((org.picketlink.idm.model.basic.User) identity.getAccount(), getRoles());
    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<Role> roles) {
    User user = new User();
    user.setLoginName(picketLinkUser.getLoginName());
    user.setLastName(picketLinkUser.getLastName());
    user.setFirstName(picketLinkUser.getFirstName());
    user.setEmail(picketLinkUser.getEmail());
    user.setRoles(roles);
    return user;
  }
View Full Code Here

    this.authenticationService = authenticationService;
  }

  @AroundInvoke
  public Object aroundInvoke(InvocationContext context) throws Exception {
    final User user = authenticationService.getUser();
    final RestrictedAccess annotation = getRestrictedAccessAnnotation(context.getTarget().getClass(), context.getMethod());
    if (user == null) {
      throw new UnauthenticatedException();
    }
    else if (!hasAllRoles(user.getRoles(), annotation.roles())) {
      throw new UnauthorizedException();
    } else {
      return context.proceed();
    }
  }
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();
        final Set<Role> extractedRoles = roleExtractor.extractAllRoles((RestrictedAccess) annotation);

        if (User.ANONYMOUS.equals(user) || !user.getRoles().containsAll(extractedRoles)) {
          element.addClassName(RestrictedAccess.CSS_CLASS_NAME);
        }
        else {
          element.removeClassName(RestrictedAccess.CSS_CLASS_NAME);
        }
View Full Code Here

    this.authenticationService = authenticationService;
  }

  @AroundInvoke
  public Object aroundInvoke(InvocationContext context) throws Exception {
    final User user = authenticationService.getUser();
    final RestrictedAccess annotation = getRestrictedAccessAnnotation(context.getTarget().getClass(),
            context.getMethod());
    if (User.ANONYMOUS.equals(user)) {
      throw new UnauthenticatedException();
    }
    else if (!user.hasAllRoles(annotation.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.