public CachedClientTemplate(RealmCache cache, RealmProvider delegate, RealmModel realm, ClientTemplateModel model) { id = model.getId(); name = model.getName(); description = model.getDescription(); this.realm = realm.getId(); protocol = model.getProtocol(); fullScopeAllowed = model.isFullScopeAllowed(); for (ProtocolMapperModel mapper : model.getProtocolMappers()) { this.protocolMappers.add(mapper); } for (RoleModel role : model.getScopeMappings()) { scope.add(role.getId()); } attributes.putAll(model.getAttributes()); frontchannelLogout = model.isFrontchannelLogout(); publicClient = model.isPublicClient(); bearerOnly = model.isBearerOnly(); consentRequired = model.isConsentRequired(); standardFlowEnabled = model.isStandardFlowEnabled(); implicitFlowEnabled = model.isImplicitFlowEnabled(); directAccessGrantsEnabled = model.isDirectAccessGrantsEnabled(); serviceAccountsEnabled = model.isServiceAccountsEnabled(); } public String getId() {
@Override public ProtocolMapperModel addProtocolMapper(ProtocolMapperModel model) { getDelegateForUpdate(); return updated.addProtocolMapper(model); }
public static ClientTemplateRepresentation toRepresentation(ClientTemplateModel clientModel) { ClientTemplateRepresentation rep = new ClientTemplateRepresentation(); rep.setId(clientModel.getId()); rep.setName(clientModel.getName()); rep.setDescription(clientModel.getDescription()); rep.setProtocol(clientModel.getProtocol()); if (!clientModel.getProtocolMappers().isEmpty()) { List<ProtocolMapperRepresentation> mappings = new LinkedList<>(); for (ProtocolMapperModel model : clientModel.getProtocolMappers()) { mappings.add(toRepresentation(model)); } rep.setProtocolMappers(mappings); } rep.setFullScopeAllowed(clientModel.isFullScopeAllowed()); return rep; }
public static ClientTemplateModel createClientTemplate(KeycloakSession session, RealmModel realm, ClientTemplateRepresentation resourceRep) { logger.debug("Create client template: {0}" + resourceRep.getName()); ClientTemplateModel client = resourceRep.getId()!=null ? realm.addClientTemplate(resourceRep.getId(), resourceRep.getName()) : realm.addClientTemplate(resourceRep.getName()); if (resourceRep.getName() != null) client.setName(resourceRep.getName()); if(resourceRep.getDescription() != null) client.setDescription(resourceRep.getDescription()); if (resourceRep.getProtocol() != null) client.setProtocol(resourceRep.getProtocol()); if (resourceRep.isFullScopeAllowed() != null) client.setFullScopeAllowed(resourceRep.isFullScopeAllowed()); if (resourceRep.getProtocolMappers() != null) { // first, remove all default/built in mappers Set<ProtocolMapperModel> mappers = client.getProtocolMappers(); for (ProtocolMapperModel mapper : mappers) client.removeProtocolMapper(mapper); for (ProtocolMapperRepresentation mapper : resourceRep.getProtocolMappers()) { client.addProtocolMapper(toModel(mapper)); } } if (resourceRep.isBearerOnly() != null) client.setBearerOnly(resourceRep.isBearerOnly()); if (resourceRep.isConsentRequired() != null) client.setConsentRequired(resourceRep.isConsentRequired()); if (resourceRep.isStandardFlowEnabled() != null) client.setStandardFlowEnabled(resourceRep.isStandardFlowEnabled()); if (resourceRep.isImplicitFlowEnabled() != null) client.setImplicitFlowEnabled(resourceRep.isImplicitFlowEnabled()); if (resourceRep.isDirectAccessGrantsEnabled() != null) client.setDirectAccessGrantsEnabled(resourceRep.isDirectAccessGrantsEnabled()); if (resourceRep.isServiceAccountsEnabled() != null) client.setServiceAccountsEnabled(resourceRep.isServiceAccountsEnabled()); if (resourceRep.isPublicClient() != null) client.setPublicClient(resourceRep.isPublicClient()); if (resourceRep.isFrontchannelLogout() != null) client.setFrontchannelLogout(resourceRep.isFrontchannelLogout()); if (resourceRep.getAttributes() != null) { for (Map.Entry<String, String> entry : resourceRep.getAttributes().entrySet()) { client.setAttribute(entry.getKey(), entry.getValue()); } } return client; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ClientModel)) return false; ClientTemplateModel that = (ClientTemplateModel) o; return that.getId().equals(getId()); }
if (template.getName().equals(resourceRep.getClientTemplate())) { client.setClientTemplate(template); break; } else { if (client.getClientTemplate() != null) { client.setFullScopeAllowed(!client.isConsentRequired() && client.getClientTemplate().isFullScopeAllowed());
@Override public String getName() { if (updated != null) return updated.getName(); return cached.getName(); }
@Override public boolean isServiceAccountsEnabled() { if (updated != null) return updated.isServiceAccountsEnabled(); return cached.isServiceAccountsEnabled(); }
@Override public boolean isConsentRequired() { if (updated != null) return updated.isConsentRequired(); return cached.isConsentRequired(); }
@Override public boolean isStandardFlowEnabled() { if (updated != null) return updated.isStandardFlowEnabled(); return cached.isStandardFlowEnabled(); }
@Override public String getDescription() { if (updated != null) return updated.getDescription(); return cached.getDescription(); }
@Override public String getProtocol() { if (updated != null) return updated.getProtocol(); return cached.getProtocol(); }
@Override public Set<ProtocolMapperModel> getProtocolMappers() { if (updated != null) return updated.getProtocolMappers(); return cached.getProtocolMappers(); }
@Override public boolean isFullScopeAllowed() { if (updated != null) return updated.isFullScopeAllowed(); return cached.isFullScopeAllowed(); }
@Override public String getId() { if (updated != null) return updated.getId(); return cached.getId(); }
private static Map<String, ClientTemplateModel> createClientTemplates(KeycloakSession session, RealmRepresentation rep, RealmModel realm) { Map<String, ClientTemplateModel> appMap = new HashMap<>(); for (ClientTemplateRepresentation resourceRep : rep.getClientTemplates()) { ClientTemplateModel app = createClientTemplate(session, realm, resourceRep); appMap.put(app.getName(), app); } return appMap; }
boolean isServiceAccountsEnabled() { if (clientTemplate != null && client.useTemplateConfig()) { return clientTemplate.isServiceAccountsEnabled(); } return client.isServiceAccountsEnabled(); } }
boolean isConsentRequired() { if (clientTemplate != null && client.useTemplateConfig()) { return clientTemplate.isConsentRequired(); } return client.isConsentRequired(); }
boolean isStandardFlowEnabled() { if (clientTemplate != null && client.useTemplateConfig()) { return clientTemplate.isStandardFlowEnabled(); } return client.isStandardFlowEnabled(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ClientTemplateModel)) return false; ClientTemplateModel that = (ClientTemplateModel) o; return that.getId().equals(getId()); }