use of edu.uiuc.ncsa.security.delegation.client.request.DelegationResponse in project OA4MP by ncsa.
the class AbstractOA4MPService method requestCert.
protected OA4MPResponse requestCert(Asset asset, Map additionalParameters) {
if (additionalParameters == null) {
additionalParameters = new HashMap();
}
try {
preRequestCert(asset, additionalParameters);
OA4MPResponse mpdsResponse = new OA4MPResponse();
mpdsResponse.setPrivateKey(asset.getPrivateKey());
DelegationRequest daReq = new DelegationRequest();
daReq.setParameters(additionalParameters);
daReq.setClient(getEnvironment().getClient());
daReq.setBaseUri(getEnvironment().getAuthorizationUri());
DelegationResponse daResp = (DelegationResponse) getEnvironment().getDelegationService().process(daReq);
if (daResp.getAuthorizationGrant() != null) {
asset.setToken(BasicIdentifier.newID(daResp.getAuthorizationGrant().getToken()));
if (asset.getIdentifier() == null) {
asset.setIdentifier(makeb64Uri(daResp.getAuthorizationGrant().getToken().toString()));
}
}
String skin = getEnvironment().getSkin();
String r = daResp.getRedirectUri().toString();
if (skin != null) {
r = r + "&" + SKIN_PARAMETER + "=" + skin;
}
// FIXME!! For OAuth 2, how do we introduce the skin parameter if there is no rewriting of the url before
// getting forwarded to an Authz module? Might have to send it across in the initial call.
mpdsResponse.setRedirect(URI.create(r));
getAssetStore().save(asset);
postRequestCert(asset, mpdsResponse);
return mpdsResponse;
} catch (Throwable e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new GeneralException("Error generating request", e);
}
}
Aggregations