use of com.enonic.xp.idprovider.IdProviderDescriptor in project xp by enonic.
the class IdProviderControllerServiceImpl method execute.
@Override
public PortalResponse execute(final IdProviderControllerExecutionParams params) throws IOException {
final IdProviderKey idProviderKey = retrieveIdProviderKey(params);
final IdProvider idProvider = retrieveIdProvider(idProviderKey);
final IdProviderDescriptor idProviderDescriptor = retrieveIdProviderDescriptor(idProvider);
if (idProviderDescriptor != null) {
final IdProviderControllerScript idProviderControllerScript = idProviderControllerScriptFactory.fromScript(idProviderDescriptor.getResourceKey());
final String functionName = params.getFunctionName();
if (idProviderControllerScript.hasMethod(functionName)) {
PortalRequest portalRequest = params.getPortalRequest();
if (portalRequest == null) {
portalRequest = new PortalRequestAdapter().adapt(params.getServletRequest());
}
portalRequest.setApplicationKey(idProviderDescriptor.getKey());
portalRequest.setIdProvider(idProvider);
final PortalResponse portalResponse = idProviderControllerScript.execute(functionName, portalRequest);
if (portalResponse != null) {
final HttpServletResponse response = params.getResponse();
if (response != null) {
responseSerializationService.serialize(portalRequest, portalResponse, response);
}
}
return portalResponse;
}
}
return null;
}
use of com.enonic.xp.idprovider.IdProviderDescriptor in project xp by enonic.
the class ApplicationInfoServiceImplTest method mockIdProviderApplication.
private void mockIdProviderApplication(final ApplicationKey applicationKey) {
final IdProviderDescriptor idProviderDescriptor = IdProviderDescriptor.create().config(Form.create().build()).key(applicationKey).mode(IdProviderDescriptorMode.EXTERNAL).build();
final IdProvider idProvider1 = IdProvider.create().displayName("idProvider1").key(IdProviderKey.from("idProvider1")).idProviderConfig(IdProviderConfig.create().applicationKey(applicationKey).config(new PropertyTree()).build()).build();
final IdProvider idProvider2 = IdProvider.create().displayName("idProvider2").key(IdProviderKey.from("idProvider2" + "")).idProviderConfig(IdProviderConfig.create().applicationKey(applicationKey).config(new PropertyTree()).build()).build();
Mockito.when(this.idProviderDescriptorService.getDescriptor(applicationKey)).thenReturn(idProviderDescriptor);
Mockito.when(this.securityService.getIdProviders()).thenReturn(IdProviders.from(idProvider1, idProvider2));
}
use of com.enonic.xp.idprovider.IdProviderDescriptor in project xp by enonic.
the class ApplicationInfoServiceImplTest method testIdProviderApplication.
@Test
public void testIdProviderApplication() {
mockIdProviderApplication(this.applicationKey);
final IdProviderDescriptor idProviderDescriptor = this.service.getIdProviderDescriptor(this.applicationKey);
assertNotNull(idProviderDescriptor);
final IdProviders idProviders = this.service.getIdProviderReferences(this.applicationKey);
assertEquals(idProviders.getSize(), 2);
}
use of com.enonic.xp.idprovider.IdProviderDescriptor in project xp by enonic.
the class IdProviderDescriptorServiceTest method testGetDescriptor.
@Test
public void testGetDescriptor() throws Exception {
final IdProviderDescriptor idProviderDescriptor = this.service.getDescriptor(ApplicationKey.from("myapp1"));
assertNotNull(idProviderDescriptor);
assertEquals(ApplicationKey.from("myapp1"), idProviderDescriptor.getKey());
assertEquals(IdProviderDescriptorMode.MIXED, idProviderDescriptor.getMode());
final Input titleInput = Input.create().name("title").label("Title").inputType(InputTypeName.TEXT_LINE).build();
assertEquals(Form.create().addFormItem(titleInput).build(), idProviderDescriptor.getConfig());
}
Aggregations