java中的case1怎么说_Java Cas20ServiceTicketValidator類代碼示例

本文整理匯總了Java中org.jasig.cas.client.validation.Cas20ServiceTicketValidator類的典型用法代碼示例。如果您正苦於以下問題:Java Cas20ServiceTicketValidator類的具體用法?Java Cas20ServiceTicketValidator怎麽用?Java Cas20ServiceTicketValidator使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

Cas20ServiceTicketValidator類屬於org.jasig.cas.client.validation包,在下文中一共展示了Cas20ServiceTicketValidator類的18個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: init

​點讚 3

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

public void init(FilterConfig filterConfig) throws ServletException {

String casServerLoginUrl = "http://sso.jadyer.com:8080/cas-server-web/login";

String casServerUrlPrefix = "http://sso.jadyer.com:8080/cas-server-web";

String casClientServerName = "http://boss.jadyer.com:8080";

AuthenticationFilter casAuthenticationFilter = new AuthenticationFilter();

casAuthenticationFilter.setCasServerLoginUrl(casServerLoginUrl);

casAuthenticationFilter.setServerName(casClientServerName);

Cas20ProxyReceivingTicketValidationFilter casTicketValidationFilter = new Cas20ProxyReceivingTicketValidationFilter();

casTicketValidationFilter.setServerName(casClientServerName);

casTicketValidationFilter.setTicketValidator(new Cas20ServiceTicketValidator(casServerUrlPrefix));

filters[0] = new SingleSignOutFilter();

//filters[1] = new AuthenticationFilter();

//filters[2] = new Cas20ProxyReceivingTicketValidationFilter();

filters[1] = casAuthenticationFilter;

filters[2] = casTicketValidationFilter;

filters[3] = new HttpServletRequestWrapperFilter();

filters[4] = new AssertionThreadLocalFilter();

for(Filter obj : filters){

System.out.println("[複合Filter]-->Initializing Filter defined in ApplicationContext: '" + obj.toString() + "'");

obj.init(filterConfig);

}

}

開發者ID:v5java,項目名稱:demo-cas-client,代碼行數:23,

示例2: getCas20ProxyReceivingTicketValidationFilter

​點讚 3

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

public Cas20ProxyReceivingTicketValidationFilter getCas20ProxyReceivingTicketValidationFilter() {

Cas20ProxyReceivingTicketValidationFilter cas20ProxyReceivingTicketValidationFilter = new Cas20ProxyReceivingTicketValidationFilter();

cas20ProxyReceivingTicketValidationFilter.setServerName(serverUrl);

cas20ProxyReceivingTicketValidationFilter.setTicketValidator(new Cas20ServiceTicketValidator(casServerUrlPrefix));

cas20ProxyReceivingTicketValidationFilter.setRedirectAfterValidation(true);

return cas20ProxyReceivingTicketValidationFilter;

}

開發者ID:XiaoMi,項目名稱:shepher,代碼行數:8,

示例3: authenticate

​點讚 3

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Override

public Authentication authenticate(Authentication authentication) throws AuthenticationException {

if (authentication.getDetails() instanceof ProxyCallbackAndServiceAuthenticationDetails &&

getTicketValidator() instanceof Cas20ServiceTicketValidator) {

String proxyCallbackUrl = ((ProxyCallbackAndServiceAuthenticationDetails) authentication.getDetails())

.getProxyCallbackUrl();

((Cas20ServiceTicketValidator) getTicketValidator()).setProxyCallbackUrl(proxyCallbackUrl);

}

return super.authenticate(authentication);

}

開發者ID:kakawait,項目名稱:cas-security-spring-boot-starter,代碼行數:11,

示例4: build

​點讚 3

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Override

public TicketValidator build() {

Cas20ServiceTicketValidator ticketValidator = new Cas20ServiceTicketValidator(casServerUrlPrefix);

if (proxyChainsValidation != null) {

logger.warn(OMISSION_MESSAGE_TEMPLATE, "proxyChainsValidation");

}

if (proxyChains != null) {

logger.warn(OMISSION_MESSAGE_TEMPLATE, "proxyChains");

}

if (allowEmptyProxyChain != null) {

logger.warn(OMISSION_MESSAGE_TEMPLATE, "allowEmptyProxyChain");

}

configure(ticketValidator);

return ticketValidator;

}

開發者ID:kakawait,項目名稱:cas-security-spring-boot-starter,代碼行數:16,

示例5: configure

​點讚 3

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Override

protected void configure(Cas20ServiceTicketValidator ticketValidator) {

super.configure(ticketValidator);

if (proxyGrantingTicketStorage != null) {

ticketValidator.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);

}

if (proxyRetriever != null) {

ticketValidator.setProxyRetriever(proxyRetriever);

}

if (StringUtils.hasText(proxyCallbackUrl)) {

ticketValidator.setProxyCallbackUrl(proxyCallbackUrl);

}

}

開發者ID:kakawait,項目名稱:cas-security-spring-boot-starter,代碼行數:14,

示例6: testDoGetBadTicket

​點讚 3

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Test

public void testDoGetBadTicket() throws Exception {

//Mock some objects.

HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET, TICKET, "false");

HttpServletResponse response = createMockHttpServletResponse();

Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas20ServiceTicketValidator.class);

PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION)).thenThrow(new TicketValidationException("Invalid Ticket"));

PowerMockito.mockStatic(ExternalAuthentication.class);

BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willThrow(new ExternalAuthenticationException());

//Prep our object

ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

//Override the internal Cas20TicketValidator because we don't want it to call a real server

MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

//Standard request/response - bad ticket

BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("false");

BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("false");

shibcasAuthServlet.doGet(request, response);

//Verify

verify(request).getRequestDispatcher("/no-conversation-state.jsp");

verify(response).setStatus(404);

}

開發者ID:Unicon,項目名稱:shib-cas-authn3,代碼行數:27,

示例7: casAuthenticationProvider

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Bean

@ConditionalOnMissingBean(CasAuthenticationProvider.class)

public CasAuthenticationProvider casAuthenticationProvider(){

CasAuthenticationProvider casProvider = new CasAuthenticationProvider();

casProvider.setAuthenticationUserDetailsService(new UserDetailsByNameServiceWrapper<>(userDetailsService));

casProvider.setServiceProperties(serviceProperties());

casProvider.setTicketValidator(new Cas20ServiceTicketValidator(bootSecurityConfig.getCas().getCasServerUrl()));

casProvider.setKey(bootSecurityConfig.getCas().getKey());

return casProvider;

}

開發者ID:wayshall,項目名稱:onetwo,代碼行數:11,

示例8: testDoGetStandard

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Test

public void testDoGetStandard() throws Exception {

//Mock some objects.

HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET, TICKET, null);

HttpServletResponse response = createMockHttpServletResponse();

Assertion assertion = createMockAssertion();

Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas20ServiceTicketValidator.class);

PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION)).thenReturn(assertion);

PowerMockito.mockStatic(ExternalAuthentication.class);

BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);

//Prep our object

ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

//Override the internal Cas20TicketValidator because we don't want it to call a real server

MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

//Standard request/response

BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("false");

BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("false");

shibcasAuthServlet.doGet(request, response);

//Verify

verify(request).setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, JDOE);

}

開發者ID:Unicon,項目名稱:shib-cas-authn3,代碼行數:28,

示例9: testDoGetPassiveAuthenticated

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Test

public void testDoGetPassiveAuthenticated() throws Exception {

//Mock some objects.

HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET + "&gatewayAttempted=true", TICKET, "true");

HttpServletResponse response = createMockHttpServletResponse();

Assertion assertion = createMockAssertion();

Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas20ServiceTicketValidator.class);

PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION_GATEWAY_ATTEMPTED)).thenReturn(assertion);

PowerMockito.mockStatic(ExternalAuthentication.class);

BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);

//Prep our object

ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

//Override the internal Cas20TicketValidator because we don't want it to call a real server

MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

//Passive request/response with authenticated user

BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("false");

BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("true");

shibcasAuthServlet.doGet(request, response);

//Verify

verify(request).setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, JDOE);

}

開發者ID:Unicon,項目名稱:shib-cas-authn3,代碼行數:28,

示例10: testDoGetPassiveNotAuthenticated

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Test

public void testDoGetPassiveNotAuthenticated() throws Exception {

//Mock some objects.

HttpServletRequest request = createDoGetHttpServletRequest("conversation=e1s1&gatewayAttempted=true", null, "true");

HttpServletResponse response = createMockHttpServletResponse();

Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas20ServiceTicketValidator.class);

PowerMockito.mockStatic(ExternalAuthentication.class);

BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);

//Prep our object

ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

//Override the internal Cas20TicketValidator because we don't want it to call a real server

MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

//Passive request/response with no user

BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("false");

BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("true");

shibcasAuthServlet.doGet(request, response);

//Verify

verify(request, never()).setAttribute(eq(ExternalAuthentication.PRINCIPAL_NAME_KEY), any());

verify(request).setAttribute(ExternalAuthentication.AUTHENTICATION_ERROR_KEY, "NoPassive");

verify(ticketValidator, never()).validate(anyString(), anyString());

}

開發者ID:Unicon,項目名稱:shib-cas-authn3,代碼行數:28,

示例11: testDoGetForced

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Test

public void testDoGetForced() throws Exception {

//Mock some objects.

HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET, TICKET, null);

HttpServletResponse response = createMockHttpServletResponse();

Assertion assertion = createMockAssertion();

Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas20ServiceTicketValidator.class);

PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION)).thenReturn(assertion);

PowerMockito.mockStatic(ExternalAuthentication.class);

BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);

//Prep our object

ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

//Override the internal Cas20TicketValidator because we don't want it to call a real server

MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

//Forced request/response

BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("true");

BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("false");

shibcasAuthServlet.doGet(request, response);

//Verify

verify(request).setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, JDOE);

}

開發者ID:Unicon,項目名稱:shib-cas-authn3,代碼行數:28,

示例12: testDoGetPassiveAndForced

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Test

public void testDoGetPassiveAndForced() throws Exception {

//Mock some objects.

HttpServletRequest request = createDoGetHttpServletRequest(CONVERSATION_TICKET_GATEWAY_ATTEMPTED, TICKET, "true");

HttpServletResponse response = createMockHttpServletResponse();

Assertion assertion = createMockAssertion();

Cas20ServiceTicketValidator ticketValidator = PowerMockito.mock(Cas30ServiceTicketValidator.class);

PowerMockito.when(ticketValidator.validate(TICKET, URL_WITH_CONVERSATION_GATEWAY_ATTEMPTED)).thenReturn(assertion);

PowerMockito.mockStatic(ExternalAuthentication.class);

BDDMockito.given(ExternalAuthentication.startExternalAuthentication(request)).willReturn(E1S1);

//Prep our object

ShibcasAuthServlet shibcasAuthServlet = createShibcasAuthServlet();

//Override the internal Cas30TicketValidator because we don't want it to call a real server

MemberModifier.field(ShibcasAuthServlet.class, "ticketValidator").set(shibcasAuthServlet, ticketValidator);

//Passive and forced request/response

BDDMockito.given(request.getAttribute(ExternalAuthentication.FORCE_AUTHN_PARAM)).willReturn("true");

BDDMockito.given(request.getAttribute(ExternalAuthentication.PASSIVE_AUTHN_PARAM)).willReturn("true");

shibcasAuthServlet.doGet(request, response);

//Verify

verify(request).setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, JDOE);

}

開發者ID:Unicon,項目名稱:shib-cas-authn3,代碼行數:28,

示例13: instantiateValidator

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

public Cas20ServiceTicketValidator instantiateValidator()

{

Cas20ServiceTicketValidator toReturn = new Cas20ServiceTicketValidator(casServiceUrl);

toReturn.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);

toReturn.setProxyCallbackUrl(proxyCallbackUrl);

return toReturn;

}

開發者ID:ozoneplatform,項目名稱:owf-security,代碼行數:8,

示例14: searchExperiment

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

public void searchExperiment() throws ServerConnectionException, FailedLoginException,

ClientProtocolException, IOException {

SearchExperimentsByCriteria experimentSearchCriteria = new SearchExperimentsByCriteria();

CaArrayServer server = new CaArrayServer(BaseProperties.getServerHostname(),

BaseProperties.getServerJndiPort());

server.connect();

/*

* Verify anonymous search does not return results.

*/

experimentSearchCriteria.doSearch(server);

// Emulate a login from caIntegrator through CAS

String ticket = login();

/*

* Validate the ticket.

*/

try {

Cas20ServiceTicketValidator v = new Cas20ServiceTicketValidator(BaseProperties.CAS_URL);

v.validate(ticket, BaseProperties.getServiceURLforCAS());

} catch (Exception e) {

System.out.println(e);

}

/*

* To properly authenticate users with CAS information for EJB calls the caArray application requires 2 pieces of information:

* + The service value that was used at authentication time when the ticket was created

* + The ticket value that was provided by CAS

*/

server.connect(BaseProperties.getServiceURLforCAS(), ticket);

experimentSearchCriteria.doSearch(server);

/*

* This shows that in addition to being able to authenticate with CAS the application also provides

* the capability to authenticate against ldap in an SSO environment.

*/

server.connect(BaseProperties.CAS_USERNAME, BaseProperties.CAS_USER_CAARRAY_PASSWORD);

experimentSearchCriteria.doSearch(server);

}

開發者ID:NCIP,項目名稱:caarray,代碼行數:40,

示例15: cas20ServiceTicketValidator

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Bean

public Cas20ServiceTicketValidator cas20ServiceTicketValidator() {

return new Cas20ServiceTicketValidator(casProperties.getCasServerUrl());

}

開發者ID:mouxiao,項目名稱:shootmimi,代碼行數:5,

示例16: testRestBasicWithCas20TicketValidator

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Test

public void testRestBasicWithCas20TicketValidator() throws HttpAction, UnsupportedEncodingException {

final CasRestAuthenticator authenticator = new CasRestAuthenticator(CAS_PREFIX_URL);

authenticator.setTicketValidator(new Cas20ServiceTicketValidator(CAS_PREFIX_URL));

internalTestRestBasic(new CasRestBasicAuthClient(authenticator, VALUE, NAME), 0);

}

開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:7,

示例17: cas20ServiceTicketValidator

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

@Bean

public Cas20ServiceTicketValidator cas20ServiceTicketValidator() {

return new Cas20ServiceTicketValidator(env.getRequiredProperty(CAS_URL_PREFIX));

}

開發者ID:jgribonvald,項目名稱:demo-spring-security-cas,代碼行數:5,

示例18: doFilter

​點讚 2

import org.jasig.cas.client.validation.Cas20ServiceTicketValidator; //導入依賴的package包/類

/**

* {@inheritDoc}

*/

@Override

public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,

final FilterChain chain) throws IOException, ServletException {

final HttpServletRequest request = (HttpServletRequest) servletRequest;

final HttpServletResponse response = (HttpServletResponse) servletResponse;

HttpSession session = request.getSession();

final String ticket = CommonUtils.safeGetParameter(request, getArtifactParameterName());

if (session != null && session.getAttribute(CONST_CAS_ASSERTION) == null && ticket != null) {

try {

final String service = constructServiceUrl(request, response);

Cas20ServiceTicketValidator v = new Cas20ServiceTicketValidator(casServerUrl);

v.validate(ticket, service);

if (!new WebAuthentication().login(service, ticket)) {

throw new GeneralSecurityException("JBoss Web authentication failed.");

}

/*

* This line of obtaining the session again was necessary as following the login with

* the WebAuthentication above, the original Session that was obtained was no longer

* valid.

*/

session = request.getSession();

if (request.getUserPrincipal() instanceof AssertionPrincipal) {

final AssertionPrincipal principal = (AssertionPrincipal) request.getUserPrincipal();

session.setAttribute(CONST_CAS_ASSERTION, principal.getAssertion());

} else {

throw new GeneralSecurityException(

"JBoss Web authentication did not produce CAS AssertionPrincipal.");

}

} catch (final GeneralSecurityException e) {

response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());

} catch (TicketValidationException tve) {

response.sendError(HttpServletResponse.SC_FORBIDDEN, tve.getMessage());

}

} else if (session != null && request.getUserPrincipal() == null) {

// There is evidence that in some cases the principal can disappear

// in JBoss despite a valid session.

// This block forces consistency between principal and assertion.

session.removeAttribute(CONST_CAS_ASSERTION);

}

chain.doFilter(request, response);

}

開發者ID:NCIP,項目名稱:caarray,代碼行數:46,

注:本文中的org.jasig.cas.client.validation.Cas20ServiceTicketValidator類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值