Commit 3510ce4d authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Added username and password for Synthesis Processor, implemented delete function

parent 78080575
......@@ -611,6 +611,14 @@ we are happy to inform you that the password request was execute successfully fo
<PlainSchema id="synthesisProcessorBaseURL" mandatoryCondition="true"
multivalue="0" readonly="0" type="String" uniqueConstraint="0" anyTypeClass_id="Synthesis Processor"/>
 
<SyncopeSchema id="synthesisProcessorUsername"/>
<PlainSchema id="synthesisProcessorUsername" mandatoryCondition="false"
multivalue="0" readonly="0" type="String" uniqueConstraint="0" anyTypeClass_id="Synthesis Processor"/>
<SyncopeSchema id="synthesisProcessorPassword"/>
<PlainSchema id="synthesisProcessorPassword" cipherAlgorithm="AES" secretKey="synthesisProcessorPassword" type="Encrypted" mandatoryCondition="false"
multivalue="0" readonly="0" uniqueConstraint="0" anyTypeClass_id="Synthesis Processor"/>
<SyncopeGroup id="0635553c-3f38-4a6d-b555-3c3f382a6ddb" name="ServiceProviderApprover"
realm_id="ea696a4f-e77a-4ef1-be67-8f8093bc8686"
creator="admin" lastModifier="admin"
......@@ -650,6 +658,14 @@ we are happy to inform you that the password request was execute successfully fo
schema_id="synthesisProcessorBaseURL"/>
<APlainAttrValue id="4f802e66-a3ba-49dd-825f-9a1c9cbe88cd" attribute_id="3ca18013-7efd-462f-84a8-c8dfe059e851"
stringValue="http://localhost:9080/choremocks/rest/synthesis"/>
<APlainAttr id="3bd79075-def6-4c34-8002-d02206727320" owner_id="467a4bfb-d9eb-42b1-bbe8-0246e665e47f"
schema_id="synthesisProcessorUsername"/>
<APlainAttrValue id="e560653e-9b01-4eb0-be67-2a1471f8ad7a" attribute_id="3bd79075-def6-4c34-8002-d02206727320"
stringValue="admin"/>
<APlainAttr id="a84d3aa1-fafa-41ea-9f5b-1225af92adc9" owner_id="467a4bfb-d9eb-42b1-bbe8-0246e665e47f"
schema_id="synthesisProcessorPassword"/>
<APlainAttrValue id="42d4059f-ffc7-4a93-8b5f-e78f4f7d397a" attribute_id="a84d3aa1-fafa-41ea-9f5b-1225af92adc9"
stringValue="ODW7yZy5CJjZ3DJGChOing=="/>
<!-- [END] CHOReVOLUTION -->
 
<!-- [START Choreographies -->
......@@ -19,11 +19,18 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.AnyDataProvider;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.commons.EnactmentEngineDataProvider;
import org.apache.syncope.client.console.pages.BasePage;
import org.apache.syncope.client.console.pages.EnactmentEngineDetailPage;
import org.apache.syncope.client.console.pages.EnactmentEnginePage;
import static org.apache.syncope.client.console.panels.DirectoryPanel.LOG;
import org.apache.syncope.client.console.rest.EnactmentEngineRestClient;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
......@@ -48,9 +55,13 @@ public class EnactmentEngineDirectoryPanel extends AnyObjectDirectoryPanel {
private final BaseModal<Serializable> utilityModal = new BaseModal<>("outer");
private final EnactmentEngineRestClient enactmentEngineRestClient;
public EnactmentEngineDirectoryPanel(final String id, final PageReference pageRef) {
super(id, new Builder(AnyTypeKind.ANY_OBJECT.name(), pageRef), false);
this.enactmentEngineRestClient = new EnactmentEngineRestClient();
utilityModal.addSubmitButton();
utilityModal.size(Modal.Size.Medium);
addOuterObject(utilityModal);
......@@ -142,7 +153,16 @@ public class EnactmentEngineDirectoryPanel extends AnyObjectDirectoryPanel {
@Override
public void onClick(final AjaxRequestTarget target) {
try {
enactmentEngineRestClient.delete(model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.DELETE);
item.add(choreographyActionsPanel);
......
......@@ -42,4 +42,8 @@ public class EnactmentEngineRestClient extends BaseRestClient {
public void update(final EnactmentEngineTO enactmentEngineTO) {
getService(EEService.class).update(enactmentEngineTO);
}
public void delete(final String enactmentEngineKey) {
getService(EEService.class).delete(enactmentEngineKey);
}
}
......@@ -80,12 +80,6 @@ public class EELogic extends AbstractTransactionalLogic<AbstractBaseBean> {
.schema(ENACTMENT_ENGINE_BASE_URL_SCHEMA).value(updatedEEData.getBaseUrl()).build()).build());
}
if (updatedEEData.getUsername() != null && !updatedEEData.getUsername()
.equals(enactmentEngine.getPlainAttrMap().get(ENACTMENT_ENGINE_USERNAME_SCHEMA).getValues().get(0))) {
eePatch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(new AttrTO.Builder()
.schema(ENACTMENT_ENGINE_USERNAME_SCHEMA).value(updatedEEData.getUsername()).build()).build());
}
if (updatedEEData.getPassword() != null && !updatedEEData.getPassword()
.equals(enactmentEngine.getPlainAttrMap().get(ENACTMENT_ENGINE_PASSWORD_SCHEMA).getValues().get(0))) {
eePatch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(new AttrTO.Builder()
......@@ -95,6 +89,10 @@ public class EELogic extends AbstractTransactionalLogic<AbstractBaseBean> {
anyObjectLogic.update(eePatch, false);
}
public void delete(final String enactmentEngineKey) {
anyObjectLogic.delete(enactmentEngineKey, true);
}
@Override
protected AbstractBaseBean resolveReference(final Method method, final Object... os)
throws UnresolvedReferenceException {
......
......@@ -16,10 +16,13 @@
package org.apache.syncope.common.rest.api.service;
import eu.chorevolution.idm.common.to.EnactmentEngineTO;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
......@@ -29,13 +32,34 @@ import javax.ws.rs.core.Response;
@Path("enactmentengine")
public interface EEService extends JAXRSService {
/**
* Create a new Enactment Engine
*
* @param enactmentEngineTO enactment engine to be created
* @return the id of the created Enactment Engine
*/
@POST
@Path("/create")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
Response create(EnactmentEngineTO enactmentEngineTO);
/**
* Update an Enactment Engine
*
* @param enactmentEngineTO enactment engine to be updated
*/
@PUT
@Path("/update")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
void update(EnactmentEngineTO enactmentEngineTO);
/**
* Delete an Enactment Engine
*
* @param key enactment engine key
*/
@DELETE
@Path("{key}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
void delete(@NotNull @PathParam("key") String key);
}
......@@ -41,4 +41,8 @@ public class EEServiceImpl extends AbstractServiceImpl implements EEService {
logic.update(enactmentEngineTO);
}
@Override
public void delete(final String enactmentEngineKey) {
logic.delete(enactmentEngineKey);
}
}
......@@ -17,6 +17,7 @@ package org.apache.syncope.client.console.panels;
import java.io.Serializable;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPasswordFieldPanel;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
import org.apache.wicket.PageReference;
......@@ -32,8 +33,13 @@ public abstract class AbstractSynthesisProcessorModalPanel extends AbstractModal
protected final FieldPanel<String> nameInput;
protected final FieldPanel<String> usernameInput;
protected final FieldPanel<String> passwordInput;
protected final FieldPanel<String> urlInput;
public AbstractSynthesisProcessorModalPanel(
final BaseModal<Serializable> modal,
final PageReference pageRef) {
......@@ -45,8 +51,8 @@ public abstract class AbstractSynthesisProcessorModalPanel extends AbstractModal
container.setOutputMarkupId(true);
add(container);
final Form<String> form = new Form<>("AddEEForm");
form.setMarkupId("AddEEForm");
final Form<String> form = new Form<>("AddSynthesisProcessorForm");
form.setMarkupId("AddSynthesisProcessorForm");
form.setOutputMarkupId(true);
container.add(form);
......@@ -55,6 +61,16 @@ public abstract class AbstractSynthesisProcessorModalPanel extends AbstractModal
nameInput.addRequiredLabel();
form.add(nameInput);
this.usernameInput = new AjaxTextFieldPanel("username", "Username", new Model<>(), true);
usernameInput.setRequired(true);
usernameInput.addRequiredLabel();
form.add(usernameInput);
this.passwordInput = new AjaxPasswordFieldPanel("password", "Password", new Model<>(), true);
passwordInput.setRequired(true);
passwordInput.addRequiredLabel();
form.add(passwordInput);
this.urlInput = new AjaxTextFieldPanel("url", "Base URL", new Model<>(), true);
urlInput.setRequired(true);
urlInput.addRequiredLabel();
......
......@@ -47,6 +47,8 @@ public class AddSynthesisProcessorModalPanel extends AbstractSynthesisProcessorM
SynthesisProcessorTO synthesisProcessorTO = new SynthesisProcessorTO();
synthesisProcessorTO.setName(nameInput.getModelObject());
synthesisProcessorTO.setBaseUrl(urlInput.getModelObject());
synthesisProcessorTO.setUsername(usernameInput.getModelObject());
synthesisProcessorTO.setPassword(passwordInput.getModelObject());
restClient.create(synthesisProcessorTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
......
......@@ -49,6 +49,12 @@ public class EditSynthesisProcessorModalPanel extends AbstractSynthesisProcessor
nameInput.setModelObject(synthesisProcessor.getName());
urlInput.setModelObject(synthesisProcessor.getPlainAttrMap()
.get("synthesisProcessorBaseURL").getValues().get(0));
usernameInput.setModelObject(synthesisProcessor.getPlainAttrMap()
.get("synthesisProcessorUsername").getValues().get(0));
/*passwordInput.setModelObject(synthesisProcessor.
getPlainAttrMap().get("synthesisProcessorPassword").getValues().get(0));*/
passwordInput.setRequired(false);
passwordInput.setEnabled(false);
}
@Override
......@@ -58,6 +64,8 @@ public class EditSynthesisProcessorModalPanel extends AbstractSynthesisProcessor
synthesisProcessorTO.setKey((synthesisProcessor.getKey()));
synthesisProcessorTO.setName(nameInput.getModelObject());
synthesisProcessorTO.setBaseUrl(urlInput.getModelObject());
synthesisProcessorTO.setUsername(usernameInput.getModelObject());
synthesisProcessorTO.setPassword(passwordInput.getModelObject());
restClient.update(synthesisProcessorTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
......
......@@ -4,11 +4,17 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.AnyDataProvider;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.commons.SynthesisProcessorDataProvider;
import org.apache.syncope.client.console.pages.BasePage;
import org.apache.syncope.client.console.pages.SynthesisProcessorDetailPage;
import org.apache.syncope.client.console.pages.SynthesisProcessorPage;
import org.apache.syncope.client.console.rest.SynthesisProcessorRestClient;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
......@@ -49,9 +55,13 @@ public class SynthesisProcessorDirectoryPanel extends AnyObjectDirectoryPanel {
private final BaseModal<Serializable> utilityModal = new BaseModal<>("outer");
private final SynthesisProcessorRestClient synthesisProcessorRestClient;
public SynthesisProcessorDirectoryPanel(final String id, final PageReference pageRef) {
super(id, new Builder(AnyTypeKind.ANY_OBJECT.name(), pageRef), false);
this.synthesisProcessorRestClient = new SynthesisProcessorRestClient();
utilityModal.addSubmitButton();
utilityModal.size(Modal.Size.Medium);
addOuterObject(utilityModal);
......@@ -146,7 +156,16 @@ public class SynthesisProcessorDirectoryPanel extends AnyObjectDirectoryPanel {
@Override
public void onClick(final AjaxRequestTarget target) {
try {
synthesisProcessorRestClient.delete(model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.DELETE);
item.add(choreographyActionsPanel);
......
......@@ -29,4 +29,8 @@ public class SynthesisProcessorRestClient extends BaseRestClient {
public void update(final SynthesisProcessorTO synthesisProcessorTO) {
getService(SynthesisProcessorService.class).update(synthesisProcessorTO);
}
public void delete(final String synthesisProcessorKey) {
getService(SynthesisProcessorService.class).delete(synthesisProcessorKey);
}
}
......@@ -18,13 +18,19 @@ limitations under the License.
<wicket:panel>
<span wicket:id="container">
<div class="form-group">
<form wicket:id="AddEEForm">
<form wicket:id="AddSynthesisProcessorForm">
<div class="form-group">
<span wicket:id="name"/>
</div>
<div class="form-group">
<span wicket:id="url"/>
</div>
<div class="form-group">
<span wicket:id="username"/>
</div>
<div class="form-group">
<span wicket:id="password"/>
</div>
</form>
</div>
</span>
......
......@@ -25,8 +25,11 @@ public class SynthesisProcessorTO extends AbstractBaseBean {
private String name;
private String baseUrl;
private String username;
private String password;
private String baseUrl;
public String getKey() {
return key;
......@@ -44,6 +47,22 @@ public class SynthesisProcessorTO extends AbstractBaseBean {
this.name = name;
}
public String getUsername() {
return username;
}
public void setUsername(final String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(final String password) {
this.password = password;
}
public String getBaseUrl() {
return baseUrl;
}
......@@ -51,5 +70,5 @@ public class SynthesisProcessorTO extends AbstractBaseBean {
public void setBaseUrl(final String baseUrl) {
this.baseUrl = baseUrl;
}
}
......@@ -34,6 +34,10 @@ public class SynthesisProcessorLogic extends AbstractLogic<AbstractBaseBean> {
private static final String SYNTHESIS_PROCESSOR_BASE_URL_SCHEMA = "synthesisProcessorBaseURL";
private static final String SYNTHESIS_PROCESSOR_USERNAME_SCHEMA = "synthesisProcessorUsername";
private static final String SYNTHESIS_PROCESSOR_PASSWORD_SCHEMA = "synthesisProcessorPassword";
@Autowired
private AnyObjectLogic anyObjectLogic;
......@@ -46,6 +50,12 @@ public class SynthesisProcessorLogic extends AbstractLogic<AbstractBaseBean> {
sp.getPlainAttrs().add(new AttrTO.Builder()
.schema(SYNTHESIS_PROCESSOR_BASE_URL_SCHEMA).value(synthesisProcessorTO.getBaseUrl()).build());
sp.getPlainAttrs().add(new AttrTO.Builder()
.schema(SYNTHESIS_PROCESSOR_USERNAME_SCHEMA).value(synthesisProcessorTO.getUsername()).build());
sp.getPlainAttrs().add(new AttrTO.Builder()
.schema(SYNTHESIS_PROCESSOR_PASSWORD_SCHEMA).value(synthesisProcessorTO.getPassword()).build());
return anyObjectLogic.create(sp, false).getEntity().getKey();
}
......@@ -64,9 +74,25 @@ public class SynthesisProcessorLogic extends AbstractLogic<AbstractBaseBean> {
.schema(SYNTHESIS_PROCESSOR_BASE_URL_SCHEMA).value(updatedSPData.getBaseUrl()).build()).build());
}
if (updatedSPData.getUsername() != null && !updatedSPData.getUsername().equals(enactmentEngine.getPlainAttrMap()
.get(SYNTHESIS_PROCESSOR_USERNAME_SCHEMA).getValues().get(0))) {
spPatch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(new AttrTO.Builder()
.schema(SYNTHESIS_PROCESSOR_USERNAME_SCHEMA).value(updatedSPData.getUsername()).build()).build());
}
if (updatedSPData.getPassword() != null && !updatedSPData.getPassword().equals(enactmentEngine.getPlainAttrMap()
.get(SYNTHESIS_PROCESSOR_PASSWORD_SCHEMA).getValues().get(0))) {
spPatch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(new AttrTO.Builder()
.schema(SYNTHESIS_PROCESSOR_PASSWORD_SCHEMA).value(updatedSPData.getPassword()).build()).build());
}
anyObjectLogic.update(spPatch, false);
}
public void delete(final String synthesisProcessorKey) {
anyObjectLogic.delete(synthesisProcessorKey, true);
}
@Override
protected AbstractBaseBean resolveReference(final Method method, final Object... args)
throws UnresolvedReferenceException {
......
......@@ -16,10 +16,13 @@
package org.apache.syncope.common.rest.api.service;
import eu.chorevolution.idm.common.to.SynthesisProcessorTO;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
......@@ -29,14 +32,34 @@ import javax.ws.rs.core.Response;
@Path("synthesisProcessor")
public interface SynthesisProcessorService extends JAXRSService {
/**
* Create a new Synthesis Processor
*
* @param synthesisProcessorTO Synthesis Processor to be created
* @return the id of the created Synthesis Processor
*/
@POST
@Path("/create")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
Response create(SynthesisProcessorTO synthesisProcessorTO);
/**
* Update a Synthesis Processor
*
* @param synthesisProcessorTO Synthesis Processor to be updated
*/
@PUT
@Path("/update")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
void update(SynthesisProcessorTO synthesisProcessorTO);
/**
* Delete a Synthesis Processor
*
* @param key Synthesis Processor key
*/
@DELETE
@Path("{key}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
void delete(@NotNull @PathParam("key") String key);
}
......@@ -39,4 +39,9 @@ public class SynthesisProcessorServiceImpl extends AbstractServiceImpl implement
public void update(final SynthesisProcessorTO synthesisProcessorTO) {
logic.update(synthesisProcessorTO);
}
@Override
public void delete(final String synthesisProcessorKey) {
logic.delete(synthesisProcessorKey);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment