<project name="Shibboleth Identity Provider" basedir="." default="install">
-
+
<!-- User based property file that overrides any property below -->
<property file="${user.name}-build.properties" />
<!-- Compile core (non-test) classes -->
<target name="compile-core" depends="build-init, clean-compile">
+ <mkdir dir="${core-prep-source.dir}" />
<mkdir dir="${core-classes.dir}" />
- <javac srcdir="${core-src.dir}" destdir="${core-classes.dir}" includes="**/*.java" debug="on" source="1.5">
+ <copy todir="${core-prep-source.dir}" preservelastmodified="true">
+ <fileset dir="${core-src.dir}" />
+ <filterset begintoken="$" endtoken="$">
+ <filter token="IDP_HOME" value="${idp.home}" />
+ <filter token="IDP_VERSION" value="${version}" />
+ </filterset>
+ </copy>
+
+ <javac srcdir="${core-prep-source.dir}" destdir="${core-classes.dir}" includes="**/*.java" debug="on" source="1.5">
<classpath refid="build-path" />
</javac>
+ <delete dir="${core-prep-source.dir}" />
+
</target>
<!-- Compile unit test classes -->
<mkdir dir="${test-results.dir}" />
<echo message="Excuting unit tests using endorsed directory ${java.endorsed.dirs}" />
- <junit printsummary="off"
- fork="yes"
- forkmode="once"
- haltonerror="false"
- haltonfailure="false"
- dir="${basedir}"
- errorproperty="testFailed">
+ <junit printsummary="off" fork="yes" forkmode="once" haltonerror="false" haltonfailure="false" dir="${basedir}" errorproperty="testFailed">
<jvmarg value="-Djava.endorsed.dirs=${java.endorsed.dirs}" />
<classpath refid="test-path" />
<formatter type="xml" />
<!-- Javadoc core (non-test) classes -->
<target name="javadoc" description="Creates the JavaDoc documentatin for the project.">
<mkdir dir="${javadoc.dir}" />
- <javadoc packagenames="org.opensaml.*"
- sourcepath="${core-src.dir}"
- destdir="${javadoc.dir}"
- author="false"
- version="true"
- windowtitle="${ant.project.name} ${version} Java API"
- doctitle="${ant.project.name} ${version} Java API"
- bottom="${copyright}"
- overview="${core-src.dir}/overview.html">
+ <javadoc packagenames="org.opensaml.*" sourcepath="${core-src.dir}" destdir="${javadoc.dir}" author="false" version="true" windowtitle="${ant.project.name} ${version} Java API" doctitle="${ant.project.name} ${version} Java API" bottom="${copyright}" overview="${core-src.dir}/overview.html">
<classpath refid="build-path" />
</javadoc>
</target>
<fileset file="${dist.dir}/${jar.name}" />
<fileset file="${build-lib.dir}/servlet-2.4.jar" />
</copy>
-
+
<if>
<available file="${idp.home}/conf" />
<then>
/** Spring context used to publish login and logout events. */
private ApplicationContext appCtx;
-
+
/** Backing service used to store sessions. */
private StorageService<String, SessionManagerEntry> sessionStore;
-
+
/** Parition in which entries are stored. */
private String partition;
-
+
/** Lifetime, in milliseconds, of session. */
private long sessionLifetime;
-
+
/**
* Constructor.
- *
+ *
* @param storageService service used to store sessions
* @param lifetime lifetime, in milliseconds, of sessions
*/
- public SessionManagerImpl(StorageService<String, SessionManagerEntry> storageService, long lifetime){
+ public SessionManagerImpl(StorageService<String, SessionManagerEntry> storageService, long lifetime) {
sessionStore = storageService;
partition = "session";
sessionLifetime = lifetime;
}
-
+
/**
* Constructor.
- *
+ *
* @param storageService service used to store session
* @param storageParition partition in which sessions are stored
* @param lifetime lifetime, in milliseconds, of sessions
*/
- public SessionManagerImpl(StorageService<String, SessionManagerEntry> storageService, String storageParition, long lifetime){
+ public SessionManagerImpl(StorageService<String, SessionManagerEntry> storageService, String storageParition,
+ long lifetime) {
sessionStore = storageService;
- if(!DatatypeHelper.isEmpty(storageParition)){
+ if (!DatatypeHelper.isEmpty(storageParition)) {
partition = DatatypeHelper.safeTrim(storageParition);
- }else{
+ } else {
partition = "session";
}
sessionLifetime = lifetime;
}
-
+
/** {@inheritDoc} */
public void setApplicationContext(ApplicationContext applicationContext) {
appCtx = applicationContext;
}
-
+
/** {@inheritDoc} */
public Session createSession(InetAddress presenter, String principal) {
Session session = new SessionImpl(presenter, principal);
/** {@inheritDoc} */
public void destroySession(String sessionID) {
- if(sessionID == null){
+ if (sessionID == null) {
return;
}
-
+
SessionManagerEntry sessionEntry = sessionStore.get(partition, sessionID);
- if(sessionEntry != null){
+ if (sessionEntry != null) {
appCtx.publishEvent(new LogoutEvent(sessionEntry.getSession()));
}
}
/** {@inheritDoc} */
public Session getSession(String sessionID) {
- if(sessionID == null){
+ if (sessionID == null) {
return null;
}
-
+
SessionManagerEntry sessionEntry = sessionStore.get(partition, sessionID);
- if(sessionEntry == null){
+ if (sessionEntry == null) {
return null;
}
-
- if(sessionEntry.isExpired()){
+
+ if (sessionEntry.isExpired()) {
destroySession(sessionEntry.getSessionId());
return null;
- }else{
+ } else {
return sessionEntry.getSession();
}
}
-
+
/**
* Session store entry.
*/
public class SessionManagerEntry implements ExpiringObject {
-
+
/** User's session. */
private Session userSession;
-
+
/** Manager that owns the session. */
private SessionManager<Session> sessionManager;
-
+
/** Time this entry expires. */
private DateTime expirationTime;
-
+
/**
* Constructor.
- *
+ *
* @param manager manager that owns the session
* @param session user session
- * @param sessionLifetime lifetime of session
+ * @param lifetime lifetime of session
*/
- public SessionManagerEntry(SessionManager<Session> manager, Session session, long sessionLifetime){
+ public SessionManagerEntry(SessionManager<Session> manager, Session session, long lifetime) {
sessionManager = manager;
userSession = session;
- expirationTime = new DateTime().plus(sessionLifetime);
+ expirationTime = new DateTime().plus(lifetime);
}
-
+
/**
* Gets the user session.
*
* @return user session
*/
- public Session getSession(){
+ public Session getSession() {
return userSession;
}
-
+
/**
* Gets the ID of the user session.
*
* @return ID of the user session
*/
- public String getSessionId(){
+ public String getSessionId() {
return userSession.getSessionID();
}
public boolean isExpired() {
return expirationTime.isBeforeNow();
}
-
+
/** {@inheritDoc} */
public void onExpire() {
sessionManager.destroySession(userSession.getSessionID());