@Override public ServerAccessToken createAccessToken(final AccessTokenRegistration accessToken) throws OAuthServiceException { if (!accessToken.getRequestedScope().contains(OAuthConstants.REFRESH_TOKEN_SCOPE)) { accessToken.setRequestedScope(new ArrayList<>(accessToken.getRequestedScope())); accessToken.getRequestedScope().add(OAuthConstants.REFRESH_TOKEN_SCOPE); } if (!accessToken.getApprovedScope().contains(OAuthConstants.REFRESH_TOKEN_SCOPE)) { accessToken.setApprovedScope(new ArrayList<>(accessToken.getApprovedScope())); accessToken.getApprovedScope().add(OAuthConstants.REFRESH_TOKEN_SCOPE); } return delegate.createAccessToken(accessToken); }
@POST @Consumes("application/x-www-form-urlencoded") @Produces("text/html") public Response authorize(MultivaluedMap<String, String> params) { SecurityContext sc = getAndValidateSecurityContext(params); Client client = getClient(params); // Create a UserSubject representing the end user UserSubject userSubject = createUserSubject(sc, params); AccessTokenRegistration reg = new AccessTokenRegistration(); reg.setClient(client); reg.setGrantType(OAuthConstants.DIRECT_TOKEN_GRANT); reg.setSubject(userSubject); String providedScope = params.getFirst(OAuthConstants.SCOPE); List<String> requestedScope = OAuthUtils.getRequestedScopes(client, providedScope, useAllClientScopes, partialMatchScopeValidation); reg.setRequestedScope(requestedScope); reg.setApprovedScope(requestedScope); ServerAccessToken token = getDataProvider().createAccessToken(reg); ClientAccessToken clientToken = OAuthUtils.toClientAccessToken(token, isWriteOptionalParameters()); return Response.ok(clientToken).build(); }
@POST @Consumes("application/x-www-form-urlencoded") @Produces("text/html") public Response authorize(MultivaluedMap<String, String> params) { SecurityContext sc = getAndValidateSecurityContext(params); Client client = getClient(params); // Create a UserSubject representing the end user UserSubject userSubject = createUserSubject(sc, params); AccessTokenRegistration reg = new AccessTokenRegistration(); reg.setClient(client); reg.setGrantType(OAuthConstants.DIRECT_TOKEN_GRANT); reg.setSubject(userSubject); String providedScope = params.getFirst(OAuthConstants.SCOPE); List<String> requestedScope = OAuthUtils.getRequestedScopes(client, providedScope, useAllClientScopes, partialMatchScopeValidation); reg.setRequestedScope(requestedScope); reg.setApprovedScope(requestedScope); ServerAccessToken token = getDataProvider().createAccessToken(reg); ClientAccessToken clientToken = OAuthUtils.toClientAccessToken(token, isWriteOptionalParameters()); return Response.ok(clientToken).build(); }
protected ServerAccessToken doCreateAccessToken(Client client, UserSubject subject, String requestedGrant, List<String> requestedScopes, List<String> audiences) { ServerAccessToken token = getPreAuthorizedToken(client, subject, requestedGrant, requestedScopes, audiences); if (token != null) { return token; } // Delegate to the data provider to create the one AccessTokenRegistration reg = new AccessTokenRegistration(); reg.setClient(client); reg.setGrantType(requestedGrant); reg.setSubject(subject); reg.setRequestedScope(requestedScopes); reg.setApprovedScope(getApprovedScopes(client, subject, requestedScopes)); reg.setAudiences(audiences); return dataProvider.createAccessToken(reg); }
protected ServerAccessToken doCreateAccessToken(Client client, UserSubject subject, String requestedGrant, List<String> requestedScopes, List<String> audiences) { ServerAccessToken token = getPreAuthorizedToken(client, subject, requestedGrant, requestedScopes, audiences); if (token != null) { return token; } // Delegate to the data provider to create the one AccessTokenRegistration reg = new AccessTokenRegistration(); reg.setClient(client); reg.setGrantType(requestedGrant); reg.setSubject(subject); reg.setRequestedScope(requestedScopes); reg.setApprovedScope(getApprovedScopes(client, subject, requestedScopes)); reg.setAudiences(audiences); return dataProvider.createAccessToken(reg); }
protected AccessTokenRegistration createTokenRegistration(OAuthRedirectionState state, Client client, List<String> requestedScope, List<String> approvedScope, UserSubject userSubject) { AccessTokenRegistration reg = new AccessTokenRegistration(); reg.setClient(client); reg.setGrantType(super.getSupportedGrantType()); reg.setResponseType(state.getResponseType()); reg.setSubject(userSubject); reg.setRequestedScope(requestedScope); reg.setApprovedScope(getApprovedScope(requestedScope, approvedScope)); reg.setAudiences(Collections.singletonList(state.getAudience())); reg.setNonce(state.getNonce()); reg.getExtraProperties().putAll(state.getExtraProperties()); return reg; } protected void finalizeResponse(StringBuilder sb, OAuthRedirectionState state) {
protected AccessTokenRegistration createTokenRegistration(OAuthRedirectionState state, Client client, List<String> requestedScope, List<String> approvedScope, UserSubject userSubject) { AccessTokenRegistration reg = new AccessTokenRegistration(); reg.setClient(client); reg.setGrantType(super.getSupportedGrantType()); reg.setResponseType(state.getResponseType()); reg.setSubject(userSubject); reg.setRequestedScope(requestedScope); reg.setApprovedScope(getApprovedScope(requestedScope, approvedScope)); reg.setAudiences(Collections.singletonList(state.getAudience())); reg.setNonce(state.getNonce()); reg.getExtraProperties().putAll(state.getExtraProperties()); return reg; } protected void finalizeResponse(StringBuilder sb, OAuthRedirectionState state) {
reg.setGrantType(requestedGrant); reg.setSubject(grant.getSubject()); reg.setRequestedScope(grant.getRequestedScopes()); reg.setNonce(grant.getNonce()); if (grant.getApprovedScopes() != null) {
reg.setGrantType(requestedGrant); reg.setSubject(grant.getSubject()); reg.setRequestedScope(grant.getRequestedScopes()); reg.setNonce(grant.getNonce()); if (grant.getApprovedScopes() != null) {