Class CommentSecurity

java.lang.Object
com.example.blogs.app.api.comment.security.CommentSecurity

@Component public class CommentSecurity extends Object
Verifies comment ownership by coordinating with the comment repository and security context.
  • Constructor Details

    • CommentSecurity

      public CommentSecurity()
  • Method Details

    • isOwner

      public boolean isOwner(Long commentId)
      Checks if the authenticated user is the owner of the specified comment. Verifies comment existence before checking ownership.
      Parameters:
      commentId - the ID of the comment to check
      Returns:
      true if the authenticated user owns the comment, false otherwise
      Throws:
      CommentNotFoundException - if the comment does not exist