Class PostSecurityImpl

java.lang.Object
com.example.blogs.app.api.post.security.PostSecurityImpl
All Implemented Interfaces:
PostSecurity

@Component("postSecurity") public class PostSecurityImpl extends Object implements PostSecurity
Verifies post ownership by coordinating with the post repository and security context.
  • Constructor Details

    • PostSecurityImpl

      public PostSecurityImpl()
  • Method Details

    • isOwner

      public boolean isOwner(Long postId)
      Checks if the authenticated user is the owner of the specified post. Verifies post existence before checking ownership.
      Specified by:
      isOwner in interface PostSecurity
      Parameters:
      postId - the ID of the post to check
      Returns:
      true if the authenticated user owns the post, false otherwise
      Throws:
      PostNotFoundException - if the post does not exist