本文整理汇总了Java中org.jasig.cas.authentication.principal.Service.setPrincipal方法的典型用法代码示例。如果您正苦于以下问题:Java Service.setPrincipal方法的具体用法?Java Service.setPrincipal怎么用?Java Service.setPrincipal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jasig.cas.authentication.principal.Service
的用法示例。
在下文中一共展示了Service.setPrincipal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateServiceAndTrackSession
import org.jasig.cas.authentication.principal.Service; //导入方法依赖的package包/类
/**
* Update service and track session.
*
* @param id the id
* @param service the service
* @param onlyTrackMostRecentSession the only track most recent session
*/
protected void updateServiceAndTrackSession(final String id, final Service service, final boolean onlyTrackMostRecentSession) {
updateState();
final List<Authentication> authentications = getChainedAuthentications();
service.setPrincipal(authentications.get(authentications.size()-1).getPrincipal());
if (onlyTrackMostRecentSession) {
final String path = normalizePath(service);
final Collection<Service> existingServices = services.values();
// loop on existing services
for (final Service existingService : existingServices) {
final String existingPath = normalizePath(existingService);
// if an existing service has the same normalized path, remove it
// and its service ticket to keep the latest one
if (StringUtils.equals(path, existingPath)) {
existingServices.remove(existingService);
LOGGER.trace("Removed previous tickets for service: {}", existingService);
break;
}
}
}
this.services.put(id, service);
}
示例2: grantServiceTicket
import org.jasig.cas.authentication.principal.Service; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>The state of the ticket is affected by this operation and the
* ticket will be considered used. The state update subsequently may
* impact the ticket expiration policy in that, depending on the policy
* configuration, the ticket may be considered expired.
*/
@Override
public synchronized ServiceTicket grantServiceTicket(final String id,
final Service service, final ExpirationPolicy expirationPolicy,
final boolean credentialsProvided) {
final ServiceTicket serviceTicket = new ServiceTicketImpl(id, this,
service, this.getCountOfUses() == 0 || credentialsProvided,
expirationPolicy);
updateState();
final List<Authentication> authentications = getChainedAuthentications();
service.setPrincipal(authentications.get(authentications.size()-1).getPrincipal());
this.services.put(id, service);
return serviceTicket;
}