Removal of never used classes from the changeset package

This commit is contained in:
Bruno Oliveira 2016-08-10 17:28:38 -03:00
parent 2df7d6252e
commit 4d8e19eb7c
No known key found for this signature in database
GPG key ID: 6119F27084DC9914
2 changed files with 0 additions and 727 deletions

View file

@ -1,387 +0,0 @@
/*
* Copyright 2016 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.storage.changeset;
import org.keycloak.common.util.MultivaluedHashMap;
import org.keycloak.models.UserCredentialValueModel;
import org.keycloak.models.entities.AbstractIdentifiableEntity;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
public class UserData {
private String id;
private boolean idChanged;
private String username;
private boolean usernameChanged;
private Long createdTimestamp;
private boolean createdTimestampChanged;
private String firstName;
private boolean firstNameChanged;
private String lastName;
private boolean lastNameChanged;
private String email;
private boolean emailChanged;
private boolean emailVerified;
private boolean emailVerifiedChanged;
private boolean totp;
private boolean totpChanged;
private boolean enabled;
private boolean enabledChanged;
private Set<String> roleIds = new HashSet<>();
private boolean rolesChanged;
private Set<String> groupIds = new HashSet<>();
private boolean groupsChanged;
private MultivaluedHashMap<String, String> attributes = new MultivaluedHashMap<>();
private boolean attributesChanged;
private Set<String> requiredActions = new HashSet<>();
private boolean requiredActionsChanged;
private List<UserCredentialValueModel> credentials = new LinkedList<>();
private boolean credentialsChanged;
public void rememberState() {
original = new UserData();
original.id = id;
original.username = username;
original.createdTimestamp = createdTimestamp;
original.firstName = firstName;
original.lastName = lastName;
original.email = email;
original.emailVerified = emailVerified;
original.totp = totp;
original.enabled = enabled;
original.attributes.putAll(attributes);
original.requiredActions.addAll(requiredActions);
original.credentials.addAll(credentials);
}
private UserData original = null;
public void clearChangeFlags() {
original = null;
idChanged = false;
usernameChanged = false;
createdTimestampChanged = false;
firstNameChanged = false;
lastNameChanged = false;
emailChanged = false;
emailVerifiedChanged = false;
totpChanged = false;
enabledChanged = false;
rolesChanged = false;
groupsChanged = false;
attributesChanged = false;
requiredActionsChanged = false;
credentialsChanged = false;
}
public boolean isChanged() {
return !idChanged
&& !usernameChanged
&& !createdTimestampChanged
&& !firstNameChanged
&& !lastNameChanged
&& !emailChanged
&& !emailVerifiedChanged
&& !totpChanged
&& !enabledChanged
&& !rolesChanged
&& !groupsChanged
&& !attributesChanged
&& !requiredActionsChanged
&& !credentialsChanged;
}
public boolean isIdChanged() {
return idChanged;
}
public boolean isUsernameChanged() {
return usernameChanged;
}
public boolean isCreatedTimestampChanged() {
return createdTimestampChanged;
}
public boolean isFirstNameChanged() {
return firstNameChanged;
}
public boolean isLastNameChanged() {
return lastNameChanged;
}
public boolean isEmailChanged() {
return emailChanged;
}
public boolean isEmailVerifiedChanged() {
return emailVerifiedChanged;
}
public boolean isTotpChanged() {
return totpChanged;
}
public boolean isEnabledChanged() {
return enabledChanged;
}
public boolean isRolesChanged() {
return rolesChanged;
}
public boolean isGroupsChanged() {
return groupsChanged;
}
public boolean isAttributesChanged() {
return attributesChanged;
}
public boolean isRequiredActionsChanged() {
return requiredActionsChanged;
}
public boolean isCredentialsChanged() {
return credentialsChanged;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
idChanged = true;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
usernameChanged = true;
}
public Long getCreatedTimestamp() {
return createdTimestamp;
}
public void setCreatedTimestamp(Long timestamp) {
this.createdTimestamp = timestamp;
createdTimestampChanged = true;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
firstNameChanged = true;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
lastNameChanged = true;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
emailChanged = true;
}
public boolean isEmailVerified() {
return emailVerified;
}
public void setEmailVerified(boolean emailVerified) {
this.emailVerified = emailVerified;
emailVerifiedChanged = true;
}
public boolean isTotp() {
return totp;
}
public void setTotp(boolean totp) {
this.totp = totp;
totpChanged = true;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
enabledChanged = true;
}
public Set<String> getRoleMappings() {
return Collections.unmodifiableSet(roleIds);
}
public void grantRole(String roleId) {
if (roleIds.contains(roleId)) return;
roleIds.add(roleId);
rolesChanged = true;
}
public void deleteRoleMapping(String roleId) {
if (!roleIds.contains(roleId)) return;
roleIds.remove(roleId);
rolesChanged = true;
}
public MultivaluedHashMap<String, String> getAttributes() {
return attributes;
}
public void setSingleAttribute(String name, String value) {
attributes.putSingle(name, value);
attributesChanged = true;
}
public void setAttribute(String name, List<String> values) {
attributes.put(name, values);
attributesChanged = true;
}
public void removeAttribute(String name) {
attributes.remove(name);
attributesChanged = true;
}
public Set<String> getRequiredActions() {
return Collections.unmodifiableSet(requiredActions);
}
public void addRequiredAction(String action) {
if (requiredActions.contains(action)) return;
requiredActions.add(action);
requiredActionsChanged = true;
}
public void removeRequiredAction(String action) {
if (!requiredActions.contains(action)) return;
requiredActions.remove(action);
requiredActionsChanged = true;
}
public List<UserCredentialValueModel> getCredentials() {
return Collections.unmodifiableList(credentials);
}
public void removeCredentialType(String type) {
Iterator<UserCredentialValueModel> it = credentials.iterator();
while (it.hasNext()) {
if (it.next().getType().equals(type)) {
it.remove();
credentialsChanged = true;
}
}
}
public void removeCredentialDevice(String type, String device) {
Iterator<UserCredentialValueModel> it = credentials.iterator();
while (it.hasNext()) {
UserCredentialValueModel next = it.next();
if (next.getType().equals(type) && next.getDevice().equals(device)) {
it.remove();
credentialsChanged = true;
}
}
}
public void setCredential(UserCredentialValueModel cred) {
removeCredentialType(cred.getType());
addCredential(cred);
}
public void addCredential(UserCredentialValueModel cred) {
credentials.add(cred);
credentialsChanged = true;
}
public Set<String> getGroupIds() {
return Collections.unmodifiableSet(groupIds);
}
public void joinGroup(String groupId) {
if (groupIds.contains(groupId)) return;
groupIds.add(groupId);
groupsChanged = true;
}
public void leaveGroup(String groupId) {
if (!groupIds.contains(groupId)) return;
groupIds.remove(groupId);
groupsChanged = true;
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (this.id == null) return false;
if (o == null || getClass() != o.getClass()) return false;
AbstractIdentifiableEntity that = (AbstractIdentifiableEntity) o;
if (!getId().equals(that.getId())) return false;
return true;
}
@Override
public int hashCode() {
return id!=null ? id.hashCode() : super.hashCode();
}
@Override
public String toString() {
return String.format("%s [ id=%s ]", getClass().getSimpleName(), getId());
}
}

View file

@ -1,340 +0,0 @@
/*
* Copyright 2016 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.storage.changeset;
import org.keycloak.common.util.Time;
import org.keycloak.hash.PasswordHashManager;
import org.keycloak.models.ClientModel;
import org.keycloak.models.GroupModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.OTPPolicy;
import org.keycloak.models.PasswordPolicy;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RoleContainerModel;
import org.keycloak.models.RoleModel;
import org.keycloak.models.UserCredentialModel;
import org.keycloak.models.UserCredentialValueModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.KeycloakModelUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*
*
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class UserDataAdapter implements UserModel {
protected UserData userData;
protected RealmModel realm;
protected KeycloakSession session;
protected Set<String> managedCredentialTypes;
protected List<UserCredentialModel> updatedManagedCredentials = new LinkedList<>();
public UserDataAdapter(KeycloakSession session, RealmModel realm, UserData userData) {
this.session = session;
this.realm = realm;
this.userData = userData;
this.userData.rememberState();
}
@Override
public String getId() {
return userData.getId();
}
@Override
public String getUsername() {
return userData.getUsername();
}
@Override
public void setUsername(String username) {
userData.setUsername(username);
}
@Override
public Long getCreatedTimestamp() {
return userData.getCreatedTimestamp();
}
@Override
public void setCreatedTimestamp(Long timestamp) {
userData.setCreatedTimestamp(timestamp);
}
@Override
public boolean isEnabled() {
return userData.isEnabled();
}
@Override
public boolean isOtpEnabled() {
return userData.isTotp();
}
@Override
public void setEnabled(boolean enabled) {
userData.setEnabled(enabled);
}
@Override
public void setSingleAttribute(String name, String value) {
userData.setSingleAttribute(name, value);
}
@Override
public void setAttribute(String name, List<String> values) {
userData.setAttribute(name, values);
}
@Override
public void removeAttribute(String name) {
userData.removeAttribute(name);
}
@Override
public String getFirstAttribute(String name) {
return userData.getAttributes().getFirst(name);
}
@Override
public List<String> getAttribute(String name) {
return userData.getAttributes().get(name);
}
@Override
public Map<String, List<String>> getAttributes() {
return userData.getAttributes();
}
@Override
public Set<String> getRequiredActions() {
return userData.getRequiredActions();
}
@Override
public void addRequiredAction(String action) {
userData.addRequiredAction(action);
}
@Override
public void removeRequiredAction(String action) {
userData.removeRequiredAction(action);
}
@Override
public void addRequiredAction(RequiredAction action) {
userData.addRequiredAction(action.name());
}
@Override
public void removeRequiredAction(RequiredAction action) {
userData.removeRequiredAction(action.name());
}
@Override
public String getFirstName() {
return userData.getFirstName();
}
@Override
public void setFirstName(String firstName) {
userData.setFirstName(firstName);
}
@Override
public String getLastName() {
return userData.getLastName();
}
@Override
public void setLastName(String lastName) {
userData.setLastName(lastName);
}
@Override
public String getEmail() {
return userData.getEmail();
}
@Override
public void setEmail(String email) {
userData.setEmail(email);
}
@Override
public boolean isEmailVerified() {
return userData.isEmailVerified();
}
@Override
public void setEmailVerified(boolean verified) {
userData.setEmailVerified(verified);
}
@Override
public void setOtpEnabled(boolean totp) {
userData.setTotp(totp);
}
@Override
public void updateCredential(UserCredentialModel cred) {
}
@Override
public List<UserCredentialValueModel> getCredentialsDirectly() {
return null;
}
@Override
public void updateCredentialDirectly(UserCredentialValueModel cred) {
}
@Override
public Set<GroupModel> getGroups() {
Set<String> groups = userData.getGroupIds();
Set<GroupModel> set = new HashSet<>();
for (String id : groups) {
GroupModel group = realm.getGroupById(id);
if (group != null) set.add(group);
}
return set;
}
@Override
public void joinGroup(GroupModel group) {
userData.joinGroup(group.getId());
}
@Override
public void leaveGroup(GroupModel group) {
userData.leaveGroup(group.getId());
}
@Override
public boolean isMemberOf(GroupModel group) {
Set<GroupModel> roles = getGroups();
return KeycloakModelUtils.isMember(roles, group);
}
@Override
public String getFederationLink() {
return null;
}
@Override
public void setFederationLink(String link) {
}
@Override
public String getServiceAccountClientLink() {
return null;
}
@Override
public void setServiceAccountClientLink(String clientInternalId) {
}
@Override
public Set<RoleModel> getRealmRoleMappings() {
Set<RoleModel> roleMappings = getRoleMappings();
Set<RoleModel> realmRoles = new HashSet<RoleModel>();
for (RoleModel role : roleMappings) {
RoleContainerModel container = role.getContainer();
if (container instanceof RealmModel) {
realmRoles.add(role);
}
}
return realmRoles;
}
@Override
public Set<RoleModel> getClientRoleMappings(ClientModel app) {
Set<RoleModel> roleMappings = getRoleMappings();
Set<RoleModel> roles = new HashSet<RoleModel>();
for (RoleModel role : roleMappings) {
RoleContainerModel container = role.getContainer();
if (container instanceof ClientModel) {
ClientModel appModel = (ClientModel)container;
if (appModel.getId().equals(app.getId())) {
roles.add(role);
}
}
}
return roles;
}
@Override
public boolean hasRole(RoleModel role) {
Set<RoleModel> roles = getRoleMappings();
return KeycloakModelUtils.hasRole(roles, role);
}
@Override
public void grantRole(RoleModel role) {
userData.grantRole(role.getId());
}
@Override
public Set<RoleModel> getRoleMappings() {
Set<String> roles = userData.getRoleMappings();
Set<RoleModel> set = new HashSet<>();
for (String id : roles) {
RoleModel role = realm.getRoleById(id);
if (role != null) set.add(role);
}
return set;
}
@Override
public void deleteRoleMapping(RoleModel role) {
userData.deleteRoleMapping(role.getId());
}
}