package mit.roles ;

public class Authorizations
	implements	roles.Authorizations
		, 	java.io.Serializable
{
	private static final String ALGORITHM_SIMPLE = "SIMPLE" ;
	private static final String ALGORITHM_F_WITH_Q = "F_WITH_Q" ;
	private static final String ALGORITHM_WHO_CAN_DO = "WHO_CAN_DO" ;
	private static final String GETAUTHORIZATIONSQUERYSQL = "ROLESAPI_GET_SQL_AUTH1" ;

	protected sql.Rows rows = null ;
	protected mit.roles.RolesFactory rolesFactory = null ;

	public boolean hasMoreAuthorizations()
		throws Exception
	{
		if( null != this.rows )
		{
			return this.rows.hasMoreRows() ;
		}
		return false ;
	}

	public roles.Authorization nextAuthorization()
		throws Exception
	{
		if( null != this.rows )
		{
			if( this.rows.hasMoreRows() )
			{
				return getAuthorization( this.rows.getColumnNames() , this.rows.nextRow() ) ;
			}
		}
		throw new roles.RolesException( roles.RolesException.AUTHORIZATIONENUMERATIONFAILED ) ;
	}

	public static roles.Authorizations getAuthorizationsForPerson
		( mit.roles.RolesFactory rolesFactory
		, roles.Person person
		, mit.roles.FunctionCategory functionCategory
		, Boolean isActiveNow
		, int start
		, int number
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, person
			, null
			, null
			, isActiveNow
			, null
			, null
			) ;
	}

	/**
	 * Given a Function and a Qualifier
	 * returns an enumeration of all Authorizations that would allow people
	 * to do the Function with Qualifier. This method differs from the simple
	 * form of getAuthsSimpleForm in that this method looks for any Authorization
	 * that permits doing the Function with the Qualifier even if the Authorization's
	 * Qualifier happens to be a parent of this Qualifier argument.
	 */
	public static roles.Authorizations getAuthsForDoingFWithQ
		( mit.roles.RolesFactory rolesFactory
		, roles.Function function
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_F_WITH_Q
			, null
			, null
			, function
			, qualifier
			, isActiveNow
			, null
			, null
			) ;
	}

	/**
	 * Given a FunctionCategory and a Qualifier
	 * returns an enumeration of all Authorizations that would allow people
	 * to do Functions in the FunctionCategory with Qualifier. This method differs
	 * from getAuthsSimpleForm in that this method looks for any Authorization
	 * that permits doing the Function with the Qualifier even if the
	 * Authorization's Qualifier happens to be a parent of the Qualifier argument.
	 */
	public static roles.Authorizations getAuthsForDoingFWithQ
		( mit.roles.RolesFactory rolesFactory
		, roles.FunctionCategory functionCategory
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_F_WITH_Q
			, ( String ) null
			, ( String ) null
			, ( String ) null
			, ( String ) null
			, ( String ) ( ( null == functionCategory ) ? null : functionCategory.getCategory() )
			, ( String ) ( ( null == qualifier ) ? null : qualifier.getId().toString() )
			, ( String ) ( ( null == qualifier ) ? null : qualifier.getCode() )
			, ( String ) ( ( null == qualifier ) ? null : ( ( null == qualifier.getQualifierType().getType() ) ? null : qualifier.getQualifierType().getType() ) )
			, ( String ) ( ( null == isActiveNow ) ? null : ( isActiveNow.booleanValue() ? "Y" : "N" ) )
			, ( String ) null
			, ( String ) null
			) ;
	}

	/**
	 * Given at a Person, a Function, and a Qualifier
	 * returns an enumeration of matching authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Person person
		, roles.Function function
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, person
			, function
			, qualifier
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	/**
	 * Given at a Person, a FunctionCategory, and a Qualifier
	 * returns an enumeration of matching authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Person person
		, roles.FunctionCategory functionCategory
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, ( String ) null
			, ( String ) null
			, ( String ) ( ( null == person ) ? null : ( ( mit.roles.Person ) person ).getKerberosName() )
			, ( String ) null
			, ( String ) ( ( null == functionCategory ) ? null : functionCategory.getCategory() )
			, ( String ) ( ( null == qualifier ) ? null : qualifier.getId().toString() )
			, ( String ) ( ( null == qualifier ) ? null : qualifier.getCode() )
			, ( String ) ( ( null == qualifier ) ? null : ( ( null == qualifier.getQualifierType().getType() ) ? null : qualifier.getQualifierType().getType() ) )
			, ( String ) ( ( null == isActiveNow ) ? null : ( isActiveNow.booleanValue() ? "Y" : "N" ) )
			, ( String ) ( ( null == expandFunctions ) ? null : ( expandFunctions.booleanValue() ? "Y" : "N" ) )
			, ( String ) ( ( null == expandQualifiers ) ? null : ( expandQualifiers.booleanValue() ? "Y" : "N" ) )
			) ;
	}

	/**
	 * Given a Person and a Function
	 * returns an enumeration of Authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Person person
		, roles.Function function
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, person
			, function
			, null
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	/**
	 * Given a Person and a FunctionCategory
	 * returns an enumeration of Authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Person person
		, roles.FunctionCategory functionCategory
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, ( String ) null
			, ( String ) null
			, ( String ) ( ( null == person ) ? null : ( ( mit.roles.Person ) person ).getKerberosName() )
			, ( String ) null
			, ( String ) ( ( null == functionCategory ) ? null : functionCategory.getCategory() )
			, ( String ) null
			, ( String ) null
			, ( String ) null
			, ( String ) ( ( null == isActiveNow ) ? null : ( isActiveNow.booleanValue() ? "Y" : "N" ) )
			, ( String ) ( ( null == expandFunctions ) ? null : ( expandFunctions.booleanValue() ? "Y" : "N" ) )
			, ( String ) ( ( null == expandQualifiers ) ? null : ( expandQualifiers.booleanValue() ? "Y" : "N" ) )
			) ;
	}

	/**
	 * Given a Person and a Qualifier
	 * returns an enumeration of Authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Person person
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, person
			, null
			, qualifier
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	/**
	 * Given a Person
	 * returns an enumeration of Authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Person person
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, person
			, null
			, null
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	/**
	 * Given a Function and a Qualifier
	 * returns an enumeration of matching authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Function function
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, null
			, function
			, qualifier
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	/**
	 * Given a Qualifier
	 * returns an enumeration of matching authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, null
			, null
			, qualifier
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	/**
	 * Given a FunctionCategory and a Qualifier
	 * returns an enumeration of matching authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.FunctionCategory functionCategory
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, ( String ) null
			, ( String ) null
			, ( String ) null
			, ( String ) null
			, ( String ) ( ( null == functionCategory ) ? null : functionCategory.getCategory() )
			, ( String ) ( ( null == qualifier ) ? null : qualifier.getId().toString() )
			, ( String ) ( ( null == qualifier ) ? null : qualifier.getCode() )
			, ( String ) ( ( null == qualifier ) ? null : ( ( null == qualifier.getQualifierType().getType() ) ? null : qualifier.getQualifierType().getType() ) )
			, ( String ) ( ( null == isActiveNow ) ? null : ( isActiveNow.booleanValue() ? "Y" : "N" ) )
			, ( String ) ( ( null == expandFunctions ) ? null : ( expandFunctions.booleanValue() ? "Y" : "N" ) )
			, ( String ) ( ( null == expandQualifiers ) ? null : ( expandQualifiers.booleanValue() ? "Y" : "N" ) )
			) ;
	}

	/**
	 * Given a Function
	 * returns an enumeration of matching authorizations.
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, roles.Function function
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, null
			, null
			, function
			, null
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	/**
	 * @param AuthorizationID
	 * @return an enumeration of matching authorizations
	 * (should return 1 authorization, unless user has requested
	 * expansion by Functions or Qualifiers).
	 */
	public static roles.Authorizations getAuthsSimpleForm
		( mit.roles.RolesFactory rolesFactory
		, Object authorizationID
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		return getAuthsSimpleFormInternal
			( rolesFactory
			, ALGORITHM_SIMPLE
			, authorizationID
			, null
			, null
			, null
			, isActiveNow
			, expandFunctions
			, expandQualifiers
			) ;
	}

	private static roles.Authorizations getAuthsSimpleFormInternal
		( mit.roles.RolesFactory rolesFactory
		, String algorithm
		, Object authorizationId
		, roles.Person person
		, roles.Function function
		, roles.Qualifier qualifier
		, Boolean isActiveNow
		, Boolean expandFunctions
		, Boolean expandQualifiers
		)
		throws Exception
	{
		String authorizationIdStr  = ( null == authorizationId ) ? null : authorizationId.toString() ;
		String kerberosName = ( null == person ) ? null : ( ( mit.roles.Person ) person ).getKerberosName() ;
		String functionCategory = ( null == function ) ? null : ( ( null == function.getFunctionCategory() ) ? null : function.getFunctionCategory().getCategory() ) ;
		String functionName = ( null == function ) ? null : function.getName() ;
		String functionId = ( null == function ) ? null : function.getId().toString() ;
		String qualifierType = ( null == qualifier ) ? null : ( ( null == qualifier.getQualifierType().getType() ) ? null : qualifier.getQualifierType().getType() ) ;
		String qualifierCode = ( null == qualifier ) ? null : qualifier.getCode() ;
		String qualifierIdStr = ( null == qualifier ) ? null : qualifier.getId().toString() ;
		String expandFunctionsStr
			= ( null == expandFunctions ) ? "N" : ( expandFunctions.booleanValue() ? "Y" : "N" ) ;
		String expandQualifiersStr
			= ( null == expandQualifiers ) ? "N" : ( expandQualifiers.booleanValue() ? "Y" : "N" ) ;
		String isActiveNowStr
			= ( null == isActiveNow ) ? "Y" : ( isActiveNow.booleanValue() ? "Y" : "N" ) ;
		return
			getAuthsSimpleFormInternal
			( rolesFactory
			, algorithm
			, authorizationIdStr
			, kerberosName
			, functionId
			, functionName
			, functionCategory
			, qualifierIdStr
			, qualifierCode
			, qualifierType
			, isActiveNowStr
			, expandFunctionsStr
			, expandQualifiersStr
			) ;
	}


	private static roles.Authorizations getAuthsSimpleFormInternal
		( mit.roles.RolesFactory rolesFactory
		, String algorithm
		, String authorizationIdStr
		, String kerberosName
		, String functionIdStr
		, String functionName
		, String functionCategory
		, String qualifierIdStr
		, String qualifierCode
		, String qualifierType
		, String isActiveNowStr
		, String expandFunctionsStr
		, String expandQualifiersStr
		)
		throws Exception
	{
		try
		{
			if
			(  ( null != isActiveNowStr )
			&& ( null != expandFunctionsStr )
			&& ( null != expandQualifiersStr )
			)
			{
System.out.println( "1" ) ;
				String sqlQuery
					= getAuthSQL
						( rolesFactory
						, algorithm
						, expandQualifiersStr
						, isActiveNowStr
						, authorizationIdStr
						, functionCategory
						, functionName
						, functionIdStr
						, qualifierType
						, qualifierCode
						, qualifierIdStr
						, kerberosName
						) ;
System.out.println( "2" ) ;
				roles.Authorizations authorizations = getAuthorizations( rolesFactory , sqlQuery ) ;
				if( ! authorizations.hasMoreAuthorizations() )
				{
System.out.println( "3" ) ;
					roles.Person person = null ;
					if( null != kerberosName )
					{
						person = new mit.roles.Person( rolesFactory , kerberosName , null , null , null , null , null , null , null , null ) ;
						if( null != person )
						{
							if( ! person.isFoundInRoles().booleanValue() )
							{
								throw new roles.RolesException( roles.RolesException.PERSONNOTFOUNDINROLES ) ;
							}
						}
					}
System.out.println( "4" ) ;
					roles.Function function = null ;
					if
						(  ( null != functionName )
						&& ( ( null != functionCategory ) || ( null != qualifierType ) )
						)
					{
						roles.FunctionCategory fc = null ;
						if( null != functionCategory )
						{
							fc = new mit.roles.FunctionCategory( functionCategory , null ) ;
						}
						roles.QualifierType qt = null ;
						if( null != qualifierType )
						{
							qt = new mit.roles.QualifierType( rolesFactory , qualifierType , null ) ;
						}
						function
							= new mit.roles.Function
								( rolesFactory
								, functionName
								, ( String ) null
								, fc
								, qt
								) ;
						if( ! function.isFoundInRoles().booleanValue() )
						{
							throw new roles.RolesException( roles.RolesException.FUNCTIONNOTFOUNDINROLES ) ;
						}
					}
System.out.println( "5" ) ;
					roles.Qualifier qualifier = null ;
					if( null != qualifierCode )
					{
						roles.QualifierType qt = null ;
						if( null != qualifierType )
						{
							qt = new mit.roles.QualifierType( rolesFactory , qualifierType , null ) ;
						}
						qualifier
							= new mit.roles.Qualifier
								( rolesFactory
								, qualifierCode
								, ( String ) null
								, qt
								) ;
						if( ! qualifier.isFoundInRoles().booleanValue() )
						{
							throw new roles.RolesException( roles.RolesException.QUALIFIERNOTFOUNDINROLES ) ;
						}
					}
				}
System.out.println( "6" ) ;
				return authorizations ;
			}
			throw new roles.RolesException
				( roles.RolesException.QUERYAUTHORIZATIONFAILED ) ;
		}
		catch( Exception ex )
		{
ex.printStackTrace() ;
			throw new roles.RolesException
			( new String
				( roles.RolesException.QUERYAUTHORIZATIONFAILED
				+ ex.getMessage()
				)
			) ;
		}
	}

	/**
	 * Given a list of selection criteria field/value pairs
	 * returns an enumeration of Authorizations.
	 */
	public static roles.Authorizations getAuthsGeneralForm
		( roles.FieldValue[] selectionCriteria
		)
		throws Exception
	{
		throw new roles.RolesException( roles.RolesException.UNIMPLEMENTED ) ;
	}

	protected static roles.Authorizations getAuthorizations
		( mit.roles.RolesFactory rolesFactory
		, String sqlQuery
		)
		throws Exception
	{
		try
		{
			if
				(  ( null != rolesFactory )
				&& ( null != sqlQuery )
				)
			{
				sql.Connection connection = rolesFactory.getConnection() ;
				sql.Table table
					= connection.executeQuery
						( sqlQuery
						) ;
				mit.roles.Authorizations authorizations = new mit.roles.Authorizations() ;
				authorizations.rolesFactory = rolesFactory ;
				authorizations.rows = table.getRows() ;
				return authorizations ;
			}
		}
		catch( Exception ex )
		{
			throw new roles.RolesException( ex.getMessage() ) ;
		}
		throw new roles.RolesException
			( roles.RolesException.QUERYAUTHORIZATIONFAILED ) ;
	}

	/**
	 * @param algorithm is "SIMPLE" or "F_WITH_Q" or "WHO_CAN_DO"
	 * @param expandQualifiers is either "Y" or "N", default is "N"
	 * @param isActiveNow is either "Y" or "N", default is "N"
	 */
	private static String getAuthSQL
		( mit.roles.RolesFactory rolesFactory
		, String algorithm
		, String expandQualifiers
		, String isActiveNow
		, String authorizationId
		, String functionCategory
		, String functionName
		, String functionId
		, String qualifierType
		, String qualifierCode
		, String qualifierId
		, String kerberosName
		)
		throws Exception
	{
System.out.println( "getAuthSQL" ) ;
		if( null != rolesFactory )
		{
System.out.println( "getAuthSQL 1" ) ;
			sql.Connection connection = rolesFactory.getConnection() ;
System.out.println( "getAuthSQL 2 connection: " + connection ) ;
			Object[] args = new Object[ 11 ] ;
			args[ 0 ] = algorithm ;
			args[ 1 ] = expandQualifiers ;
			args[ 2 ] = isActiveNow ;
			args[ 3 ] = authorizationId ;
			args[ 4 ] = functionCategory ;
			args[ 5 ] = functionName ;
			args[ 6 ] = functionId ;
			args[ 7 ] = qualifierType ;
			args[ 8 ] = qualifierCode ;
			args[ 9 ] = qualifierId ;
			args[ 10 ] = kerberosName ;
			int[] columnTypes = new int[ 12 ] ;
			columnTypes[ 0 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 1 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 2 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 3 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 4 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 5 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 6 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 7 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 8 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 9 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 10 ] = java.sql.DatabaseMetaData.procedureColumnIn ;
			columnTypes[ 11 ] = java.sql.DatabaseMetaData.procedureColumnOut ;
			int[] dataTypes = new int[ 12 ] ;
			dataTypes[ 0 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 1 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 2 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 3 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 4 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 5 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 6 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 7 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 8 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 9 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 10 ] = java.sql.Types.VARCHAR ;
			dataTypes[ 11 ] = java.sql.Types.VARCHAR ;
System.out.println( "getAuthSQL 3" ) ;
			sql.Table tab =
				connection.callProcedure
					( GETAUTHORIZATIONSQUERYSQL
					, args
					, columnTypes
					, dataTypes
					) ;
System.out.println( "getAuthSQL 4" ) ;
			if( null != tab )
			{
System.out.println( "getAuthSQL 5" ) ;
				if( null != tab.getRows() )
				{
System.out.println( "getAuthSQL 6" ) ;
					sql.Rows rows = tab.getRows() ;
					if( rows.hasMoreRows() )
					{
System.out.println( "getAuthSQL 7" ) ;
						Object[] row = rows.nextRow() ;
						if( null != row )
						{
System.out.println( "getAuthSQL 8" ) ;
							String sql = ( String ) row[ 0 ] ;
System.out.println
	( "Sql string for:"
	+ "\nalgorithm: " + algorithm
	+ "\nexpandQualifiers: " + expandQualifiers
	+ "\nisActiveNow: " + isActiveNow
	+ "\nauthorizationId: " + authorizationId
	+ "\nfunctionCategory: " + functionCategory
	+ "\nfunctionName: " + functionName
	+ "\nfunctionId: " + functionId
	+ "\nqualifierType: " + qualifierType
	+ "\nqualifierCode: " + qualifierCode
	+ "\nqualifierid: " + qualifierId
	+ "\nkerberosName: " + kerberosName
	+ "\ngenerated sql:\n"
	+ sql
	) ;

							return sql ;
						}
					}
				}
			}
		}
		throw new roles.RolesException( roles.RolesException.AUTHORIZATIONENUMERATIONFAILED ) ;
	}

	private roles.Authorization getAuthorization
		( String[] columnNames
		, Object[] row
		)
		throws Exception
	{
		if( ( null != columnNames ) && ( null != row ) )
		{
			java.util.Properties properties = new java.util.Properties() ;
			for( int i = 0 ; columnNames.length != i ; i ++ )
			{
				properties.put( columnNames[ i ] , row[ i ] ) ;
			}
			return new mit.roles.Authorization( this.rolesFactory , properties ) ;
		}
		throw new roles.RolesException
			( roles.RolesException.AUTHORIZATIONENUMERATIONFAILED ) ;
	}

}
