Store enums as Integers in HotRod store

Closes #12502
This commit is contained in:
Michal Hajas 2022-06-02 15:37:32 +02:00 committed by Bruno Oliveira da Silva
parent 48266fa48f
commit cbb88ed75d
20 changed files with 38 additions and 618 deletions

View file

@ -97,6 +97,7 @@ public class GenerateHotRodEntityImplementationsProcessor extends AbstractGenera
private TypeElement generalHotRodDelegate;
private TypeElement abstractEntity;
private TypeElement abstractHotRodEntity;
private TypeElement enumWithStableId;
private TypeElement hotRodUtils;
@Override
@ -129,6 +130,7 @@ public class GenerateHotRodEntityImplementationsProcessor extends AbstractGenera
generalHotRodDelegate = elements.getTypeElement("org.keycloak.models.map.storage.hotRod.common.HotRodEntityDelegate");
abstractEntity = elements.getTypeElement("org.keycloak.models.map.common.AbstractEntity");
abstractHotRodEntity = elements.getTypeElement("org.keycloak.models.map.storage.hotRod.common.AbstractHotRodEntity");
enumWithStableId = elements.getTypeElement("org.keycloak.util.EnumWithStableIndex");
hotRodUtils = elements.getTypeElement("org.keycloak.models.map.storage.hotRod.common.HotRodTypesUtils");
boolean hasDeepClone = allMembers.stream()
@ -523,6 +525,14 @@ public class GenerateHotRodEntityImplementationsProcessor extends AbstractGenera
}
if (isAssignable(fromType[0], enumWithStableId.asType())) {
return fieldNames[0] + ".getStableIndex()";
}
if (isAssignable(toType, enumWithStableId.asType())) {
return toType.toString() + ".valueOfInteger(" + fieldNames[0] + ")";
}
// Try to find constructor that can do the migration
if (findSuitableConstructor(toType, fromType).isPresent()) {
return "new " + toType.toString() + "(" + String.join(", ", fieldNames) + ")";

View file

@ -19,17 +19,15 @@ package org.keycloak.models.map.storage.hotRod;
import org.keycloak.authorization.model.Policy;
import org.keycloak.events.Event;
import org.keycloak.events.EventType;
import org.keycloak.events.admin.AdminEvent;
import org.keycloak.events.admin.OperationType;
import org.keycloak.models.ClientModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.UserSessionModel;
import org.keycloak.models.map.storage.CriterionNotSupportedException;
import org.keycloak.models.map.storage.ModelCriteriaBuilder;
import org.keycloak.models.map.storage.hotRod.common.HotRodTypesUtils;
import org.keycloak.storage.SearchableModelField;
import org.keycloak.storage.StorageId;
import org.keycloak.util.EnumWithStableIndex;
import java.util.Arrays;
import java.util.Collection;
@ -66,8 +64,8 @@ public class IckleQueryWhereClauses {
WHERE_CLAUSE_PRODUCER_OVERRIDES.put(UserModel.SearchableFields.CONSENT_CLIENT_FEDERATION_LINK, IckleQueryWhereClauses::whereClauseForConsentClientFederationLink);
WHERE_CLAUSE_PRODUCER_OVERRIDES.put(UserSessionModel.SearchableFields.CORRESPONDING_SESSION_ID, IckleQueryWhereClauses::whereClauseForCorrespondingSessionId);
WHERE_CLAUSE_PRODUCER_OVERRIDES.put(Policy.SearchableFields.CONFIG, IckleQueryWhereClauses::whereClauseForPolicyConfig);
WHERE_CLAUSE_PRODUCER_OVERRIDES.put(Event.SearchableFields.EVENT_TYPE, IckleQueryWhereClauses::whereClauseForEventType);
WHERE_CLAUSE_PRODUCER_OVERRIDES.put(AdminEvent.SearchableFields.OPERATION_TYPE, IckleQueryWhereClauses::whereClauseForOperationType);
WHERE_CLAUSE_PRODUCER_OVERRIDES.put(Event.SearchableFields.EVENT_TYPE, IckleQueryWhereClauses::whereClauseForEnumWithStableIndex);
WHERE_CLAUSE_PRODUCER_OVERRIDES.put(AdminEvent.SearchableFields.OPERATION_TYPE, IckleQueryWhereClauses::whereClauseForEnumWithStableIndex);
}
@FunctionalInterface
@ -215,30 +213,17 @@ public class IckleQueryWhereClauses {
return "(" + nameClause + ")" + " AND " + "(" + valueClause + ")";
}
private static String whereClauseForEventType(String modelFieldName, ModelCriteriaBuilder.Operator op, Object[] values, Map<String, Object> parameters) {
private static String whereClauseForEnumWithStableIndex(String modelFieldName, ModelCriteriaBuilder.Operator op, Object[] values, Map<String, Object> parameters) {
if (values != null && values.length == 1) {
if (values[0] instanceof EventType) {
values[0] = HotRodTypesUtils.migrateEventTypeToHotRodEventType((EventType) values[0]);
if (values[0] instanceof EnumWithStableIndex) {
values[0] = ((EnumWithStableIndex) values[0]).getStableIndex();
} else if (values[0] instanceof Collection) {
values[0] = ((Collection<EventType>) values[0]).stream().map(HotRodTypesUtils::migrateEventTypeToHotRodEventType).collect(Collectors.toSet());
values[0] = ((Collection<EnumWithStableIndex>) values[0]).stream().map(EnumWithStableIndex::getStableIndex).collect(Collectors.toSet());
} else if (values[0] instanceof Stream) {
values[0] = ((Stream<EventType>) values[0]).map(HotRodTypesUtils::migrateEventTypeToHotRodEventType);
values[0] = ((Stream<EnumWithStableIndex>) values[0]).map(EnumWithStableIndex::getStableIndex);
}
}
return produceWhereClause(modelFieldName, op, values, parameters);
}
private static String whereClauseForOperationType(String modelFieldName, ModelCriteriaBuilder.Operator op, Object[] values, Map<String, Object> parameters) {
if (values != null && values.length == 1) {
if (values[0] instanceof OperationType) {
values[0] = HotRodTypesUtils.migrateOperationTypeToHotRodOperationType((OperationType) values[0]);
} else if (values[0] instanceof Collection) {
values[0] = ((Collection<OperationType>) values[0]).stream().map(HotRodTypesUtils::migrateOperationTypeToHotRodOperationType).collect(Collectors.toSet());
} else if (values[0] instanceof Stream) {
values[0] = ((Stream<OperationType>) values[0]).map(HotRodTypesUtils::migrateOperationTypeToHotRodOperationType);
}
}
return produceWhereClause(modelFieldName, op, values, parameters);
}
}

View file

@ -61,7 +61,7 @@ public class HotRodAuthenticationSessionEntity extends AbstractHotRodEntity {
public Set<String> clientScopes;
@ProtoField(number = 8)
public Set<HotRodPair<String, HotRodExecutionStatus>> executionStatuses;
public Set<HotRodPair<String, Integer>> executionStatuses;
@ProtoField(number = 9)
public String protocol;
@ -82,20 +82,20 @@ public class HotRodAuthenticationSessionEntity extends AbstractHotRodEntity {
@Override
public Map<String, AuthenticationSessionModel.ExecutionStatus> getExecutionStatuses() {
Set<HotRodPair<String, HotRodExecutionStatus>> executionStatuses = getHotRodEntity().executionStatuses;
Set<HotRodPair<String, Integer>> executionStatuses = getHotRodEntity().executionStatuses;
if (executionStatuses == null) {
return Collections.emptyMap();
}
return executionStatuses.stream().collect(Collectors.toMap(HotRodPair::getKey,
v -> AuthenticationSessionModel.ExecutionStatus.valueOf(v.getValue().name())));
v -> AuthenticationSessionModel.ExecutionStatus.valueOfInteger(v.getValue())));
}
@Override
public void setExecutionStatuses(Map<String, AuthenticationSessionModel.ExecutionStatus> executionStatus) {
HotRodAuthenticationSessionEntity hotRodEntity = getHotRodEntity();
Set<HotRodPair<String, HotRodExecutionStatus>> executionStatusSet = executionStatus == null ? null :
Set<HotRodPair<String, Integer>> executionStatusSet = executionStatus == null ? null :
executionStatus.entrySet().stream()
.map(e -> new HotRodPair<>(e.getKey(), HotRodExecutionStatus.valueOf(e.getValue().name())))
.map(e -> new HotRodPair<>(e.getKey(), e.getValue().getStableIndex()))
.collect(Collectors.toSet());
hotRodEntity.updated |= ! Objects.equals(hotRodEntity.executionStatuses, executionStatusSet);
hotRodEntity.executionStatuses = executionStatusSet;
@ -109,7 +109,7 @@ public class HotRodAuthenticationSessionEntity extends AbstractHotRodEntity {
}
boolean valueUndefined = status == null;
hotRodEntity.updated |= HotRodTypesUtils.removeFromSetByMapKey(hotRodEntity.executionStatuses, authenticator, HotRodTypesUtils::getKey);
hotRodEntity.updated |= !valueUndefined && hotRodEntity.executionStatuses.add(new HotRodPair<>(authenticator, HotRodExecutionStatus.valueOf(status.name())));
hotRodEntity.updated |= !valueUndefined && hotRodEntity.executionStatuses.add(new HotRodPair<>(authenticator, status.getStableIndex()));
}
}

View file

@ -1,47 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.authSession;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodExecutionStatus {
@ProtoEnumValue(number = 0)
FAILED,
@ProtoEnumValue(number = 1)
SUCCESS,
@ProtoEnumValue(number = 2)
SETUP_REQUIRED,
@ProtoEnumValue(number = 3)
ATTEMPTED,
@ProtoEnumValue(number = 4)
SKIPPED,
@ProtoEnumValue(number = 5)
CHALLENGED,
@ProtoEnumValue(number = 6)
EVALUATED_TRUE,
@ProtoEnumValue(number = 7)
EVALUATED_FALSE
}

View file

@ -51,8 +51,7 @@ public class HotRodRootAuthenticationSessionEntity extends AbstractHotRodEntity
@AutoProtoSchemaBuilder(
includeClasses = {
HotRodRootAuthenticationSessionEntity.class,
HotRodAuthenticationSessionEntity.class,
HotRodExecutionStatus.class,
HotRodAuthenticationSessionEntity.class
},
schemaFilePath = "proto/",
schemaPackageName = CommonPrimitivesProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE,

View file

@ -1,41 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.authorization;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodDecisionStrategy {
/**
* Defines that at least one policy must evaluate to a positive decision in order to the overall decision be also positive.
*/
@ProtoEnumValue(number = 0)
AFFIRMATIVE,
/**
* Defines that all policies must evaluate to a positive decision in order to the overall decision be also positive.
*/
@ProtoEnumValue(number = 1)
UNANIMOUS,
/**
* Defines that the number of positive decisions must be greater than the number of negative decisions. If the number of positive and negative is the same,
* the final decision will be negative.
*/
@ProtoEnumValue(number = 2)
CONSENSUS
}

View file

@ -1,34 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.authorization;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodLogic {
/**
* Defines that this policy follows a positive logic. In other words, the final decision is the policy outcome.
*/
@ProtoEnumValue(number = 0)
POSITIVE,
/**
* Defines that this policy uses a logical negation. In other words, the final decision would be a negative of the policy outcome.
*/
@ProtoEnumValue(number = 1)
NEGATIVE,
}

View file

@ -1,40 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.authorization;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodPolicyEnforcementMode {
/**
* Requests are denied by default even when there is no policy associated with a given resource.
*/
@ProtoEnumValue(number = 0)
ENFORCING,
/**
* Requests are allowed even when there is no policy associated with a given resource.
*/
@ProtoEnumValue(number = 1)
PERMISSIVE,
/**
* Completely disables the evaluation of policies and allow access to any resource.
*/
@ProtoEnumValue(number = 2)
DISABLED
}

View file

@ -48,12 +48,11 @@ public class HotRodPolicyEntity extends AbstractHotRodEntity {
@AutoProtoSchemaBuilder(
includeClasses = {
HotRodPolicyEntity.class,
HotRodLogic.class
HotRodPolicyEntity.class
},
schemaFilePath = "proto/",
schemaPackageName = CommonPrimitivesProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE,
dependsOn = {CommonPrimitivesProtoSchemaInitializer.class, HotRodResourceServerEntity.HotRodResourceServerEntitySchema.class}
dependsOn = {CommonPrimitivesProtoSchemaInitializer.class}
)
public interface HotRodPolicyEntitySchema extends GeneratedSchema {
HotRodPolicyEntitySchema INSTANCE = new HotRodPolicyEntitySchemaImpl();
@ -88,10 +87,10 @@ public class HotRodPolicyEntity extends AbstractHotRodEntity {
public String type;
@ProtoField(number = 8)
public HotRodDecisionStrategy decisionStrategy;
public Integer decisionStrategy;
@ProtoField(number = 9)
public HotRodLogic logic;
public Integer logic;
@ProtoField(number = 10)
@ProtoDoc("@Field(index = Index.YES, store = Store.YES)")

View file

@ -46,8 +46,6 @@ public class HotRodResourceServerEntity extends AbstractHotRodEntity {
@AutoProtoSchemaBuilder(
includeClasses = {
HotRodResourceServerEntity.class,
HotRodPolicyEnforcementMode.class,
HotRodDecisionStrategy.class
},
schemaFilePath = "proto/",
schemaPackageName = CommonPrimitivesProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE)
@ -76,10 +74,10 @@ public class HotRodResourceServerEntity extends AbstractHotRodEntity {
public Boolean allowRemoteResourceManagement;
@ProtoField(number = 6)
public HotRodPolicyEnforcementMode policyEnforcementMode;
public Integer policyEnforcementMode;
@ProtoField(number = 7)
public HotRodDecisionStrategy decisionStrategy;
public Integer decisionStrategy;
public static abstract class AbstractHotRodResourceServerEntity extends UpdatableHotRodEntityDelegateImpl<HotRodResourceServerEntity> implements MapResourceServerEntity {

View file

@ -17,25 +17,11 @@
package org.keycloak.models.map.storage.hotRod.common;
import org.keycloak.events.EventType;
import org.keycloak.events.admin.OperationType;
import org.keycloak.models.AuthenticationExecutionModel;
import org.keycloak.models.UserSessionModel;
import org.keycloak.models.map.common.AbstractEntity;
import org.keycloak.models.map.storage.hotRod.authSession.HotRodAuthenticationSessionEntity;
import org.keycloak.models.map.storage.hotRod.authorization.HotRodDecisionStrategy;
import org.keycloak.models.map.storage.hotRod.authorization.HotRodLogic;
import org.keycloak.models.map.storage.hotRod.authorization.HotRodPolicyEnforcementMode;
import org.keycloak.models.map.storage.hotRod.events.HotRodEventType;
import org.keycloak.models.map.storage.hotRod.events.HotRodOperationType;
import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodLocalizationTexts;
import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodRequirement;
import org.keycloak.models.map.storage.hotRod.user.HotRodUserConsentEntity;
import org.keycloak.models.map.storage.hotRod.user.HotRodUserFederatedIdentityEntity;
import org.keycloak.models.map.storage.hotRod.userSession.HotRodSessionState;
import org.keycloak.representations.idm.authorization.DecisionStrategy;
import org.keycloak.representations.idm.authorization.Logic;
import org.keycloak.representations.idm.authorization.PolicyEnforcementMode;
import java.util.HashMap;
import java.util.List;
@ -143,14 +129,6 @@ public class HotRodTypesUtils {
return hotRodAuthenticationSessionEntity.tabId;
}
public static AuthenticationExecutionModel.Requirement migrateHotRodRequirementToRequirement(HotRodRequirement p0) {
return p0 == null ? null : AuthenticationExecutionModel.Requirement.values()[p0.ordinal()];
}
public static HotRodRequirement migrateRequirementToHotRodRequirement(AuthenticationExecutionModel.Requirement p0) {
return p0 == null ? null : HotRodRequirement.values()[p0.ordinal()];
}
public static String getKey(HotRodLocalizationTexts hotRodLocalizationTexts) {
return hotRodLocalizationTexts.getLocale();
}
@ -167,52 +145,4 @@ public class HotRodTypesUtils {
return hotRodLocalizationTexts;
}
public static UserSessionModel.State migrateHotRodSessionStateToState(HotRodSessionState hotRodState) {
return UserSessionModel.State.valueOf(hotRodState.name());
}
public static HotRodSessionState migrateStateToHotRodSessionState(UserSessionModel.State state) {
return HotRodSessionState.valueOf(state.name());
}
public static HotRodDecisionStrategy migrateDecisionStrategyToHotRodDecisionStrategy(DecisionStrategy p0) {
return p0 == null ? null : HotRodDecisionStrategy.values()[p0.ordinal()];
}
public static DecisionStrategy migrateHotRodDecisionStrategyToDecisionStrategy(HotRodDecisionStrategy p0) {
return p0 == null ? null : DecisionStrategy.values()[p0.ordinal()];
}
public static HotRodPolicyEnforcementMode migratePolicyEnforcementModeToHotRodPolicyEnforcementMode(PolicyEnforcementMode p0) {
return p0 == null ? null : HotRodPolicyEnforcementMode.values()[p0.ordinal()];
}
public static PolicyEnforcementMode migrateHotRodPolicyEnforcementModeToPolicyEnforcementMode(HotRodPolicyEnforcementMode p0) {
return p0 == null ? null : PolicyEnforcementMode.values()[p0.ordinal()];
}
public static HotRodLogic migrateLogicToHotRodLogic(Logic p0) {
return p0 == null ? null : HotRodLogic.values()[p0.ordinal()];
}
public static Logic migrateHotRodLogicToLogic(HotRodLogic p0) {
return p0 == null ? null : Logic.values()[p0.ordinal()];
}
public static OperationType migrateHotRodOperationTypeToOperationType(HotRodOperationType p0) {
return p0 == null ? null : OperationType.values()[p0.ordinal()];
}
public static HotRodOperationType migrateOperationTypeToHotRodOperationType(OperationType p0) {
return p0 == null ? null : HotRodOperationType.values()[p0.ordinal()];
}
public static HotRodEventType migrateEventTypeToHotRodEventType(EventType p0) {
return p0 == null ? null : HotRodEventType.values()[p0.ordinal()];
}
public static EventType migrateHotRodEventTypeToEventType(HotRodEventType p0) {
return p0 == null ? null : EventType.values()[p0.ordinal()];
}
}

View file

@ -43,8 +43,7 @@ public class HotRodAdminEventEntity extends AbstractHotRodEntity {
@AutoProtoSchemaBuilder(
includeClasses = {
HotRodAdminEventEntity.class,
HotRodOperationType.class
HotRodAdminEventEntity.class
},
schemaFilePath = "proto/",
schemaPackageName = CommonPrimitivesProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE)
@ -68,7 +67,7 @@ public class HotRodAdminEventEntity extends AbstractHotRodEntity {
@ProtoDoc("@Field(index = Index.YES, store = Store.YES)")
@ProtoField(number = 5)
public HotRodOperationType operationType;
public Integer operationType;
@ProtoDoc("@Field(index = Index.YES, store = Store.YES)")
@ProtoField(number = 6)

View file

@ -45,8 +45,7 @@ public class HotRodAuthEventEntity extends AbstractHotRodEntity {
@AutoProtoSchemaBuilder(
includeClasses = {
HotRodAuthEventEntity.class,
HotRodEventType.class,
HotRodAuthEventEntity.class
},
schemaFilePath = "proto/",
schemaPackageName = CommonPrimitivesProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE,
@ -65,7 +64,7 @@ public class HotRodAuthEventEntity extends AbstractHotRodEntity {
@ProtoDoc("@Field(index = Index.YES, store = Store.YES)")
@ProtoField(number = 3)
public HotRodEventType type;
public Integer type;
@ProtoDoc("@Field(index = Index.YES, store = Store.YES)")
@ProtoField(number = 4)

View file

@ -1,238 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.events;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodEventType {
@ProtoEnumValue(number = 0)
LOGIN,
@ProtoEnumValue(number = 1)
LOGIN_ERROR,
@ProtoEnumValue(number = 2)
REGISTER,
@ProtoEnumValue(number = 3)
REGISTER_ERROR,
@ProtoEnumValue(number = 4)
LOGOUT,
@ProtoEnumValue(number = 5)
LOGOUT_ERROR,
@ProtoEnumValue(number = 6)
CODE_TO_TOKEN,
@ProtoEnumValue(number = 7)
CODE_TO_TOKEN_ERROR,
@ProtoEnumValue(number = 8)
CLIENT_LOGIN,
@ProtoEnumValue(number = 9)
CLIENT_LOGIN_ERROR,
@ProtoEnumValue(number = 10)
REFRESH_TOKEN,
@ProtoEnumValue(number = 11)
REFRESH_TOKEN_ERROR,
@ProtoEnumValue(number = 12)
/**
* @deprecated see KEYCLOAK-2266
*/
@Deprecated
VALIDATE_ACCESS_TOKEN,
@ProtoEnumValue(number = 13)
@Deprecated
VALIDATE_ACCESS_TOKEN_ERROR,
@ProtoEnumValue(number = 14)
INTROSPECT_TOKEN,
@ProtoEnumValue(number = 15)
INTROSPECT_TOKEN_ERROR,
@ProtoEnumValue(number = 16)
FEDERATED_IDENTITY_LINK,
@ProtoEnumValue(number = 17)
FEDERATED_IDENTITY_LINK_ERROR,
@ProtoEnumValue(number = 18)
REMOVE_FEDERATED_IDENTITY,
@ProtoEnumValue(number = 19)
REMOVE_FEDERATED_IDENTITY_ERROR,
@ProtoEnumValue(number = 20)
UPDATE_EMAIL,
@ProtoEnumValue(number = 21)
UPDATE_EMAIL_ERROR,
@ProtoEnumValue(number = 22)
UPDATE_PROFILE,
@ProtoEnumValue(number = 23)
UPDATE_PROFILE_ERROR,
@ProtoEnumValue(number = 24)
UPDATE_PASSWORD,
@ProtoEnumValue(number = 25)
UPDATE_PASSWORD_ERROR,
@ProtoEnumValue(number = 26)
UPDATE_TOTP,
@ProtoEnumValue(number = 27)
UPDATE_TOTP_ERROR,
@ProtoEnumValue(number = 28)
VERIFY_EMAIL,
@ProtoEnumValue(number = 29)
VERIFY_EMAIL_ERROR,
@ProtoEnumValue(number = 30)
VERIFY_PROFILE,
@ProtoEnumValue(number = 31)
VERIFY_PROFILE_ERROR,
@ProtoEnumValue(number = 32)
REMOVE_TOTP,
@ProtoEnumValue(number = 33)
REMOVE_TOTP_ERROR,
@ProtoEnumValue(number = 34)
GRANT_CONSENT,
@ProtoEnumValue(number = 35)
GRANT_CONSENT_ERROR,
@ProtoEnumValue(number = 36)
UPDATE_CONSENT,
@ProtoEnumValue(number = 37)
UPDATE_CONSENT_ERROR,
@ProtoEnumValue(number = 38)
REVOKE_GRANT,
@ProtoEnumValue(number = 39)
REVOKE_GRANT_ERROR,
@ProtoEnumValue(number = 40)
SEND_VERIFY_EMAIL,
@ProtoEnumValue(number = 41)
SEND_VERIFY_EMAIL_ERROR,
@ProtoEnumValue(number = 42)
SEND_RESET_PASSWORD,
@ProtoEnumValue(number = 43)
SEND_RESET_PASSWORD_ERROR,
@ProtoEnumValue(number = 44)
SEND_IDENTITY_PROVIDER_LINK,
@ProtoEnumValue(number = 45)
SEND_IDENTITY_PROVIDER_LINK_ERROR,
@ProtoEnumValue(number = 46)
RESET_PASSWORD,
@ProtoEnumValue(number = 47)
RESET_PASSWORD_ERROR,
@ProtoEnumValue(number = 48)
RESTART_AUTHENTICATION,
@ProtoEnumValue(number = 49)
RESTART_AUTHENTICATION_ERROR,
@ProtoEnumValue(number = 50)
INVALID_SIGNATURE,
@ProtoEnumValue(number = 51)
INVALID_SIGNATURE_ERROR,
@ProtoEnumValue(number = 52)
REGISTER_NODE,
@ProtoEnumValue(number = 53)
REGISTER_NODE_ERROR,
@ProtoEnumValue(number = 54)
UNREGISTER_NODE,
@ProtoEnumValue(number = 55)
UNREGISTER_NODE_ERROR,
@ProtoEnumValue(number = 56)
USER_INFO_REQUEST,
@ProtoEnumValue(number = 57)
USER_INFO_REQUEST_ERROR,
@ProtoEnumValue(number = 58)
IDENTITY_PROVIDER_LINK_ACCOUNT,
@ProtoEnumValue(number = 59)
IDENTITY_PROVIDER_LINK_ACCOUNT_ERROR,
@ProtoEnumValue(number = 60)
IDENTITY_PROVIDER_LOGIN,
@ProtoEnumValue(number = 61)
IDENTITY_PROVIDER_LOGIN_ERROR,
@ProtoEnumValue(number = 62)
IDENTITY_PROVIDER_FIRST_LOGIN,
@ProtoEnumValue(number = 63)
IDENTITY_PROVIDER_FIRST_LOGIN_ERROR,
@ProtoEnumValue(number = 64)
IDENTITY_PROVIDER_POST_LOGIN,
@ProtoEnumValue(number = 65)
IDENTITY_PROVIDER_POST_LOGIN_ERROR,
@ProtoEnumValue(number = 66)
IDENTITY_PROVIDER_RESPONSE,
@ProtoEnumValue(number = 67)
IDENTITY_PROVIDER_RESPONSE_ERROR,
@ProtoEnumValue(number = 68)
IDENTITY_PROVIDER_RETRIEVE_TOKEN,
@ProtoEnumValue(number = 69)
IDENTITY_PROVIDER_RETRIEVE_TOKEN_ERROR,
@ProtoEnumValue(number = 70)
IMPERSONATE,
@ProtoEnumValue(number = 71)
IMPERSONATE_ERROR,
@ProtoEnumValue(number = 72)
CUSTOM_REQUIRED_ACTION,
@ProtoEnumValue(number = 73)
CUSTOM_REQUIRED_ACTION_ERROR,
@ProtoEnumValue(number = 74)
EXECUTE_ACTIONS,
@ProtoEnumValue(number = 75)
EXECUTE_ACTIONS_ERROR,
@ProtoEnumValue(number = 76)
EXECUTE_ACTION_TOKEN,
@ProtoEnumValue(number = 77)
EXECUTE_ACTION_TOKEN_ERROR,
@ProtoEnumValue(number = 78)
CLIENT_INFO,
@ProtoEnumValue(number = 79)
CLIENT_INFO_ERROR,
@ProtoEnumValue(number = 80)
CLIENT_REGISTER,
@ProtoEnumValue(number = 81)
CLIENT_REGISTER_ERROR,
@ProtoEnumValue(number = 82)
CLIENT_UPDATE,
@ProtoEnumValue(number = 83)
CLIENT_UPDATE_ERROR,
@ProtoEnumValue(number = 84)
CLIENT_DELETE,
@ProtoEnumValue(number = 85)
CLIENT_DELETE_ERROR,
@ProtoEnumValue(number = 86)
CLIENT_INITIATED_ACCOUNT_LINKING,
@ProtoEnumValue(number = 87)
CLIENT_INITIATED_ACCOUNT_LINKING_ERROR,
@ProtoEnumValue(number = 88)
TOKEN_EXCHANGE,
@ProtoEnumValue(number = 89)
TOKEN_EXCHANGE_ERROR,
@ProtoEnumValue(number = 90)
OAUTH2_DEVICE_AUTH,
@ProtoEnumValue(number = 91)
OAUTH2_DEVICE_AUTH_ERROR,
@ProtoEnumValue(number = 92)
OAUTH2_DEVICE_VERIFY_USER_CODE,
@ProtoEnumValue(number = 93)
OAUTH2_DEVICE_VERIFY_USER_CODE_ERROR,
@ProtoEnumValue(number = 94)
OAUTH2_DEVICE_CODE_TO_TOKEN,
@ProtoEnumValue(number = 95)
OAUTH2_DEVICE_CODE_TO_TOKEN_ERROR,
@ProtoEnumValue(number = 96)
AUTHREQID_TO_TOKEN,
@ProtoEnumValue(number = 97)
AUTHREQID_TO_TOKEN_ERROR,
@ProtoEnumValue(number = 98)
PERMISSION_TOKEN,
@ProtoEnumValue(number = 99)
PERMISSION_TOKEN_ERROR,
@ProtoEnumValue(number = 100)
DELETE_ACCOUNT,
@ProtoEnumValue(number = 101)
DELETE_ACCOUNT_ERROR,
@ProtoEnumValue(number = 102)
// PAR request.
PUSHED_AUTHORIZATION_REQUEST,
@ProtoEnumValue(number = 103)
PUSHED_AUTHORIZATION_REQUEST_ERROR;
}

View file

@ -1,31 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.events;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodOperationType {
@ProtoEnumValue(number = 0)
CREATE,
@ProtoEnumValue(number = 1)
UPDATE,
@ProtoEnumValue(number = 2)
DELETE,
@ProtoEnumValue(number = 3)
ACTION;
}

View file

@ -59,7 +59,6 @@ import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodOTPPolicyEntity
import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodRequiredActionProviderEntity;
import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodRequiredActionProviderEntityDelegate;
import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodRequiredCredentialEntity;
import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodRequirement;
import org.keycloak.models.map.storage.hotRod.realm.entity.HotRodWebAuthnPolicyEntity;
import java.util.Collections;
@ -96,7 +95,6 @@ public class HotRodRealmEntity extends AbstractHotRodEntity {
HotRodOTPPolicyEntity.class,
HotRodRequiredActionProviderEntity.class,
HotRodRequiredCredentialEntity.class,
HotRodRequirement.class,
HotRodWebAuthnPolicyEntity.class,
HotRodRealmEntity.class
},

View file

@ -15,7 +15,7 @@ public class HotRodAuthenticationExecutionEntity extends AbstractHotRodEntity {
@ProtoField(number = 3)
public Integer priority;
@ProtoField(number = 4)
public HotRodRequirement requirement;
public Integer requirement;
@ProtoField(number = 5)
public String authenticator;
@ProtoField(number = 6)

View file

@ -1,31 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.realm.entity;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodRequirement {
@ProtoEnumValue(number = 0)
REQUIRED,
@ProtoEnumValue(number = 1)
CONDITIONAL,
@ProtoEnumValue(number = 2)
ALTERNATIVE,
@ProtoEnumValue(number = 3, name = "EXECUTION_DISABLED")
DISABLED
}

View file

@ -1,34 +0,0 @@
/*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.models.map.storage.hotRod.userSession;
import org.infinispan.protostream.annotations.ProtoEnumValue;
public enum HotRodSessionState {
@ProtoEnumValue(number = 0)
LOGGED_IN,
@ProtoEnumValue(number = 1)
LOGGING_OUT,
@ProtoEnumValue(number = 2)
LOGGED_OUT,
@ProtoEnumValue(number = 3)
LOGGED_OUT_UNCONFIRMED
}

View file

@ -48,8 +48,7 @@ public class HotRodUserSessionEntity extends AbstractHotRodEntity {
@AutoProtoSchemaBuilder(
includeClasses = {
HotRodUserSessionEntity.class,
HotRodSessionState.class
HotRodUserSessionEntity.class
},
schemaFilePath = "proto/",
schemaPackageName = CommonPrimitivesProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE,
@ -110,7 +109,7 @@ public class HotRodUserSessionEntity extends AbstractHotRodEntity {
public Set<HotRodStringPair> notes;
@ProtoField(number = 15)
public HotRodSessionState state;
public Integer state;
@ProtoDoc("@Field(index = Index.YES, store = Store.YES)")
@ProtoField(number = 16)