parent
aa6a131b73
commit
b4281468d0
19 changed files with 1178 additions and 2135 deletions
|
@ -100,10 +100,22 @@ public class Util {
|
|||
}
|
||||
|
||||
public static String singularToPlural(String word) {
|
||||
return word.endsWith("y") ? word.substring(0, word.length() -1) + "ies" : word + "s";
|
||||
if (word.endsWith("y")) {
|
||||
return word.substring(0, word.length() -1) + "ies";
|
||||
} else if (word.endsWith("ss")) {
|
||||
return word + "es";
|
||||
} else {
|
||||
return word + "s";
|
||||
}
|
||||
}
|
||||
|
||||
public static String pluralToSingular(String word) {
|
||||
return word.endsWith("ies") ? word.substring(0, word.length() - 3) + "y" : word.endsWith("s") ? word.substring(0, word.length() - 1) : word;
|
||||
if (word.endsWith("ies")) {
|
||||
return word.substring(0, word.length() - 3) + "y";
|
||||
} else if (word.endsWith("sses")) {
|
||||
return word.substring(0, word.length() - 2);
|
||||
} else {
|
||||
return word.endsWith("s") ? word.substring(0, word.length() - 1) : word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -74,7 +74,8 @@ public class MapRealmProvider implements RealmProvider {
|
|||
|
||||
LOG.tracef("createRealm(%s, %s)%s", id, name, getShortStackTrace());
|
||||
|
||||
MapRealmEntity entity = new MapRealmEntity(id);
|
||||
MapRealmEntity entity = new MapRealmEntityImpl();
|
||||
entity.setId(id);
|
||||
entity.setName(name);
|
||||
|
||||
entity = tx.create(entity);
|
||||
|
@ -170,12 +171,10 @@ public class MapRealmProvider implements RealmProvider {
|
|||
//TODO move the following method to adapter
|
||||
@Override
|
||||
public void saveLocalizationText(RealmModel realm, String locale, String key, String text) {
|
||||
// implemented according to behaviour in JpaRealmProvider (as java-doc was not added)
|
||||
if (! updateLocalizationText(realm, locale, key, text)) {
|
||||
Map<String, String> texts = new HashMap<>();
|
||||
texts.put(key, text);
|
||||
realm.createOrUpdateRealmLocalizationTexts(locale, texts);
|
||||
}
|
||||
if (locale == null || key == null || text == null) return;
|
||||
Map<String, String> texts = new HashMap<>();
|
||||
texts.put(key, text);
|
||||
realm.createOrUpdateRealmLocalizationTexts(locale, texts);
|
||||
}
|
||||
|
||||
//TODO move the following method to adapter
|
||||
|
@ -189,9 +188,7 @@ public class MapRealmProvider implements RealmProvider {
|
|||
@Override
|
||||
public boolean updateLocalizationText(RealmModel realm, String locale, String key, String text) {
|
||||
if (locale == null || key == null || text == null || (! realm.getRealmLocalizationTextsByLocale(locale).containsKey(key))) return false;
|
||||
Map<String, String> texts = new HashMap<>(realm.getRealmLocalizationTextsByLocale(locale));
|
||||
texts.replace(key, text);
|
||||
realm.createOrUpdateRealmLocalizationTexts(locale, texts);
|
||||
saveLocalizationText(realm, locale, key, text);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -17,28 +17,19 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.AuthenticationExecutionModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapAuthenticationExecutionEntity extends UpdatableEntity.Impl {
|
||||
|
||||
private String id;
|
||||
private String authenticator;
|
||||
private String authenticatorConfig;
|
||||
private String flowId;
|
||||
private String parentFlowId;
|
||||
private AuthenticationExecutionModel.Requirement requirement;
|
||||
private Boolean autheticatorFlow = false;
|
||||
private Integer priority = 0;
|
||||
|
||||
|
||||
private MapAuthenticationExecutionEntity() {}
|
||||
|
||||
public static MapAuthenticationExecutionEntity fromModel(AuthenticationExecutionModel model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapAuthenticationExecutionEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapAuthenticationExecutionEntity fromModel(AuthenticationExecutionModel model) {
|
||||
if (model == null) return null;
|
||||
MapAuthenticationExecutionEntity entity = new MapAuthenticationExecutionEntity();
|
||||
MapAuthenticationExecutionEntity entity = new MapAuthenticationExecutionEntityImpl();
|
||||
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAuthenticator(model.getAuthenticator());
|
||||
|
@ -51,7 +42,7 @@ public class MapAuthenticationExecutionEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static AuthenticationExecutionModel toModel(MapAuthenticationExecutionEntity entity) {
|
||||
static AuthenticationExecutionModel toModel(MapAuthenticationExecutionEntity entity) {
|
||||
if (entity == null) return null;
|
||||
AuthenticationExecutionModel model = new AuthenticationExecutionModel();
|
||||
model.setId(entity.getId());
|
||||
|
@ -60,94 +51,31 @@ public class MapAuthenticationExecutionEntity extends UpdatableEntity.Impl {
|
|||
model.setFlowId(entity.getFlowId());
|
||||
model.setParentFlow(entity.getParentFlowId());
|
||||
model.setRequirement(entity.getRequirement());
|
||||
model.setAuthenticatorFlow(entity.isAutheticatorFlow());
|
||||
model.setPriority(entity.getPriority());
|
||||
Boolean authenticatorFlow = entity.isAutheticatorFlow();
|
||||
model.setAuthenticatorFlow(authenticatorFlow == null ? false : authenticatorFlow);
|
||||
Integer priority = entity.getPriority();
|
||||
model.setPriority(priority == null ? 0 : priority);
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
String getAuthenticator();
|
||||
void setAuthenticator(String authenticator);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
String getAuthenticatorConfig();
|
||||
void setAuthenticatorConfig(String authenticatorConfig);
|
||||
|
||||
public String getAuthenticator() {
|
||||
return authenticator;
|
||||
}
|
||||
AuthenticationExecutionModel.Requirement getRequirement();
|
||||
void setRequirement(AuthenticationExecutionModel.Requirement requirement);
|
||||
|
||||
public void setAuthenticator(String authenticator) {
|
||||
this.updated = !Objects.equals(this.authenticator, authenticator);
|
||||
this.authenticator = authenticator;
|
||||
}
|
||||
Boolean isAutheticatorFlow();
|
||||
void setAutheticatorFlow(Boolean autheticatorFlow);
|
||||
|
||||
public String getAuthenticatorConfig() {
|
||||
return authenticatorConfig;
|
||||
}
|
||||
String getFlowId();
|
||||
void setFlowId(String flowId);
|
||||
|
||||
public void setAuthenticatorConfig(String authenticatorConfig) {
|
||||
this.updated = !Objects.equals(this.authenticatorConfig, authenticatorConfig);
|
||||
this.authenticatorConfig = authenticatorConfig;
|
||||
}
|
||||
|
||||
public AuthenticationExecutionModel.Requirement getRequirement() {
|
||||
return requirement;
|
||||
}
|
||||
|
||||
public void setRequirement(AuthenticationExecutionModel.Requirement requirement) {
|
||||
this.updated = !Objects.equals(this.requirement, requirement);
|
||||
this.requirement = requirement;
|
||||
}
|
||||
|
||||
public Boolean isAutheticatorFlow() {
|
||||
return autheticatorFlow;
|
||||
}
|
||||
|
||||
public void setAutheticatorFlow(boolean autheticatorFlow) {
|
||||
this.updated = !Objects.equals(this.requirement, requirement);
|
||||
this.autheticatorFlow = autheticatorFlow;
|
||||
}
|
||||
|
||||
public String getFlowId() {
|
||||
return flowId;
|
||||
}
|
||||
|
||||
public void setFlowId(String flowId) {
|
||||
this.updated = !Objects.equals(this.flowId, flowId);
|
||||
this.flowId = flowId;
|
||||
}
|
||||
|
||||
public String getParentFlowId() {
|
||||
return parentFlowId;
|
||||
}
|
||||
|
||||
public void setParentFlowId(String parentFlowId) {
|
||||
this.updated = !Objects.equals(this.parentFlowId, parentFlowId);
|
||||
this.parentFlowId = parentFlowId;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(Integer priority) {
|
||||
this.updated = !Objects.equals(this.priority, priority);
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapAuthenticationExecutionEntity)) return false;
|
||||
final MapAuthenticationExecutionEntity other = (MapAuthenticationExecutionEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
String getParentFlowId();
|
||||
void setParentFlowId(String parentFlowId);
|
||||
|
||||
Integer getPriority();
|
||||
void setPriority(Integer priority);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,26 +17,18 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.AuthenticationFlowModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapAuthenticationFlowEntity extends UpdatableEntity.Impl {
|
||||
|
||||
private String id;
|
||||
private String alias;
|
||||
private String description;
|
||||
private String providerId;
|
||||
private Boolean builtIn = false;
|
||||
private Boolean topLevel = false;
|
||||
|
||||
|
||||
private MapAuthenticationFlowEntity() {}
|
||||
|
||||
public static MapAuthenticationFlowEntity fromModel(AuthenticationFlowModel model) {
|
||||
if (model == null) return null;
|
||||
MapAuthenticationFlowEntity entity = new MapAuthenticationFlowEntity();
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapAuthenticationFlowEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapAuthenticationFlowEntity fromModel(AuthenticationFlowModel model) {
|
||||
MapAuthenticationFlowEntity entity = new MapAuthenticationFlowEntityImpl();
|
||||
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAlias(model.getAlias());
|
||||
|
@ -48,82 +40,31 @@ public class MapAuthenticationFlowEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static AuthenticationFlowModel toModel(MapAuthenticationFlowEntity entity) {
|
||||
if (entity == null) return null;
|
||||
static AuthenticationFlowModel toModel(MapAuthenticationFlowEntity entity) {
|
||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||
model.setId(entity.getId());
|
||||
model.setAlias(entity.getAlias());
|
||||
model.setBuiltIn(entity.isBuiltIn());
|
||||
Boolean builtIn = entity.isBuiltIn();
|
||||
model.setBuiltIn(builtIn == null ? false : builtIn);
|
||||
model.setDescription(entity.getDescription());
|
||||
model.setProviderId(entity.getProviderId());
|
||||
model.setTopLevel(entity.isTopLevel());
|
||||
Boolean topLevel = entity.isTopLevel();
|
||||
model.setTopLevel(topLevel == null ? false : topLevel);
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
String getAlias();
|
||||
void setAlias(String alias);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
String getDescription();
|
||||
void setDescription(String description);
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
String getProviderId();
|
||||
void setProviderId(String providerId);
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.updated = !Objects.equals(this.alias, alias);
|
||||
this.alias = alias;
|
||||
}
|
||||
Boolean isBuiltIn();
|
||||
void setBuiltIn(Boolean builtIn);
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.updated = !Objects.equals(this.description, description);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.updated = !Objects.equals(this.providerId, providerId);
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public Boolean isBuiltIn() {
|
||||
return builtIn;
|
||||
}
|
||||
|
||||
public void setBuiltIn(boolean builtIn) {
|
||||
this.updated = !Objects.equals(this.builtIn, builtIn);
|
||||
this.builtIn = builtIn;
|
||||
}
|
||||
|
||||
public Boolean isTopLevel() {
|
||||
return topLevel;
|
||||
}
|
||||
|
||||
public void setTopLevel(boolean topLevel) {
|
||||
this.updated = !Objects.equals(this.topLevel, topLevel);
|
||||
this.topLevel = topLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapAuthenticationFlowEntity)) return false;
|
||||
final MapAuthenticationFlowEntity other = (MapAuthenticationFlowEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
Boolean isTopLevel();
|
||||
void setTopLevel(Boolean topLevel);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -17,78 +17,41 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.AuthenticatorConfigModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapAuthenticatorConfigEntity extends UpdatableEntity.Impl {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
private String id;
|
||||
private String alias;
|
||||
private Map<String, String> config = new HashMap<>();
|
||||
|
||||
|
||||
private MapAuthenticatorConfigEntity() {}
|
||||
|
||||
public static MapAuthenticatorConfigEntity fromModel(AuthenticatorConfigModel model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapAuthenticatorConfigEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapAuthenticatorConfigEntity fromModel(AuthenticatorConfigModel model) {
|
||||
if (model == null) return null;
|
||||
MapAuthenticatorConfigEntity entity = new MapAuthenticatorConfigEntity();
|
||||
MapAuthenticatorConfigEntity entity = new MapAuthenticatorConfigEntityImpl();
|
||||
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAlias(model.getAlias());
|
||||
entity.setConfig(model.getConfig() == null ? null : new HashMap<>(model.getConfig()));
|
||||
entity.setConfig(model.getConfig());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static AuthenticatorConfigModel toModel(MapAuthenticatorConfigEntity entity) {
|
||||
static AuthenticatorConfigModel toModel(MapAuthenticatorConfigEntity entity) {
|
||||
if (entity == null) return null;
|
||||
AuthenticatorConfigModel model = new AuthenticatorConfigModel();
|
||||
model.setId(entity.getId());
|
||||
model.setAlias(entity.getAlias());
|
||||
model.setConfig(entity.getConfig() == null ? null : new HashMap<>(entity.getConfig()));
|
||||
model.setConfig(entity.getConfig());
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
String getAlias();
|
||||
void setAlias(String alias);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.updated = !Objects.equals(this.alias, alias);
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public Map<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, String> config) {
|
||||
this.updated = !Objects.equals(this.config, config);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapAuthenticatorConfigEntity)) return false;
|
||||
final MapAuthenticatorConfigEntity other = (MapAuthenticatorConfigEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
Map<String, String> getConfig();
|
||||
void setConfig(Map<String, String> config);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,27 +17,21 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.keycloak.common.util.Time;
|
||||
import org.keycloak.models.ClientInitialAccessModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapClientInitialAccessEntity extends UpdatableEntity.Impl {
|
||||
|
||||
private String id;
|
||||
private Integer timestamp = 0;
|
||||
private Integer expiration = 0;
|
||||
private Integer count = 0;
|
||||
private Integer remainingCount = 0;
|
||||
|
||||
|
||||
private MapClientInitialAccessEntity() {}
|
||||
|
||||
public static MapClientInitialAccessEntity createEntity(int expiration, int count) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapClientInitialAccessEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapClientInitialAccessEntity createEntity(int expiration, int count) {
|
||||
int currentTime = Time.currentTime();
|
||||
|
||||
MapClientInitialAccessEntity entity = new MapClientInitialAccessEntity();
|
||||
MapClientInitialAccessEntity entity = new MapClientInitialAccessEntityImpl();
|
||||
entity.setId(KeycloakModelUtils.generateId());
|
||||
entity.setTimestamp(currentTime);
|
||||
entity.setExpiration(expiration);
|
||||
|
@ -46,72 +40,30 @@ public class MapClientInitialAccessEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static ClientInitialAccessModel toModel(MapClientInitialAccessEntity entity) {
|
||||
static ClientInitialAccessModel toModel(MapClientInitialAccessEntity entity) {
|
||||
if (entity == null) return null;
|
||||
ClientInitialAccessModel model = new ClientInitialAccessModel();
|
||||
model.setId(entity.getId());
|
||||
model.setTimestamp(entity.getTimestamp());
|
||||
model.setExpiration(entity.getExpiration());
|
||||
model.setCount(entity.getCount());
|
||||
model.setRemainingCount(entity.getRemainingCount());
|
||||
Integer timestamp = entity.getTimestamp();
|
||||
model.setTimestamp(timestamp == null ? 0 : timestamp);
|
||||
Integer expiration = entity.getExpiration();
|
||||
model.setExpiration(expiration == null ? 0 : expiration);
|
||||
Integer count = entity.getCount();
|
||||
model.setCount(count == null ? 0 : count);
|
||||
Integer remainingCount = entity.getRemainingCount();
|
||||
model.setRemainingCount(remainingCount == null ? 0 : remainingCount);
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
Integer getTimestamp();
|
||||
void setTimestamp(Integer timestamp);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
Integer getExpiration();
|
||||
void setExpiration(Integer expiration);
|
||||
|
||||
public Integer getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
Integer getCount();
|
||||
void setCount(Integer count);
|
||||
|
||||
public void setTimestamp(int timestamp) {
|
||||
this.updated = !Objects.equals(this.timestamp, timestamp);
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public Integer getExpiration() {
|
||||
return expiration;
|
||||
}
|
||||
|
||||
public void setExpiration(int expiration) {
|
||||
this.updated = !Objects.equals(this.expiration, expiration);
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
public Integer getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.updated = !Objects.equals(this.count, count);
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public Integer getRemainingCount() {
|
||||
return remainingCount;
|
||||
}
|
||||
|
||||
public void setRemainingCount(int remainingCount) {
|
||||
this.updated = !Objects.equals(this.remainingCount, remainingCount);
|
||||
this.remainingCount = remainingCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapClientInitialAccessEntity)) return false;
|
||||
final MapClientInitialAccessEntity other = (MapClientInitialAccessEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
Integer getRemainingCount();
|
||||
void setRemainingCount(Integer remainingCount);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,28 +17,22 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.keycloak.common.util.MultivaluedHashMap;
|
||||
import org.keycloak.component.ComponentModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapComponentEntity extends UpdatableEntity.Impl {
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String providerId;
|
||||
private String providerType;
|
||||
private String subType;
|
||||
private String parentId;
|
||||
private MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
|
||||
|
||||
|
||||
private MapComponentEntity() {}
|
||||
|
||||
public static MapComponentEntity fromModel(ComponentModel model) {
|
||||
if (model == null) return null;
|
||||
MapComponentEntity entity = new MapComponentEntity();
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapComponentEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapComponentEntity fromModel(ComponentModel model) {
|
||||
MapComponentEntity entity = new MapComponentEntityImpl();
|
||||
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||
entity.setId(id);
|
||||
entity.setName(model.getName());
|
||||
|
@ -46,12 +40,11 @@ public class MapComponentEntity extends UpdatableEntity.Impl {
|
|||
entity.setProviderType(model.getProviderType());
|
||||
entity.setSubType(model.getSubType());
|
||||
entity.setParentId(model.getParentId());
|
||||
entity.setConfig(model.getConfig() == null ? null : new MultivaluedHashMap<>(model.getConfig()));
|
||||
entity.setConfig(model.getConfig());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static ComponentModel toModel(MapComponentEntity entity) {
|
||||
if (entity == null) return null;
|
||||
static ComponentModel toModel(MapComponentEntity entity) {
|
||||
ComponentModel model = new ComponentModel();
|
||||
model.setId(entity.getId());
|
||||
model.setName(entity.getName());
|
||||
|
@ -59,83 +52,26 @@ public class MapComponentEntity extends UpdatableEntity.Impl {
|
|||
model.setProviderType(entity.getProviderType());
|
||||
model.setSubType(entity.getSubType());
|
||||
model.setParentId(entity.getParentId());
|
||||
model.setConfig(entity.getConfig() == null ? null : new MultivaluedHashMap<>(entity.getConfig()));
|
||||
Map<String, List<String>> config = entity.getConfig();
|
||||
model.setConfig(config == null ? null : new MultivaluedHashMap<>(config));
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
String getName();
|
||||
void setName(String name);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
String getProviderId();
|
||||
void setProviderId(String providerId);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
String getProviderType();
|
||||
void setProviderType(String providerType);
|
||||
|
||||
public void setName(String name) {
|
||||
this.updated = !Objects.equals(this.name, name);
|
||||
this.name = name;
|
||||
}
|
||||
String getSubType();
|
||||
void setSubType(String subType);
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
String getParentId();
|
||||
void setParentId(String parentId);
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.updated = !Objects.equals(this.providerId, providerId);
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getProviderType() {
|
||||
return providerType;
|
||||
}
|
||||
|
||||
public void setProviderType(String providerType) {
|
||||
this.updated = !Objects.equals(this.providerType, providerType);
|
||||
this.providerType = providerType;
|
||||
}
|
||||
|
||||
public String getSubType() {
|
||||
return subType;
|
||||
}
|
||||
|
||||
public void setSubType(String subType) {
|
||||
this.updated = !Objects.equals(this.subType, subType);
|
||||
this.subType = subType;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.updated = !Objects.equals(this.parentId, parentId);
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public MultivaluedHashMap<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(MultivaluedHashMap<String, String> config) {
|
||||
this.updated = !Objects.equals(this.config, config);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapComponentEntity)) return false;
|
||||
final MapComponentEntity other = (MapComponentEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
Map<String, List<String>> getConfig();
|
||||
void setConfig(Map<String, List<String>> config);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,35 +17,22 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.IdentityProviderModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapIdentityProviderEntity extends UpdatableEntity.Impl {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
private String id;
|
||||
private String alias;
|
||||
private String displayName;
|
||||
private String providerId;
|
||||
private String firstBrokerLoginFlowId;
|
||||
private String postBrokerLoginFlowId;
|
||||
private Boolean enabled = false;
|
||||
private Boolean trustEmail = false;
|
||||
private Boolean storeToken = false;
|
||||
private Boolean linkOnly = false;
|
||||
private Boolean addReadTokenRoleOnCreate = false;
|
||||
private Boolean authenticateByDefault = false;
|
||||
private Map<String, String> config = new HashMap<>();
|
||||
|
||||
|
||||
private MapIdentityProviderEntity() {}
|
||||
|
||||
public static MapIdentityProviderEntity fromModel(IdentityProviderModel model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapIdentityProviderEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapIdentityProviderEntity fromModel(IdentityProviderModel model) {
|
||||
if (model == null) return null;
|
||||
MapIdentityProviderEntity entity = new MapIdentityProviderEntity();
|
||||
MapIdentityProviderEntity entity = new MapIdentityProviderEntityImpl();
|
||||
String id = model.getInternalId() == null ? KeycloakModelUtils.generateId() : model.getInternalId();
|
||||
entity.setId(id);
|
||||
entity.setAlias(model.getAlias());
|
||||
|
@ -63,7 +50,7 @@ public class MapIdentityProviderEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static IdentityProviderModel toModel(MapIdentityProviderEntity entity) {
|
||||
static IdentityProviderModel toModel(MapIdentityProviderEntity entity) {
|
||||
if (entity == null) return null;
|
||||
IdentityProviderModel model = new IdentityProviderModel();
|
||||
model.setInternalId(entity.getId());
|
||||
|
@ -72,143 +59,55 @@ public class MapIdentityProviderEntity extends UpdatableEntity.Impl {
|
|||
model.setProviderId(entity.getProviderId());
|
||||
model.setFirstBrokerLoginFlowId(entity.getFirstBrokerLoginFlowId());
|
||||
model.setPostBrokerLoginFlowId(entity.getPostBrokerLoginFlowId());
|
||||
model.setEnabled(entity.isEnabled());
|
||||
model.setTrustEmail(entity.isTrustEmail());
|
||||
model.setStoreToken(entity.isStoreToken());
|
||||
model.setLinkOnly(entity.isLinkOnly());
|
||||
model.setAddReadTokenRoleOnCreate(entity.isAddReadTokenRoleOnCreate());
|
||||
model.setAuthenticateByDefault(entity.isAuthenticateByDefault());
|
||||
Boolean enabled = entity.isEnabled();
|
||||
model.setEnabled(enabled == null ? false : enabled);
|
||||
Boolean trustEmail = entity.isTrustEmail();
|
||||
model.setTrustEmail(trustEmail == null ? false : trustEmail);
|
||||
Boolean storeToken = entity.isStoreToken();
|
||||
model.setStoreToken(storeToken == null ? false : storeToken);
|
||||
Boolean linkOnly = entity.isLinkOnly();
|
||||
model.setLinkOnly(linkOnly == null ? false : linkOnly);
|
||||
Boolean addReadTokenRoleOnCreate = entity.isAddReadTokenRoleOnCreate();
|
||||
model.setAddReadTokenRoleOnCreate(addReadTokenRoleOnCreate == null ? false : addReadTokenRoleOnCreate);
|
||||
Boolean authenticateByDefault = entity.isAuthenticateByDefault();
|
||||
model.setAuthenticateByDefault(authenticateByDefault == null ? false : authenticateByDefault);
|
||||
model.setConfig(entity.getConfig() == null ? null : new HashMap<>(entity.getConfig()));
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
String getAlias();
|
||||
void setAlias(String alias);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
String getDisplayName();
|
||||
void setDisplayName(String displayName);
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
String getProviderId();
|
||||
void setProviderId(String providerId);
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.updated = !Objects.equals(this.alias, alias);
|
||||
this.alias = alias;
|
||||
}
|
||||
String getFirstBrokerLoginFlowId();
|
||||
void setFirstBrokerLoginFlowId(String firstBrokerLoginFlowId);
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
String getPostBrokerLoginFlowId();
|
||||
void setPostBrokerLoginFlowId(String postBrokerLoginFlowId);
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.updated = !Objects.equals(this.displayName, displayName);
|
||||
this.displayName = displayName;
|
||||
}
|
||||
Boolean isEnabled();
|
||||
void setEnabled(Boolean enabled);
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
Boolean isTrustEmail();
|
||||
void setTrustEmail(Boolean trustEmail);
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.updated = !Objects.equals(this.providerId, providerId);
|
||||
this.providerId = providerId;
|
||||
}
|
||||
Boolean isStoreToken();
|
||||
void setStoreToken(Boolean storeToken);
|
||||
|
||||
public String getFirstBrokerLoginFlowId() {
|
||||
return firstBrokerLoginFlowId;
|
||||
}
|
||||
Boolean isLinkOnly();
|
||||
void setLinkOnly(Boolean linkOnly);
|
||||
|
||||
public void setFirstBrokerLoginFlowId(String firstBrokerLoginFlowId) {
|
||||
this.updated = !Objects.equals(this.firstBrokerLoginFlowId, firstBrokerLoginFlowId);
|
||||
this.firstBrokerLoginFlowId = firstBrokerLoginFlowId;
|
||||
}
|
||||
Boolean isAddReadTokenRoleOnCreate();
|
||||
void setAddReadTokenRoleOnCreate(Boolean addReadTokenRoleOnCreate);
|
||||
|
||||
public String getPostBrokerLoginFlowId() {
|
||||
return postBrokerLoginFlowId;
|
||||
}
|
||||
Boolean isAuthenticateByDefault();
|
||||
void setAuthenticateByDefault(Boolean authenticateByDefault);
|
||||
|
||||
public void setPostBrokerLoginFlowId(String postBrokerLoginFlowId) {
|
||||
this.updated = !Objects.equals(this.postBrokerLoginFlowId, postBrokerLoginFlowId);
|
||||
this.postBrokerLoginFlowId = postBrokerLoginFlowId;
|
||||
}
|
||||
|
||||
public Boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.updated = !Objects.equals(this.enabled, enabled);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean isTrustEmail() {
|
||||
return trustEmail;
|
||||
}
|
||||
|
||||
public void setTrustEmail(boolean trustEmail) {
|
||||
this.updated = !Objects.equals(this.trustEmail, trustEmail);
|
||||
this.trustEmail = trustEmail;
|
||||
}
|
||||
|
||||
public Boolean isStoreToken() {
|
||||
return storeToken;
|
||||
}
|
||||
|
||||
public void setStoreToken(boolean storeToken) {
|
||||
this.updated = !Objects.equals(this.storeToken, storeToken);
|
||||
this.storeToken = storeToken;
|
||||
}
|
||||
|
||||
public Boolean isLinkOnly() {
|
||||
return linkOnly;
|
||||
}
|
||||
|
||||
public void setLinkOnly(boolean linkOnly) {
|
||||
this.updated = !Objects.equals(this.linkOnly, linkOnly);
|
||||
this.linkOnly = linkOnly;
|
||||
}
|
||||
|
||||
public Boolean isAddReadTokenRoleOnCreate() {
|
||||
return addReadTokenRoleOnCreate;
|
||||
}
|
||||
|
||||
public void setAddReadTokenRoleOnCreate(boolean addReadTokenRoleOnCreate) {
|
||||
this.updated = !Objects.equals(this.addReadTokenRoleOnCreate, addReadTokenRoleOnCreate);
|
||||
this.addReadTokenRoleOnCreate = addReadTokenRoleOnCreate;
|
||||
}
|
||||
|
||||
public Boolean isAuthenticateByDefault() {
|
||||
return authenticateByDefault;
|
||||
}
|
||||
|
||||
public void setAuthenticateByDefault(boolean authenticateByDefault) {
|
||||
this.updated = !Objects.equals(this.authenticateByDefault, authenticateByDefault);
|
||||
this.authenticateByDefault = authenticateByDefault;
|
||||
}
|
||||
|
||||
public Map<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, String> config) {
|
||||
this.updated = !Objects.equals(this.config, config);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapIdentityProviderEntity)) return false;
|
||||
final MapIdentityProviderEntity other = (MapIdentityProviderEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
Map<String, String> getConfig();
|
||||
void setConfig(Map<String, String> config);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,27 +17,22 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.IdentityProviderMapperModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapIdentityProviderMapperEntity extends UpdatableEntity.Impl {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String identityProviderAlias;
|
||||
private String identityProviderMapper;
|
||||
private Map<String, String> config = new HashMap<>();
|
||||
|
||||
|
||||
private MapIdentityProviderMapperEntity() {}
|
||||
|
||||
public static MapIdentityProviderMapperEntity fromModel(IdentityProviderMapperModel model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapIdentityProviderMapperEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapIdentityProviderMapperEntity fromModel(IdentityProviderMapperModel model) {
|
||||
if (model == null) return null;
|
||||
MapIdentityProviderMapperEntity entity = new MapIdentityProviderMapperEntity();
|
||||
MapIdentityProviderMapperEntity entity = new MapIdentityProviderMapperEntityImpl();
|
||||
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||
entity.setId(id);
|
||||
entity.setName(model.getName());
|
||||
|
@ -47,7 +42,7 @@ public class MapIdentityProviderMapperEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static IdentityProviderMapperModel toModel(MapIdentityProviderMapperEntity entity) {
|
||||
static IdentityProviderMapperModel toModel(MapIdentityProviderMapperEntity entity) {
|
||||
if (entity == null) return null;
|
||||
IdentityProviderMapperModel model = new IdentityProviderMapperModel();
|
||||
model.setId(entity.getId());
|
||||
|
@ -58,61 +53,15 @@ public class MapIdentityProviderMapperEntity extends UpdatableEntity.Impl {
|
|||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
String getName();
|
||||
void setName(String name);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
String getIdentityProviderAlias();
|
||||
void setIdentityProviderAlias(String identityProviderAlias);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
String getIdentityProviderMapper();
|
||||
void setIdentityProviderMapper(String identityProviderMapper);
|
||||
|
||||
public void setName(String name) {
|
||||
this.updated = !Objects.equals(this.name, name);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIdentityProviderAlias() {
|
||||
return identityProviderAlias;
|
||||
}
|
||||
|
||||
public void setIdentityProviderAlias(String identityProviderAlias) {
|
||||
this.updated = !Objects.equals(this.identityProviderAlias, identityProviderAlias);
|
||||
this.identityProviderAlias = identityProviderAlias;
|
||||
}
|
||||
|
||||
public String getIdentityProviderMapper() {
|
||||
return identityProviderMapper;
|
||||
}
|
||||
|
||||
public void setIdentityProviderMapper(String identityProviderMapper) {
|
||||
this.updated = !Objects.equals(this.identityProviderMapper, identityProviderMapper);
|
||||
this.identityProviderMapper = identityProviderMapper;
|
||||
}
|
||||
|
||||
public Map<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, String> config) {
|
||||
this.updated = !Objects.equals(this.config, config);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapIdentityProviderMapperEntity)) return false;
|
||||
final MapIdentityProviderMapperEntity other = (MapIdentityProviderMapperEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
Map<String, String> getConfig();
|
||||
void setConfig(Map<String, String> config);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,25 +17,17 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.OTPPolicy;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
|
||||
public class MapOTPPolicyEntity extends UpdatableEntity.Impl {
|
||||
|
||||
private Integer otpPolicyInitialCounter = 0;
|
||||
private Integer otpPolicyDigits = 0;
|
||||
private Integer otpPolicyLookAheadWindow = 0;
|
||||
private Integer otpPolicyPeriod = 0;
|
||||
private String otpPolicyType;
|
||||
private String otpPolicyAlgorithm;
|
||||
|
||||
|
||||
private MapOTPPolicyEntity() {}
|
||||
|
||||
public static MapOTPPolicyEntity fromModel(OTPPolicy model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapOTPPolicyEntity extends UpdatableEntity {
|
||||
static MapOTPPolicyEntity fromModel(OTPPolicy model) {
|
||||
if (model == null) return null;
|
||||
MapOTPPolicyEntity entity = new MapOTPPolicyEntity();
|
||||
MapOTPPolicyEntity entity = new MapOTPPolicyEntityImpl();
|
||||
entity.setOtpPolicyAlgorithm(model.getAlgorithm());
|
||||
entity.setOtpPolicyDigits(model.getDigits());
|
||||
entity.setOtpPolicyInitialCounter(model.getInitialCounter());
|
||||
|
@ -45,95 +37,37 @@ public class MapOTPPolicyEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static OTPPolicy toModel(MapOTPPolicyEntity entity) {
|
||||
static OTPPolicy toModel(MapOTPPolicyEntity entity) {
|
||||
if (entity == null) return null;
|
||||
OTPPolicy model = new OTPPolicy();
|
||||
model.setDigits(entity.getOtpPolicyDigits());
|
||||
Integer otpPolicyDigits = entity.getOtpPolicyDigits();
|
||||
model.setDigits(otpPolicyDigits == null ? 0 : otpPolicyDigits);
|
||||
model.setAlgorithm(entity.getOtpPolicyAlgorithm());
|
||||
model.setInitialCounter(entity.getOtpPolicyInitialCounter());
|
||||
model.setLookAheadWindow(entity.getOtpPolicyLookAheadWindow());
|
||||
Integer otpPolicyInitialCounter = entity.getOtpPolicyInitialCounter();
|
||||
model.setInitialCounter(otpPolicyInitialCounter == null ? 0 : otpPolicyInitialCounter);
|
||||
Integer otpPolicyLookAheadWindow = entity.getOtpPolicyLookAheadWindow();
|
||||
model.setLookAheadWindow(otpPolicyLookAheadWindow == null ? 0 : otpPolicyLookAheadWindow);
|
||||
model.setType(entity.getOtpPolicyType());
|
||||
model.setPeriod(entity.getOtpPolicyPeriod());
|
||||
Integer otpPolicyPeriod = entity.getOtpPolicyPeriod();
|
||||
model.setPeriod(otpPolicyPeriod == null ? 0 : otpPolicyPeriod);
|
||||
return model;
|
||||
}
|
||||
|
||||
public Integer getOtpPolicyInitialCounter() {
|
||||
return otpPolicyInitialCounter;
|
||||
}
|
||||
Integer getOtpPolicyInitialCounter();
|
||||
void setOtpPolicyInitialCounter(Integer otpPolicyInitialCounter);
|
||||
|
||||
public void setOtpPolicyInitialCounter(int otpPolicyInitialCounter) {
|
||||
this.updated = !Objects.equals(this.otpPolicyInitialCounter, otpPolicyInitialCounter);
|
||||
this.otpPolicyInitialCounter = otpPolicyInitialCounter;
|
||||
}
|
||||
Integer getOtpPolicyDigits();
|
||||
void setOtpPolicyDigits(Integer otpPolicyDigits);
|
||||
|
||||
public Integer getOtpPolicyDigits() {
|
||||
return otpPolicyDigits;
|
||||
}
|
||||
Integer getOtpPolicyLookAheadWindow();
|
||||
void setOtpPolicyLookAheadWindow(Integer otpPolicyLookAheadWindow);
|
||||
|
||||
public void setOtpPolicyDigits(int otpPolicyDigits) {
|
||||
this.updated = !Objects.equals(this.otpPolicyDigits, otpPolicyDigits);
|
||||
this.otpPolicyDigits = otpPolicyDigits;
|
||||
}
|
||||
Integer getOtpPolicyPeriod();
|
||||
void setOtpPolicyPeriod(Integer otpPolicyPeriod);
|
||||
|
||||
public Integer getOtpPolicyLookAheadWindow() {
|
||||
return otpPolicyLookAheadWindow;
|
||||
}
|
||||
String getOtpPolicyType();
|
||||
void setOtpPolicyType(String otpPolicyType);
|
||||
|
||||
public void setOtpPolicyLookAheadWindow(int otpPolicyLookAheadWindow) {
|
||||
this.updated = !Objects.equals(this.otpPolicyLookAheadWindow, otpPolicyLookAheadWindow);
|
||||
this.otpPolicyLookAheadWindow = otpPolicyLookAheadWindow;
|
||||
}
|
||||
|
||||
public Integer getOtpPolicyPeriod() {
|
||||
return otpPolicyPeriod;
|
||||
}
|
||||
|
||||
public void setOtpPolicyPeriod(int otpPolicyPeriod) {
|
||||
this.updated = !Objects.equals(this.otpPolicyPeriod, otpPolicyPeriod);
|
||||
this.otpPolicyPeriod = otpPolicyPeriod;
|
||||
}
|
||||
|
||||
public String getOtpPolicyType() {
|
||||
return otpPolicyType;
|
||||
}
|
||||
|
||||
public void setOtpPolicyType(String otpPolicyType) {
|
||||
this.updated = !Objects.equals(this.otpPolicyType, otpPolicyType);
|
||||
this.otpPolicyType = otpPolicyType;
|
||||
}
|
||||
|
||||
public String getOtpPolicyAlgorithm() {
|
||||
return otpPolicyAlgorithm;
|
||||
}
|
||||
|
||||
public void setOtpPolicyAlgorithm(String otpPolicyAlgorithm) {
|
||||
this.updated = !Objects.equals(this.otpPolicyAlgorithm, otpPolicyAlgorithm);
|
||||
this.otpPolicyAlgorithm = otpPolicyAlgorithm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 59 * hash + this.otpPolicyInitialCounter;
|
||||
hash = 59 * hash + this.otpPolicyDigits;
|
||||
hash = 59 * hash + this.otpPolicyLookAheadWindow;
|
||||
hash = 59 * hash + this.otpPolicyPeriod;
|
||||
hash = 59 * hash + Objects.hashCode(this.otpPolicyType);
|
||||
hash = 59 * hash + Objects.hashCode(this.otpPolicyAlgorithm);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapOTPPolicyEntity)) return false;
|
||||
final MapOTPPolicyEntity other = (MapOTPPolicyEntity) obj;
|
||||
return Objects.equals(other.getOtpPolicyAlgorithm(), getOtpPolicyAlgorithm()) &&
|
||||
Objects.equals(other.getOtpPolicyDigits(), getOtpPolicyDigits()) &&
|
||||
Objects.equals(other.getOtpPolicyInitialCounter(), getOtpPolicyInitialCounter()) &&
|
||||
Objects.equals(other.getOtpPolicyLookAheadWindow(), getOtpPolicyLookAheadWindow()) &&
|
||||
Objects.equals(other.getOtpPolicyPeriod(), getOtpPolicyPeriod()) &&
|
||||
Objects.equals(other.getOtpPolicyType(), getOtpPolicyType());
|
||||
}
|
||||
|
||||
String getOtpPolicyAlgorithm();
|
||||
void setOtpPolicyAlgorithm(String otpPolicyAlgorithm);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,30 +17,22 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.RequiredActionProviderModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.AbstractEntity;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
|
||||
public class MapRequiredActionProviderEntity extends UpdatableEntity.Impl {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
private String id;
|
||||
private String alias;
|
||||
private String name;
|
||||
private String providerId;
|
||||
private Integer priority = 0;
|
||||
private Boolean enabled = false;
|
||||
private Boolean defaultAction = false;
|
||||
private Map<String, String> config = new HashMap<>();
|
||||
|
||||
|
||||
private MapRequiredActionProviderEntity() {}
|
||||
|
||||
public static MapRequiredActionProviderEntity fromModel(RequiredActionProviderModel model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapRequiredActionProviderEntity extends UpdatableEntity, AbstractEntity {
|
||||
static MapRequiredActionProviderEntity fromModel(RequiredActionProviderModel model) {
|
||||
if (model == null) return null;
|
||||
MapRequiredActionProviderEntity entity = new MapRequiredActionProviderEntity();
|
||||
MapRequiredActionProviderEntity entity = new MapRequiredActionProviderEntityImpl();
|
||||
String id = model.getId() == null ? KeycloakModelUtils.generateId() : model.getId();
|
||||
entity.setId(id);
|
||||
entity.setAlias(model.getAlias());
|
||||
|
@ -49,106 +41,45 @@ public class MapRequiredActionProviderEntity extends UpdatableEntity.Impl {
|
|||
entity.setPriority(model.getPriority());
|
||||
entity.setEnabled(model.isEnabled());
|
||||
entity.setDefaultAction(model.isDefaultAction());
|
||||
entity.setConfig(model.getConfig() == null ? null : new HashMap<>(model.getConfig()));
|
||||
entity.setConfig(model.getConfig());
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static RequiredActionProviderModel toModel(MapRequiredActionProviderEntity entity) {
|
||||
static RequiredActionProviderModel toModel(MapRequiredActionProviderEntity entity) {
|
||||
if (entity == null) return null;
|
||||
RequiredActionProviderModel model = new RequiredActionProviderModel();
|
||||
model.setId(entity.getId());
|
||||
model.setAlias(entity.getAlias());
|
||||
model.setName(entity.getName());
|
||||
model.setProviderId(entity.getProviderId());
|
||||
model.setPriority(entity.getPriority());
|
||||
model.setEnabled(entity.isEnabled());
|
||||
model.setDefaultAction(entity.isDefaultAction());
|
||||
model.setConfig(entity.getConfig() == null ? null : new HashMap<>(entity.getConfig()));
|
||||
Integer priority = entity.getPriority();
|
||||
model.setPriority(priority == null ? 0 : priority);
|
||||
Boolean enabled = entity.isEnabled();
|
||||
model.setEnabled(enabled == null ? false : enabled);
|
||||
Boolean defaultAction = entity.isDefaultAction();
|
||||
model.setDefaultAction(defaultAction == null ? false : defaultAction);
|
||||
model.setConfig(entity.getConfig());
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
String getAlias();
|
||||
void setAlias(String alias);
|
||||
|
||||
public void setId(String id) {
|
||||
this.updated = !Objects.equals(this.id, id);
|
||||
this.id = id;
|
||||
}
|
||||
String getName();
|
||||
void setName(String name);
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
String getProviderId();
|
||||
void setProviderId(String providerId);
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.updated = !Objects.equals(this.alias, alias);
|
||||
this.alias = alias;
|
||||
}
|
||||
Integer getPriority();
|
||||
void setPriority(Integer priority);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
Boolean isEnabled();
|
||||
void setEnabled(Boolean enabled);
|
||||
|
||||
public void setName(String name) {
|
||||
this.updated = !Objects.equals(this.name, name);
|
||||
this.name = name;
|
||||
}
|
||||
Boolean isDefaultAction();
|
||||
void setDefaultAction(Boolean defaultAction);
|
||||
|
||||
public String getProviderId() {
|
||||
return providerId;
|
||||
}
|
||||
|
||||
public void setProviderId(String providerId) {
|
||||
this.updated = !Objects.equals(this.providerId, providerId);
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.updated = !Objects.equals(this.priority, priority);
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public Boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.updated = !Objects.equals(this.enabled, enabled);
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean isDefaultAction() {
|
||||
return defaultAction;
|
||||
}
|
||||
|
||||
public void setDefaultAction(boolean defaultAction) {
|
||||
this.updated = !Objects.equals(this.defaultAction, defaultAction);
|
||||
this.defaultAction = defaultAction;
|
||||
}
|
||||
|
||||
public Map<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, String> config) {
|
||||
this.updated = !Objects.equals(this.config, config);
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapRequiredActionProviderEntity)) return false;
|
||||
final MapRequiredActionProviderEntity other = (MapRequiredActionProviderEntity) obj;
|
||||
return Objects.equals(other.getId(), getId());
|
||||
}
|
||||
Map<String, String> getConfig();
|
||||
void setConfig(Map<String, String> config);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,23 +17,17 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.RequiredCredentialModel;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
|
||||
public class MapRequiredCredentialEntity extends UpdatableEntity.Impl {
|
||||
|
||||
private String type;
|
||||
private String formLabel;
|
||||
private Boolean input = false;
|
||||
private Boolean secret = false;
|
||||
|
||||
|
||||
private MapRequiredCredentialEntity() {}
|
||||
|
||||
public static MapRequiredCredentialEntity fromModel(RequiredCredentialModel model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapRequiredCredentialEntity extends UpdatableEntity {
|
||||
static MapRequiredCredentialEntity fromModel(RequiredCredentialModel model) {
|
||||
if (model == null) return null;
|
||||
MapRequiredCredentialEntity entity = new MapRequiredCredentialEntity();
|
||||
MapRequiredCredentialEntity entity = new MapRequiredCredentialEntityImpl();
|
||||
entity.setFormLabel(model.getFormLabel());
|
||||
entity.setType(model.getType());
|
||||
entity.setInput(model.isInput());
|
||||
|
@ -41,62 +35,27 @@ public class MapRequiredCredentialEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static RequiredCredentialModel toModel(MapRequiredCredentialEntity entity) {
|
||||
static RequiredCredentialModel toModel(MapRequiredCredentialEntity entity) {
|
||||
if (entity == null) return null;
|
||||
RequiredCredentialModel model = new RequiredCredentialModel();
|
||||
model.setFormLabel(entity.getFormLabel());
|
||||
model.setType(entity.getType());
|
||||
model.setSecret(entity.isSecret());
|
||||
model.setInput(entity.isInput());
|
||||
Boolean secret = entity.isSecret();
|
||||
model.setSecret(secret == null ? false : secret);
|
||||
Boolean input = entity.isInput();
|
||||
model.setInput(input == null ? false : input);
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
String getType();
|
||||
void setType(String type);
|
||||
|
||||
public void setType(String type) {
|
||||
this.updated = !Objects.equals(this.type, type);
|
||||
this.type = type;
|
||||
}
|
||||
String getFormLabel();
|
||||
void setFormLabel(String formLabel);
|
||||
|
||||
public String getFormLabel() {
|
||||
return formLabel;
|
||||
}
|
||||
Boolean isSecret();
|
||||
void setSecret(Boolean secret);
|
||||
|
||||
public void setFormLabel(String formLabel) {
|
||||
this.updated = !Objects.equals(this.formLabel, formLabel);
|
||||
this.formLabel = formLabel;
|
||||
}
|
||||
|
||||
public Boolean isSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(boolean secret) {
|
||||
this.updated = !Objects.equals(this.formLabel, formLabel);
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public Boolean isInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public void setInput(boolean input) {
|
||||
this.updated = !Objects.equals(this.input, input);
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getType().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapRequiredCredentialEntity)) return false;
|
||||
final MapRequiredCredentialEntity other = (MapRequiredCredentialEntity) obj;
|
||||
return Objects.equals(other.getType(), getType());
|
||||
}
|
||||
Boolean isInput();
|
||||
void setInput(Boolean input);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* Copyright 2022 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -17,36 +17,22 @@
|
|||
|
||||
package org.keycloak.models.map.realm.entity;
|
||||
|
||||
import org.keycloak.models.Constants;
|
||||
import org.keycloak.models.WebAuthnPolicy;
|
||||
import org.keycloak.models.map.annotations.GenerateEntityImplementations;
|
||||
import org.keycloak.models.map.common.DeepCloner;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.keycloak.models.Constants;
|
||||
import org.keycloak.models.WebAuthnPolicy;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
|
||||
public class MapWebAuthnPolicyEntity extends UpdatableEntity.Impl {
|
||||
|
||||
// mandatory
|
||||
private String rpEntityName;
|
||||
private List<String> signatureAlgorithms = new LinkedList<>();
|
||||
|
||||
// optional
|
||||
private String rpId;
|
||||
private String attestationConveyancePreference;
|
||||
private String authenticatorAttachment;
|
||||
private String requireResidentKey;
|
||||
private String userVerificationRequirement;
|
||||
private Integer createTimeout = 0;
|
||||
private Boolean avoidSameAuthenticatorRegister = false;
|
||||
private List<String> acceptableAaguids = new LinkedList<>();
|
||||
|
||||
|
||||
private MapWebAuthnPolicyEntity() {}
|
||||
|
||||
public static MapWebAuthnPolicyEntity fromModel(WebAuthnPolicy model) {
|
||||
@GenerateEntityImplementations
|
||||
@DeepCloner.Root
|
||||
public interface MapWebAuthnPolicyEntity extends UpdatableEntity {
|
||||
static MapWebAuthnPolicyEntity fromModel(WebAuthnPolicy model) {
|
||||
if (model == null) return null;
|
||||
MapWebAuthnPolicyEntity entity = new MapWebAuthnPolicyEntity();
|
||||
MapWebAuthnPolicyEntity entity = new MapWebAuthnPolicyEntityImpl();
|
||||
entity.setRpEntityName(model.getRpEntityName());
|
||||
entity.setSignatureAlgorithms(model.getSignatureAlgorithm());
|
||||
entity.setRpId(model.getRpId());
|
||||
|
@ -60,7 +46,7 @@ public class MapWebAuthnPolicyEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public static WebAuthnPolicy toModel(MapWebAuthnPolicyEntity entity) {
|
||||
static WebAuthnPolicy toModel(MapWebAuthnPolicyEntity entity) {
|
||||
if (entity == null) return null;
|
||||
WebAuthnPolicy model = new WebAuthnPolicy();
|
||||
model.setRpEntityName(entity.getRpEntityName());
|
||||
|
@ -76,8 +62,8 @@ public class MapWebAuthnPolicyEntity extends UpdatableEntity.Impl {
|
|||
return model;
|
||||
}
|
||||
|
||||
public static MapWebAuthnPolicyEntity defaultWebAuthnPolicy() {
|
||||
MapWebAuthnPolicyEntity entity = new MapWebAuthnPolicyEntity();
|
||||
static MapWebAuthnPolicyEntity defaultWebAuthnPolicy() {
|
||||
MapWebAuthnPolicyEntity entity = new MapWebAuthnPolicyEntityImpl();
|
||||
entity.setRpEntityName(Constants.DEFAULT_WEBAUTHN_POLICY_RP_ENTITY_NAME);
|
||||
entity.setSignatureAlgorithms(Arrays.asList(Constants.DEFAULT_WEBAUTHN_POLICY_SIGNATURE_ALGORITHMS.split(",")));
|
||||
entity.setRpId("");
|
||||
|
@ -91,106 +77,33 @@ public class MapWebAuthnPolicyEntity extends UpdatableEntity.Impl {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public String getRpEntityName() {
|
||||
return rpEntityName;
|
||||
}
|
||||
String getRpEntityName();
|
||||
void setRpEntityName(String rpEntityName);
|
||||
|
||||
public void setRpEntityName(String rpEntityName) {
|
||||
this.updated = !Objects.equals(this.rpEntityName, rpEntityName);
|
||||
this.rpEntityName = rpEntityName;
|
||||
}
|
||||
List<String> getSignatureAlgorithms();
|
||||
void setSignatureAlgorithms(List<String> signatureAlgorithms);
|
||||
|
||||
public List<String> getSignatureAlgorithms() {
|
||||
return signatureAlgorithms;
|
||||
}
|
||||
String getRpId();
|
||||
void setRpId(String rpId);
|
||||
|
||||
public void setSignatureAlgorithms(List<String> signatureAlgorithms) {
|
||||
this.updated = !Objects.equals(this.signatureAlgorithms, signatureAlgorithms);
|
||||
this.signatureAlgorithms = signatureAlgorithms;
|
||||
}
|
||||
String getAttestationConveyancePreference();
|
||||
void setAttestationConveyancePreference(String attestationConveyancePreference);
|
||||
|
||||
public String getRpId() {
|
||||
return rpId;
|
||||
}
|
||||
String getAuthenticatorAttachment();
|
||||
void setAuthenticatorAttachment(String authenticatorAttachment);
|
||||
|
||||
public void setRpId(String rpId) {
|
||||
this.updated = !Objects.equals(this.rpId, rpId);
|
||||
this.rpId = rpId;
|
||||
}
|
||||
String getRequireResidentKey();
|
||||
void setRequireResidentKey(String requireResidentKey);
|
||||
|
||||
public String getAttestationConveyancePreference() {
|
||||
return attestationConveyancePreference;
|
||||
}
|
||||
String getUserVerificationRequirement();
|
||||
void setUserVerificationRequirement(String userVerificationRequirement);
|
||||
|
||||
public void setAttestationConveyancePreference(String attestationConveyancePreference) {
|
||||
this.updated = !Objects.equals(this.attestationConveyancePreference, attestationConveyancePreference);
|
||||
this.attestationConveyancePreference = attestationConveyancePreference;
|
||||
}
|
||||
Integer getCreateTimeout();
|
||||
void setCreateTimeout(Integer createTimeout);
|
||||
|
||||
public String getAuthenticatorAttachment() {
|
||||
return authenticatorAttachment;
|
||||
}
|
||||
Boolean isAvoidSameAuthenticatorRegister();
|
||||
void setAvoidSameAuthenticatorRegister(Boolean avoidSameAuthenticatorRegister);
|
||||
|
||||
public void setAuthenticatorAttachment(String authenticatorAttachment) {
|
||||
this.updated = !Objects.equals(this.authenticatorAttachment, authenticatorAttachment);
|
||||
this.authenticatorAttachment = authenticatorAttachment;
|
||||
}
|
||||
|
||||
public String getRequireResidentKey() {
|
||||
return requireResidentKey;
|
||||
}
|
||||
|
||||
public void setRequireResidentKey(String requireResidentKey) {
|
||||
this.updated = !Objects.equals(this.requireResidentKey, requireResidentKey);
|
||||
this.requireResidentKey = requireResidentKey;
|
||||
}
|
||||
|
||||
public String getUserVerificationRequirement() {
|
||||
return userVerificationRequirement;
|
||||
}
|
||||
|
||||
public void setUserVerificationRequirement(String userVerificationRequirement) {
|
||||
this.updated = !Objects.equals(this.userVerificationRequirement, userVerificationRequirement);
|
||||
this.userVerificationRequirement = userVerificationRequirement;
|
||||
}
|
||||
|
||||
public Integer getCreateTimeout() {
|
||||
return createTimeout;
|
||||
}
|
||||
|
||||
public void setCreateTimeout(int createTimeout) {
|
||||
this.updated = !Objects.equals(this.createTimeout, createTimeout);
|
||||
this.createTimeout = createTimeout;
|
||||
}
|
||||
|
||||
public Boolean isAvoidSameAuthenticatorRegister() {
|
||||
return avoidSameAuthenticatorRegister;
|
||||
}
|
||||
|
||||
public void setAvoidSameAuthenticatorRegister(boolean avoidSameAuthenticatorRegister) {
|
||||
this.updated = !Objects.equals(this.avoidSameAuthenticatorRegister, avoidSameAuthenticatorRegister);
|
||||
this.avoidSameAuthenticatorRegister = avoidSameAuthenticatorRegister;
|
||||
}
|
||||
|
||||
public List<String> getAcceptableAaguids() {
|
||||
return acceptableAaguids;
|
||||
}
|
||||
|
||||
public void setAcceptableAaguids(List<String> acceptableAaguids) {
|
||||
this.updated = !Objects.equals(this.acceptableAaguids, acceptableAaguids);
|
||||
this.acceptableAaguids = acceptableAaguids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getRpEntityName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof MapWebAuthnPolicyEntity)) return false;
|
||||
final MapWebAuthnPolicyEntity other = (MapWebAuthnPolicyEntity) obj;
|
||||
return Objects.equals(other.getRpEntityName(), getRpEntityName());
|
||||
}
|
||||
List<String> getAcceptableAaguids();
|
||||
void setAcceptableAaguids(List<String> acceptableAaguids);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@ import org.keycloak.models.map.common.DeepCloner;
|
|||
import org.keycloak.models.map.common.Serialization;
|
||||
import org.keycloak.models.map.common.UpdatableEntity;
|
||||
import org.keycloak.models.map.group.MapGroupEntityImpl;
|
||||
import org.keycloak.models.map.realm.MapRealmEntity;
|
||||
import org.keycloak.models.map.realm.MapRealmEntityImpl;
|
||||
import org.keycloak.models.map.realm.entity.*;
|
||||
import org.keycloak.models.map.role.MapRoleEntityImpl;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import java.io.File;
|
||||
|
@ -107,6 +110,18 @@ public class ConcurrentHashMapStorageProviderFactory implements AmphibianProvide
|
|||
.constructor(MapScopeEntity.class, MapScopeEntityImpl::new)
|
||||
.constructor(MapPolicyEntity.class, MapPolicyEntityImpl::new)
|
||||
.constructor(MapPermissionTicketEntity.class, MapPermissionTicketEntityImpl::new)
|
||||
.constructor(MapRealmEntity.class, MapRealmEntityImpl::new)
|
||||
.constructor(MapAuthenticationExecutionEntity.class, MapAuthenticationExecutionEntityImpl::new)
|
||||
.constructor(MapAuthenticationFlowEntity.class, MapAuthenticationFlowEntityImpl::new)
|
||||
.constructor(MapAuthenticatorConfigEntity.class, MapAuthenticatorConfigEntityImpl::new)
|
||||
.constructor(MapClientInitialAccessEntity.class, MapClientInitialAccessEntityImpl::new)
|
||||
.constructor(MapComponentEntity.class, MapComponentEntityImpl::new)
|
||||
.constructor(MapIdentityProviderEntity.class, MapIdentityProviderEntityImpl::new)
|
||||
.constructor(MapIdentityProviderMapperEntity.class, MapIdentityProviderMapperEntityImpl::new)
|
||||
.constructor(MapOTPPolicyEntity.class, MapOTPPolicyEntityImpl::new)
|
||||
.constructor(MapRequiredActionProviderEntity.class, MapRequiredActionProviderEntityImpl::new)
|
||||
.constructor(MapRequiredCredentialEntity.class, MapRequiredCredentialEntityImpl::new)
|
||||
.constructor(MapWebAuthnPolicyEntity.class, MapWebAuthnPolicyEntityImpl::new)
|
||||
.build();
|
||||
|
||||
private static final Map<String, StringKeyConvertor> KEY_CONVERTORS = new HashMap<>();
|
||||
|
|
|
@ -485,7 +485,7 @@ public class MapFieldPredicates {
|
|||
|
||||
private static MapModelCriteriaBuilder<Object, MapRealmEntity, RealmModel> checkRealmsWithComponentType(MapModelCriteriaBuilder<Object, MapRealmEntity, RealmModel> mcb, Operator op, Object[] values) {
|
||||
String providerType = ensureEqSingleValue(RealmModel.SearchableFields.COMPONENT_PROVIDER_TYPE, "component_provider_type", op, values);
|
||||
Function<MapRealmEntity, ?> getter = realmEntity -> realmEntity.getComponents().anyMatch(component -> component.getProviderType().equals(providerType));
|
||||
Function<MapRealmEntity, ?> getter = realmEntity -> Optional.ofNullable(realmEntity.getComponents()).orElseGet(Collections::emptySet).stream().anyMatch(component -> component.getProviderType().equals(providerType));
|
||||
return mcb.fieldCompare(Boolean.TRUE::equals, getter);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ public class FlowOverrideTest extends AbstractTestRealmKeycloakTest {
|
|||
challengeOTP.setTopLevel(true);
|
||||
challengeOTP.setBuiltIn(true);
|
||||
|
||||
realm.addAuthenticationFlow(challengeOTP);
|
||||
challengeOTP = realm.addAuthenticationFlow(challengeOTP);
|
||||
|
||||
execution = new AuthenticationExecutionModel();
|
||||
execution.setParentFlow(challengeOTP.getId());
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright 2021 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.keycloak.testsuite.model;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.keycloak.models.Constants;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.RealmProvider;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.aMapWithSize;
|
||||
import static org.hamcrest.Matchers.anEmptyMap;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasEntry;
|
||||
|
||||
@RequireProvider(RealmProvider.class)
|
||||
public class RealmModelTest extends KeycloakModelTest {
|
||||
|
||||
private String realmId;
|
||||
|
||||
@Override
|
||||
public void createEnvironment(KeycloakSession s) {
|
||||
RealmModel realm = s.realms().createRealm("realm");
|
||||
realm.setDefaultRole(s.roles().addRealmRole(realm, Constants.DEFAULT_ROLES_ROLE_PREFIX + "-" + realm.getName()));
|
||||
this.realmId = realm.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanEnvironment(KeycloakSession s) {
|
||||
s.realms().removeRealm(realmId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRealmLocalizationTexts() {
|
||||
withRealm(realmId, (session, realm) -> {
|
||||
// Assert emptyMap
|
||||
assertThat(realm.getRealmLocalizationTexts(), anEmptyMap());
|
||||
// Add a localization test
|
||||
session.realms().saveLocalizationText(realm, "en", "key-a", "text-a_en");
|
||||
return null;
|
||||
});
|
||||
|
||||
withRealm(realmId, (session, realm) -> {
|
||||
// Assert the map contains the added value
|
||||
assertThat(realm.getRealmLocalizationTexts(), aMapWithSize(1));
|
||||
assertThat(realm.getRealmLocalizationTexts(),
|
||||
hasEntry(equalTo("en"), allOf(aMapWithSize(1),
|
||||
hasEntry(equalTo("key-a"), equalTo("text-a_en")))));
|
||||
|
||||
// Add another localization text to previous locale
|
||||
session.realms().saveLocalizationText(realm, "en", "key-b", "text-b_en");
|
||||
return null;
|
||||
});
|
||||
|
||||
withRealm(realmId, (session, realm) -> {
|
||||
assertThat(realm.getRealmLocalizationTexts(), aMapWithSize(1));
|
||||
assertThat(realm.getRealmLocalizationTexts(),
|
||||
hasEntry(equalTo("en"), allOf(aMapWithSize(2),
|
||||
hasEntry(equalTo("key-a"), equalTo("text-a_en")),
|
||||
hasEntry(equalTo("key-b"), equalTo("text-b_en")))));
|
||||
|
||||
// Add new locale
|
||||
session.realms().saveLocalizationText(realm, "de", "key-a", "text-a_de");
|
||||
return null;
|
||||
});
|
||||
|
||||
withRealm(realmId, (session, realm) -> {
|
||||
// Check everything created successfully
|
||||
assertThat(realm.getRealmLocalizationTexts(), aMapWithSize(2));
|
||||
assertThat(realm.getRealmLocalizationTexts(),
|
||||
hasEntry(equalTo("en"), allOf(aMapWithSize(2),
|
||||
hasEntry(equalTo("key-a"), equalTo("text-a_en")),
|
||||
hasEntry(equalTo("key-b"), equalTo("text-b_en")))));
|
||||
assertThat(realm.getRealmLocalizationTexts(),
|
||||
hasEntry(equalTo("de"), allOf(aMapWithSize(1),
|
||||
hasEntry(equalTo("key-a"), equalTo("text-a_de")))));
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue