Search in sources :

Example 1 with PasswordCredential

use of com.bakdata.conquery.apiv1.auth.PasswordCredential in project conquery by bakdata.

the class LocalAuthenticationRealm method updateUser.

@Override
public boolean updateUser(User user, List<CredentialType> credentials) {
    Optional<PasswordCredential> optPassword = getTypePassword(credentials);
    if (optPassword.isEmpty()) {
        log.trace("No password credential provided. Not adding {} to {}", user.getName(), getName());
        return false;
    }
    HashedEntry passwordByteIt = optPassword.map(LocalAuthenticationRealm::passwordToHashedEntry).get();
    passwordStore.update(user.getId(), passwordByteIt);
    return true;
}
Also used : PasswordCredential(com.bakdata.conquery.apiv1.auth.PasswordCredential) HashedEntry(com.bakdata.conquery.models.auth.basic.PasswordHasher.HashedEntry)

Example 2 with PasswordCredential

use of com.bakdata.conquery.apiv1.auth.PasswordCredential in project conquery by bakdata.

the class LocalAuthRealmTest method setupEach.

@BeforeEach
public void setupEach() {
    // Create User in Realm
    user1 = new User("TestUser", "Test User", storage);
    PasswordCredential user1Password = new PasswordCredential("testPassword".toCharArray());
    storage.addUser(user1);
    realm.addUser(user1, List.of(user1Password));
}
Also used : User(com.bakdata.conquery.models.auth.entities.User) PasswordCredential(com.bakdata.conquery.apiv1.auth.PasswordCredential) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with PasswordCredential

use of com.bakdata.conquery.apiv1.auth.PasswordCredential in project conquery by bakdata.

the class LocalAuthenticationRealm method addUser.

// ////////////////// USER MANAGEMENT ////////////////////
@Override
public boolean addUser(User user, List<CredentialType> credentials) {
    Optional<PasswordCredential> optPassword = getTypePassword(credentials);
    if (optPassword.isEmpty()) {
        log.trace("No password credential provided. Not adding {} to {}", user.getName(), getName());
        return false;
    }
    HashedEntry passwordByteIt = optPassword.map(LocalAuthenticationRealm::passwordToHashedEntry).get();
    passwordStore.add(user.getId(), passwordByteIt);
    return true;
}
Also used : PasswordCredential(com.bakdata.conquery.apiv1.auth.PasswordCredential) HashedEntry(com.bakdata.conquery.models.auth.basic.PasswordHasher.HashedEntry)

Example 4 with PasswordCredential

use of com.bakdata.conquery.apiv1.auth.PasswordCredential in project conquery by bakdata.

the class SerializationTests method passwordCredential.

@Test
public void passwordCredential() throws IOException, JSONException {
    PasswordCredential credential = new PasswordCredential(new String("testPassword").toCharArray());
    SerializationTestUtil.forType(PasswordCredential.class).test(credential);
}
Also used : PasswordCredential(com.bakdata.conquery.apiv1.auth.PasswordCredential) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Aggregations

PasswordCredential (com.bakdata.conquery.apiv1.auth.PasswordCredential)4 HashedEntry (com.bakdata.conquery.models.auth.basic.PasswordHasher.HashedEntry)2 User (com.bakdata.conquery.models.auth.entities.User)1 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1