@GET public Response getAuthenticate(@QueryParam("oauth_token") String token){ OAuthServerRequest request = new OAuthServerRequest(requestContext); OAuth1Parameters params = new OAuth1Parameters(); params.readRequest(request); log.trace("params:{}", params.toString()); String tok = params.getToken(); log.trace("check token: {}",tok); if (tok == null || tok.contentEquals("")) { throw new OAuth1Exception(Response.Status.BAD_REQUEST, null); } Set<String> roles = new HashSet<>(); roles.add("user"); String verifier = ((DefaultOAuth1Provider)provider).authorizeToken(((DefaultOAuth1Provider)provider).getRequestToken(tok), null, roles); log.debug("verifier:{}",verifier); return Response.ok().entity(verifier).build(); } }
@Override public void filter(ContainerRequestContext requestContext) throws IOException { final Method handlingMethod = uriInfo.get().getMatchedResourceMethod().getInvocable().getHandlingMethod(); if (handlingMethod.isAnnotationPresent(TokenResource.class) || handlingMethod.getDeclaringClass().isAnnotationPresent(TokenResource.class)) { return; } OAuthServerRequest request = new OAuthServerRequest(requestContext); OAuth1Parameters params = new OAuth1Parameters(); params.readRequest(request); log.trace("params:{}", params.toString()); String tok = params.getToken(); log.trace("check token: {}", tok); OAuth1Token accessToken = provider.getAccessToken(tok); if (accessToken != null) { log.debug("is in user role:{}", accessToken.isInRole("user")); }else{ log.debug("no access token"); } // requestContext.setSecurityContext(new eu.agrosense.spi.fispace.server.SecurityContext(requestContext)); } //
params.readRequest(request); log.trace("params:{}", params.toString());