class AuthorizationServiceImpl implements AuthorizationService, PostConstruct {

    @Override
    public void initialize(final SecurityConfiguration securityServiceConfiguration) {

        if ( InitializationState.NOT_INITIALIZED != initialized ) {
            return;
        }

        try {
            // Get service level config
            if ( !( securityServiceConfiguration instanceof org.glassfish.security.services.config.AuthorizationService ) ) {
                throw new IllegalStateException(
                		localStrings.getLocalString("service.atz.not_config","The Authorization service is not configured in the domain configuration file."));
            }
            atzSvCfg = (org.glassfish.security.services.config.AuthorizationService) securityServiceConfiguration;

            // Get provider level config, consider only one provider for now and take the first provider found.
            List<SecurityProvider> providersConfig = atzSvCfg.getSecurityProviders();
            if ( (providersConfig == null) || ( (atzPrvConfig = providersConfig.get(0)) == null ) ) {
                throw new IllegalStateException(
                		localStrings.getLocalString("service.atz.no_prov_config","No provider configured for the Authorization service in the domain configuration file."));
            }

            // Get the provider
            final String providerName = atzPrvConfig.getName();
            if ( isDebug() ) {
                logger.log(DEBUG_LEVEL, "Attempting to get Authorization provider \"{0}\".", providerName );
            }
            provider =  AccessController.doPrivileged(
                            new PrivilegedLookup<AuthorizationProvider>(
                                    serviceLocator, AuthorizationProvider.class, providerName)); 
            if (provider == null) {
                throw new IllegalStateException(
                    localStrings.getLocalString("service.atz.not_provider","Authorization Provider {0} not found.", providerName));
            }

            // Initialize the provider
            provider.initialize(atzPrvConfig);

            initialized = InitializationState.SUCCESS_INIT;
            reasonInitFailed = null;

            logger.log(Level.INFO, ATZSVC_INITIALIZED);

        } catch ( Exception e ) {
            String eMsg = e.getMessage();
            String eClass = e.getClass().getName();
            reasonInitFailed = localStrings.getLocalString("service.atz.init_failed",
                "Authorization Service initialization failed, exception {0}, message {1}", eClass, eMsg);
            logger.log(Level.WARNING, ATZSVC_INIT_FAILED, new Object[] {eClass, eMsg});
            throw new RuntimeException( reasonInitFailed, e );
        } finally {
            if ( InitializationState.SUCCESS_INIT != initialized ) {
                initialized = InitializationState.FAILED_INIT;
            }
        }
    }

}