@Override protected IdentityType doPopulateEntry(Map<String, Serializable> properties) throws Exception { IdentityType identityType = super.doPopulateEntry(properties); String partitionType = properties.get("partitionType").toString(); String partitionId = properties.get("partitionId").toString(); Partition partition = (Partition) Class.forName(partitionType).getConstructor(new Class[]{String.class}).newInstance(""); partition.setId(partitionId); identityType.setPartition(partition); identityType.setCreatedDate((Date) properties.get("createdDate")); identityType.setExpirationDate((Date) properties.get("expirationDate")); identityType.setEnabled((Boolean) properties.get("enabled")); return identityType; }
@Override protected IdentityType doPopulateEntry(Map<String, Serializable> properties) throws Exception { IdentityType identityType = super.doPopulateEntry(properties); String partitionType = properties.get("partitionType").toString(); String partitionId = properties.get("partitionId").toString(); Partition partition = (Partition) Class.forName(partitionType).getConstructor(new Class[]{String.class}).newInstance(""); partition.setId(partitionId); identityType.setPartition(partition); identityType.setCreatedDate((Date) properties.get("createdDate")); identityType.setExpirationDate((Date) properties.get("expirationDate")); identityType.setEnabled((Boolean) properties.get("enabled")); return identityType; }
/** * <p> * Creates a {@link IdentityType} instance using the information from the given Identity Class instance. This method already * provides the mapping for the common properties for all {@link IdentityType} types. * </p> * * @param realm * @param identity * @return */ public T createIdentityType(Realm realm, Object identity, JPAIdentityStore store) { T identityType = doCreateIdentityType(identity, store); identityType.setEnabled(store.getModelProperty(Boolean.class, identity, PROPERTY_IDENTITY_ENABLED)); identityType.setExpirationDate(store.getModelProperty(Date.class, identity, JPAIdentityStoreConfiguration.PROPERTY_IDENTITY_EXPIRES)); identityType.setCreatedDate(store.getModelProperty(Date.class, identity, JPAIdentityStoreConfiguration.PROPERTY_IDENTITY_CREATED)); return identityType; }
/** * <p> * Updated the common properties for a specific {@link IdentityType} instance from another instance. * </p> * * @param fromIdentityType * @param toIdentityType */ private void updateCommonProperties(IdentityType fromIdentityType, IdentityType toIdentityType) { toIdentityType.setEnabled(fromIdentityType.isEnabled()); toIdentityType.setCreatedDate(fromIdentityType.getCreatedDate()); toIdentityType.setExpirationDate(fromIdentityType.getExpirationDate()); for (Object object : toIdentityType.getAttributes().toArray()) { Attribute<? extends Serializable> attribute = (Attribute<? extends Serializable>) object; toIdentityType.removeAttribute(attribute.getName()); } for (Attribute<? extends Serializable> attrib : fromIdentityType.getAttributes()) { toIdentityType.setAttribute(attrib); } }
/** * <p> * Disables an user. * </p> * * @throws Exception */ @Test public void testDisable() throws Exception { T enabledIdentityTypeInstance = getIdentityType(true); assertTrue(enabledIdentityTypeInstance.isEnabled()); enabledIdentityTypeInstance.setEnabled(false); updateIdentityType(enabledIdentityTypeInstance); T disabledIdentityTypeInstance = getIdentityType(false); assertFalse(disabledIdentityTypeInstance.isEnabled()); disabledIdentityTypeInstance.setEnabled(true); updateIdentityType(disabledIdentityTypeInstance); enabledIdentityTypeInstance = getIdentityType(false); assertTrue(enabledIdentityTypeInstance.isEnabled()); }
clonedIdentityType.setExpirationDate(identityType.getExpirationDate()); clonedIdentityType.setCreatedDate(identityType.getCreatedDate()); clonedIdentityType.setEnabled(identityType.isEnabled()); } else if (Relationship.class.isInstance(attributedType)) { Relationship relationship = (Relationship) attributedType;
clonedIdentityType.setExpirationDate(identityType.getExpirationDate()); clonedIdentityType.setCreatedDate(identityType.getCreatedDate()); clonedIdentityType.setEnabled(identityType.isEnabled()); } else if (Relationship.class.isInstance(attributedType)) { Relationship relationship = (Relationship) attributedType;