use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.
the class RSecurityPolicy method toJAXB.
@Override
public SecurityPolicyType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
SecurityPolicyType object = new SecurityPolicyType();
RUtil.revive(object, prismContext);
RSecurityPolicy.copyToJAXB(this, object, prismContext, options);
return object;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.
the class PageSecurityQuestions method initLayout.
public void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
pqPanels = new ArrayList<MyPasswordQuestionsPanel>();
PrismObject<SecurityPolicyType> securityPolicy = getSecurityPolicy();
LOGGER.trace("Found security policy: {}", securityPolicy);
if (securityPolicy == null) {
LOGGER.error("No security policy, cannot process security questions");
// we do not want to provide any information to the attacker.
throw new RestartResponseException(PageError.class);
}
questionNumber = securityPolicy.asObjectable().getCredentials() != null && securityPolicy.asObjectable().getCredentials().getSecurityQuestions() != null ? securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestionNumber() : 0;
policyQuestionList = securityPolicy.asObjectable().getCredentials() != null && securityPolicy.asObjectable().getCredentials().getSecurityQuestions() != null ? securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestion() : new ArrayList<SecurityQuestionDefinitionType>();
List<SecurityQuestionAnswerDTO> userQuestionList = model.getObject().getSecurityAnswers();
if (userQuestionList == null) {
getSession().error(getString("pageForgetPassword.message.ContactAdminQuestionsNotSet"));
SecurityContext securityContext = SecurityContextHolder.getContext();
securityContext.setAuthentication(null);
throw new RestartResponseException(PageForgotPassword.class);
}
if (questionNumber <= userQuestionList.size()) {
// Questions
for (Iterator iterator = policyQuestionList.iterator(); iterator.hasNext(); ) {
SecurityQuestionDefinitionType securityQuestionDefinitionType = (SecurityQuestionDefinitionType) iterator.next();
// user's question List loop to match the questions
for (int userQuestint = 0; userQuestint < userQuestionList.size(); userQuestint++) {
// if the question is in the policy check
int panelNumber = 0;
if (userQuestionList.get(userQuestint).getPwdQuestion().equalsIgnoreCase(securityQuestionDefinitionType.getIdentifier())) {
SecurityQuestionAnswerDTO a = new SecurityQuestionAnswerDTO(userQuestionList.get(userQuestint).getPwdQuestion(), "", userQuestionList.get(userQuestint).getQuestionItself());
a = checkIfQuestionisValid(a, policyQuestionList);
MyPasswordQuestionsPanel panel = new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL + panelNumber, a);
pqPanels.add(panel);
panelNumber++;
// This is the Question!
}
}
}
}
add(mainForm);
mainForm.add(getPanels(pqPanels));
initButtons(mainForm);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.
the class SystemConfigPanel method initLayout.
protected void initLayout() {
ChooseTypePanel<ValuePolicyType> passPolicyChoosePanel = new ChooseTypePanel<ValuePolicyType>(ID_GLOBAL_PASSWORD_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<ValuePolicyType>>(getModel(), SystemConfigurationDto.F_PASSWORD_POLICY));
ChooseTypePanel<SecurityPolicyType> securityPolicyChoosePanel = new ChooseTypePanel<SecurityPolicyType>(ID_GLOBAL_SECURITY_POLICY_CHOOSER, new PropertyModel<ObjectViewDto<SecurityPolicyType>>(getModel(), SystemConfigurationDto.F_SECURITY_POLICY));
add(passPolicyChoosePanel);
add(securityPolicyChoosePanel);
ObjectPolicyConfigurationEditor objectPolicyEditor = new ObjectPolicyConfigurationEditor(ID_OBJECT_POLICY_EDITOR, new PropertyModel<List<ObjectPolicyConfigurationTypeDto>>(getModel(), SystemConfigurationDto.F_OBJECT_POLICY_LIST));
add(objectPolicyEditor);
DropDownChoice<AEPlevel> aepLevel = new DropDownChoice<>(ID_GLOBAL_AEP, new PropertyModel<AEPlevel>(getModel(), SystemConfigurationDto.F_AEP_LEVEL), WebComponentUtil.createReadonlyModelFromEnum(AEPlevel.class), new EnumChoiceRenderer<AEPlevel>(SystemConfigPanel.this));
aepLevel.setOutputMarkupId(true);
if (aepLevel.getModel().getObject() == null) {
aepLevel.getModel().setObject(null);
}
aepLevel.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
add(aepLevel);
TextField<String> auditRecordsField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_AUDIT_RECORDS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_AUDIT_CLEANUP));
TextField<String> closedTasksField = WebComponentUtil.createAjaxTextField(ID_CLEANUP_CLOSED_TASKS, new PropertyModel<String>(getModel(), SystemConfigurationDto.F_TASK_CLEANUP));
add(auditRecordsField);
add(closedTasksField);
createTooltip(ID_CLEANUP_AUDIT_RECORDS_TOOLTIP);
createTooltip(ID_CLEANUP_CLOSED_TASKS_TOOLTIP);
CheckBox experimentalCodeCheck = WebComponentUtil.createAjaxCheckBox(ID_EXPERIMENTAL_CODE_CHECKBOX, new PropertyModel<Boolean>(getModel(), SystemConfigurationDto.F_ENABLE_EXPERIMENTAL_CODE));
add(experimentalCodeCheck);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.
the class SecurityPolicyUtil method getAuthenticationPolicy.
public static AbstractAuthenticationPolicyType getAuthenticationPolicy(String authPolicyName, SecurityPolicyType securityPolicy) throws SchemaException {
MailAuthenticationPolicyType mailAuthPolicy = getMailAuthenticationPolicy(authPolicyName, securityPolicy);
SmsAuthenticationPolicyType smsAuthPolicy = getSmsAuthenticationPolicy(authPolicyName, securityPolicy);
return checkAndGetAuthPolicyConsistence(mailAuthPolicy, smsAuthPolicy);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType in project midpoint by Evolveum.
the class SecurityPolicyUtil method getCredentialPolicy.
public static NonceCredentialsPolicyType getCredentialPolicy(String policyName, SecurityPolicyType securityPolicy) throws SchemaException {
CredentialsPolicyType credentialsPolicy = securityPolicy.getCredentials();
if (credentialsPolicy == null) {
return null;
}
List<NonceCredentialsPolicyType> noncePolicies = credentialsPolicy.getNonce();
List<NonceCredentialsPolicyType> availableNoncePolicies = new ArrayList<>();
for (NonceCredentialsPolicyType noncePolicy : noncePolicies) {
if (noncePolicy.getName() == null && policyName == null) {
availableNoncePolicies.add(noncePolicy);
}
if (noncePolicy.getName() == null && policyName != null) {
continue;
}
if (noncePolicy.getName() != null && policyName == null) {
continue;
}
if (noncePolicy.getName().equals(policyName)) {
availableNoncePolicies.add(noncePolicy);
}
}
if (availableNoncePolicies.size() > 1) {
throw new SchemaException("Found more than one nonce credentials policy. Please review your configuration");
}
if (availableNoncePolicies.size() == 0) {
return null;
}
return availableNoncePolicies.iterator().next();
}
Aggregations