Tabnine Logo
UserAnnotationHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
UserAnnotationHandler
in
org.apache.shiro.authz.aop

Best Java code snippets using org.apache.shiro.authz.aop.UserAnnotationHandler (Showing top 11 results out of 315)

origin: apache/shiro

/**
 * Default no-argument constructor that ensures this interceptor looks for
 *
 * {@link org.apache.shiro.authz.annotation.RequiresUser RequiresUser} annotations in a method
 * declaration.
 */
public UserAnnotationMethodInterceptor() {
  super( new UserAnnotationHandler() );
}
origin: apache/shiro

  /**
   * Ensures that the calling <code>Subject</code> is a <em>user</em>, that is, they are <em>either</code>
   * {@link org.apache.shiro.subject.Subject#isAuthenticated() authenticated} <b><em>or</em></b> remembered via remember
   * me services before allowing access, and if not, throws an
   * <code>AuthorizingException</code> indicating access is not allowed.
   *
   * @param a the RequiresUser annotation to check
   * @throws org.apache.shiro.authz.AuthorizationException
   *         if the calling <code>Subject</code> is not authenticated or remembered via rememberMe services.
   */
  public void assertAuthorized(Annotation a) throws AuthorizationException {
    if (a instanceof RequiresUser && getSubject().getPrincipal() == null) {
      throw new UnauthenticatedException("Attempting to perform a user-only operation.  The current Subject is " +
          "not a user (they haven't been authenticated or remembered from a previous login).  " +
          "Access denied.");
    }
  }
}
origin: apache/shiro

/**
 *
 * @param resolver
 * @since 1.1
 */
public UserAnnotationMethodInterceptor(AnnotationResolver resolver) {
  super(new UserAnnotationHandler(), resolver);
}
origin: org.apache.shiro/shiro-core

  /**
   * Ensures that the calling <code>Subject</code> is a <em>user</em>, that is, they are <em>either</code>
   * {@link org.apache.shiro.subject.Subject#isAuthenticated() authenticated} <b><em>or</em></b> remembered via remember
   * me services before allowing access, and if not, throws an
   * <code>AuthorizingException</code> indicating access is not allowed.
   *
   * @param a the RequiresUser annotation to check
   * @throws org.apache.shiro.authz.AuthorizationException
   *         if the calling <code>Subject</code> is not authenticated or remembered via rememberMe services.
   */
  public void assertAuthorized(Annotation a) throws AuthorizationException {
    if (a instanceof RequiresUser && getSubject().getPrincipal() == null) {
      throw new UnauthenticatedException("Attempting to perform a user-only operation.  The current Subject is " +
          "not a user (they haven't been authenticated or remembered from a previous login).  " +
          "Access denied.");
    }
  }
}
origin: apache/shiro

private static AuthorizingAnnotationHandler createHandler(Annotation annotation) {
  Class<?> t = annotation.annotationType();
  if (RequiresPermissions.class.equals(t)) return new PermissionAnnotationHandler();
  else if (RequiresRoles.class.equals(t)) return new RoleAnnotationHandler();
  else if (RequiresUser.class.equals(t)) return new UserAnnotationHandler();
  else if (RequiresGuest.class.equals(t)) return new GuestAnnotationHandler();
  else if (RequiresAuthentication.class.equals(t)) return new AuthenticatedAnnotationHandler();
  else throw new IllegalArgumentException("Cannot create a handler for the unknown for annotation " + t);
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

  /**
   * Ensures that the calling <code>Subject</code> is a <em>user</em>, that is, they are <em>either</code>
   * {@link org.apache.shiro.subject.Subject#isAuthenticated() authenticated} <b><em>or</em></b> remembered via remember
   * me services before allowing access, and if not, throws an
   * <code>AuthorizingException</code> indicating access is not allowed.
   *
   * @param a the RequiresUser annotation to check
   * @throws org.apache.shiro.authz.AuthorizationException
   *         if the calling <code>Subject</code> is not authenticated or remembered via rememberMe services.
   */
  public void assertAuthorized(Annotation a) throws AuthorizationException {
    if (a instanceof RequiresUser && getSubject().getPrincipal() == null) {
      throw new UnauthenticatedException("Attempting to perform a user-only operation.  The current Subject is " +
          "not a user (they haven't been authenticated or remembered from a previous login).  " +
          "Access denied.");
    }
  }
}
origin: org.apache.shiro/shiro-core

/**
 *
 * @param resolver
 * @since 1.1
 */
public UserAnnotationMethodInterceptor(AnnotationResolver resolver) {
  super(new UserAnnotationHandler(), resolver);
}
origin: org.apache.shiro/shiro-core

/**
 * Default no-argument constructor that ensures this interceptor looks for
 *
 * {@link org.apache.shiro.authz.annotation.RequiresUser RequiresUser} annotations in a method
 * declaration.
 */
public UserAnnotationMethodInterceptor() {
  super( new UserAnnotationHandler() );
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 * Default no-argument constructor that ensures this interceptor looks for
 *
 * {@link org.apache.shiro.authz.annotation.RequiresUser RequiresUser} annotations in a method
 * declaration.
 */
public UserAnnotationMethodInterceptor() {
  super( new UserAnnotationHandler() );
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 *
 * @param resolver
 * @since 1.1
 */
public UserAnnotationMethodInterceptor(AnnotationResolver resolver) {
  super(new UserAnnotationHandler(), resolver);
}
origin: org.secnod.shiro/shiro-jersey

private static AuthorizingAnnotationHandler createHandler(Annotation annotation) {
  Class<?> t = annotation.annotationType();
  if (RequiresPermissions.class.equals(t)) return new PermissionAnnotationHandler();
  else if (RequiresRoles.class.equals(t)) return new RoleAnnotationHandler();
  else if (RequiresUser.class.equals(t)) return new UserAnnotationHandler();
  else if (RequiresGuest.class.equals(t)) return new GuestAnnotationHandler();
  else if (RequiresAuthentication.class.equals(t)) return new AuthenticatedAnnotationHandler();
  else throw new IllegalArgumentException("Cannot create a handler for the unknown for annotation " + t);
}
org.apache.shiro.authz.aopUserAnnotationHandler

Javadoc

Checks to see if a @ org.apache.shiro.authz.annotation.RequiresUser annotation is declared, and if so, ensures the calling Subject is either org.apache.shiro.subject.Subject#isAuthenticated() or remembered via remember me services before allowing access.

This annotation essentially ensures that subject. org.apache.shiro.subject.Subject#getPrincipal() != null.

Most used methods

  • <init>
    Default no-argument constructor that ensures this handler looks for org.apache.shiro.authz.annotatio
  • getSubject

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now