@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> * Expires an user. * </p> * * @throws Exception */ @Test public void testExpiration() throws Exception { T validIdentityTypeInstance = getIdentityType(true); Date expirationDate = new Date(); validIdentityTypeInstance.setExpirationDate(expirationDate); updateIdentityType(validIdentityTypeInstance); T expiredIdentityTypeInstance = getIdentityType(false); Thread.sleep(500); assertNotNull(expiredIdentityTypeInstance.getExpirationDate()); assertTrue(new Date().after(expiredIdentityTypeInstance.getExpirationDate())); assertTrue(expirationDate.compareTo(expiredIdentityTypeInstance.getExpirationDate()) == 0); }
/** * <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); } }
clonedIdentityType.setExpirationDate(identityType.getExpirationDate()); clonedIdentityType.setCreatedDate(identityType.getCreatedDate()); clonedIdentityType.setEnabled(identityType.isEnabled());
clonedIdentityType.setExpirationDate(identityType.getExpirationDate()); clonedIdentityType.setCreatedDate(identityType.getCreatedDate()); clonedIdentityType.setEnabled(identityType.isEnabled());