io.continual.iam.tools.ZkIamDbTool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of continualIamZk Show documentation
Show all versions of continualIamZk Show documentation
Continual IAM over Zookeeper.
package io.continual.iam.tools;
import java.io.PrintStream;
import java.util.Vector;
import io.continual.iam.IamDb;
import io.continual.iam.access.AccessControlList;
import io.continual.iam.access.AclUpdateListener;
import io.continual.iam.exceptions.IamSvcException;
import io.continual.iam.impl.common.CommonJsonDb.AclFactory;
import io.continual.iam.impl.common.CommonJsonGroup;
import io.continual.iam.impl.common.CommonJsonIdentity;
import io.continual.iam.impl.zk.StdZkIamDb;
import io.continual.iam.impl.zk.ZkIamDb;
public class ZkIamDbTool extends IamDbTool
{
public ZkIamDbTool ()
{
super ();
}
public static void main ( String[] args ) throws Exception
{
new ZkIamDbTool().runFromMain ( args );
}
private class IamDbAclFactory implements AclFactory
{
@Override
public AccessControlList createDefaultAcl ( AclUpdateListener acll )
{
return new AccessControlList ( acll );
}
}
@Override
protected IamDb createDb ( Vector args, PrintStream outTo ) throws IamSvcException
{
if ( args.size () != 2 )
{
outTo.println ( "usage: connect " );
throw new IamSvcException ( "Incorrect usage for connect." );
}
final ZkIamDb db = new StdZkIamDb.Builder ()
.connectingTo ( args.elementAt ( 0 ) )
.withPathPrefix ( args.elementAt ( 1 ) )
.usingAclFactory ( new IamDbAclFactory () )
.build ()
;
db.start ();
return db;
}
}