dschneider-pivotal commented on a change in pull request #6994:
URL: https://github.com/apache/geode/pull/6994#discussion_r731107998



##########
File path: 
geode-for-redis/src/main/java/org/apache/geode/redis/internal/services/SecurityServiceWrapper.java
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.services;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+import io.netty.channel.ChannelId;
+import org.apache.shiro.subject.Subject;
+
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.security.ResourcePermission;
+
+/**
+ * This class is a thin wrapper around Geode's {@link SecurityService} and 
delegates
+ * login (authenticate), logout and authorize calls. It exists as a central 
point to track whether
+ * a given channel (connection) has previously been authenticated.
+ */
+public class SecurityServiceWrapper {
+
+  private final Map<String, Subject> subjects = new ConcurrentHashMap<>();
+
+  private final SecurityService securityService;
+
+  public SecurityServiceWrapper(SecurityService securityService) {
+    this.securityService = securityService;
+  }
+
+  public boolean isEnabled() {
+    return securityService.isIntegratedSecurity();
+  }
+
+  public boolean isAuthenticated(ChannelId channelId) {
+    return subjects.containsKey(channelId.asShortText());
+  }
+
+  public Subject login(ChannelId channelId, Properties properties) {
+    Subject subject = securityService.login(properties);
+    subjects.put(channelId.asShortText(), subject);
+    return subject;
+  }
+
+  public void logout(ChannelId channelId) {
+    subjects.remove(channelId.asShortText());

Review comment:
       should this also call securityService.logout?

##########
File path: 
geode-for-redis/src/main/java/org/apache/geode/redis/internal/services/SecurityServiceWrapper.java
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.services;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+import io.netty.channel.ChannelId;
+import org.apache.shiro.subject.Subject;
+
+import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.security.ResourcePermission;
+
+/**
+ * This class is a thin wrapper around Geode's {@link SecurityService} and 
delegates
+ * login (authenticate), logout and authorize calls. It exists as a central 
point to track whether
+ * a given channel (connection) has previously been authenticated.
+ */
+public class SecurityServiceWrapper {

Review comment:
       Given that this class does not implement the SecurityService interface 
and has its own Map it seems like it is more than a Wrapper. It seems like it 
is the entity that manages security for geode-for-redis. I don't think you need 
to expose in its name that it delegates to geode's SecurityService. I like that 
it is in redis's services package (I wish that all the stripe stuff was in a 
subpackage of services and that some of our other "services" were in this 
package). Could it just be named RedisSecurityService?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to