Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Conflicts:
        
test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/c42a511a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/c42a511a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/c42a511a

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: c42a511a70a5d1b58d9ca1e3b8c49393cc7d4a43
Parents: 9aa4b70 0ffb01a
Author: Bill Havanki <bhava...@cloudera.com>
Authored: Thu Jan 16 22:57:20 2014 -0500
Committer: Bill Havanki <bhava...@cloudera.com>
Committed: Thu Jan 16 22:57:20 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/test/randomwalk/security/CreateUser.java    | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/c42a511a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
----------------------------------------------------------------------
diff --cc 
test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
index 995316b,0000000..cffcb95
mode 100644,000000..100644
--- 
a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
+++ 
b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/CreateUser.java
@@@ -1,69 -1,0 +1,70 @@@
 +/*
 + * 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.accumulo.test.randomwalk.security;
 +
 +import java.util.Properties;
 +
 +import org.apache.accumulo.core.client.AccumuloException;
 +import org.apache.accumulo.core.client.AccumuloSecurityException;
 +import org.apache.accumulo.core.client.Connector;
 +import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 +import org.apache.accumulo.test.randomwalk.State;
 +import org.apache.accumulo.test.randomwalk.Test;
 +
 +public class CreateUser extends Test {
 +  
 +  @Override
 +  public void visit(State state, Properties props) throws Exception {
 +    Connector conn = 
state.getInstance().getConnector(WalkingSecurity.get(state).getSysUserName(), 
WalkingSecurity.get(state).getSysToken());
 +    
 +    String tableUserName = WalkingSecurity.get(state).getTabUserName();
 +    
 +    boolean exists = WalkingSecurity.get(state).userExists(tableUserName);
 +    boolean hasPermission = 
WalkingSecurity.get(state).canCreateUser(WalkingSecurity.get(state).getSysCredentials(),
 tableUserName);
 +    PasswordToken tabUserPass = new PasswordToken("Super Sekret Table User 
Password");
 +    try {
 +      conn.securityOperations().createLocalUser(tableUserName, tabUserPass);
 +    } catch (AccumuloSecurityException ae) {
 +      switch (ae.getSecurityErrorCode()) {
 +        case PERMISSION_DENIED:
 +          if (hasPermission)
 +            throw new AccumuloException("Got a security exception when I 
should have had permission.", ae);
 +          else
 +          // create user anyway for sake of state
 +          {
 +            if (!exists) {
 +              
state.getConnector().securityOperations().createLocalUser(tableUserName, 
tabUserPass);
 +              WalkingSecurity.get(state).createUser(tableUserName, 
tabUserPass);
++              Thread.sleep(1000);
 +            }
 +            return;
 +          }
 +        case USER_EXISTS:
 +          if (!exists)
 +            throw new AccumuloException("Got security exception when the user 
shouldn't have existed", ae);
 +          else
 +            return;
 +        default:
 +          throw new AccumuloException("Got unexpected exception", ae);
 +      }
 +    }
 +    WalkingSecurity.get(state).createUser(tableUserName, tabUserPass);
 +    Thread.sleep(1000);
 +    if (!hasPermission)
 +      throw new AccumuloException("Didn't get Security Exception when we 
should have");
 +  }
 +}

Reply via email to