org.jasig.cas.web.support.ArgumentExtractor Java Examples
The following examples show how to use
org.jasig.cas.web.support.ArgumentExtractor.
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: RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractorTests.java From cas-mfa with Apache License 2.0 | 6 votes |
@Test public void testServiceWithDifferentServiceType() { final List<ArgumentExtractor> set = new ArrayList<>(); set.add(new CasArgumentExtractor()); final MultiFactorWebApplicationServiceFactory factory = mock(MultiFactorWebApplicationServiceFactory.class); final AuthenticationMethodVerifier verifier = mock(AuthenticationMethodVerifier.class); final RegisteredService svc = mock(RegisteredService.class); when(svc.getId()).thenReturn(0L); when(svc.getServiceId()).thenReturn(CAS_SERVICE); final ServicesManager mgmr = mock(ServicesManager.class); when(mgmr.findServiceBy(anyInt())).thenReturn(svc); when(mgmr.findServiceBy(any(Service.class))).thenReturn(svc); final RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor extractor = new RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor(set, factory, mgmr, verifier); final MultiFactorAuthenticationSupportingWebApplicationService webSvc = (MultiFactorAuthenticationSupportingWebApplicationService) extractor.extractService(getRequest()); assertNull(webSvc); }
Example #2
Source File: RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractorTests.java From cas-mfa with Apache License 2.0 | 6 votes |
@Test public void testServiceWithNoAttributeValue() { final List<ArgumentExtractor> set = new ArrayList<>(); set.add(new CasArgumentExtractor()); final MultiFactorWebApplicationServiceFactory factory = mock(MultiFactorWebApplicationServiceFactory.class); final AuthenticationMethodVerifier verifier = mock(AuthenticationMethodVerifier.class); final RegisteredService svc = TestUtils.getRegisteredService(CAS_SERVICE); final DefaultRegisteredServiceProperty prop = new DefaultRegisteredServiceProperty(); svc.getProperties().put(MultiFactorAuthenticationSupportingWebApplicationService.CONST_PARAM_AUTHN_METHOD, prop); final ServicesManager mgmr = mock(ServicesManager.class); when(mgmr.findServiceBy(anyInt())).thenReturn(svc); when(mgmr.findServiceBy(any(Service.class))).thenReturn(svc); final RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor extractor = new RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor(set, factory, mgmr, verifier); final MultiFactorAuthenticationSupportingWebApplicationService webSvc = (MultiFactorAuthenticationSupportingWebApplicationService) extractor.extractService(getRequest()); assertNull(webSvc); }
Example #3
Source File: AbstractMultiFactorAuthenticationArgumentExtractor.java From cas-mfa with Apache License 2.0 | 6 votes |
/** * Extract a target service. Delegates to wrapped argument extractors. * * @param request http request * * @return target service that would potentially be wrapped with an MFA supporting service */ private WebApplicationService getTargetService(final HttpServletRequest request) { WebApplicationService targetService = null; for (final ArgumentExtractor extractor : this.supportedArgumentExtractors) { targetService = extractor.extractService(request); if (targetService != null) { logger.debug("[{}] intercepted the request successfully for multifactor authentication", extractor); break; } } if (targetService == null) { logger.debug("Request is unable to identify the target application"); return null; } return targetService; }
Example #4
Source File: ServiceThemeResolverTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { this.servicesManager = new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl()); this.serviceThemeResolver = new ServiceThemeResolver(); this.serviceThemeResolver.setDefaultThemeName("test"); this.serviceThemeResolver.setServicesManager(this.servicesManager); this.serviceThemeResolver.setArgumentExtractors(Arrays.asList((ArgumentExtractor) new CasArgumentExtractor())); final Map<String, String> mobileBrowsers = new HashMap<String, String>(); mobileBrowsers.put("Mozilla", "theme"); this.serviceThemeResolver.setMobileBrowsers(mobileBrowsers); }
Example #5
Source File: RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractorTests.java From cas-mfa with Apache License 2.0 | 5 votes |
@Test public void testServiceWithMfaRole() { final List<ArgumentExtractor> set = new ArrayList<>(); set.add(new CasArgumentExtractor()); final MultiFactorWebApplicationServiceFactory factory = mock(MultiFactorWebApplicationServiceFactory.class); when(factory.create(anyString(), anyString(), anyString(), any(Response.ResponseType.class), anyString(), any(AuthenticationMethodSource.class))) .thenReturn(getMfaService()); final AuthenticationMethodVerifier verifier = mock(AuthenticationMethodVerifier.class); final RegisteredService svc = TestUtils.getRegisteredService(CAS_SERVICE); DefaultRegisteredServiceProperty prop = new DefaultRegisteredServiceProperty(); prop.setValues(Collections.singleton(CAS_AUTHN_METHOD)); svc.getProperties().put(MultiFactorAuthenticationSupportingWebApplicationService.CONST_PARAM_AUTHN_METHOD, prop); prop = new DefaultRegisteredServiceProperty(); svc.getProperties().put(RegisteredServiceMfaRoleProcessor.MFA_ATTRIBUTE_NAME, prop); prop = new DefaultRegisteredServiceProperty(); prop.setValues(Collections.singleton(CAS_AUTHN_METHOD)); svc.getProperties().put(RegisteredServiceMfaRoleProcessor.MFA_ATTRIBUTE_PATTERN, prop); final ServicesManager mgmr = mock(ServicesManager.class); when(mgmr.findServiceBy(anyInt())).thenReturn(svc); when(mgmr.findServiceBy(any(Service.class))).thenReturn(svc); final RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor extractor = new RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor(set, factory, mgmr, verifier); final MultiFactorAuthenticationSupportingWebApplicationService webSvc = (MultiFactorAuthenticationSupportingWebApplicationService) extractor.extractService(getRequest()); assertNull(webSvc); }
Example #6
Source File: RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractorTests.java From cas-mfa with Apache License 2.0 | 5 votes |
@Test public void testServiceWithDefaultMfaAttribute() { final List<ArgumentExtractor> set = new ArrayList<>(); set.add(new CasArgumentExtractor()); final MultiFactorWebApplicationServiceFactory factory = mock(MultiFactorWebApplicationServiceFactory.class); when(factory.create(anyString(), anyString(), anyString(), any(Response.ResponseType.class), anyString(), any(AuthenticationMethodSource.class))) .thenReturn(getMfaService()); final AuthenticationMethodVerifier verifier = mock(AuthenticationMethodVerifier.class); final RegisteredService svc = TestUtils.getRegisteredService(CAS_SERVICE); final DefaultRegisteredServiceProperty prop = new DefaultRegisteredServiceProperty(); prop.setValues(Collections.singleton(CAS_AUTHN_METHOD)); svc.getProperties().put(MultiFactorAuthenticationSupportingWebApplicationService.CONST_PARAM_AUTHN_METHOD, prop); final ServicesManager mgmr = mock(ServicesManager.class); when(mgmr.findServiceBy(anyInt())).thenReturn(svc); when(mgmr.findServiceBy(any(Service.class))).thenReturn(svc); final RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor extractor = new RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor(set, factory, mgmr, verifier); final MultiFactorAuthenticationSupportingWebApplicationService webSvc = (MultiFactorAuthenticationSupportingWebApplicationService) extractor.extractService(getRequest()); assertNotNull(webSvc); assertEquals(webSvc.getAuthenticationMethod(), CAS_AUTHN_METHOD); }
Example #7
Source File: CasMultiFactorApplicationContextAware.java From cas-mfa with Apache License 2.0 | 5 votes |
/** * Add multifactor argument extractor configuration. */ private void addMultifactorArgumentExtractorConfiguration() { LOGGER.debug("Configuring application context with [{}]", mfaRequestsCollectingArgumentExtractor.getClass().getName()); final List<ArgumentExtractor> list = this.flowBuilderServices.getApplicationContext().getBean("argumentExtractors", List.class); list.add(0, mfaRequestsCollectingArgumentExtractor); }
Example #8
Source File: AbstractMultiFactorAuthenticationArgumentExtractor.java From cas-mfa with Apache License 2.0 | 5 votes |
/** * Ctor. * @param supportedArgumentExtractors supportedArgumentExtractors * @param mfaWebApplicationServiceFactory mfaWebApplicationServiceFactory * @param authenticationMethodVerifier authenticationMethodVerifier */ public AbstractMultiFactorAuthenticationArgumentExtractor(final List<ArgumentExtractor> supportedArgumentExtractors, final MultiFactorWebApplicationServiceFactory mfaWebApplicationServiceFactory, final AuthenticationMethodVerifier authenticationMethodVerifier) { this.supportedArgumentExtractors = supportedArgumentExtractors; this.mfaWebApplicationServiceFactory = mfaWebApplicationServiceFactory; this.authenticationMethodVerifier = authenticationMethodVerifier; }
Example #9
Source File: WebUtilTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyFindService() { final SamlArgumentExtractor openIdArgumentExtractor = new SamlArgumentExtractor(); final CasArgumentExtractor casArgumentExtractor = new CasArgumentExtractor(); final ArgumentExtractor[] argumentExtractors = new ArgumentExtractor[] { openIdArgumentExtractor, casArgumentExtractor}; final MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("service", "test"); final Service service = WebUtils.getService(Arrays .asList(argumentExtractors), request); assertEquals("test", service.getId()); }
Example #10
Source File: InitialFlowSetupActionTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { this.warnCookieGenerator = new CookieRetrievingCookieGenerator(); this.warnCookieGenerator.setCookiePath(""); this.tgtCookieGenerator = new CookieRetrievingCookieGenerator(); this.tgtCookieGenerator.setCookiePath(""); this.action.setTicketGrantingTicketCookieGenerator(this.tgtCookieGenerator); this.action.setWarnCookieGenerator(this.warnCookieGenerator); final ArgumentExtractor[] argExtractors = new ArgumentExtractor[] {new CasArgumentExtractor()}; this.action.setArgumentExtractors(Arrays.asList(argExtractors)); this.action.afterPropertiesSet(); this.action.afterPropertiesSet(); }
Example #11
Source File: WebUtilTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testFoundNoService() { final SamlArgumentExtractor openIdArgumentExtractor = new SamlArgumentExtractor(); final ArgumentExtractor[] argumentExtractors = new ArgumentExtractor[] { openIdArgumentExtractor}; final MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("service", "test"); final Service service = WebUtils.getService(Arrays .asList(argumentExtractors), request); assertNull(service); }
Example #12
Source File: WebUtilTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testFindService() { final SamlArgumentExtractor openIdArgumentExtractor = new SamlArgumentExtractor(); final CasArgumentExtractor casArgumentExtractor = new CasArgumentExtractor(); final ArgumentExtractor[] argumentExtractors = new ArgumentExtractor[] { openIdArgumentExtractor, casArgumentExtractor}; final MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("service", "test"); final Service service = WebUtils.getService(Arrays .asList(argumentExtractors), request); assertEquals("test", service.getId()); }
Example #13
Source File: InitialFlowSetupActionTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Before public void setUp() throws Exception { this.warnCookieGenerator = new CookieRetrievingCookieGenerator(); this.tgtCookieGenerator = new CookieRetrievingCookieGenerator(); this.action.setTicketGrantingTicketCookieGenerator(this.tgtCookieGenerator); this.action.setWarnCookieGenerator(this.warnCookieGenerator); final ArgumentExtractor[] argExtractors = new ArgumentExtractor[] {new CasArgumentExtractor()}; this.action.setArgumentExtractors(Arrays.asList(argExtractors)); this.servicesManager = mock(ServicesManager.class); when(this.servicesManager.findServiceBy(any(Service.class))).thenReturn(TestUtils.getRegisteredService("test")); this.action.setServicesManager(this.servicesManager); this.action.afterPropertiesSet(); }
Example #14
Source File: WebUtilTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyFoundNoService() { final SamlArgumentExtractor openIdArgumentExtractor = new SamlArgumentExtractor(); final ArgumentExtractor[] argumentExtractors = new ArgumentExtractor[] { openIdArgumentExtractor}; final MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter("service", "test"); final Service service = WebUtils.getService(Arrays .asList(argumentExtractors), request); assertNull(service); }
Example #15
Source File: ServiceThemeResolver.java From cas4.0.x-server-wechat with Apache License 2.0 | 4 votes |
public void setArgumentExtractors(final List<ArgumentExtractor> argumentExtractors) { this.argumentExtractors = argumentExtractors; }
Example #16
Source File: ServiceValidateController.java From cas4.0.x-server-wechat with Apache License 2.0 | 4 votes |
public final void setArgumentExtractor(final ArgumentExtractor argumentExtractor) { this.argumentExtractor = argumentExtractor; }
Example #17
Source File: ConfigurableUserAgentOverrideThemeResolver.java From uPortal-start with Apache License 2.0 | 4 votes |
public void setArgumentExtractors(final List<ArgumentExtractor> argumentExtractors) { this.argumentExtractors = argumentExtractors; }
Example #18
Source File: InitialFlowSetupAction.java From cas4.0.x-server-wechat with Apache License 2.0 | 4 votes |
public void setArgumentExtractors( final List<ArgumentExtractor> argumentExtractors) { this.argumentExtractors = argumentExtractors; }
Example #19
Source File: ServiceValidateController.java From springboot-shiro-cas-mybatis with MIT License | 4 votes |
public final void setArgumentExtractor(final ArgumentExtractor argumentExtractor) { this.argumentExtractor = argumentExtractor; }
Example #20
Source File: InitialFlowSetupAction.java From springboot-shiro-cas-mybatis with MIT License | 4 votes |
public void setArgumentExtractors(final List<ArgumentExtractor> argumentExtractors) { this.argumentExtractors = argumentExtractors; }
Example #21
Source File: RequestParameterMultiFactorAuthenticationArgumentExtractor.java From cas-mfa with Apache License 2.0 | 3 votes |
/** * Ctor. * * @param supportedArgumentExtractors supported protocols by argument extractors * @param mfaWebApplicationServiceFactory mfaWebApplicationServiceFactory * @param authenticationMethodVerifier authenticationMethodVerifier */ public RequestParameterMultiFactorAuthenticationArgumentExtractor(final List<ArgumentExtractor> supportedArgumentExtractors, final MultiFactorWebApplicationServiceFactory mfaWebApplicationServiceFactory, final AuthenticationMethodVerifier authenticationMethodVerifier) { super(supportedArgumentExtractors, mfaWebApplicationServiceFactory, authenticationMethodVerifier); }
Example #22
Source File: RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor.java From cas-mfa with Apache License 2.0 | 3 votes |
/** * Ctor. * * @param supportedArgumentExtractors supported protocols by argument extractors * @param mfaWebApplicationServiceFactory mfaWebApplicationServiceFactory * @param servicesManager services manager * @param authenticationMethodVerifier authenticationMethodVerifier */ public RegisteredServiceAttributeMultiFactorAuthenticationArgumentExtractor(final List<ArgumentExtractor> supportedArgumentExtractors, final MultiFactorWebApplicationServiceFactory mfaWebApplicationServiceFactory, final ServicesManager servicesManager, final AuthenticationMethodVerifier authenticationMethodVerifier) { super(supportedArgumentExtractors, mfaWebApplicationServiceFactory, authenticationMethodVerifier); this.servicesManager = servicesManager; }