📄 cas20proxyhandler.java
字号:
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.ja-sig.org/products/cas/overview/license/ */package org.jasig.cas.ticket.proxy.support;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.jasig.cas.authentication.principal.Credentials;import org.jasig.cas.authentication.principal.HttpBasedServiceCredentials;import org.jasig.cas.ticket.proxy.ProxyHandler;import org.jasig.cas.util.DefaultUniqueTicketIdGenerator;import org.jasig.cas.util.HttpClient;import org.jasig.cas.util.UniqueTicketIdGenerator;import org.jasig.cas.util.annotation.NotNull;/** * Proxy Handler to handle the default callback functionality of CAS 2.0. * <p> * The default behavior as defined in the CAS 2 Specification is to callback the * URL provided and give it a pgtIou and a pgtId. * </p> * * @author Scott Battaglia * @version $Revision: 42053 $ $Date: 2007-06-10 09:17:55 -0400 (Sun, 10 Jun 2007) $ * @since 3.0 */public final class Cas20ProxyHandler implements ProxyHandler { /** The Commons Logging instance. */ private final Log log = LogFactory.getLog(getClass()); /** The PGTIOU ticket prefix. */ private static final String PGTIOU_PREFIX = "PGTIOU"; /** Generate unique ids. */ @NotNull private UniqueTicketIdGenerator uniqueTicketIdGenerator = new DefaultUniqueTicketIdGenerator(); /** Instance of Apache Commons HttpClient */ @NotNull private HttpClient httpClient; public String handle(final Credentials credentials, final String proxyGrantingTicketId) { final HttpBasedServiceCredentials serviceCredentials = (HttpBasedServiceCredentials) credentials; final String proxyIou = this.uniqueTicketIdGenerator .getNewTicketId(PGTIOU_PREFIX); final String serviceCredentialsAsString = serviceCredentials.toString(); final StringBuilder stringBuffer = new StringBuilder( serviceCredentialsAsString.length() + proxyIou.length() + proxyGrantingTicketId.length() + 15); stringBuffer.append(serviceCredentialsAsString); if (serviceCredentials.getCallbackUrl().getQuery() != null) { stringBuffer.append("&"); } else { stringBuffer.append("?"); } stringBuffer.append("pgtIou="); stringBuffer.append(proxyIou); stringBuffer.append("&pgtId="); stringBuffer.append(proxyGrantingTicketId); if (this.httpClient.isValidEndPoint(stringBuffer.toString())) { if (log.isDebugEnabled()) { log.debug("Sent ProxyIou of " + proxyIou + " for service: " + serviceCredentials.toString()); } return proxyIou; } if (log.isDebugEnabled()) { log.debug("Failed to send ProxyIou of " + proxyIou + " for service: " + serviceCredentials.toString()); } return null; } /** * @param uniqueTicketIdGenerator The uniqueTicketIdGenerator to set. */ public void setUniqueTicketIdGenerator( final UniqueTicketIdGenerator uniqueTicketIdGenerator) { this.uniqueTicketIdGenerator = uniqueTicketIdGenerator; } public void setHttpClient(final HttpClient httpClient) { this.httpClient = httpClient; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -