use of org.bimserver.models.store.OAuthAuthorizationCode in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllPrivateProfiles.
@Override
public List<SProfileDescriptor> getAllPrivateProfiles(String notificationsUrl, String serviceIdentifier) throws ServerException, UserException {
if (notificationsUrl == null) {
throw new UserException("Missing notificationsUrl");
}
requireRealUserAuthentication();
try (DatabaseSession session = getBimServer().getDatabase().createSession()) {
try (BimServerClientFactory factory = new JsonBimServerClientFactory(notificationsUrl, getBimServer().getServicesMap(), getBimServer().getJsonSocketReflectorFactory(), getBimServer().getReflectorFactory(), getBimServer().getMetaDataManager())) {
BimServerClientInterface client = factory.create();
OAuthServer oAuthServer = session.querySingle(StorePackage.eINSTANCE.getOAuthServer_ApiUrl(), notificationsUrl);
User user = session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
for (OAuthAuthorizationCode oAuthAuthorizationCode : user.getOAuthAuthorizationCodes()) {
if (oAuthAuthorizationCode.getOauthServer() == oAuthServer) {
return client.getRemoteServiceInterface().getPrivateProfiles(serviceIdentifier, oAuthAuthorizationCode.getCode());
}
}
return null;
}
} catch (Exception e) {
return handleException(e);
}
}
Aggregations