Skip to content

Commit

Permalink
client config refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
patriot1burke committed Dec 22, 2015
1 parent ea63741 commit dbac147
Show file tree
Hide file tree
Showing 17 changed files with 769 additions and 132 deletions.
Expand Up @@ -18,6 +18,39 @@
<column name="FULL_SCOPE_ALLOWED" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="CONSENT_REQUIRED" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="STANDARD_FLOW_ENABLED" type="BOOLEAN" defaultValueBoolean="true">
<constraints nullable="false"/>
</column>
<column name="IMPLICIT_FLOW_ENABLED" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="DIRECT_ACCESS_GRANTS_ENABLED" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="SERVICE_ACCOUNTS_ENABLED" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="FRONTCHANNEL_LOGOUT" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="BEARER_ONLY" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="PUBLIC_CLIENT" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
</createTable>
<createTable tableName="CLIENT_TEMPLATE_ATTRIBUTES">
<column name="TEMPLATE_ID" type="VARCHAR(36)">
<constraints nullable="false"/>
</column>
<column name="VALUE" type="VARCHAR(2048)"/>
<column name="NAME" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
</createTable>
<createTable tableName="TEMPLATE_SCOPE_MAPPING">
<column name="TEMPLATE_ID" type="VARCHAR(36)">
Expand Down Expand Up @@ -69,6 +102,8 @@
<addPrimaryKey columnNames="TEMPLATE_ID, ROLE_ID" constraintName="PK_TEMPLATE_SCOPE" tableName="TEMPLATE_SCOPE_MAPPING"/>
<addForeignKeyConstraint baseColumnNames="TEMPLATE_ID" baseTableName="TEMPLATE_SCOPE_MAPPING" constraintName="FK_TEMPL_SCOPE_TEMPL" referencedColumnNames="ID" referencedTableName="CLIENT_TEMPLATE"/>
<addForeignKeyConstraint baseColumnNames="ROLE_ID" baseTableName="TEMPLATE_SCOPE_MAPPING" constraintName="FK_TEMPL_SCOPE_ROLE" referencedColumnNames="ID" referencedTableName="KEYCLOAK_ROLE"/>
<addPrimaryKey columnNames="TEMPLATE_ID, NAME" constraintName="PK_CL_TMPL_ATTR" tableName="CLIENT_TEMPLATE_ATTRIBUTES"/>
<addForeignKeyConstraint baseColumnNames="TEMPLATE_ID" baseTableName="CLIENT_TEMPLATE_ATTRIBUTES" constraintName="FK_CL_TEMPL_ATTR_TEMPL" referencedColumnNames="ID" referencedTableName="CLIENT_TEMPLATE"/>


</changeSet>
Expand Down
Expand Up @@ -23,5 +23,35 @@ public interface ClientTemplateModel extends ProtocolMapperContainerModel, Scope
String getProtocol();
void setProtocol(String protocol);

void setAttribute(String name, String value);
void removeAttribute(String name);
String getAttribute(String name);
Map<String, String> getAttributes();

boolean isFrontchannelLogout();
void setFrontchannelLogout(boolean flag);

boolean isBearerOnly();
void setBearerOnly(boolean only);

boolean isPublicClient();
void setPublicClient(boolean flag);

boolean isConsentRequired();
void setConsentRequired(boolean consentRequired);

boolean isStandardFlowEnabled();
void setStandardFlowEnabled(boolean standardFlowEnabled);

boolean isImplicitFlowEnabled();
void setImplicitFlowEnabled(boolean implicitFlowEnabled);

boolean isDirectAccessGrantsEnabled();
void setDirectAccessGrantsEnabled(boolean directAccessGrantsEnabled);

boolean isServiceAccountsEnabled();
void setServiceAccountsEnabled(boolean serviceAccountsEnabled);



}
Expand Up @@ -15,8 +15,17 @@ public class ClientTemplateEntity extends AbstractIdentifiableEntity {
private String realmId;
private String protocol;
private boolean fullScopeAllowed;
private List<String> scopeIds = new ArrayList<String>();
private List<ProtocolMapperEntity> protocolMappers = new ArrayList<ProtocolMapperEntity>();
private boolean bearerOnly;
private boolean consentRequired;
private boolean standardFlowEnabled;
private boolean implicitFlowEnabled;
private boolean directAccessGrantsEnabled;
private boolean serviceAccountsEnabled;
private boolean publicClient;
private boolean frontchannelLogout;
private List<String> scopeIds = new ArrayList<>();
private List<ProtocolMapperEntity> protocolMappers = new ArrayList<>();
private Map<String, String> attributes = new HashMap<>();

public String getName() {
return name;
Expand Down Expand Up @@ -73,5 +82,77 @@ public List<String> getScopeIds() {
public void setScopeIds(List<String> scopeIds) {
this.scopeIds = scopeIds;
}

public boolean isBearerOnly() {
return bearerOnly;
}

public void setBearerOnly(boolean bearerOnly) {
this.bearerOnly = bearerOnly;
}

public boolean isConsentRequired() {
return consentRequired;
}

public void setConsentRequired(boolean consentRequired) {
this.consentRequired = consentRequired;
}

public boolean isStandardFlowEnabled() {
return standardFlowEnabled;
}

public void setStandardFlowEnabled(boolean standardFlowEnabled) {
this.standardFlowEnabled = standardFlowEnabled;
}

public boolean isImplicitFlowEnabled() {
return implicitFlowEnabled;
}

public void setImplicitFlowEnabled(boolean implicitFlowEnabled) {
this.implicitFlowEnabled = implicitFlowEnabled;
}

public boolean isDirectAccessGrantsEnabled() {
return directAccessGrantsEnabled;
}

public void setDirectAccessGrantsEnabled(boolean directAccessGrantsEnabled) {
this.directAccessGrantsEnabled = directAccessGrantsEnabled;
}

public boolean isServiceAccountsEnabled() {
return serviceAccountsEnabled;
}

public void setServiceAccountsEnabled(boolean serviceAccountsEnabled) {
this.serviceAccountsEnabled = serviceAccountsEnabled;
}

public boolean isPublicClient() {
return publicClient;
}

public void setPublicClient(boolean publicClient) {
this.publicClient = publicClient;
}

public Map<String, String> getAttributes() {
return attributes;
}

public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}

public boolean isFrontchannelLogout() {
return frontchannelLogout;
}

public void setFrontchannelLogout(boolean frontchannelLogout) {
this.frontchannelLogout = frontchannelLogout;
}
}

Expand Up @@ -194,6 +194,127 @@ public boolean hasScope(RoleModel role) {
return false;
}

public boolean isPublicClient() {
if (updated != null) return updated.isPublicClient();
return cached.isPublicClient();
}

public void setPublicClient(boolean flag) {
getDelegateForUpdate();
updated.setPublicClient(flag);
}

public boolean isFrontchannelLogout() {
if (updated != null) return updated.isPublicClient();
return cached.isFrontchannelLogout();
}

public void setFrontchannelLogout(boolean flag) {
getDelegateForUpdate();
updated.setFrontchannelLogout(flag);
}

@Override
public void setAttribute(String name, String value) {
getDelegateForUpdate();
updated.setAttribute(name, value);

}

@Override
public void removeAttribute(String name) {
getDelegateForUpdate();
updated.removeAttribute(name);

}

@Override
public String getAttribute(String name) {
if (updated != null) return updated.getAttribute(name);
return cached.getAttributes().get(name);
}

@Override
public Map<String, String> getAttributes() {
if (updated != null) return updated.getAttributes();
Map<String, String> copy = new HashMap<String, String>();
copy.putAll(cached.getAttributes());
return copy;
}

@Override
public boolean isBearerOnly() {
if (updated != null) return updated.isBearerOnly();
return cached.isBearerOnly();
}

@Override
public void setBearerOnly(boolean only) {
getDelegateForUpdate();
updated.setBearerOnly(only);
}

@Override
public boolean isConsentRequired() {
if (updated != null) return updated.isConsentRequired();
return cached.isConsentRequired();
}

@Override
public void setConsentRequired(boolean consentRequired) {
getDelegateForUpdate();
updated.setConsentRequired(consentRequired);
}

@Override
public boolean isStandardFlowEnabled() {
if (updated != null) return updated.isStandardFlowEnabled();
return cached.isStandardFlowEnabled();
}

@Override
public void setStandardFlowEnabled(boolean standardFlowEnabled) {
getDelegateForUpdate();
updated.setStandardFlowEnabled(standardFlowEnabled);
}

@Override
public boolean isImplicitFlowEnabled() {
if (updated != null) return updated.isImplicitFlowEnabled();
return cached.isImplicitFlowEnabled();
}

@Override
public void setImplicitFlowEnabled(boolean implicitFlowEnabled) {
getDelegateForUpdate();
updated.setImplicitFlowEnabled(implicitFlowEnabled);
}

@Override
public boolean isDirectAccessGrantsEnabled() {
if (updated != null) return updated.isDirectAccessGrantsEnabled();
return cached.isDirectAccessGrantsEnabled();
}

@Override
public void setDirectAccessGrantsEnabled(boolean directAccessGrantsEnabled) {
getDelegateForUpdate();
updated.setDirectAccessGrantsEnabled(directAccessGrantsEnabled);
}

@Override
public boolean isServiceAccountsEnabled() {
if (updated != null) return updated.isServiceAccountsEnabled();
return cached.isServiceAccountsEnabled();
}

@Override
public void setServiceAccountsEnabled(boolean serviceAccountsEnabled) {
getDelegateForUpdate();
updated.setServiceAccountsEnabled(serviceAccountsEnabled);
}




@Override
Expand Down
Expand Up @@ -29,8 +29,17 @@ public class CachedClientTemplate implements Serializable {
private String realm;
private String protocol;
private boolean fullScopeAllowed;
private boolean publicClient;
private boolean frontchannelLogout;
private boolean bearerOnly;
private boolean consentRequired;
private boolean standardFlowEnabled;
private boolean implicitFlowEnabled;
private boolean directAccessGrantsEnabled;
private boolean serviceAccountsEnabled;
private Set<String> scope = new HashSet<String>();
private Set<ProtocolMapperModel> protocolMappers = new HashSet<ProtocolMapperModel>();
private Map<String, String> attributes = new HashMap<String, String>();

public CachedClientTemplate(RealmCache cache, RealmProvider delegate, RealmModel realm, ClientTemplateModel model) {
id = model.getId();
Expand All @@ -45,6 +54,15 @@ public CachedClientTemplate(RealmCache cache, RealmProvider delegate, RealmModel
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() {
return id;
Expand Down Expand Up @@ -77,4 +95,40 @@ public boolean isFullScopeAllowed() {
public Set<String> getScope() {
return scope;
}

public boolean isPublicClient() {
return publicClient;
}

public boolean isFrontchannelLogout() {
return frontchannelLogout;
}

public boolean isBearerOnly() {
return bearerOnly;
}

public boolean isConsentRequired() {
return consentRequired;
}

public boolean isStandardFlowEnabled() {
return standardFlowEnabled;
}

public boolean isImplicitFlowEnabled() {
return implicitFlowEnabled;
}

public boolean isDirectAccessGrantsEnabled() {
return directAccessGrantsEnabled;
}

public boolean isServiceAccountsEnabled() {
return serviceAccountsEnabled;
}

public Map<String, String> getAttributes() {
return attributes;
}
}

0 comments on commit dbac147

Please sign in to comment.