本文整理汇总了Java中com.authlete.common.api.AuthleteApi类的典型用法代码示例。如果您正苦于以下问题:Java AuthleteApi类的具体用法?Java AuthleteApi怎么用?Java AuthleteApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthleteApi类属于com.authlete.common.api包,在下文中一共展示了AuthleteApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
private void execute(String[] args)
{
// Parse the command line arguments.
Settings settings = parseArguments(args);
// Validate the settings.
validateSettings(settings);
// Load "authlete.properties" and create an AuthleteApi instance.
AuthleteApi api = AuthleteApiFactory.getDefaultApi();
try
{
// Execute the specified API.
executeApi(api, settings);
}
catch (AuthleteApiException e)
{
// Report the error.
reportError(e);
}
}
示例2: executeGetClientApi
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
private void executeGetClientApi(AuthleteApi api, Settings settings)
{
String value = getFirstKeyOrExit(settings.parameters, "getClient", "clientId");
long clientId;
try
{
clientId = Long.parseLong(value);
}
catch (Exception e)
{
showErrorAndExit("The value of {clientId} is invalid.");
return;
}
// Get the client information.
verbose(settings, "Calling getClient(clientId=%d)", clientId);
Client client = api.getClient(clientId);
// Dump the client information.
System.out.println(Utils.toJson(client, true));
}
示例3: executeGetServiceApi
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
private void executeGetServiceApi(AuthleteApi api, Settings settings)
{
String value = getFirstKeyOrExit(settings.parameters, "getService", "serviceApiKey");
long serviceApiKey;
try
{
serviceApiKey = Long.parseLong(value);
}
catch (Exception e)
{
showErrorAndExit("The value of {serviceApiKey} is invalid.");
return;
}
// Get the service information.
verbose(settings, "Calling getService(serviceApiKey=%d)", serviceApiKey);
Service service = api.getService(serviceApiKey);
// Dump the service information.
System.out.println(Utils.toJson(service, true));
}
示例4: executeGetServiceListApi
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
private void executeGetServiceListApi(AuthleteApi api, Settings settings)
{
ServiceListResponse response;
if (settings.parameters.containsKey("start") || settings.parameters.containsKey("end"))
{
int start = getIntegerOrExitIfNeeded(settings.parameters, "start", 0);
int end = getIntegerOrExitIfNeeded(settings.parameters, "end", 5);
// Get the service list.
verbose(settings, "Calling getServiceList(start=%d, end=%d)", start, end);
response = api.getServiceList(start, end);
}
else
{
// Get the service list.
verbose(settings, "Calling getServiceList()");
response = api.getServiceList();
}
// Dump the list.
System.out.println(Utils.toJson(response, true));
}
示例5: executeApi
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
private void executeApi(AuthleteApi api, Settings settings)
{
switch (settings.apiName)
{
case GET_CLIENT:
executeGetClientApi(api, settings);
break;
case GET_CLIENT_AUTHORIZATION_LIST:
executeGetClientAuthorizationListApi(api, settings);
break;
case GET_CLIENT_LIST:
executeGetClientListApi(api, settings);
break;
case GET_SERVICE:
executeGetServiceApi(api, settings);
break;
case GET_SERVICE_CONFIGURATION:
executeGetServiceConfigurationApi(api, settings);
break;
case GET_SERVICE_JWKS:
executeGetServiceJwksApi(api, settings);
break;
case GET_SERVICE_LIST:
executeGetServiceListApi(api, settings);
break;
default:
// Not implemented unexpectedly.
throw new AssertionError(settings.apiName.name());
}
}
示例6: executeGetServiceConfigurationApi
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
private void executeGetServiceConfigurationApi(AuthleteApi api, Settings settings)
{
boolean pretty = getBoolean(settings.parameters, "pretty", true);
// Get the service configuration.
verbose(settings, "Calling getServiceConfiguration(pretty=%s)", pretty);
String configuration = api.getServiceConfiguration(pretty);
// Dump the configuration.
System.out.println(configuration);
}
示例7: executeGetServiceJwksApi
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
private void executeGetServiceJwksApi(AuthleteApi api, Settings settings)
{
boolean pretty = getBoolean(settings.parameters, "pretty", true);
boolean include = getBoolean(settings.parameters, "includePrivateKeys", false);
// Get the JWKS of the service.
verbose(settings, "Calling getServiceJwks(pretty=%s, includePrivateKeys=%s)", pretty, include);
String jwks = api.getServiceJwks(pretty, include);
// Dump the JWKS.
System.out.println(jwks);
}
示例8: BaseHandler
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
protected BaseHandler(AuthleteApi api)
{
mApiCaller = new AuthleteApiCaller(api);
}
示例9: handle
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
/**
* Handle a revocation request.
*
* <p>
* This method internally creates a {@link RevocationRequestHandler} instance
* and calls its {@link RevocationRequestHandler#handle(MultivaluedMap, String)
* handle()} method with the {@code parameters} argument and the {@code authorization}
* argument. Then, this method uses the value returned from the {@code handle()}
* method as a response from this method.
* </p>
*
* <p>
* When {@code RevocationRequestHandler.handle()} method raises a {@link
* WebApplicationException}, this method calls {@link #onError(WebApplicationException)
* onError()} method with the exception. The default implementation of {@code onError()}
* calls {@code printStackTrace()} of the exception and does nothing else. You
* can override the method as necessary. After calling {@code onError()} method,
* this method calls {@code getResponse()} method of the exception and uses the
* returned value as a response from this method.
* </p>
*
* @param api
* An implementation of {@link AuthleteApi}.
*
* @param parameters
* Request parameters of a revocation request.
*
* @param authorization
* The value of {@code Authorization} header.
*
* @return
* A response that should be returned to the client application.
*/
public Response handle(AuthleteApi api, MultivaluedMap<String, String> parameters, String authorization)
{
try
{
// Create a handler.
RevocationRequestHandler handler = new RevocationRequestHandler(api);
// Delegate the task to the handler.
return handler.handle(parameters, authorization);
}
catch (WebApplicationException e)
{
// An error occurred in the handler.
onError(e);
// Convert the error to a Response.
return e.getResponse();
}
}
示例10: handle
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
/**
* Handle an authorization request.
*
* <p>
* This method internally creates a {@link AuthorizationRequestHandler} instance and
* calls its {@link AuthorizationRequestHandler#handle(MultivaluedMap)} method.
* Then, this method uses the value returned from the {@code handle()} method
* as a response from this method.
* </p>
*
* <p>
* When {@code AuthorizationRequestHandler.handle()} method raises a {@link
* WebApplicationException}, this method calls {@link #onError(WebApplicationException)
* onError()} method with the exception. The default implementation of {@code onError()}
* calls {@code printStackTrace()} of the exception and does nothing else. You
* can override the method as necessary. After calling {@code onError()} method,
* this method calls {@code getResponse()} method of the exception and uses the
* returned value as a response from this method.
* </p>
*
* @param api
* An implementation of {@link AuthleteApi}.
*
* @param spi
* An implementation of {@link AuthorizationRequestHandlerSpi}.
*
* @param parameters
* Request parameters of the authorization request.
*
* @return
* A response that should be returned to the client application.
*/
public Response handle(
AuthleteApi api, AuthorizationRequestHandlerSpi spi,
MultivaluedMap<String, String> parameters)
{
try
{
// Create a handler.
AuthorizationRequestHandler handler = new AuthorizationRequestHandler(api, spi);
// Delegate the task to the handler.
return handler.handle(parameters);
}
catch (WebApplicationException e)
{
// An error occurred in the handler.
onError(e);
// Convert the error to a Response.
return e.getResponse();
}
}
示例11: handle
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
/**
* Handle a token request.
*
* <p>
* This method internally creates a {@link TokenRequestHandler} instance and
* calls its {@link TokenRequestHandler#handle(MultivaluedMap, String)} method.
* Then, this method uses the value returned from the {@code handle()} method
* as a response from this method.
* </p>
*
* <p>
* When {@code TokenRequestHandler.handle()} method raises a {@link
* WebApplicationException}, this method calls {@link #onError(WebApplicationException)
* onError()} method with the exception. The default implementation of {@code onError()}
* calls {@code printStackTrace()} of the exception and does nothing else. You
* can override the method as necessary. After calling {@code onError()} method,
* this method calls {@code getResponse()} method of the exception and uses the
* returned value as a response from this method.
* </p>
*
* @param api
* An implementation of {@link AuthleteApi}.
*
* @param spi
* An implementation of {@link TokenRequestHandlerSpi}.
*
* @param parameters
* Request parameters of the token request.
*
* @param authorization
* The value of {@code Authorization} header of the token request.
*
* @return
* A response that should be returned to the client application.
*/
public Response handle(
AuthleteApi api, TokenRequestHandlerSpi spi,
MultivaluedMap<String, String> parameters, String authorization)
{
try
{
// Create a handler.
TokenRequestHandler handler = new TokenRequestHandler(api, spi);
// Delegate the task to the handler.
return handler.handle(parameters, authorization);
}
catch (WebApplicationException e)
{
// An error occurred in the handler.
onError(e);
// Convert the error to a Response.
return e.getResponse();
}
}
示例12: handle
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
/**
* Handle a request for OpenID Provider configuration.
*
* <p>
* This method internally creates a {@link ConfigurationRequestHandler}
* instance and calls its {@link ConfigurationRequestHandler#handle()} method.
* Then, this method uses the value returned from the {@code handle()} method
* as a response from this method.
* </p>
*
* <p>
* When {@code ConfigurationRequestHandler.handle()} method raises a {@link
* WebApplicationException}, this method calls {@link #onError(WebApplicationException)
* onError()} method with the exception. The default implementation of {@code onError()}
* calls {@code printStackTrace()} of the exception and does nothing else. You
* can override the method as necessary. After calling {@code onError()} method,
* this method calls {@code getResponse()} method of the exception and uses the
* returned value as a response from this method.
* </p>
*
* @param api
* An implementation of {@link AuthleteApi}.
*
* @return
* A response that should be returned to the client application.
*/
public Response handle(AuthleteApi api)
{
try
{
// Create a handler.
ConfigurationRequestHandler handler = new ConfigurationRequestHandler(api);
// Delegate the task to the handler.
return handler.handle();
}
catch (WebApplicationException e)
{
// An error occurred in the handler.
onError(e);
// Convert the error to a Response.
return e.getResponse();
}
}
示例13: handle
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
/**
* Handle an introspection request.
*
* <p>
* This method internally creates an {@link IntrospectionRequestHandler}
* instance and calls its {@link IntrospectionRequestHandler#handle(MultivaluedMap)
* handle()} method with the {@code parameters} argument. Then, this
* method uses the value returned from the {@code handle()} method as a
* response from this method.
* </p>
*
* <p>
* When {@code IntrospectionRequestHandler.handle()} method raises a
* {@link WebApplicationException}, this method calls {@link
* #onError(WebApplicationException) onError()} method with the exception.
* The default implementation of {@code onError()} calls {@code
* printStackTrace()} of the exception and does nothing else. You can
* override the method as necessary. After calling {@code onError()}
* method, this method calls {@code getResponse()} method of the
* exception and uses the returned value as a response from this method.
* </p>
*
* @param api
* An implementation of {@link AuthleteApi}.
*
* @param parameters
* Request parameters of an introspection request.
*
* @return
* A response that should be returned to the client application.
*/
public Response handle(AuthleteApi api, MultivaluedMap<String, String> parameters)
{
try
{
// Create a handler.
IntrospectionRequestHandler handler = new IntrospectionRequestHandler(api);
// Delegate the task to the handler.
return handler.handle(parameters);
}
catch (WebApplicationException e)
{
// An error occurred in the handler.
onError(e);
// Convert the error to a Response.
return e.getResponse();
}
}
示例14: AuthleteApiCaller
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
/**
* Constructor with an implementation of {@link AuthleteApi} interface.
*/
AuthleteApiCaller(AuthleteApi api)
{
mApi = api;
}
示例15: handle
import com.authlete.common.api.AuthleteApi; //导入依赖的package包/类
/**
* Handle an authorization decision request.
*
* <p>
* This method internally creates a {@link AuthorizationDecisionHandler} instance and
* calls its {@link AuthorizationDecisionHandler#handle(String, String[], String[])}
* method. Then, this method uses the value returned from the {@code handle()} method
* as a response from this method.
* </p>
*
* <p>
* When {@code AuthorizationDecisionHandler.handle()} method raises a {@link
* WebApplicationException}, this method calls {@link #onError(WebApplicationException)
* onError()} method with the exception. The default implementation of {@code onError()}
* calls {@code printStackTrace()} of the exception and does nothing else. You
* can override the method as necessary. After calling {@code onError()} method,
* this method calls {@code getResponse()} method of the exception and uses the
* returned value as a response from this method.
* </p>
*
* @param api
* An implementation of {@link AuthleteApi}.
*
* @param spi
* An implementation of {@link AuthorizationDecisionHandlerSpi}.
*
* @param ticket
* A ticket that was issued by Authlete's {@code /api/auth/authorization} API.
*
* @param claimNames
* Names of requested claims. Use the value of the {@code claims}
* parameter in a response from Authlete's {@code /api/auth/authorization} API.
*
* @param claimLocales
* Requested claim locales. Use the value of the {@code claimsLocales}
* parameter in a response from Authlete's {@code /api/auth/authorization} API.
*
* @return
* A response that should be returned to the client application.
*/
public Response handle(
AuthleteApi api, AuthorizationDecisionHandlerSpi spi,
String ticket, String[] claimNames, String[] claimLocales)
{
try
{
// Create a handler.
AuthorizationDecisionHandler handler = new AuthorizationDecisionHandler(api, spi);
// Delegate the task to the handler.
return handler.handle(ticket, claimNames, claimLocales);
}
catch (WebApplicationException e)
{
// An error occurred in the handler.
onError(e);
// Convert the error to a Response.
return e.getResponse();
}
}