Search in sources :

Example 1 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class PersonalInfoPanel method loadPersonalInfo.

private PersonalInfoDto loadPersonalInfo() {
    UserType user = SecurityUtils.getPrincipalUser().getUser();
    CredentialsType credentials = user.getCredentials();
    PersonalInfoDto dto = new PersonalInfoDto();
    if (credentials != null) {
        PasswordType password = credentials.getPassword();
        if (password.getPreviousSuccessfulLogin() != null) {
            dto.setLastLoginDate(MiscUtil.asDate(password.getPreviousSuccessfulLogin().getTimestamp()));
            dto.setLastLoginFrom(password.getPreviousSuccessfulLogin().getFrom());
        }
        if (password.getLastFailedLogin() != null) {
            dto.setLastFailDate(MiscUtil.asDate(password.getLastFailedLogin().getTimestamp()));
            dto.setLastFailFrom(password.getLastFailedLogin().getFrom());
        }
    }
    if (user.getActivation() != null) {
        //todo fix, this is not password expiration date...
        dto.setPasswordExp(MiscUtil.asDate(user.getActivation().getValidTo()));
    }
    return dto;
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PersonalInfoDto(com.evolveum.midpoint.web.page.admin.home.dto.PersonalInfoDto) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)

Example 2 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class PageSelfRegistration method createCredentials.

private void createCredentials(UserType user, NonceCredentialsPolicyType noncePolicy, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
    NonceType nonceType = createNonce(noncePolicy, task, result);
    // PasswordType password = createPassword();
    CredentialsType credentials = user.getCredentials();
    if (user.getCredentials() == null) {
        credentials = new CredentialsType();
        user.setCredentials(credentials);
    }
    credentials.setNonce(nonceType);
// credentials.setPassword(password);
// return credentials;
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) NonceType(com.evolveum.midpoint.xml.ns._public.common.common_3.NonceType)

Example 3 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class FocusTypeUtil method getPasswordValue.

public static ProtectedStringType getPasswordValue(UserType user) {
    if (user == null) {
        return null;
    }
    CredentialsType creds = user.getCredentials();
    if (creds == null) {
        return null;
    }
    PasswordType passwd = creds.getPassword();
    if (passwd == null) {
        return null;
    }
    return passwd.getValue();
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)

Example 4 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class ModelClientUtil method createPasswordCredentials.

public static CredentialsType createPasswordCredentials(String password) {
    CredentialsType credentialsType = new CredentialsType();
    credentialsType.setPassword(createPasswordType(password));
    return credentialsType;
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType)

Example 5 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class TestAbstractRestService method test600modifySecurityQuestionAnswer.

@Test
public void test600modifySecurityQuestionAnswer() throws Exception {
    final String TEST_NAME = "test600modifySecurityQuestionAnswer";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/" + USER_DARTHADDER_OID);
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(getRequestFile(MODIFICATION_REPLACE_ANSWER));
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    traceResponse(response);
    assertEquals("Expected 204 but got " + response.getStatus(), 204, response.getStatus());
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(4);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
    getDummyAuditService().assertHasDelta(1, ChangeType.MODIFY, UserType.class);
    TestUtil.displayWhen(TEST_NAME);
    response = client.get();
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertEquals("Expected 200 but got " + response.getStatus(), 200, response.getStatus());
    UserType userDarthadder = response.readEntity(UserType.class);
    CredentialsType credentials = userDarthadder.getCredentials();
    assertNotNull("No credentials in user. Something is wrong.", credentials);
    SecurityQuestionsCredentialsType securityQuestions = credentials.getSecurityQuestions();
    assertNotNull("No security questions defined for user. Something is wrong.", securityQuestions);
    List<SecurityQuestionAnswerType> secQuestionAnswers = securityQuestions.getQuestionAnswer();
    assertEquals("Expected just one question-answer couple, but found " + secQuestionAnswers.size(), 1, secQuestionAnswers.size());
    SecurityQuestionAnswerType secQuestionAnswer = secQuestionAnswers.iterator().next();
    String decrypted = getPrismContext().getDefaultProtector().decryptString(secQuestionAnswer.getQuestionAnswer());
    assertEquals("Unexpected answer " + decrypted + ". Expected 'newAnswer'.", "newAnswer", decrypted);
}
Also used : Response(javax.ws.rs.core.Response) SecurityQuestionsCredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsType) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) SecurityQuestionsCredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionsCredentialsType) WebClient(org.apache.cxf.jaxrs.client.WebClient) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SecurityQuestionAnswerType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityQuestionAnswerType) Test(org.testng.annotations.Test)

Aggregations

CredentialsType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType)25 PasswordType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)15 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)15 Test (org.testng.annotations.Test)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)2 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)2 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 PasswordHistoryEntryType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType)2