[ 
https://issues.apache.org/jira/browse/GEODE-1535?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dan Smith updated GEODE-1535:
-----------------------------
    Labels: bug-hunt  (was: )

> NullPointerException from SampleJsonAuthorization with valid credentials
> ------------------------------------------------------------------------
>
>                 Key: GEODE-1535
>                 URL: https://issues.apache.org/jira/browse/GEODE-1535
>             Project: Geode
>          Issue Type: Bug
>          Components: security
>            Reporter: Dan Smith
>              Labels: bug-hunt
>
> I'm trying to configure a client to connect with authorization using the 
> SampleJsonAuthorization class. I got the below NPE when trying to connect.
> {code}
> com.gemstone.gemfire.cache.client.ServerOperationException: remote server on 
> 172.16.115.238(72978:loner):60610:2e0de43c: : While performing a remote put
>       at 
> com.gemstone.gemfire.cache.client.internal.PutOp$PutOpImpl.processAck(PutOp.java:445)
>       at 
> com.gemstone.gemfire.cache.client.internal.PutOp$PutOpImpl.processResponse(PutOp.java:355)
>       at 
> com.gemstone.gemfire.cache.client.internal.PutOp$PutOpImpl.attemptReadResponse(PutOp.java:540)
>       at 
> com.gemstone.gemfire.cache.client.internal.AbstractOp.attempt(AbstractOp.java:378)
>       at 
> com.gemstone.gemfire.cache.client.internal.ConnectionImpl.execute(ConnectionImpl.java:274)
>       at 
> com.gemstone.gemfire.cache.client.internal.pooling.PooledConnection.execute(PooledConnection.java:328)
>       at 
> com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.executeWithPossibleReAuthentication(OpExecutorImpl.java:937)
>       at 
> com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:155)
>       at 
> com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:110)
>       at 
> com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:700)
>       at 
> com.gemstone.gemfire.cache.client.internal.PutOp.execute(PutOp.java:102)
>       at 
> com.gemstone.gemfire.cache.client.internal.ServerRegionProxy.put(ServerRegionProxy.java:175)
>       at 
> com.gemstone.gemfire.internal.cache.LocalRegion.serverPut(LocalRegion.java:3061)
>       at 
> com.gemstone.gemfire.internal.cache.LocalRegion.cacheWriteBeforePut(LocalRegion.java:3188)
>       at 
> com.gemstone.gemfire.internal.cache.ProxyRegionMap.basicPut(ProxyRegionMap.java:230)
>       at 
> com.gemstone.gemfire.internal.cache.LocalRegion.virtualPut(LocalRegion.java:5845)
>       at 
> com.gemstone.gemfire.internal.cache.LocalRegionDataView.putEntry(LocalRegionDataView.java:132)
>       at 
> com.gemstone.gemfire.internal.cache.LocalRegion.basicPut(LocalRegion.java:5240)
>       at 
> com.gemstone.gemfire.internal.cache.LocalRegion.validatedPut(LocalRegion.java:1557)
>       at 
> com.gemstone.gemfire.internal.cache.LocalRegion.put(LocalRegion.java:1544)
>       at 
> com.gemstone.gemfire.internal.cache.AbstractRegion.put(AbstractRegion.java:288)
>       at TestClient.test(TestClient.java:20)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>       at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
>       at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
>       at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.shiro.authz.permission.WildcardPermission.implies(WildcardPermission.java:205)
>       at 
> com.gemstone.gemfire.security.templates.SampleJsonAuthorization.authorizeOperation(SampleJsonAuthorization.java:216)
>       at 
> com.gemstone.gemfire.internal.security.AuthorizeRequest.putAuthorize(AuthorizeRequest.java:143)
>       at 
> com.gemstone.gemfire.internal.security.AuthorizeRequest.putAuthorize(AuthorizeRequest.java:132)
>       at 
> com.gemstone.gemfire.internal.cache.tier.sockets.command.Put65.cmdExecute(Put65.java:271)
>       at 
> com.gemstone.gemfire.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:142)
>       at 
> com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection.doNormalMsg(ServerConnection.java:797)
>       at 
> com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection.doOneMessage(ServerConnection.java:924)
>       at 
> com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1173)
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>       at 
> com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl$1$1.run(AcceptorImpl.java:519)
>       at java.lang.Thread.run(Thread.java:745)
> {code}
> This is my security.json file. Note that connecting through gfsh works
> {code}
> {
>   "roles": [
>     {
>       "name": "cluster",
>       "operationsAllowed": [
>         "CLUSTER:MANAGE",
>         "CLUSTER:WRITE",
>         "CLUSTER:READ"
>       ]
>     },
>     {
>       "name": "data",
>       "operationsAllowed": [
>         "DATA:MANAGE",
>         "DATA:WRITE",
>         "DATA:READ",
>         "CLUSTER:READ"
>       ]
>     }
>   ],
>   "users": [
>     {
>       "name": "root",
>       "password": "123",
>       "roles": [
>         "cluster",
>         "data"
>       ]
>     },
>     {
>       "name": "dan",
>       "password": "123",
>       "roles": [
>         "data"
>       ]
>     }
>   ]
> }
> {code}
> And here is my client configuration
> {code}
> import java.util.Properties;
> import com.gemstone.gemfire.LogWriter;
> import com.gemstone.gemfire.distributed.DistributedMember;
> import com.gemstone.gemfire.management.internal.security.ResourceConstants;
> import com.gemstone.gemfire.security.AuthInitialize;
> import com.gemstone.gemfire.security.AuthenticationFailedException;
> public class MyAuthInitialize implements AuthInitialize {
>   @Override public void init(final LogWriter systemLogger, final LogWriter 
> securityLogger)
>     throws AuthenticationFailedException
>   {
>   }
>   @Override
>   public Properties getCredentials(final Properties securityProps, final 
> DistributedMember server, final boolean isPeer)
>     throws AuthenticationFailedException
>   {
>     Properties props = new Properties();
>     props.put(ResourceConstants.USER_NAME, "root");
>     props.put(ResourceConstants.PASSWORD, "123");
>     return props;
>   }
>   @Override public void close() {
>   }
>   public static AuthInitialize create() {
>     return new MyAuthInitialize();
>   }
> }
> public class TestClient {
>   @Test
>   public void test() {
>     ClientCacheFactory factory = new ClientCacheFactory();
>     factory.set("security-client-auth-init", "MyAuthInitialize.create");
>     factory.addPoolServer("localhost", 40404);
> //    factory.setPoolMultiuserAuthentication(true);
>     ClientCache cache = factory.create();
>     Region region = 
> cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("region");
>      region.put("A","B");
>     region.put("C", "D");
>   }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to