net.oauth.OAuthValidator Java Examples
The following examples show how to use
net.oauth.OAuthValidator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataApiOAuthServlet.java From swellrt with Apache License 2.0 | 6 votes |
@Inject public DataApiOAuthServlet(@Named("request_token_path") String requestTokenPath, @Named("authorize_token_path") String authorizeTokenPath, @Named("access_token_path") String accessTokenPath, @Named("all_tokens_path") String allTokensPath, OAuthServiceProvider serviceProvider, OAuthValidator validator, DataApiTokenContainer tokenContainer, SessionManager sessionManager, TokenGenerator tokenGenerator) { this.requestTokenPath = requestTokenPath; this.authorizeTokenPath = authorizeTokenPath; this.accessTokenPath = accessTokenPath; this.allTokensPath = allTokensPath; this.serviceProvider = serviceProvider; this.validator = validator; this.tokenContainer = tokenContainer; this.sessionManager = sessionManager; this.tokenGenerator = tokenGenerator; this.xsrfTokens = CacheBuilder.newBuilder() .expireAfterWrite(XSRF_TOKEN_TIMEOUT_HOURS, TimeUnit.HOURS) .<ParticipantId, String>build().asMap(); }
Example #2
Source File: DataApiOAuthServlet.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
@Inject public DataApiOAuthServlet(@Named("request_token_path") String requestTokenPath, @Named("authorize_token_path") String authorizeTokenPath, @Named("access_token_path") String accessTokenPath, @Named("all_tokens_path") String allTokensPath, OAuthServiceProvider serviceProvider, OAuthValidator validator, DataApiTokenContainer tokenContainer, SessionManager sessionManager, TokenGenerator tokenGenerator) { this.requestTokenPath = requestTokenPath; this.authorizeTokenPath = authorizeTokenPath; this.accessTokenPath = accessTokenPath; this.allTokensPath = allTokensPath; this.serviceProvider = serviceProvider; this.validator = validator; this.tokenContainer = tokenContainer; this.sessionManager = sessionManager; this.tokenGenerator = tokenGenerator; this.xsrfTokens = CacheBuilder.newBuilder() .expireAfterWrite(XSRF_TOKEN_TIMEOUT_HOURS, TimeUnit.HOURS) .<ParticipantId, String>build().asMap(); }
Example #3
Source File: RobotApiModule.java From swellrt with Apache License 2.0 | 5 votes |
@Provides @Singleton protected OAuthValidator provideOAuthValidator() { // TODO(ljvderijk): This isn't an industrial strength validator, it grows // over time. It should be replaced or cleaned out on a regular interval. return new SimpleOAuthValidator(); }
Example #4
Source File: DataApiOAuthServletTest.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { validator = mock(OAuthValidator.class); sessionManager = mock(SessionManager.class); TokenGenerator tokenGenerator = mock(TokenGenerator.class); when(tokenGenerator.generateToken(anyInt())).thenReturn(FAKE_TOKEN); tokenContainer = new DataApiTokenContainer(tokenGenerator); req = mock(HttpServletRequest.class); when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com/robot")); when(req.getLocale()).thenReturn(Locale.ENGLISH); HttpSession sessionMock = mock(HttpSession.class); when(req.getSession()).thenReturn(sessionMock); when(req.getSession(anyBoolean())).thenReturn(sessionMock); resp = mock(HttpServletResponse.class); outputStream = new ServletOutputStreamStub(); when(resp.getOutputStream()).thenReturn(outputStream); outputWriter = new StringWriter(); when(resp.getWriter()).thenReturn(new PrintWriter(outputWriter)); OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", ""); consumer = new OAuthConsumer("", "consumerkey", "consumersecret", serviceProvider); servlet = new DataApiOAuthServlet(REQUEST_TOKEN_PATH, AUTHORIZE_TOKEN_PATH, ACCESS_TOKEN_PATH, GET_ALL_TOKENS_PATH, serviceProvider, validator, tokenContainer, sessionManager, tokenGenerator); }
Example #5
Source File: DataApiServletTest.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { robotSerializer = mock(RobotSerializer.class); converterManager = mock(EventDataConverterManager.class); waveletProvider = mock(WaveletProvider.class); operationRegistry = mock(OperationServiceRegistry.class); ConversationUtil conversationUtil = mock(ConversationUtil.class); validator = mock(OAuthValidator.class); TokenGenerator tokenGenerator = mock(TokenGenerator.class); when(tokenGenerator.generateToken(anyInt())).thenReturn(FAKE_TOKEN); tokenContainer = new DataApiTokenContainer(tokenGenerator); OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", ""); consumer = new OAuthConsumer("", "consumerkey", "consumersecret", serviceProvider); req = mock(HttpServletRequest.class); when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com")); when(req.getReader()).thenReturn(new BufferedReader(new StringReader(""))); when(req.getMethod()).thenReturn("POST"); resp = mock(HttpServletResponse.class); stringWriter = new StringWriter(); PrintWriter writer = new PrintWriter(stringWriter); when(resp.getWriter()).thenReturn(writer); servlet = new DataApiServlet(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, validator, tokenContainer); }
Example #6
Source File: ActiveApiServletTest.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { robotSerializer = mock(RobotSerializer.class); operationRegistry = mock(OperationServiceRegistry.class); validator = mock(OAuthValidator.class); EventDataConverterManager converterManager = mock(EventDataConverterManager.class); WaveletProvider waveletProvider = mock(WaveletProvider.class); ConversationUtil conversationUtil = mock(ConversationUtil.class); OAuthServiceProvider oAuthServiceProvider = mock(OAuthServiceProvider.class); AccountStore accountStore = mock(AccountStore.class); when(accountStore.getAccount(ROBOT)).thenReturn( new RobotAccountDataImpl(ROBOT, "", "secret", null, true)); req = mock(HttpServletRequest.class); when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com/robot")); when(req.getHeaderNames()).thenReturn( convertRawEnumerationToGeneric(new StringTokenizer("Authorization"))); when(req.getReader()).thenReturn(new BufferedReader(new StringReader(""))); resp = mock(HttpServletResponse.class); outputWriter = new StringWriter(); when(resp.getWriter()).thenReturn(new PrintWriter(outputWriter)); servlet = new ActiveApiServlet(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, oAuthServiceProvider, validator, accountStore); }
Example #7
Source File: DataApiServlet.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Inject public DataApiServlet(RobotSerializer robotSerializer, EventDataConverterManager converterManager, WaveletProvider waveletProvider, @Named("DataApiRegistry") OperationServiceRegistry operationRegistry, ConversationUtil conversationUtil, OAuthValidator validator, DataApiTokenContainer tokenContainer) { super(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, validator); this.tokenContainer = tokenContainer; }
Example #8
Source File: BaseApiServlet.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
public BaseApiServlet(RobotSerializer robotSerializer, EventDataConverterManager converterManager, WaveletProvider waveletProvider, OperationServiceRegistry operationRegistry, ConversationUtil conversationUtil, OAuthValidator validator) { this.robotSerializer = robotSerializer; this.converterManager = converterManager; this.waveletProvider = waveletProvider; this.conversationUtil = conversationUtil; this.operationRegistry = operationRegistry; this.validator = validator; }
Example #9
Source File: RobotApiModule.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Provides @Singleton protected OAuthValidator provideOAuthValidator() { // TODO(ljvderijk): This isn't an industrial strength validator, it grows // over time. It should be replaced or cleaned out on a regular interval. return new SimpleOAuthValidator(); }
Example #10
Source File: ActiveApiServlet.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
@Inject public ActiveApiServlet(RobotSerializer robotSerializer, EventDataConverterManager converterManager, WaveletProvider waveletProvider, @Named("ActiveApiRegistry") OperationServiceRegistry operationRegistry, ConversationUtil conversationUtil, OAuthServiceProvider oAuthServiceProvider, OAuthValidator validator, AccountStore accountStore) { super(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, validator); this.oauthServiceProvider = oAuthServiceProvider; this.accountStore = accountStore; }
Example #11
Source File: OAuthUtils.java From cxf with Apache License 2.0 | 5 votes |
public static void validateMessage(OAuthMessage oAuthMessage, Client client, Token token, OAuthDataProvider provider, OAuthValidator validator) throws Exception { OAuthConsumer consumer = new OAuthConsumer(null, client.getConsumerKey(), client.getSecretKey(), null); OAuthAccessor accessor = new OAuthAccessor(consumer); if (token != null) { if (token instanceof RequestToken) { accessor.requestToken = token.getTokenKey(); } else { accessor.accessToken = token.getTokenKey(); } accessor.tokenSecret = token.getTokenSecret(); } try { validator.validateMessage(oAuthMessage, accessor); } catch (Exception ex) { if (token != null) { provider.removeToken(token); } throw ex; } if (token != null && validator instanceof DefaultOAuthValidator) { ((DefaultOAuthValidator)validator).validateToken(token, provider); } }
Example #12
Source File: DataApiOAuthServletTest.java From swellrt with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { validator = mock(OAuthValidator.class); sessionManager = mock(SessionManager.class); TokenGenerator tokenGenerator = mock(TokenGenerator.class); when(tokenGenerator.generateToken(anyInt())).thenReturn(FAKE_TOKEN); tokenContainer = new DataApiTokenContainer(tokenGenerator); req = mock(HttpServletRequest.class); when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com/robot")); when(req.getLocale()).thenReturn(Locale.ENGLISH); HttpSession sessionMock = mock(HttpSession.class); when(req.getSession()).thenReturn(sessionMock); when(req.getSession(anyBoolean())).thenReturn(sessionMock); resp = mock(HttpServletResponse.class); outputStream = new ServletOutputStreamStub(); when(resp.getOutputStream()).thenReturn(outputStream); outputWriter = new StringWriter(); when(resp.getWriter()).thenReturn(new PrintWriter(outputWriter)); OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", ""); consumer = new OAuthConsumer("", "consumerkey", "consumersecret", serviceProvider); servlet = new DataApiOAuthServlet(REQUEST_TOKEN_PATH, AUTHORIZE_TOKEN_PATH, ACCESS_TOKEN_PATH, GET_ALL_TOKENS_PATH, serviceProvider, validator, tokenContainer, sessionManager, tokenGenerator); }
Example #13
Source File: DataApiServletTest.java From swellrt with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { robotSerializer = mock(RobotSerializer.class); converterManager = mock(EventDataConverterManager.class); waveletProvider = mock(WaveletProvider.class); operationRegistry = mock(OperationServiceRegistry.class); ConversationUtil conversationUtil = mock(ConversationUtil.class); validator = mock(OAuthValidator.class); TokenGenerator tokenGenerator = mock(TokenGenerator.class); when(tokenGenerator.generateToken(anyInt())).thenReturn(FAKE_TOKEN); tokenContainer = new DataApiTokenContainer(tokenGenerator); OAuthServiceProvider serviceProvider = new OAuthServiceProvider("", "", ""); consumer = new OAuthConsumer("", "consumerkey", "consumersecret", serviceProvider); req = mock(HttpServletRequest.class); when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com")); when(req.getReader()).thenReturn(new BufferedReader(new StringReader(""))); when(req.getMethod()).thenReturn("POST"); resp = mock(HttpServletResponse.class); stringWriter = new StringWriter(); PrintWriter writer = new PrintWriter(stringWriter); when(resp.getWriter()).thenReturn(writer); servlet = new DataApiServlet(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, validator, tokenContainer); }
Example #14
Source File: ActiveApiServletTest.java From swellrt with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { robotSerializer = mock(RobotSerializer.class); operationRegistry = mock(OperationServiceRegistry.class); validator = mock(OAuthValidator.class); EventDataConverterManager converterManager = mock(EventDataConverterManager.class); WaveletProvider waveletProvider = mock(WaveletProvider.class); ConversationUtil conversationUtil = mock(ConversationUtil.class); OAuthServiceProvider oAuthServiceProvider = mock(OAuthServiceProvider.class); AccountStore accountStore = mock(AccountStore.class); when(accountStore.getAccount(ROBOT)).thenReturn( new RobotAccountDataImpl(ROBOT, "", "secret", null, true)); req = mock(HttpServletRequest.class); when(req.getRequestURL()).thenReturn(new StringBuffer("www.example.com/robot")); when(req.getHeaderNames()).thenReturn( convertRawEnumerationToGeneric(new StringTokenizer("Authorization"))); when(req.getReader()).thenReturn(new BufferedReader(new StringReader(""))); resp = mock(HttpServletResponse.class); outputWriter = new StringWriter(); when(resp.getWriter()).thenReturn(new PrintWriter(outputWriter)); servlet = new ActiveApiServlet(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, oAuthServiceProvider, validator, accountStore); }
Example #15
Source File: DataApiServlet.java From swellrt with Apache License 2.0 | 5 votes |
@Inject public DataApiServlet(RobotSerializer robotSerializer, EventDataConverterManager converterManager, WaveletProvider waveletProvider, @Named("DataApiRegistry") OperationServiceRegistry operationRegistry, ConversationUtil conversationUtil, OAuthValidator validator, DataApiTokenContainer tokenContainer) { super(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, validator); this.tokenContainer = tokenContainer; }
Example #16
Source File: BaseApiServlet.java From swellrt with Apache License 2.0 | 5 votes |
public BaseApiServlet(RobotSerializer robotSerializer, EventDataConverterManager converterManager, WaveletProvider waveletProvider, OperationServiceRegistry operationRegistry, ConversationUtil conversationUtil, OAuthValidator validator) { this.robotSerializer = robotSerializer; this.converterManager = converterManager; this.waveletProvider = waveletProvider; this.conversationUtil = conversationUtil; this.operationRegistry = operationRegistry; this.validator = validator; }
Example #17
Source File: ActiveApiServlet.java From swellrt with Apache License 2.0 | 5 votes |
@Inject public ActiveApiServlet(RobotSerializer robotSerializer, EventDataConverterManager converterManager, WaveletProvider waveletProvider, @Named("ActiveApiRegistry") OperationServiceRegistry operationRegistry, ConversationUtil conversationUtil, OAuthServiceProvider oAuthServiceProvider, OAuthValidator validator, AccountStore accountStore) { super(robotSerializer, converterManager, waveletProvider, operationRegistry, conversationUtil, validator); this.oauthServiceProvider = oAuthServiceProvider; this.accountStore = accountStore; }
Example #18
Source File: AbstractOAuthService.java From cxf with Apache License 2.0 | 4 votes |
public void setValidator(OAuthValidator validator) { this.validator = validator; }
Example #19
Source File: AbstractAuthFilter.java From cxf with Apache License 2.0 | 4 votes |
public void setValidator(OAuthValidator validator) { this.validator = validator; }
Example #20
Source File: AbstractOAuthService.java From cxf with Apache License 2.0 | 4 votes |
public OAuthValidator getValidator() { return validator; }