Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Apr 22, 2015
2 parents e9a4236 + 0165057 commit 6cd257c
Show file tree
Hide file tree
Showing 17 changed files with 342 additions and 37 deletions.
Expand Up @@ -4,9 +4,11 @@ PageBase.button.cancel=Cancel
PageBase.button.delete=Delete
PageBase.button.run=Run
PageBase.button.save=Save
PageBase.button.send=Send
PageBase.button.saveAndRun=Save & Run
PageBase.button.search=Search
PageBase.button.update=Update
PageBase.button.send=Send
PageBase.clearCssCache=Clear less/js cache
WorkItemsPanel.assigned=Assigned to
WorkItemsPanel.created=Created
Expand Down
Expand Up @@ -18,6 +18,7 @@ pageBase.unknownBuildNumber=bilinmeyen


PageBase.button.save=Kaydet
PageBase.button.send=Gönder
PageBase.button.update=Güncelle
PageBase.button.search=Ara
PageBase.button.back=Geri
Expand Down
Expand Up @@ -384,10 +384,14 @@ private List<ContainerWrapper> createResourceContainerWrapper(PrismObject<Connec
ConnectorType connectorType = connector.asObjectable();
PrismSchema schema = ConnectorTypeUtil.parseConnectorSchema(connectorType, connector.getPrismContext());
PrismContainerDefinition definition = ConnectorTypeUtil.findConfigurationContainerDefintion(connectorType, schema);

ContainerStatus status = container != null ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
if (container == null) {
container = definition.instantiate();
// brutal hack - the definition has (errorneously) set maxOccurs = unbounded. But there can be only one configuration container.
// See MID-2317 and related issues
PrismContainerDefinition definitionFixed = definition.clone();
definitionFixed.setMaxOccurs(1);
container = definitionFixed.instantiate();
}

return createContainerWrapper(container, new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION), pageBase);
Expand Down
Expand Up @@ -191,6 +191,11 @@ public MappingType prepareDtoToSave(PrismContext prismContext) throws SchemaExce
mappingObject.setExpression(new ExpressionType());
}

//TODO - dirty fix for MID-2335
if(ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(expressionType)){
expression = expression.replace("<script>", "<script xmlns=\"http://midpoint.evolveum.com/xml/ns/public/common/common-3\">");
}

mappingObject.getExpression().getExpressionEvaluator().clear();
mappingObject.getExpression().getExpressionEvaluator().add(deserializeExpression(prismContext, expression));
}
Expand All @@ -200,6 +205,11 @@ public MappingType prepareDtoToSave(PrismContext prismContext) throws SchemaExce
mappingObject.setCondition(new ExpressionType());
}

//TODO - dirty fix for MID-2335
if(ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(conditionType)){
condition = condition.replace("<script>", "<script xmlns=\"http://midpoint.evolveum.com/xml/ns/public/common/common-3\">");
}

mappingObject.getCondition().getExpressionEvaluator().clear();
mappingObject.getCondition().getExpressionEvaluator().add(deserializeExpression(prismContext, condition));
}
Expand Down
@@ -0,0 +1,17 @@
#Mon May 12 18:18:36 CEST 2014
PageBase.button.back=Back
PageBase.button.cancel=Cancel
PageBase.button.delete=Delete
PageBase.button.run=Run
PageBase.button.save=Save
PageBase.button.send=Send
PageBase.button.saveAndRun=Save & Run
PageBase.button.search=Search
PageBase.button.update=Update
PageBase.button.send=Send
PageBase.clearCssCache=Clear less/js cache
WorkItemsPanel.assigned=Assigned to
WorkItemsPanel.created=Created
WorkItemsPanel.name=Name
pageBase.midPointVersion=Version\: ${pom.version}, ${describe}
pageBase.unknownBuildNumber=unknown
Expand Up @@ -21,6 +21,7 @@
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.util.string.StringValue;
import org.aspectj.util.LangUtil.ProcessController.Thrown;
import org.eclipse.core.internal.runtime.PrintStackUtil;

import ch.qos.logback.classic.Logger;

Expand Down Expand Up @@ -225,9 +226,11 @@ public void initLayout(){

Task task = getPageBase().createSimpleTask(OPERATION_LOAD_QUESTION_POLICY);
OperationResult subResult = result.createSubresult(OPERATION_LOAD_QUESTION_POLICY);
try{
PrismObject<SystemConfigurationType> config = getPageBase().getModelService().getObject(
SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null,
task, result);

PrismObject<SecurityPolicyType> securityPolicy = getModelService().getObject(SecurityPolicyType.class,config.asObjectable().getGlobalSecurityPolicyRef().getOid(), null, task, subResult);
//Global Policy set question numbers
questionNumber=securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestionNumber();
Expand All @@ -237,8 +240,84 @@ public void initLayout(){


// Actual Policy Question List



policyQuestionList = securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestion();
}catch(Exception ex){

System.out.println("Access");
List<SecurityQuestionAnswerDTO> userQuestionList= model.getObject().getSecurityAnswers();
int panelNumber=0;
PrismObject<UserType> user = null;



Collection options = SelectorOptions.createCollection(UserType.F_CREDENTIALS,
GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
Task taskTwo = createSimpleTask("LOAD USER WRAPPER");
user = getModelService().getObject(UserType.class, SecurityUtils.getPrincipalUser().getOid(), options, taskTwo, result);

OperationResult parentResult = new OperationResult(OPERATION_LOAD_QUESTION_POLICY);
questionNumber = getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestionNumber();

policyQuestionList=getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestion();
if(userQuestionList==null){

for(int i=0;i<questionNumber;i++){
System.out.println("Adding panel element");
SecurityQuestionAnswerDTO a=new SecurityQuestionAnswerDTO(policyQuestionList.get(panelNumber).getIdentifier(),"",policyQuestionList.get(panelNumber).getQuestionText());
MyPasswordQuestionsPanel panel=new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL+ panelNumber,a);
pqPanels.add(panel);
panelNumber++;
}

System.out.println(getModelInteractionService().getCredentialsPolicy(user, parentResult).getSecurityQuestions().getQuestionNumber());
//TODO Warn user


}else{
System.out.println("Else");
for(int userQuestint=0;userQuestint<userQuestionList.size();userQuestint++){
// SecurityQuestionAnswerDTO answerDTO= checkIfQuestionisValid(userQuestionList.get(userQuestint), policyQuestionList);
SecurityQuestionAnswerDTO answerDTO= checkIfQuestionisValid(userQuestionList.get(userQuestint), policyQuestionList);
if (userQuestionList.get(userQuestint)!=null){

MyPasswordQuestionsPanel panel=new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL+ panelNumber,userQuestionList.get(userQuestint));
pqPanels.add(panel);
panelNumber++;
}

}
//rest of the questions
//TODO same questions check should be implemented
/*
int difference=questionNumber-panelNumber;
for(int i=0;i<difference;i++){
System.out.println("Adding panel element");
SecurityQuestionAnswerDTO a=new SecurityQuestionAnswerDTO(policyQuestionList.get(panelNumber).getIdentifier(),"",policyQuestionList.get(panelNumber).getQuestionText());
MyPasswordQuestionsPanel panel=new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL+ panelNumber,a);
pqPanels.add(panel);
panelNumber++;
}
*/

}
add(mainForm);
mainForm.add(getPanels(pqPanels));







initButtons(mainForm);
return;


}
//User's pre set Question List
List<SecurityQuestionAnswerDTO> userQuestionList= model.getObject().getSecurityAnswers();

Expand Down
Expand Up @@ -34,7 +34,7 @@
<span class="button-group">
<a class="btn btn-default" wicket:id="back" />
</span>
<a class="btn btn-primary" wicket:id="save"/>
<a class="btn btn-primary" wicket:id="send"/>
</div>


Expand Down
Expand Up @@ -107,7 +107,7 @@ public class PageSecurityQuestions extends PageBase {
private static final String OPERATION_RESET_PASSWORD = DOT_CLASS + "resetPassword";
private static final String ID_MAIN_FORM = "mainForm";
private static final String ID_BACK = "back";
private static final String ID_SAVE = "save";
private static final String ID_SAVE = "send";

private static final String SESSION_ATTRIBUTE_POID="pOid";

Expand Down Expand Up @@ -436,7 +436,7 @@ private void savePerformed(AjaxRequestTarget target) {
}

if(questionNumber==correctAnswers){
resetPassword(principalModel.getObject().asObjectable());
resetPassword(principalModel.getObject().asObjectable(),target);

}
else{
Expand Down Expand Up @@ -525,7 +525,7 @@ public PageBase getPageBase() {
return (PageBase) getPage();
}

private void resetPassword(UserType user){
private void resetPassword(UserType user,AjaxRequestTarget target){


Task task = createSimpleTask(OPERATION_RESET_PASSWORD);
Expand All @@ -539,14 +539,27 @@ private void resetPassword(UserType user){
String newPassword="";
PageBase page = (PageBase) getPage();

ModelService model = page.getModelService();
ModelService modelService = page.getModelService();
try {

systemConfig = model.getObject(SystemConfigurationType.class,
systemConfig = modelService.getObject(SystemConfigurationType.class,
SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, task, result);
if(systemConfig.asObjectable().getNotificationConfiguration()!=null){
PrismObject<ValuePolicyType> valPolicy =model.getObject(ValuePolicyType.class, systemConfig.asObjectable().getGlobalPasswordPolicyRef().getOid(), options, task, result);
newPassword=ValuePolicyGenerator.generate(valPolicy.asObjectable().getStringPolicy(), valPolicy.asObjectable().getStringPolicy().getLimitations().getMinLength(), result);
//New password is automatically reset according to the global 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);
newPassword=ValuePolicyGenerator.generate(valPolicy.asObjectable().getStringPolicy(), valPolicy.asObjectable().getStringPolicy().getLimitations().getMinLength(), 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());
setAuthenticationNull();
return;
}



}else{
//TODO localization
Expand Down
Expand Up @@ -16,14 +16,18 @@

package com.evolveum.midpoint.web.page.login;

import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.application.AuthorizationAction;
import com.evolveum.midpoint.web.application.PageDescriptor;
import com.evolveum.midpoint.web.component.menu.top.LocalePanel;
import com.evolveum.midpoint.web.component.menu.top.TopMenuBar;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.page.admin.home.PageDashboard;
import com.evolveum.midpoint.web.security.MidPointAuthWebSession;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemObjectsType;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.PasswordTextField;
Expand All @@ -42,12 +46,17 @@ public class PageLogin extends PageBase {
private static final String ID_USERNAME = "username";
private static final String ID_PASSWORD = "password";

protected static final String OPERATION_LOAD_RESET_PASSWORD_POLICY = "LOAD PASSWORD RESET POLICY";


public PageLogin() {
TopMenuBar menuBar = getTopMenuBar();
menuBar.addOrReplace(new LocalePanel(TopMenuBar.ID_RIGHT_PANEL));

menuBar.addOrReplace(new LocalePanel(TopMenuBar.ID_RIGHT_PANEL));


Form form = new Form(ID_LOGIN_FORM) {



@Override
protected void onSubmit() {
MidPointAuthWebSession session = MidPointAuthWebSession.getSession();
Expand All @@ -56,17 +65,24 @@ protected void onSubmit() {
PasswordTextField password = (PasswordTextField) get(ID_PASSWORD);
if (session.authenticate(username.getModelObject(), password.getModelObject())) {
setResponsePage(PageDashboard.class);


}
}
};

form.add(new RequiredTextField(ID_USERNAME, new Model<String>()));
form.add(new PasswordTextField(ID_PASSWORD, new Model<String>()));

add(form);
}

@Override
protected IModel<String> createPageTitleModel() {
return new Model<>("");
}

public PageBase getPageBase() {
return (PageBase) getPage();
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -304,7 +304,7 @@ private Collection<RefinedAssociationDefinition> cloneAssociations(
}

private List<RefinedAttributeDefinition<?>> cloneDefinitions(Collection<? extends RefinedAttributeDefinition<?>> origDefs) {
if (this.attributeDefinitions == null) {
if (origDefs == null) {
return null;
}
List<RefinedAttributeDefinition<?>> clonedAttributes = new ArrayList<>();
Expand Down
Expand Up @@ -104,7 +104,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
protected static final String RESOURCE_DUMMY_DRINK = "rum";

// RED resource has STRONG mappings
protected static final String RESOURCE_DUMMY_RED_FILENAME = COMMON_DIR + "/resource-dummy-red.xml";
protected static final File RESOURCE_DUMMY_RED_FILE = new File(COMMON_DIR, "resource-dummy-red.xml");
protected static final String RESOURCE_DUMMY_RED_OID = "10000000-0000-0000-0000-000000000104";
protected static final String RESOURCE_DUMMY_RED_NAME = "red";
protected static final String RESOURCE_DUMMY_RED_NAMESPACE = MidPointConstants.NS_RI;
Expand Down
Expand Up @@ -172,7 +172,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
dummyResourceCtlRed = DummyResourceContoller.create(RESOURCE_DUMMY_RED_NAME, resourceDummyRed);
dummyResourceCtlRed.extendSchemaPirate();
dummyResourceRed = dummyResourceCtlRed.getDummyResource();
resourceDummyRed = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_RED_FILENAME, RESOURCE_DUMMY_RED_OID, initTask, initResult);
resourceDummyRed = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_RED_FILE, RESOURCE_DUMMY_RED_OID, initTask, initResult);
resourceDummyRedType = resourceDummyRed.asObjectable();
dummyResourceCtlRed.setResource(resourceDummyRed);

Expand Down

0 comments on commit 6cd257c

Please sign in to comment.