class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory {

    @Inject
    private org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory factory;

    @Inject
    private LegacySupport legacySupport;

    @Inject
    private PlexusContainer container;

    public ArtifactRepositoryLayout getLayout(String layoutId) throws UnknownRepositoryLayoutException {
        return factory.getLayout(layoutId);
    }

    public ArtifactRepository createDeploymentArtifactRepository(
            String id, String url, String layoutId, boolean uniqueVersion) throws UnknownRepositoryLayoutException {
        return injectSession(factory.createDeploymentArtifactRepository(id, url, layoutId, uniqueVersion), false);
    }

    public ArtifactRepository createDeploymentArtifactRepository(
            String id, String url, ArtifactRepositoryLayout repositoryLayout, boolean uniqueVersion) {
        return injectSession(
                factory.createDeploymentArtifactRepository(id, url, repositoryLayout, uniqueVersion), false);
    }

    public ArtifactRepository createArtifactRepository(
            String id,
            String url,
            String layoutId,
            ArtifactRepositoryPolicy snapshots,
            ArtifactRepositoryPolicy releases)
            throws UnknownRepositoryLayoutException {
        return injectSession(factory.createArtifactRepository(id, url, layoutId, snapshots, releases), true);
    }

    public ArtifactRepository createArtifactRepository(
            String id,
            String url,
            ArtifactRepositoryLayout repositoryLayout,
            ArtifactRepositoryPolicy snapshots,
            ArtifactRepositoryPolicy releases) {
        return injectSession(factory.createArtifactRepository(id, url, repositoryLayout, snapshots, releases), true);
    }

    public void setGlobalUpdatePolicy(String updatePolicy) {
        factory.setGlobalUpdatePolicy(updatePolicy);
    }

    public void setGlobalChecksumPolicy(String checksumPolicy) {
        factory.setGlobalChecksumPolicy(checksumPolicy);
    }

    private ArtifactRepository injectSession(ArtifactRepository repository, boolean mirrors) {<FILL_FUNCTION_BODY>}

    private boolean isLocalRepository(ArtifactRepository repository) {
        // unfortunately, the API doesn't allow to tell a remote repo and the local repo apart...
        return "local".equals(repository.getId());
    }
}

        RepositorySystemSession session = legacySupport.getRepositorySession();

        if (session != null && repository != null && !isLocalRepository(repository)) {
            List<ArtifactRepository> repositories = Arrays.asList(repository);

            RepositorySystem repositorySystem;
            try {
                repositorySystem = container.lookup(RepositorySystem.class);
            } catch (ComponentLookupException e) {
                throw new IllegalStateException("Unable to lookup " + RepositorySystem.class.getName());
            }

            if (mirrors) {
                repositorySystem.injectMirror(session, repositories);
            }

            repositorySystem.injectProxy(session, repositories);

            repositorySystem.injectAuthentication(session, repositories);
        }

        return repository;
    
<no_super_class>