Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7188185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:00:58+00:00 2026-05-28T19:00:58+00:00

Let’s say there is an object TaskList which can be edited and deleted only

  • 0

Let’s say there is an object TaskList which can be edited and deleted only by its owner. Other users should only by able to take a task and update its status.

The following options come to my mind:

  • check the ownership and access in the controller of the web application
  • let the repository return proxy object which throws exception on certain operations, but the controller (or view) would still need to know which actions (in form of links or form fields) should be visible
  • pass the caller (user) to the method of the domain object, so that the domain object can itself check whether the caller ist allowed or not.

The used technology is Java.

Any other/better ideas?

Interesting articles about security and DDD

  • Domain Object Security with the Spring framework
  • Security in Domain-Driven Design

I have accepted my own answer now, because that is what I actually use, but further suggestions are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:00:58+00:00Added an answer on May 28, 2026 at 7:00 pm

    I found it unnecessarily complex to create accessor classes for each protected domain class as suggested by ‘Gray’. My solution is probably not perfect, but simple to use and – more important – robust. You cannot forget to use a certain object or to check conditions outside.

    public class TaskList {
    
        private SystemUser owner;
        private List<Task> tasks = new ArrayList<>();
    
        public TastList(SystemUser owner) {
            this.owner = owner;
        }
    
        public void Add(Task task) {
            Guard.allowFor(owner); 
            tasks.add(task);
        }
    }
    

    The Guard knows the current user (from a thread local for example) and compares it to the owner passed as parameter to allowFor(owner). If access is denied a security exception will be thrown.

    That is simple, robust and even easy to maintain since only the guard has to be changed if the underlying authentication changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a dataset, which can be neatly classified using weka's J48
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I can call a method like this: core::get() . What is the
Let's say there is a graph and some set of functions like: create-node ::
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say I'm making a tool to help epicureans keep track of which delicacies
Let's say I'm writing a Windows Forms (.NET Framework 3.5) application which shows the
Let's say the rule is as follows: .largeField { width: 65%; } Is there
Let's say there is a list of List<UInt32> Thus, : 12|12 23|33 33|22 11|22
Let's say R is a mxn random matrix. How can generate R with each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.