use of oauth.common.ConsumerRegistration in project tesb-rt-se by Talend.
the class ThirdPartyRegistrationService method registerForm.
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/")
public ConsumerRegistration registerForm(@FormParam("appName") String appName, @FormParam("appURI") String appURI) {
String clientId = generateClientId(appName, appURI);
String clientSecret = generateClientSecret();
Client newClient = new Client(clientId, clientSecret, appName, appURI);
manager.registerClient(newClient);
return new ConsumerRegistration(clientId, clientSecret);
}
use of oauth.common.ConsumerRegistration in project tesb-rt-se by Talend.
the class ThirdPartyRegistrationService method register.
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/")
public ConsumerRegistration register(MultipartBody body) {
String appName = body.getAttachmentObject("appName", String.class);
String appURI = body.getAttachmentObject("appURI", String.class);
String appDesc = body.getAttachmentObject("appDescription", String.class);
URI logoURI = null;
Attachment att = body.getAttachment("appLogo");
if (att != null) {
InputStream logoStream = att.getObject(InputStream.class);
CachedOutputStream cos = new CachedOutputStream();
try {
IOUtils.copy(logoStream, cos);
appLogos.put(appName.toLowerCase(), cos);
UriBuilder ub = uriInfo.getAbsolutePathBuilder();
ub.path("logo").path(appName.toLowerCase());
ContentDisposition cd = att.getContentDisposition();
if (cd != null && cd.getParameter("filename") != null) {
ub.path(cd.getParameter("filename"));
}
logoURI = ub.build();
} catch (IOException ex) {
// ignore
}
}
String clientId = generateClientId(appName, appURI);
String clientSecret = generateClientSecret();
Client newClient = new Client(clientId, clientSecret, appName, appURI);
newClient.setApplicationDescription(appDesc);
newClient.setLogoUri(logoURI.toString());
manager.registerClient(newClient);
return new ConsumerRegistration(clientId, clientSecret);
}
Aggregations