public class OpenIdServiceImpl extends WebProtegeRemoteServiceServlet implements OpenIdService {
private static final long serialVersionUID = 3551138317576962582L;
public OpenIdData getUsersOpenId(String name) {
OpenIdData oIdData = new OpenIdData();
try {
List<String> openIdList = new ArrayList<String>();
List<String> openIdAccId = new ArrayList<String>();
List<String> openIdProvider = new ArrayList<String>();
User user = MetaProjectManager.getManager().getMetaProject().getUser(name);
Collection<PropertyValue> propColl = user.getPropertyValues();
for (Iterator<PropertyValue> iterator = propColl.iterator(); iterator.hasNext();) {
PropertyValue propertyValue = iterator.next();
if (propertyValue.getPropertyName().startsWith(OpenIdConstants.OPENID_PROPERTY_PREFIX)
&& propertyValue.getPropertyName().endsWith(OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX)) {
String openIdAccNamePropName = propertyValue.getPropertyName().replace(
OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX, OpenIdConstants.OPENID_PROPERTY_ID_SUFFIX);
String openIdProvdNamePropName = propertyValue.getPropertyName()
.replace(OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX,
OpenIdConstants.OPENID_PROPERTY_PROVIDER_SUFFIX);
String openIdAccNamePropValue = user.getPropertyValue(openIdAccNamePropName);
String openIdProvdNamePropValue = user.getPropertyValue(openIdProvdNamePropName);
openIdList.add(propertyValue.getPropertyValue());
openIdAccId.add(openIdAccNamePropValue);
openIdProvider.add(openIdProvdNamePropValue);
}
}
oIdData.setName(name);
oIdData.setOpenIdList(openIdList);
oIdData.setOpenIdAccId(openIdAccId);
oIdData.setOpenIdProvider(openIdProvider);
} catch (Exception e) {
Log.getLogger().log(Level.WARNING, "Errors at retrieving Users OpenId:", e);
}
return oIdData;
}