use of org.bimserver.interfaces.objects.SOAuthServer in project BIMserver by opensourceBIM.
the class OAuthServiceImpl method listRegisteredServersLocal.
@Override
public List<SOAuthServer> listRegisteredServersLocal() throws ServerException, UserException {
try (DatabaseSession session = getBimServer().getDatabase().createSession()) {
List<OAuthServer> allOfType = session.getAllOfType(StorePackage.eINSTANCE.getOAuthServer(), OAuthServer.class, OldQuery.getDefault());
Iterator<OAuthServer> iterator = allOfType.iterator();
while (iterator.hasNext()) {
OAuthServer next = iterator.next();
if (!next.isIncoming()) {
iterator.remove();
}
}
return getBimServer().getSConverter().convertToSListOAuthServer(allOfType);
} catch (BimserverDatabaseException e) {
return handleException(e);
}
}
use of org.bimserver.interfaces.objects.SOAuthServer in project BIMserver by opensourceBIM.
the class OAuthServiceImpl method listRegisteredServers.
@Override
public List<SOAuthServer> listRegisteredServers() throws ServerException, UserException {
try (DatabaseSession session = getBimServer().getDatabase().createSession()) {
List<OAuthServer> allOfType = session.getAllOfType(StorePackage.eINSTANCE.getOAuthServer(), OAuthServer.class, OldQuery.getDefault());
Iterator<OAuthServer> iterator = allOfType.iterator();
while (iterator.hasNext()) {
OAuthServer next = iterator.next();
if (next.isIncoming()) {
iterator.remove();
}
}
return getBimServer().getSConverter().convertToSListOAuthServer(allOfType);
} catch (BimserverDatabaseException e) {
return handleException(e);
}
}
use of org.bimserver.interfaces.objects.SOAuthServer in project BIMserver by opensourceBIM.
the class OAuthServiceImpl method registerRemoteApplication.
public SOAuthServer registerRemoteApplication(String redirectUrl, String name, String description) throws UserException {
try {
OAuthClientRequest request = OAuthClientRegistrationRequest.location(getBimServer().getServerSettingsCache().getServerSettings().getSiteAddress() + "/oauth/register/", OAuthRegistration.Type.PUSH).setName(name).setUrl(redirectUrl).setDescription(description).setRedirectURL(redirectUrl).buildJSONMessage();
OAuthRegistrationClient oauthclient = new OAuthRegistrationClient(new org.bimserver.webservices.impl.URLConnectionClient());
OAuthClientRegistrationResponse response = oauthclient.clientInfo(request);
SOAuthServer server = new SOAuthServer();
server.setClientId(response.getClientId());
server.setClientSecret(response.getClientSecret());
return server;
} catch (Exception e) {
throw new UserException(e);
}
}
Aggregations