All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.continual.iam.tools.S3IamDbTool Maven / Gradle / Ivy

There is a newer version: 0.3.14
Show newest version
package io.continual.iam.tools;

import java.io.PrintStream;
import java.util.Vector;

import io.continual.builder.Builder.BuildFailure;
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.common.jwt.JwtProducer;
import io.continual.iam.impl.s3.S3IamDb;

public class S3IamDbTool extends IamDbTool
{
	public S3IamDbTool ()
	{
		super ();
	}

	public static void main ( String[] args ) throws Exception
	{
		new S3IamDbTool().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, BuildFailure
	{
		final int argc = args.size ();
		if ( argc != 4 && argc != 6 )
		{
			outTo.println ( "usage: connect     [ ]" );
			throw new IamSvcException ( "Incorrect usage for connect." );
		}

		JwtProducer jwt = null;
		if ( argc > 4 )
		{
			jwt = new JwtProducer.Builder ()
				.withIssuerName ( args.elementAt ( 4 ) )
				.usingSigningKey ( args.elementAt ( 5 ) )
	//			.lasting ( int seconds )
				.build ()
			;
		}
		
		return new S3IamDb.Builder ()
			.withAccessKey ( args.elementAt ( 0 ) )
			.withSecretKey ( args.elementAt ( 1 ) )
			.withBucket ( args.elementAt ( 2 ) )
			.withPathPrefix ( args.elementAt ( 3 ) )
			.usingAclFactory ( new IamDbAclFactory () )
			.withJwtProducer ( jwt )
			.build ();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy