use of com.authlete.common.dto.Client in project authlete-java-common by authlete.
the class CLI method executeGetClientApi.
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));
}
use of com.authlete.common.dto.Client in project java-oauth-server by authlete.
the class ObbUtils method isObbDynamicClient.
/**
* Judge whether the client identified by the client ID is a client that
* has been dynamically registered for Open Banking Brasil.
*
* @param api
* An implementation of {@link AuthleteApi}.
*
* @param clientId
* A client ID.
*
* @return
* {@code true} if the client identified by the client ID is a
* client that has been dynamically registered for Open Banking
* Brasil.
*
* @see <a href="https://openbanking-brasil.github.io/specs-seguranca/open-banking-brasil-dynamic-client-registration-1_ID1.html"
* >Open Banking Brasil Financial-grade API Dynamic Client Registration 1.0 Implementers Draft 1</a>
*/
@SuppressWarnings("unchecked")
public static boolean isObbDynamicClient(AuthleteApi api, String clientId) {
Client client;
try {
// Get information about the client identified by the client ID
// by calling Authlete's /api/client/get/{clientIdentifier} API.
client = api.getClient(clientId);
} catch (Exception e) {
// The API call failed.
return false;
}
if (client == null) {
// Client information is not available.
return false;
}
// Custom metadata of the client. This implementation assumes that
// a client is registered with some client metadata.
String json = client.getCustomMetadata();
if (json == null) {
// The client does not have custom metadata.
return false;
}
Map<String, Object> metadata;
try {
// Parse the string as JSON.
metadata = Utils.fromJson(json, Map.class);
} catch (Exception e) {
// Failed to parse the string as JSON.
return false;
}
// If the custom metadata does not contain "software_roles".
if (!metadata.containsKey("software_roles")) {
return false;
}
return true;
}
use of com.authlete.common.dto.Client in project java-oauth-server by authlete.
the class AuthorizationDecisionEndpoint method post.
/**
* Process a request from the form in the authorization page.
*
* <p>
* NOTE:
* A better implementation would re-display the authorization page
* when the pair of login ID and password is wrong, but this
* implementation does not do it for brevity. A much better
* implementation would check the login credentials by Ajax.
* </p>
*
* @param request
* A request from the form in the authorization page.
*
* @param parameters
* Request parameters.
*
* @return
* A response to the user agent. Basically, the response
* will trigger redirection to the client's redirect
* endpoint.
*/
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response post(@Context HttpServletRequest request, MultivaluedMap<String, String> parameters) {
// Get the existing session.
HttpSession session = getSession(request);
// Retrieve some variables from the session. See the implementation
// of AuthorizationRequestHandlerSpiImpl.getAuthorizationPage().
Params params = (Params) takeAttribute(session, "params");
String[] acrs = (String[]) takeAttribute(session, "acrs");
Client client = (Client) takeAttribute(session, "client");
User user = getUser(session, parameters);
Date authTime = (Date) session.getAttribute("authTime");
// Implementation of AuthorizationDecisionHandlerSpi.
AuthorizationDecisionHandlerSpi spi = new AuthorizationDecisionHandlerSpiImpl(parameters, user, authTime, params.getIdTokenClaims(), acrs, client);
// Handle the end-user's decision.
return handle(AuthleteApiFactory.getDefaultApi(), spi, params);
}
Aggregations