org.eclipse.edc.iam.mock.IamMockExtension Maven / Gradle / Ivy
/*
* Copyright (c) 2020 - 2022 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - initial API and implementation
*
*/
package org.eclipse.edc.iam.mock;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Provides;
import org.eclipse.edc.spi.iam.IdentityService;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.types.TypeManager;
/**
* An IAM provider mock used for testing.
*/
@Provides(IdentityService.class)
@Extension(value = IamMockExtension.NAME)
public class IamMockExtension implements ServiceExtension {
public static final String NAME = "Mock IAM";
@Inject
private TypeManager typeManager;
@Override
public String name() {
return NAME;
}
@Override
public void initialize(ServiceExtensionContext context) {
var region = context.getSetting("edc.mock.region", "eu");
var participantId = context.getParticipantId();
context.registerService(IdentityService.class, new MockIdentityService(typeManager, region, participantId));
}
}