KEYCLOAK-1070 Persistent grants - step 1
This commit is contained in:
1 parent
aea5055b30
commit
78830836b8
49 files changed
+1532
-117
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package org.keycloak.models;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
|
||||
*/
|
||||
public class GrantedConsentModel {
|
||||
|
||||
private final String clientId;
|
||||
private Set<String> protocolMapperIds = new HashSet<String>();
|
||||
private Set<String> roleIds = new HashSet<String>();
|
||||
|
||||
public GrantedConsentModel(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void addGrantedRole(String roleId) {
|
||||
roleIds.add(roleId);
|
||||
}
|
||||
|
||||
public Set<String> getGrantedRoles() {
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public boolean isRoleGranted(String roleId) {
|
||||
return roleIds.contains(roleId);
|
||||
}
|
||||
|
||||
public void addGrantedProtocolMapper(String protocolMapperId) {
|
||||
protocolMapperIds.add(protocolMapperId);
|
||||
}
|
||||
|
||||
public Set<String> getGrantedProtocolMappers() {
|
||||
return protocolMapperIds;
|
||||
}
|
||||
|
||||
public boolean isProtocolMapperGranted(String protocolMapperId) {
|
||||
return protocolMapperIds.contains(protocolMapperId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -320,6 +320,16 @@ public class UserFederationManager implements UserProvider {
|
||||
session.userStorage().preRemove(realm, role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRemove(RealmModel realm, ClientModel client) {
|
||||
session.userStorage().preRemove(realm, client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRemove(ClientModel client, ProtocolMapperModel protocolMapper) {
|
||||
session.userStorage().preRemove(client, protocolMapper);
|
||||
}
|
||||
|
||||
public void updateCredential(RealmModel realm, UserModel user, UserCredentialModel credential) {
|
||||
if (credential.getType().equals(UserCredentialModel.PASSWORD)) {
|
||||
if (realm.getPasswordPolicy() != null) {
|
||||
|
||||
@@ -75,9 +75,11 @@ public interface UserModel {
|
||||
String getFederationLink();
|
||||
void setFederationLink(String link);
|
||||
|
||||
|
||||
|
||||
|
||||
GrantedConsentModel addGrantedConsent(GrantedConsentModel consent);
|
||||
GrantedConsentModel getGrantedConsentByClient(String clientId);
|
||||
List<GrantedConsentModel> getGrantedConsents();
|
||||
void updateGrantedConsent(GrantedConsentModel consent);
|
||||
boolean revokeGrantedConsentForClient(String clientId);
|
||||
|
||||
public static enum RequiredAction {
|
||||
VERIFY_EMAIL, UPDATE_PROFILE, CONFIGURE_TOTP, UPDATE_PASSWORD
|
||||
|
||||
@@ -41,6 +41,9 @@ public interface UserProvider extends Provider {
|
||||
|
||||
void preRemove(RealmModel realm, RoleModel role);
|
||||
|
||||
void preRemove(RealmModel realm, ClientModel client);
|
||||
void preRemove(ClientModel realm, ProtocolMapperModel protocolMapper);
|
||||
|
||||
boolean validCredentials(RealmModel realm, UserModel user, List<UserCredentialModel> input);
|
||||
boolean validCredentials(RealmModel realm, UserModel user, UserCredentialModel... input);
|
||||
CredentialValidationOutput validCredentials(RealmModel realm, UserCredentialModel... input);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.keycloak.models.utils;
|
||||
|
||||
import org.keycloak.models.ClientModel;
|
||||
import org.keycloak.models.GrantedConsentModel;
|
||||
import org.keycloak.models.RoleModel;
|
||||
import org.keycloak.models.UserCredentialModel;
|
||||
import org.keycloak.models.UserCredentialValueModel;
|
||||
@@ -185,4 +186,29 @@ public class UserModelDelegate implements UserModel {
|
||||
public void setFederationLink(String link) {
|
||||
delegate.setFederationLink(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantedConsentModel addGrantedConsent(GrantedConsentModel consent) {
|
||||
return delegate.addGrantedConsent(consent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantedConsentModel getGrantedConsentByClient(String clientId) {
|
||||
return delegate.getGrantedConsentByClient(clientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GrantedConsentModel> getGrantedConsents() {
|
||||
return delegate.getGrantedConsents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGrantedConsent(GrantedConsentModel consent) {
|
||||
delegate.updateGrantedConsent(consent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeGrantedConsentForClient(String clientId) {
|
||||
return delegate.revokeGrantedConsentForClient(clientId);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user