97 ClientDetailsEntity client;
104 if (authorizedGrantTypes != null && !authorizedGrantTypes.isEmpty()
105 && !authorizedGrantTypes.contains(DeviceTokenGranter.GRANT_TYPE)) {
106 throw new InvalidClientException(
"Unauthorized grant type: " + DeviceTokenGranter.GRANT_TYPE);
109 }
catch (IllegalArgumentException e) {
110 logger.error(
"IllegalArgumentException was thrown when attempting to load client", e);
111 model.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
112 return HttpCodeView.VIEWNAME;
115 if (client == null) {
116 logger.error(
"could not find client " + clientId);
117 model.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
118 return HttpCodeView.VIEWNAME;
122 Set<String> requestedScopes = OAuth2Utils.parseParameterList(scope);
123 Set<String> allowedScopes = client.getScope();
127 logger.error(
"Client asked for " + requestedScopes +
" but is allowed " + allowedScopes);
128 model.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
129 model.put(JsonErrorView.ERROR,
"invalid_scope");
130 return JsonErrorView.VIEWNAME;
138 Map<String, Object> response =
new HashMap<>();
139 response.put(
"device_code", dc.getDeviceCode());
140 response.put(
"user_code", dc.getUserCode());
142 if (client.getDeviceCodeValiditySeconds() != null) {
143 response.put(
"expires_in", client.getDeviceCodeValiditySeconds());
146 model.put(JsonEntityView.ENTITY, response);
149 return JsonEntityView.VIEWNAME;
150 }
catch (DeviceCodeCreationException dcce) {
152 model.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
153 model.put(JsonErrorView.ERROR, dcce.getError());
154 model.put(JsonErrorView.ERROR_MESSAGE, dcce.getMessage());
156 return JsonErrorView.VIEWNAME;
SystemScopeService scopeService
Definition: DeviceEndpoint.java:83
ClientDetailsEntityService clientService
Definition: DeviceEndpoint.java:80
static final Logger logger
Definition: DeviceEndpoint.java:77
ConfigurationPropertiesBean config
Definition: DeviceEndpoint.java:86
static final String USER_URL
Definition: DeviceEndpoint.java:75
Set< String > getAuthorizedGrantTypes()
Definition: ClientDetailsEntity.java:475
boolean scopesMatch(Set< String > expected, Set< String > actual)
DeviceCode createNewDeviceCode(Set< String > requestedScopes, ClientDetailsEntity client, Map< String, String > parameters)
ClientDetailsEntity loadClientByClientId(String clientId)
DeviceCodeService deviceCodeService
Definition: DeviceEndpoint.java:89
String getIssuer()
Definition: ConfigurationPropertiesBean.java:100