Uploaded image for project: 'MyFaces CODI'
  1. MyFaces CODI
  2. EXTCDI-262

custom meta-data for @Secured

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.3
    • 1.0.4
    • Core
    • None

    Description

      examples:

      #1:

      //...
      @Named
      @Admin
      public class MyBean implements Serializable
      {
      //...
      }

      //...
      @Stereotype
      @Secured(RoleAccessDecisionVoter.class)
      public @interface Admin
      {
      }

      @ApplicationScoped
      public class RoleAccessDecisionVoter implements AccessDecisionVoter
      {
      private static final long serialVersionUID = -8007511215776345835L;

      @Inject
      private AccessDecisionVoterContext voterContext;

      public Set<SecurityViolation> checkPermission(InvocationContext invocationContext)

      { Admin admin = voterContext.getMetaDataFor(Admin.class.getName(), Admin.class); //... }

      }

      #2:

      //...
      @Named
      @HasRole("admin")
      public class MyBean implements Serializable
      {
      //...
      }

      //...
      @Stereotype
      @Secured(RoleAccessDecisionVoter.class)
      public @interface HasRole
      {
      String value();
      }

      @ApplicationScoped
      public class RoleAccessDecisionVoter implements AccessDecisionVoter
      {
      private static final long serialVersionUID = -8007511215776345835L;

      @Inject
      private AccessDecisionVoterContext voterContext;

      public Set<SecurityViolation> checkPermission(InvocationContext invocationContext)

      { HasRole hasRole = voterContext.getMetaDataFor(HasRole.class.getName(), HasRole.class); String roleName = hasRole.value(); //... }

      }

      Attachments

        Activity

          People

            gpetracek Gerhard Petracek
            gpetracek Gerhard Petracek
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: