-
Notifications
You must be signed in to change notification settings - Fork 14
US77587: Added attribute reader factory and connector to arbitrary attribute store #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @@ -0,0 +1,29 @@ | |||
| package com.ge.predix.acs.attribute.connectors; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space
| @Autowired | ||
| private DefaultSubjectAttributeReader defaultSubjectAttributeReader; | ||
|
|
||
| private AttributeReader resourceAttributeReader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No setters or getters and also not wiring the bean, how will we use the resourceAttributeReader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to construct resourceAttributeReader based on zone configuration read from the database.
| private AttributeReader resourceAttributeReader; | ||
| private SubjectAttributeReader subjectAttributeReader; | ||
|
|
||
| public AttributeReader getResourceAttributeReader(final String zoneId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this zoneId as an argument a stub for when we will lookup the which attributeReader to use from the persistent store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we are ready to persist zone configuration, zoneId will be used to read zone configuration from the database
| private PolicySetValidator policySetValidator; | ||
| @Autowired | ||
| private ZoneResolver zoneResolver; | ||
| @Autowired |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ZoneConfiguration or ZoneId can be directly loaded from spring authentication, This will avoid any changes to higher layers and pushing this info downstream.
((ZoneOAuth2Authentication) SecurityContextHolder.getContext().getAuthentication()).getZoneId()
| import com.ge.predix.acs.model.Attribute; | ||
|
|
||
| @Component | ||
| public class InMemoryAttributeStore { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is unnecessary - InMemoryStoreAdapter can simply hold a map within it.
|
|
||
| import com.ge.predix.acs.model.Attribute; | ||
|
|
||
| public class InMemoryAttributeStoreAdapter implements AttributeStoreAdapter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hindsight, because the adapter really belongs outside ACS, this story should just have the initial CustomResourceAttributeReader return a fixed set of attributes. (Or the policy evaluation test can mock the attributeReader)
The key part of this story is the Evaluation test you, wrote and changes in evaluation code path to use a CustomResourceAttributeReader
|
|
||
| import com.ge.predix.acs.model.Attribute; | ||
|
|
||
| public class CustomResourceAttributeReader implements AttributeReader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more thoughts on naming :)
AttributeReader is how its consumers use it. The classes which implement them can be different things. e.g.
ResourceAttributeConnector implements AttributeReaderPrivilegeManagementServiceImpl implements PrivilegeManagementService, AttributeReader, SubjectAttributeReader(this also means we can get rid of DefaultSubjectAttributeReader and DefaultResourceAttributeReader)
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class ZoneConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration will be fleshed out in the next story - most likely these 2 fields will become part of ZoneEntity class, and link to a ConnectorConfiguration JPAEntity.
|
|
||
| public interface AttributeReader { | ||
| Set<Attribute> getAttributes(String identifier); | ||
| Set<Attribute> getAttributes(final String identifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concrete classes implementing interface methods should declare the parameters as final so this is a redundant use of it. This is also supposed to be enforced by our CheckStyle rules via the RedundantModifier module but it's not due to a bug in the version of CheckStyle we're using. As part of DE22352 I've updated to the latest version of CheckStyle on the develop branch so please rebase this branch onto develop and rebuild; once you do so you'll see this issue being flagged properly.
| import com.ge.predix.acs.model.Attribute; | ||
|
|
||
| public interface AttributeStoreAdapter { | ||
| Set<Attribute> getAttributes(final String identifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment re. redundant use of final in interface methods
|
|
||
| public interface SubjectAttributeReader extends AttributeReader { | ||
| Set<Attribute> getAttributesByScope(String identifier, Set<Attribute> scopes); | ||
| Set<Attribute> getAttributesByScope(final String identifier, final Set<Attribute> scopes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment re. redundant use of final in interface methods
87c044b to
06e0c85
Compare
| @@ -0,0 +1,5 @@ | |||
| package com.ge.predix.acs.attribute.connectors; | |||
|
|
|||
| public interface ResourceAttributeReader extends AttributeReader { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we anticipate adding more functionality to this interface in the immediate future?
If so, maybe put a comment saying that it shouldn't be refactored out?
If not, should we delete this interface and replace implements ResourceAttributeReader with implements AttributeReader everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to be explicit for code readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@irinaepshteyn this branch is ready for merge, imo. please review.
…d by AttributeReaderFactory. Signed-off-by: Irina <[email protected]>
b5a8987 to
21f85b4
Compare
No description provided.