forked from apereo/cas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added factories for ST and PT objects
- Loading branch information
1 parent
f18d257
commit 6a5bb0a
Showing
31 changed files
with
340 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...jasig/cas/ticket/ProxyGrantingTicket.java → ...cas/ticket/proxy/ProxyGrantingTicket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...as/ticket/ProxyGrantingTicketFactory.java → ...ket/proxy/ProxyGrantingTicketFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...ava/org/jasig/cas/ticket/ProxyTicket.java → ...g/jasig/cas/ticket/proxy/ProxyTicket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
cas-server-core-api-ticket/src/main/java/org/jasig/cas/ticket/proxy/ProxyTicketFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jasig.cas.ticket.proxy; | ||
|
||
import org.jasig.cas.authentication.principal.Service; | ||
import org.jasig.cas.ticket.Ticket; | ||
import org.jasig.cas.ticket.TicketFactory; | ||
|
||
/** | ||
* The {@link ProxyTicketFactory} is responsible for | ||
* creating instances of {@link ProxyTicket}. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 4.2 | ||
*/ | ||
public interface ProxyTicketFactory extends TicketFactory { | ||
|
||
/** | ||
* Create the ticket object. | ||
* | ||
* @param <T> the type parameter | ||
* @param ticketGrantingTicket the ticket granting ticket | ||
* @param service the service | ||
* @return the t | ||
*/ | ||
<T extends Ticket> T create(ProxyGrantingTicket ticketGrantingTicket, | ||
Service service); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...er-core-events/src/main/java/org/jasig/cas/support/events/CasProxyTicketGrantedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
cas-server-core-logging/src/main/java/org/slf4j/impl/CasDelegatingLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...er-core-tickets/src/main/java/org/jasig/cas/ticket/DefaultProxyGrantingTicketFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
cas-server-core-tickets/src/main/java/org/jasig/cas/ticket/DefaultProxyTicketFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.jasig.cas.ticket; | ||
|
||
import org.jasig.cas.authentication.principal.Service; | ||
import org.jasig.cas.ticket.proxy.ProxyGrantingTicket; | ||
import org.jasig.cas.ticket.proxy.ProxyTicket; | ||
import org.jasig.cas.ticket.proxy.ProxyTicketFactory; | ||
import org.jasig.cas.util.DefaultUniqueTicketIdGenerator; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.Resource; | ||
import javax.validation.constraints.NotNull; | ||
import java.util.Map; | ||
|
||
/** | ||
* The {@link DefaultProxyTicketFactory} is responsible for | ||
* creating {@link ProxyTicket} objects. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 4.2 | ||
*/ | ||
@Component("defaultProxyTicketFactory") | ||
public class DefaultProxyTicketFactory implements ProxyTicketFactory { | ||
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
|
||
/** Default instance for the ticket id generator. */ | ||
@NotNull | ||
protected final UniqueTicketIdGenerator defaultServiceTicketIdGenerator = new DefaultUniqueTicketIdGenerator(); | ||
|
||
/** Map to contain the mappings of service to {@link UniqueTicketIdGenerator}s. */ | ||
@NotNull | ||
@Resource(name="uniqueIdGeneratorsMap") | ||
protected Map<String, UniqueTicketIdGenerator> uniqueTicketIdGeneratorsForService; | ||
|
||
/** Whether we should track the most recent session by keeping the latest service ticket. */ | ||
@Value("${tgt.onlyTrackMostRecentSession:true}") | ||
protected boolean onlyTrackMostRecentSession = true; | ||
|
||
/** ExpirationPolicy for Service Tickets. */ | ||
@NotNull | ||
@Resource(name="serviceTicketExpirationPolicy") | ||
protected ExpirationPolicy serviceTicketExpirationPolicy; | ||
|
||
@Override | ||
public <T extends Ticket> T create(final ProxyGrantingTicket proxyGrantingTicket, | ||
final Service service) { | ||
final String uniqueTicketIdGenKey = service.getClass().getName(); | ||
logger.debug("Looking up service ticket id generator for [{}]", uniqueTicketIdGenKey); | ||
UniqueTicketIdGenerator serviceTicketUniqueTicketIdGenerator = | ||
this.uniqueTicketIdGeneratorsForService.get(uniqueTicketIdGenKey); | ||
if (serviceTicketUniqueTicketIdGenerator == null) { | ||
serviceTicketUniqueTicketIdGenerator = this.defaultServiceTicketIdGenerator; | ||
logger.debug("Service ticket id generator not found for [{}]. Using the default generator...", | ||
uniqueTicketIdGenKey); | ||
} | ||
|
||
final String ticketId = serviceTicketUniqueTicketIdGenerator.getNewTicketId(ProxyTicket.PROXY_TICKET_PREFIX); | ||
final ProxyTicket serviceTicket = proxyGrantingTicket.grantProxyTicket( | ||
ticketId, | ||
service, | ||
this.serviceTicketExpirationPolicy, | ||
this.onlyTrackMostRecentSession); | ||
return (T) serviceTicket; | ||
} | ||
|
||
@Override | ||
public <T extends TicketFactory> T get(final Class<? extends Ticket> clazz) { | ||
return (T) this; | ||
} | ||
|
||
public final boolean isOnlyTrackMostRecentSession() { | ||
return onlyTrackMostRecentSession; | ||
} | ||
|
||
public final void setOnlyTrackMostRecentSession(final boolean onlyTrackMostRecentSession) { | ||
this.onlyTrackMostRecentSession = onlyTrackMostRecentSession; | ||
} | ||
|
||
public void setUniqueTicketIdGeneratorsForService(final Map<String, UniqueTicketIdGenerator> uniqueTicketIdGeneratorsForService) { | ||
this.uniqueTicketIdGeneratorsForService = uniqueTicketIdGeneratorsForService; | ||
} | ||
|
||
public void setServiceTicketExpirationPolicy(final ExpirationPolicy serviceTicketExpirationPolicy) { | ||
this.serviceTicketExpirationPolicy = serviceTicketExpirationPolicy; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
cas-server-core-tickets/src/main/java/org/jasig/cas/ticket/DefaultServiceTicketFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package org.jasig.cas.ticket; | ||
|
||
import org.jasig.cas.authentication.principal.Service; | ||
import org.jasig.cas.util.DefaultUniqueTicketIdGenerator; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.Resource; | ||
import javax.validation.constraints.NotNull; | ||
import java.util.Map; | ||
|
||
/** | ||
* The {@link DefaultServiceTicketFactory} is responsible for | ||
* creating {@link ServiceTicket} objects. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 4.2 | ||
*/ | ||
@Component("defaultServiceTicketFactory") | ||
public class DefaultServiceTicketFactory implements ServiceTicketFactory { | ||
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
|
||
/** Default instance for the ticket id generator. */ | ||
@NotNull | ||
protected UniqueTicketIdGenerator defaultServiceTicketIdGenerator = new DefaultUniqueTicketIdGenerator(); | ||
|
||
|
||
/** Map to contain the mappings of service to {@link UniqueTicketIdGenerator}s. */ | ||
@NotNull | ||
@Resource(name="uniqueIdGeneratorsMap") | ||
protected Map<String, UniqueTicketIdGenerator> uniqueTicketIdGeneratorsForService; | ||
|
||
/** Whether we should track the most recent session by keeping the latest service ticket. */ | ||
@Value("${tgt.onlyTrackMostRecentSession:true}") | ||
protected boolean onlyTrackMostRecentSession = true; | ||
|
||
/** ExpirationPolicy for Service Tickets. */ | ||
@NotNull | ||
@Resource(name="serviceTicketExpirationPolicy") | ||
protected ExpirationPolicy serviceTicketExpirationPolicy; | ||
|
||
@Override | ||
public <T extends Ticket> T create(final TicketGrantingTicket ticketGrantingTicket, | ||
final Service service, | ||
final boolean credentialsProvided) { | ||
|
||
final String uniqueTicketIdGenKey = service.getClass().getName(); | ||
UniqueTicketIdGenerator serviceTicketUniqueTicketIdGenerator = null; | ||
if (this.uniqueTicketIdGeneratorsForService != null && !uniqueTicketIdGeneratorsForService.isEmpty()) { | ||
logger.debug("Looking up service ticket id generator for [{}]", uniqueTicketIdGenKey); | ||
serviceTicketUniqueTicketIdGenerator = this.uniqueTicketIdGeneratorsForService.get(uniqueTicketIdGenKey); | ||
} | ||
if (serviceTicketUniqueTicketIdGenerator == null) { | ||
serviceTicketUniqueTicketIdGenerator = this.defaultServiceTicketIdGenerator; | ||
logger.debug("Service ticket id generator not found for [{}]. Using the default generator...", | ||
uniqueTicketIdGenKey); | ||
} | ||
|
||
final String ticketId = serviceTicketUniqueTicketIdGenerator.getNewTicketId(ServiceTicket.PREFIX); | ||
final ServiceTicket serviceTicket = ticketGrantingTicket.grantServiceTicket( | ||
ticketId, | ||
service, | ||
this.serviceTicketExpirationPolicy, | ||
credentialsProvided, | ||
this.onlyTrackMostRecentSession); | ||
return (T) serviceTicket; | ||
} | ||
|
||
@Override | ||
public <T extends TicketFactory> T get(final Class<? extends Ticket> clazz) { | ||
return (T) this; | ||
} | ||
|
||
public final boolean isOnlyTrackMostRecentSession() { | ||
return onlyTrackMostRecentSession; | ||
} | ||
|
||
public final void setOnlyTrackMostRecentSession(final boolean onlyTrackMostRecentSession) { | ||
this.onlyTrackMostRecentSession = onlyTrackMostRecentSession; | ||
} | ||
|
||
public void setUniqueTicketIdGeneratorsForService(final Map<String, UniqueTicketIdGenerator> uniqueTicketIdGeneratorsForService) { | ||
this.uniqueTicketIdGeneratorsForService = uniqueTicketIdGeneratorsForService; | ||
} | ||
|
||
public void setServiceTicketExpirationPolicy(final ExpirationPolicy serviceTicketExpirationPolicy) { | ||
this.serviceTicketExpirationPolicy = serviceTicketExpirationPolicy; | ||
} | ||
|
||
public void setDefaultServiceTicketIdGenerator(final UniqueTicketIdGenerator defaultServiceTicketIdGenerator) { | ||
this.defaultServiceTicketIdGenerator = defaultServiceTicketIdGenerator; | ||
} | ||
} |
Oops, something went wrong.