Search in sources :

Example 1 with OAuthAuthorizationResponseBuilder

use of org.apache.oltu.oauth2.as.response.OAuthASResponse.OAuthAuthorizationResponseBuilder in project BIMserver by opensourceBIM.

the class OAuthAuthorizationServlet method makeUrl.

private URI makeUrl(String redirectURI, OAuthAuthorizationCode oauthCode, OAuthAuthorizationResponseBuilder builder) throws OAuthSystemException, URISyntaxException {
    OAuthAuthorizationResponseBuilder build = builder.location(redirectURI).setParam("address", getBimServer().getServerSettingsCache().getServerSettings().getSiteAddress() + "/json");
    build.setParam("serviceaddress", getBimServer().getServerSettingsCache().getServerSettings().getSiteAddress() + "/services");
    if (oauthCode.getAuthorization() instanceof SingleProjectAuthorization) {
        SingleProjectAuthorization singleProjectAuthorization = (SingleProjectAuthorization) oauthCode.getAuthorization();
        build.setParam("poid", "" + singleProjectAuthorization.getProject().getOid());
    } else if (oauthCode.getAuthorization() instanceof RunServiceAuthorization) {
        RunServiceAuthorization auth = (RunServiceAuthorization) oauthCode.getAuthorization();
        build.setParam("soid", "" + auth.getService().getOid());
    }
    final OAuthResponse response = build.buildQueryMessage();
    String locationUri = response.getLocationUri();
    URI url = new URI(locationUri);
    return url;
}
Also used : OAuthAuthorizationResponseBuilder(org.apache.oltu.oauth2.as.response.OAuthASResponse.OAuthAuthorizationResponseBuilder) SingleProjectAuthorization(org.bimserver.models.store.SingleProjectAuthorization) RunServiceAuthorization(org.bimserver.models.store.RunServiceAuthorization) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 OAuthAuthorizationResponseBuilder (org.apache.oltu.oauth2.as.response.OAuthASResponse.OAuthAuthorizationResponseBuilder)1 OAuthResponse (org.apache.oltu.oauth2.common.message.OAuthResponse)1 RunServiceAuthorization (org.bimserver.models.store.RunServiceAuthorization)1 SingleProjectAuthorization (org.bimserver.models.store.SingleProjectAuthorization)1