本文整理汇总了Java中com.nimbusds.oauth2.sdk.client.ClientRegistrationResponse类的典型用法代码示例。如果您正苦于以下问题:Java ClientRegistrationResponse类的具体用法?Java ClientRegistrationResponse怎么用?Java ClientRegistrationResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClientRegistrationResponse类属于com.nimbusds.oauth2.sdk.client包,在下文中一共展示了ClientRegistrationResponse类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doPreExecute
import com.nimbusds.oauth2.sdk.client.ClientRegistrationResponse; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
if (!super.doPreExecute(profileRequestContext)) {
log.error("{} pre-execute failed", getLogPrefix());
return false;
}
if (profileRequestContext.getOutboundMessageContext() == null) {
log.error("{} Unable to locate outbound message context", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
return false;
}
Object message = profileRequestContext.getOutboundMessageContext().getMessage();
if (message == null || !(message instanceof ClientRegistrationResponse)) {
log.error("{} Unable to locate outbound message", getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
return false;
}
response = (ClientRegistrationResponse) message;
return true;
}
示例2: getClientRegistrations
import com.nimbusds.oauth2.sdk.client.ClientRegistrationResponse; //导入依赖的package包/类
@GetMapping
public void getClientRegistrations(HttpServletRequest request, HttpServletResponse response) throws Exception {
HTTPRequest httpRequest = ServletUtils.createHTTPRequest(request);
try {
String authorizationHeader = httpRequest.getAuthorization();
if (authorizationHeader == null) {
throw new GeneralException(BearerTokenError.INVALID_TOKEN);
}
BearerAccessToken requestAccessToken = BearerAccessToken.parse(authorizationHeader);
validateAccessToken(requestAccessToken);
List<OIDCClientInformation> clients = this.clientRepository.findAll();
response.setContentType("application/json; charset=UTF-8");
PrintWriter writer = response.getWriter();
writer.print(toJsonObject(clients).toJSONString());
writer.close();
}
catch (GeneralException e) {
ClientRegistrationResponse registrationResponse = new ClientRegistrationErrorResponse(e.getErrorObject());
ServletUtils.applyHTTPResponse(registrationResponse.toHTTPResponse(), response);
}
}
示例3: deleteClientConfiguration
import com.nimbusds.oauth2.sdk.client.ClientRegistrationResponse; //导入依赖的package包/类
@DeleteMapping(path = "/{id:.*}")
public void deleteClientConfiguration(HttpServletRequest request, HttpServletResponse response,
@PathVariable ClientID id) throws IOException {
HTTPRequest httpRequest = ServletUtils.createHTTPRequest(request);
try {
ClientDeleteRequest clientDeleteRequest = ClientDeleteRequest.parse(httpRequest);
resolveAndValidateClient(id, clientDeleteRequest);
this.clientRepository.deleteById(id);
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
catch (GeneralException e) {
ClientRegistrationResponse registrationResponse = new ClientRegistrationErrorResponse(e.getErrorObject());
ServletUtils.applyHTTPResponse(registrationResponse.toHTTPResponse(), response);
}
}
示例4: registerClient
import com.nimbusds.oauth2.sdk.client.ClientRegistrationResponse; //导入依赖的package包/类
/**
* Client registration
* If the provider supports dynamic registration, a new client can be registered using the client registration process:
*
* @param initialAccessToken the initial access token
* @throws SerializeException the serialize exception
* @throws IOException Signals that an I/O exception has occurred.
* @throws ParseException the parse exception
* @throws KeyStoreException
* @throws CertificateException
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public void registerClient(BearerAccessToken initialAccessToken) throws SerializeException, IOException, ParseException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException {
// System.out.println("Client metadata");
// System.out.println(metadata.toJSONObject());
// Make registration request
OIDCClientRegistrationRequest registrationRequest = new OIDCClientRegistrationRequest(providerMetadata.getRegistrationEndpointURI(), clientMetadata, initialAccessToken);
HTTPResponse regHTTPResponse = registrationRequest.toHTTPRequest().send(null, Trust.getSocketFactory(trustStoreFile));
// Parse and check response
ClientRegistrationResponse registrationResponse = OIDCClientRegistrationResponseParser.parse(regHTTPResponse);
if (registrationResponse instanceof ClientRegistrationErrorResponse) {
ClientRegistrationErrorResponse errorResponse = ((ClientRegistrationErrorResponse) registrationResponse);
ErrorObject error = errorResponse.getErrorObject();
System.err.println(this.getClass().getSimpleName() + " - " + errorResponse.indicatesSuccess());
System.err.println("Dynamic Client Registration failed, Error:");
System.err.println(errorResponse);
System.err.println(error);
System.err.println(regHTTPResponse.getStatusCode());
System.err.println(regHTTPResponse.getContent());
System.err.println(regHTTPResponse.getWWWAuthenticate());
System.err.println(regHTTPResponse.getLocation());
} else {
clientInformation = ((OIDCClientInformationResponse) registrationResponse).getOIDCClientInformation();
clientID = clientInformation.getID();
}
}