Commit 9581a530 authored by toaster's avatar toaster
Browse files

initial merge of IMS code, 4 maven projects. Does not deploy properly at the moment, but compiles

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@165 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent 665b6cb2
......@@ -14,7 +14,7 @@
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server>
<netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
</properties>
<build>
......
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/ace-am">
<Context path="/ace-am-1.7-SNAPSHOT">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="aceam." suffix=".log" timestamp="true"/>
<!-- Configuration for authentication. This information should not need to be
changed at all unless you have your own authentication provider-->
......
......@@ -2,7 +2,7 @@ import hashlib
import binascii
from suds.client import Client
filename='test2.py'
filename='issue-example.py'
digFile = open(filename,'rb')
hashAlg = hashlib.sha256()
......
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ace</artifactId>
<groupId>edu.umiacs.ace</groupId>
<version>1.7-SNAPSHOT</version>
</parent>
<packaging>ear</packaging>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-ear</artifactId>
<name>ace-ims-ear</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
</properties>
<dependencies>
<dependency>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-war</artifactId>
<type>war</type>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<finalName>ace-ims</finalName>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<jarModule>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-server</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<jarModule>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-common</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<!-- <ejbModule>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-ejb</artifactId>
</ejbModule>
<webModule>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-war</artifactId>
</webModule>-->
</modules>
<jboss>
<version>4</version>
<loader-repository>edu.umiacs.ace:archive=ace-ims.ear</loader-repository>
</jboss>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>0.3-SNAPSHOT</version>
<configuration>
<container>
<containerId>jboss4x</containerId>
<type>remote</type>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-application PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Java EE Application 6.0//EN" "http://glassfish.org/dtds/glassfish-application_6_0-1.dtd">
<glassfish-application/>
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>ace</artifactId>
<groupId>edu.umiacs.ace</groupId>
<version>1.7-SNAPSHOT</version>
</parent>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-ejb</artifactId>
<name>ace-ims-ejb</name>
<packaging>ejb</packaging>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>edu.umiacs.ace</groupId>
<artifactId>ace-ims-server</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.umiacs.ace.ims.round;
import edu.umiacs.ace.ims.tokenclass.TokenClass;
import edu.umiacs.util.ToStringBuilder;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
*
* @author mmcgann
*/
@Entity
@Table(name="previous_round")
@NamedQueries
({
@NamedQuery(name="PreviousRound.findByTokenClass",
query="select pr from PreviousRound pr where " +
"pr.tokenClass = :tokenClass")
})
public class PreviousRound implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToOne
private TokenClass tokenClass;
@OneToOne(cascade=CascadeType.PERSIST)
private RoundSummary roundSummary;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
@Override
public int hashCode()
{
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object)
{
// TODO: Warning - this method won't work in the case the id fields are not set
if ( !(object instanceof PreviousRound) )
{
return false;
}
PreviousRound other = (PreviousRound)object;
if ( (this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)) )
{
return false;
}
return true;
}
@Override
public String toString()
{
return new ToStringBuilder()
.append("id", id)
.append("tokenClassName", tokenClass.getName())
.append("roundSummary",getRoundSummary())
.toString();
}
public TokenClass getTokenClass()
{
return tokenClass;
}
public void setTokenClass(TokenClass tokenClass)
{
this.tokenClass = tokenClass;
}
public RoundSummary getRoundSummary()
{
return roundSummary;
}
public void setRoundSummary(RoundSummary roundSummary)
{
this.roundSummary = roundSummary;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.umiacs.ace.ims.round;
import edu.umiacs.ace.server.exception.InternalException;
import javax.ejb.ApplicationException;
/**
*
* @author mmcgann
*/
@ApplicationException(rollback=true)
public class PreviousRoundException extends InternalException
{
public PreviousRoundException(int statusCode, String message)
{
super(statusCode, message);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.umiacs.ace.ims.round;
import edu.umiacs.ace.exception.StatusCode;
import edu.umiacs.ace.ims.tokenclass.TokenClass;
import edu.umiacs.ace.server.exception.InternalException;
import edu.umiacs.util.Check;
import java.util.Date;
import javax.ejb.Stateless;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
/**
*
* @author mmcgann
*/
@Stateless
public class RoundBean implements RoundLocal
{
@PersistenceContext
private EntityManager em;
public PreviousRound seedRoundSummary(RoundSummary roundSummary)
{
Check.notNull("roundSummary", roundSummary);
TokenClass tokenClass = roundSummary.getTokenClass();
Check.notNull("roundSummary.tokenClass", tokenClass);
roundSummary.setTimestamp(new Date());
PreviousRound previousRound = new PreviousRound();
previousRound.setRoundSummary(roundSummary);
previousRound.setTokenClass(tokenClass);
try
{
em.persist(roundSummary);
em.persist(previousRound);
em.flush();
}
catch ( EntityExistsException eee )
{
throw new PreviousRoundException(StatusCode.ROUND_SEED_EXISTS,
"Seed round already exists for token class: " +
tokenClass.getName());
}
return previousRound;
}
public PreviousRound findPreviousRound(TokenClass tokenClass)
{
Check.notNull("tokenClass", tokenClass);
try
{
Query q = em.createNamedQuery("PreviousRound.findByTokenClass");
q.setParameter("tokenClass", tokenClass);
return (PreviousRound)q.getSingleResult();
}
catch ( NoResultException nre )
{
throw new PreviousRoundException(StatusCode.NO_PREVIOUS_ROUND,
"No previous round for: " + tokenClass.getName());
}
}
public RoundSummary createRoundSummary(RoundSummary roundSummary)
{
Check.notNull("roundSummary", roundSummary);
Check.notEmpty("hashValue", roundSummary.getHashValue());
roundSummary.setTimestamp(new Date());
em.persist(roundSummary);
PreviousRound previousRound = findPreviousRound(
roundSummary.getTokenClass());
previousRound.setRoundSummary(roundSummary);
return roundSummary;
}
public RoundSummary getRoundSummary(long roundId)
{
RoundSummary rs;
rs = em.find(RoundSummary.class, roundId);
return rs;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.umiacs.ace.ims.round;
import edu.umiacs.ace.ims.tokenclass.TokenClass;
import javax.ejb.Local;
/**
*
* @author mmcgann
*/
@Local
public interface RoundLocal
{
PreviousRound findPreviousRound(TokenClass tokenClass);
RoundSummary createRoundSummary(RoundSummary roundSummary);
PreviousRound seedRoundSummary(RoundSummary roundSummary);
public RoundSummary getRoundSummary(long roundId);
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.umiacs.ace.ims.round;
import edu.umiacs.ace.ims.tokenclass.TokenClass;
import edu.umiacs.ace.util.HashFormatter;
import edu.umiacs.util.ToStringBuilder;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
/**
*
* @author mmcgann
*/
@Entity
@Table(name="round_summary")
@NamedQuery(name="RoundSummary.selectRoundRange", query="SELECT r from RoundSummary r WHERE r.tokenClass = :tokenClass AND r.id >= :start AND r.id <= :finish")
public class RoundSummary implements Serializable
{
@Transient
private static final HashFormatter hashFormatter = new HashFormatter();
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private TokenClass tokenClass;
@Column(name="hash_value", nullable=false)
private String hashValue;
@Temporal(TemporalType.TIMESTAMP)
@Column(name="time_stamp", nullable=false)
private Date timestamp;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
@Override
public int hashCode()
{
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object)
{
// TODO: Warning - this method won't work in the case the id fields are not set
if ( !(object instanceof RoundSummary) )
{
return false;
}
RoundSummary other = (RoundSummary)object;
if ( (this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)) )
{
return false;
}
return true;
}
@Override
public String toString()
{
return new ToStringBuilder()
.append("id", id)
.append("tokenClassName", tokenClass.getName())
.append("timestamp", timestamp)
.append("hashValue", hashFormatter.format(hashValue))
.toString();
}
public TokenClass getTokenClass()
{
return tokenClass;
}
public void setTokenClass(TokenClass tokenClass)
{
this.tokenClass = tokenClass;
}
public String getHashValue()
{
return hashValue;
}
public void setHashValue(String hashValue)
{
this.hashValue = hashValue;
}
public Date getTimestamp()
{
return timestamp;
}
public void setTimestamp(Date timestamp)
{
this.timestamp = timestamp;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.umiacs.ace.ims.store;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
/**
*
* @author mmcgann
*/
@Entity
@Table(name="issued_token")
@NamedQueries({
@NamedQuery(
name="IssuedTokens.findByTokenStore",
query="select it from IssuedToken it where it.tokenStore = :tokenStore")
})
public class IssuedToken implements Serializable
{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@ManyToOne
private TokenStore tokenStore;
@Column(name="java_token_response")
@Lob
private byte[] tokenResponse;
public void setId(Long id)
{
this.id = id;
<