FileDocCategorySizeDatePackage
JACCConfiguration.javaAPI DocHibernate 3.2.51950Wed Jul 20 23:56:18 BST 2005org.hibernate.secure

JACCConfiguration

public class JACCConfiguration extends Object
Adds Hibernate permissions to roles via JACC
author
Gavin King

Fields Summary
private static final Log
log
private final javax.security.jacc.PolicyConfiguration
policyConfiguration
Constructors Summary
public JACCConfiguration(String contextId)


	     
		try {
			policyConfiguration = PolicyConfigurationFactory
					.getPolicyConfigurationFactory()
					.getPolicyConfiguration( contextId, false );
		}
		catch (ClassNotFoundException cnfe) {
			throw new HibernateException( "JACC provider class not found", cnfe );
		}
		catch (PolicyContextException pce) {
			throw new HibernateException( "policy context exception occurred", pce );
		}
	
Methods Summary
public voidaddPermission(java.lang.String role, java.lang.String entityName, java.lang.String action)


		if ( action.equals( "*" ) ) {
			action = "insert,read,update,delete";
		}

		StringTokenizer tok = new StringTokenizer( action, "," );

		while ( tok.hasMoreTokens() ) {
			String methodName = tok.nextToken().trim();
			EJBMethodPermission permission = new EJBMethodPermission( 
					entityName, 
					methodName, 
					null, // interfaces
					null // arguments
				);

			if ( log.isDebugEnabled() ) {
				log.debug( "adding permission to role " + role + ": " + permission );
			}
			try {
				policyConfiguration.addToRole( role, permission );
			}
			catch (PolicyContextException pce) {
				throw new HibernateException( "policy context exception occurred", pce );
			}
		}