private <I extends IdentityType> I extractIdentityTypeFromToken(T token, Class<I> identityType, StereotypeProperty.Property stereotypeProperty, Object identifier) { if (hasIdentityType(token, stereotypeProperty, identifier)) { try { I identityTypeInstance = Reflections.newInstance(identityType); Property property = resolveProperty(identityType, stereotypeProperty); property.setValue(identityTypeInstance, identifier); if (Account.class.isAssignableFrom(identityType)) { Property userNameProperty = resolveProperty(identityType, StereotypeProperty.Property.IDENTITY_USER_NAME); userNameProperty.setValue(identityTypeInstance, extractSubject(token)); } return identityTypeInstance; } catch (Exception e) { throw new IdentityManagementException("Could not extract IdentityType [" + identityType + "] from Token [" + token + "].", e); } } return null; }
private <I extends IdentityType> I extractIdentityTypeFromToken(T token, Class<I> identityType, StereotypeProperty.Property stereotypeProperty, Object identifier) { if (hasIdentityType(token, stereotypeProperty, identifier)) { try { I identityTypeInstance = Reflections.newInstance(identityType); Property property = resolveProperty(identityType, stereotypeProperty); property.setValue(identityTypeInstance, identifier); if (Account.class.isAssignableFrom(identityType)) { Property userNameProperty = resolveProperty(identityType, StereotypeProperty.Property.IDENTITY_USER_NAME); userNameProperty.setValue(identityTypeInstance, extractSubject(token)); } return identityTypeInstance; } catch (Exception e) { throw new IdentityManagementException("Could not extract IdentityType [" + identityType + "] from Token [" + token + "].", e); } } return null; }