Search in sources :

Example 56 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ResourceContentPanel method importResourceObject.

protected void importResourceObject(ShadowType selected, AjaxRequestTarget target) {
    List<ShadowType> selectedShadow = null;
    if (selected != null) {
        selectedShadow = new ArrayList<>();
        selectedShadow.add(selected);
    } else {
        selectedShadow = getTable().getSelectedObjects();
    }
    OperationResult result = new OperationResult(OPERATION_IMPORT_OBJECT);
    Task task = pageBase.createSimpleTask(OPERATION_IMPORT_OBJECT);
    if (selectedShadow == null || selectedShadow.isEmpty()) {
        result.recordWarning("Nothing select to import");
        getPageBase().showResult(result);
        target.add(getPageBase().getFeedbackPanel());
        return;
    }
    for (ShadowType shadow : selectedShadow) {
        try {
            getPageBase().getModelService().importFromResource(shadow.getOid(), task, result);
        } catch (ObjectNotFoundException | SchemaException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
            result.recordPartialError("Could not import account " + shadow, e);
            LOGGER.error("Could not import account {} ", shadow, e);
            continue;
        }
    }
    result.computeStatusIfUnknown();
    getPageBase().showResult(result);
    getTable().refreshTable(null, target);
    target.add(getPageBase().getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 57 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class PageSecurityQuestions method resetPassword.

private void resetPassword(UserType user, AjaxRequestTarget target) {
    Task task = createAnonymousTask(OPERATION_RESET_PASSWORD);
    OperationResult result = task.getResult();
    LOGGER.debug("Resetting password for {}", user);
    ProtectedStringType password = new ProtectedStringType();
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createResolve(), SystemConfigurationType.F_DEFAULT_USER_TEMPLATE, SystemConfigurationType.F_GLOBAL_PASSWORD_POLICY);
    PrismObject<SystemConfigurationType> systemConfig = null;
    String newPassword = "";
    PageBase page = (PageBase) getPage();
    ModelService modelService = page.getModelService();
    try {
        systemConfig = modelService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, task, result);
        LOGGER.trace("system config {}", systemConfig);
        if (systemConfig.asObjectable().getNotificationConfiguration() != null) {
            // Security policy with the minumum number of chars
            if (systemConfig.asObjectable().getGlobalPasswordPolicyRef() != null) {
                PrismObject<ValuePolicyType> valPolicy = modelService.getObject(ValuePolicyType.class, systemConfig.asObjectable().getGlobalPasswordPolicyRef().getOid(), options, task, result);
                LOGGER.trace("password policy {}", valPolicy);
                newPassword = getModelInteractionService().generateValue(valPolicy.asObjectable().getStringPolicy(), valPolicy.asObjectable().getStringPolicy().getLimitations().getMinLength(), false, user.asPrismObject(), "security questions password generation", task, result);
            } else {
                // TODO What if there is no policy? What should be done to
                // provide a new automatic password
                warn(getString("pageSecurityQuestions.message.noPolicySet"));
                target.add(getFeedbackPanel());
                return;
            }
        } else {
            // TODO localization
            getSession().error(getString("pageSecurityQuestions.message.notificationsNotSet"));
            LOGGER.trace("Notificatons not set, returning to login page");
            throw new RestartResponseException(PageLogin.class);
        }
    } catch (ObjectNotFoundException | ExpressionEvaluationException e1) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't reset password", e1);
    } catch (SchemaException e1) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't reset password", e1);
        e1.printStackTrace();
    } catch (SecurityViolationException e1) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't reset password", e1);
    } catch (CommunicationException e1) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't reset password", e1);
    } catch (ConfigurationException e1) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't reset password", e1);
    }
    password.setClearValue(newPassword);
    WebComponentUtil.encryptProtectedString(password, true, getMidpointApplication());
    final ItemPath valuePath = new ItemPath(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
    SchemaRegistry registry = getPrismContext().getSchemaRegistry();
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    PrismObjectDefinition objDef = registry.findObjectDefinitionByCompileTimeClass(UserType.class);
    PropertyDelta delta = PropertyDelta.createModificationReplaceProperty(valuePath, objDef, password);
    Class<? extends ObjectType> type = UserType.class;
    deltas.add(ObjectDelta.createModifyDelta(user.getOid(), delta, type, getPrismContext()));
    try {
        modelService.executeChanges(deltas, null, task, result);
        OperationResult parentResult = new OperationResult(OPERATION_LOAD_RESET_PASSWORD_POLICY);
        try {
            if (getModelInteractionService().getCredentialsPolicy(null, null, parentResult).getSecurityQuestions().getResetMethod().getResetType().equals(CredentialsResetTypeType.SECURITY_QUESTIONS)) {
                getSession().setAttribute("pwdReset", newPassword);
                setResponsePage(PageShowPassword.class);
            } else if (getModelInteractionService().getCredentialsPolicy(null, null, parentResult).getSecurityQuestions().getResetMethod().getResetType().equals(CredentialsResetTypeType.SECURITY_QUESTIONS_EMAIL)) {
                if (systemConfig.asObjectable().getNotificationConfiguration() != null && systemConfig.asObjectable().getNotificationConfiguration().getMail() != null) {
                    MailConfigurationType mailConfig = systemConfig.asObjectable().getNotificationConfiguration().getMail();
                    if (mailConfig.getServer() != null) {
                        List serverList = mailConfig.getServer();
                        if (serverList.size() > 0) {
                            MailServerConfigurationType mailServerType = mailConfig.getServer().get(0);
                            sendMailToUser(mailServerType.getUsername(), getMidpointApplication().getProtector().decryptString(mailServerType.getPassword()), newPassword, mailServerType.getHost(), mailServerType.getPort().toString(), mailConfig.getDefaultFrom(), user.getEmailAddress());
                        } else {
                            getSession().error(getString("pageLogin.message.ForgetPasswordSettingsWrong"));
                            throw new RestartResponseException(PageLogin.class);
                        }
                    } else {
                        getSession().error(getString("pageLogin.message.ForgetPasswordSettingsWrong"));
                        throw new RestartResponseException(PageLogin.class);
                    }
                } else {
                    // System.out.println("ifff4");
                    getSession().error(getString("pageLogin.message.ForgetPasswordSettingsWrong"));
                    throw new RestartResponseException(PageLogin.class);
                }
            }
        } catch (ObjectNotFoundException | SchemaException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    // TODO ASAP a message should be shown as the result of the process
    // MailMessage mailMessage=new MailMessage(, port);
    // mailTransport.send(mailMessage, transportName, task,
    // parentResult);
    } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException | EncryptionException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "reset password exception", e);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ArrayList(java.util.ArrayList) MailServerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailServerConfigurationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) List(java.util.List) ArrayList(java.util.ArrayList) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) MailConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailConfigurationType) PageLogin(com.evolveum.midpoint.web.page.login.PageLogin) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ModelService(com.evolveum.midpoint.model.api.ModelService) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 58 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class OrgMemberPanel method removeManagerPerformed.

private void removeManagerPerformed(FocusType manager, AjaxRequestTarget target) {
    OperationResult parentResult = new OperationResult("Remove manager");
    Task task = getPageBase().createSimpleTask("Remove manager");
    try {
        ObjectDelta delta = ObjectDelta.createModificationDeleteContainer(manager.asPrismObject().getCompileTimeClass(), manager.getOid(), FocusType.F_ASSIGNMENT, getPageBase().getPrismContext(), createAssignmentToModify(SchemaConstants.ORG_MANAGER));
        getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, parentResult);
        parentResult.computeStatus();
    } catch (SchemaException | ObjectAlreadyExistsException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
        parentResult.recordFatalError("Failed to remove manager " + e.getMessage(), e);
        LoggingUtils.logUnexpectedException(LOGGER, "Failed to remove manager", e);
        getPageBase().showResult(parentResult);
    }
    target.add(getPageBase().getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 59 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ResourceConnectorPanel method initLayout.

private void initLayout(final IModel<PrismObject<ResourceType>> model, final PageBase parentPage) {
    setOutputMarkupId(true);
    IModel<List<ConnectorOperationalStatus>> statsModel = new AbstractReadOnlyModel<List<ConnectorOperationalStatus>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<ConnectorOperationalStatus> getObject() {
            PrismObject<ResourceType> resource = model.getObject();
            Task task = parentPage.createSimpleTask(OPERATION_GET_CONNECTOR_OPERATIONAL_STATUS);
            OperationResult result = task.getResult();
            List<ConnectorOperationalStatus> status = null;
            try {
                status = parentPage.getModelInteractionService().getConnectorOperationalStatus(resource.getOid(), task, result);
            } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
                LOGGER.error("Error getting connector status for {}: {}", resource, e.getMessage(), e);
                parentPage.showResult(result);
            }
            return status;
        }
    };
    ListView<ConnectorOperationalStatus> listview = new ListView<ConnectorOperationalStatus>(ID_CONNECTOR_LIST, statsModel) {

        private static final long serialVersionUID = 1L;

        protected void populateItem(ListItem<ConnectorOperationalStatus> item) {
            item.add(new Label("label", item.getModel()));
            IModel<ConnectorOperationalStatus> statModel = item.getModel();
            item.add(createLabel(statModel, ID_CONNECTOR_NAME, ConnectorOperationalStatus.F_CONNECTOR_NAME));
            item.add(createLabel(statModel, ID_CONNECOTR_CLASS, ConnectorOperationalStatus.F_CONNECTOR_CLASS_NAME));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_SIZE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_SIZE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MAX_IDLE, ConnectorOperationalStatus.F_POOL_CONFIG_MAX_IDLE));
            item.add(createLabel(statModel, ID_POOL_CONFIG_WAIT_TIMEOUT, ConnectorOperationalStatus.F_POOL_CONFIG_WAIT_TIMEOUT));
            item.add(createLabel(statModel, ID_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME, ConnectorOperationalStatus.F_POOL_CONFIG_MIN_EVICTABLE_IDLE_TIME));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_IDLE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_IDLE));
            item.add(createLabel(statModel, ID_POOL_STATUS_NUM_ACTIVE, ConnectorOperationalStatus.F_POOL_STATUS_NUM_ACTIVE));
        }
    };
    add(listview);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) Label(org.apache.wicket.markup.html.basic.Label) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ListView(org.apache.wicket.markup.html.list.ListView) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Example 60 with ConfigurationException

use of com.evolveum.midpoint.util.exception.ConfigurationException in project midpoint by Evolveum.

the class ResourceContentPanel method deleteAccountConfirmedPerformed.

private void deleteAccountConfirmedPerformed(AjaxRequestTarget target, OperationResult result, List<ShadowType> selected) {
    Task task = pageBase.createSimpleTask(OPERATION_DELETE_OBJECT);
    ModelExecuteOptions opts = createModelOptions();
    for (ShadowType shadow : selected) {
        try {
            ObjectDelta<ShadowType> deleteDelta = ObjectDelta.createDeleteDelta(ShadowType.class, shadow.getOid(), getPageBase().getPrismContext());
            getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(deleteDelta), opts, task, result);
        } catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
            result.recordPartialError("Could not delete object " + shadow, e);
            LOGGER.error("Could not delete {}, using option {}", shadow, opts, e);
            continue;
        }
    }
    result.computeStatusIfUnknown();
    getPageBase().showResult(result);
    getTable().refreshTable(null, target);
    target.add(getPageBase().getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Aggregations

ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)110 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)86 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)81 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)81 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)71 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)65 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)33 SystemException (com.evolveum.midpoint.util.exception.SystemException)29 Task (com.evolveum.midpoint.task.api.Task)27 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)26 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)24 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)20 QName (javax.xml.namespace.QName)20 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)18 ArrayList (java.util.ArrayList)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)13 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)13