git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@50874 248e525c-4dfb-0310-94bc-949c084e9493

This commit is contained in:
andrew.gilmore
2012-03-19 11:57:19 +00:00
parent 2a0f4900c3
commit 0e9ca75d77
1587 changed files with 500863 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<jws:workspace xmlns:jws="http://xmlns.oracle.com/ide/project">
<hash n="component-versions">
<value n="oracle.ide.model.Project" v="10.1.3.5.0"/>
<value n="oracle.jdevimpl.xml.oc4j.ds.DataSourcesMigratorHelper" v="10.1.3.5.0"/>
</hash>
<list n="listOfChildren">
<hash>
<value n="nodeClass" v="oracle.ide.model.Project"/>
<url n="URL" path="SMIME/SMIME.jpr"/>
</hash>
</list>
</jws:workspace>

View File

@@ -0,0 +1,41 @@
/*
* HashFile.java
*
* Created on 2007. janu<6E>r 21., 17:55
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package tsdemo;
import java.security.MessageDigest;
import java.io.FileInputStream;
/**
*
* @author root
*/
public class HashFile {
/** Creates a new instance of HashFile */
public HashFile() {
}
public static byte[] getHash(String Filename, String Algorithm) {
try {
MessageDigest d = MessageDigest.getInstance(Algorithm); // Get a hash handler
FileInputStream f = new FileInputStream(Filename); // open file for hashing
byte[] b = new byte[1];
while ( -1 != f.read(b, 0, 1)) // feed the message digester
d.update(b);
f.close();
return d.digest(); // get the final hash and return it
} catch (Exception e) {
System.out.println("Hashing Error " + e.getMessage());
return null;
}
}
}

View File

@@ -0,0 +1,119 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<jpr:project xmlns:jpr="http://xmlns.oracle.com/ide/project">
<hash n="component-versions">
<value n="oracle.adfdt.controller.jsf.addin.JSFProjectMigrator" v="10.1.3.5.0"/>
<value n="oracle.adfdt.controller.struts.addin.StrutsProjectMigrator" v="10.1.3.5.0"/>
<value n="oracle.bm.commonIde.ProjectUpgrader" v="10.1.3.5.0"/>
<value n="oracle.ide.model.Project" v="10.1.3.5.0"/>
<value n="oracle.ide.model.ResourcePathsMigrator" v="10.1.3.5.0"/>
<value n="oracle.jdeveloper.dbmodeler.migration.ProjectMigratorHelper" v="10.1.3.5.0"/>
<value n="oracle.jdeveloper.ejb.EjbMigrator" v="10.1.3.5.0"/>
<value n="oracle.jdeveloper.offlinedb.migration.OfflineDBProjectMigrator" v="10.1.3.5.0"/>
<value n="oracle.jdevimpl.jsp.JsfLibraryMigrator" v="10.1.3.5.0"/>
<value n="oracle.jdevimpl.jsp.JspMigrator" v="10.1.3.1.0"/>
<value n="oracle.jdevimpl.runner.RunConfigurationsMigrator" v="10.1.3.5.0"/>
<value n="oracle.jdevimpl.webservices.WebServicesMigratorHelper" v="10.1.3.5.0"/>
<value n="oracle.toplink.addin.migration.TopLinkProjectMigrator" v="10.1.3.1.0"/>
</hash>
<list n="contentSets">
<string v="oracle.jdeveloper.model.PathsConfiguration/javaContentSet"/>
<string v="oracle.ide.model.ResourcePaths/resourcesContentSet"/>
<string v="oracle.jdeveloper.offlinedb.model.OfflineDBProjectSettings/offlineDBContentSet"/>
<string v="oracle.jdeveloper.model.J2eeSettings/webContentSet"/>
<string v="oracle.toplink.addin.TopLinkProjectSettings/toplinkContentSet"/>
<string v="oracle.bm.commonIde.data.project.ModelerProjectSettings/modelersContentSet"/>
</list>
<value n="defaultPackage" v="smime"/>
<hash n="oracle.bm.commonIde.data.project.ModelerProjectSettings">
<hash n="modelersContentSet">
<list n="url-path">
<url path="model/"/>
</list>
</hash>
</hash>
<hash n="oracle.ide.model.ResourcePaths">
<hash n="resourcesContentSet">
<list n="pattern-filters">
<string v="+*"/>
</list>
<list n="url-path">
<url path="."/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.compiler.OjcConfiguration">
<value n="internalEncoding" v="Cp1252"/>
<value n="source" v="1.4"/>
<value n="target" v="1.4"/>
</hash>
<hash n="oracle.jdeveloper.model.J2eeSettings">
<value n="j2eeWebAppName" v="EFT-SMIME-webapp"/>
<value n="j2eeWebContextRoot" v="EFT-SMIME-context-root"/>
<hash n="webContentSet">
<list n="url-path">
<url path="public_html/"/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.model.PathsConfiguration">
<hash n="javaContentSet">
<list n="pattern-filters">
<string v="+**"/>
</list>
<list n="url-path">
<url path="src/"/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.offlinedb.model.OfflineDBProjectSettings">
<hash n="offlineDBContentSet">
<list n="pattern-filters">
<string v="+**"/>
</list>
<list n="url-path">
<url path="database/"/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.runner.RunConfigurations">
<hash n="runConfigurationDefinitions">
<hash n="Default">
<value n="custom" v="false"/>
<value n="name" v="Default"/>
</hash>
</hash>
<list n="runConfigurationList">
<string v="Default"/>
</list>
</hash>
<hash n="oracle.jdevimpl.config.JProjectLibraries">
<list n="exportedReferences">
<hash>
<url n="id" path="../../../../../../oracle/jdev10/jdev/system/oracle.jdeveloper.10.1.3.43.6/SMIME.library"/>
<value n="isJDK" v="false"/>
</hash>
</list>
<hash n="internalDefinitions">
<list n="libraryDefinitions"/>
</hash>
<list n="libraryReferences">
<hash>
<url n="id" path="../../../../../../oracle/jdev10/jdev/system/oracle.jdeveloper.10.1.3.43.6/SMIME.library"/>
<value n="isJDK" v="false"/>
</hash>
</list>
</hash>
<hash n="oracle.jdevimpl.config.JProjectPaths">
<url n="outputDirectory" path="classes/"/>
</hash>
<hash n="oracle.toplink.addin.TopLinkProjectSettings">
<hash n="toplinkContentSet">
<list n="pattern-filters">
<string v="+**"/>
</list>
<list n="url-path">
<url path="toplink/"/>
</list>
</hash>
</hash>
</jpr:project>

Binary file not shown.

View File

@@ -0,0 +1,408 @@
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Security;
import java.security.cert.CertStore;
import java.security.cert.CollectionCertStoreParameters;
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.sql.Connection;
//import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
import javax.activation.CommandMap;
import javax.activation.DataHandler;
import javax.activation.MailcapCommandMap;
import javax.mail.Address;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.util.ByteArrayDataSource;
import oracle.sql.BLOB;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.cms.AttributeTable;
import org.bouncycastle.asn1.smime.SMIMECapabilitiesAttribute;
import org.bouncycastle.asn1.smime.SMIMECapability;
import org.bouncycastle.asn1.smime.SMIMECapabilityVector;
import org.bouncycastle.mail.smime.SMIMESignedGenerator;
public class am_smime
{
static
{
Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 2);
}
//
// certificate serial number seed.
//
static int serialNo = 1;
//
// Javamail authenticator instance
//
private static Authenticator authenticator = null;
//
// Database connection global
//
private static Connection conn = null;
//
// Default connection settings
//
private static String username = "eft_nom";
private static String password = "eft_nom";
private static String connection = "jdbc:oracle:thin:@loordv01:1521:dev10g";
//
private static String mslo_id = null;
//
// Main Method
//
public static void main(String[] args) throws Exception
{
am_smime smime_msg = new am_smime();
//
// check for parameters
//
if (args.length >= 1) {
mslo_id = args[0];
username = args[1];
password = args[2];
connection = args[3];
}
//
// call the main routine
//
sendmsg( mslo_id
);
}
public static String Sysdate() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.Ms");
Date sysdate = new Date();
return dateFormat.format(sysdate);
}
public static void sendmsg( String mslo_id
) throws Exception {
//
// get a JDBC connection
//
try {
conn = getConnection();
System.out.println("am_smime: " + "connection opened" + ": " + Sysdate());
} catch(SQLException ex){
ex.printStackTrace();
}
//
// Initialise defaults - if no details passed, will still send a message in dev
//
String mailFrom = "\"Anthony Gilbert\"<anthony.gilbert@advanticagroup.com>";
String mailTo = "\"Anthony Gilbert\"<anthony.gilbert@advanticagroup.com>";
String mailSubject = "Mail Subject";
String mailBody = "Mail Body";
String fileName = "attachment.txt";
String fileMimeType = "application/vnd.ms-excel";
String filename = "c:\\ant.pfx";
String password = "password";
String smtpServerHost = "lomail01";
int tmpInt = 1;
oracle.sql.BLOB pBlob = BLOB.createTemporary(conn, false, tmpInt);
//
// If a parameter has been passed, override the defaults
//
if (mslo_id != null )
{
//
// Lets see if we can get the details
//
PreparedStatement stmt = conn.prepareStatement
("SELECT mslo_id " +
" ,from_name " +
" ,to_names " +
" ,subject " +
" ,message " +
" ,filename " +
" ,file_mime_type " +
" ,cout_system_configuration.get_configuration_item('G_SMIME_KEYSTORE') keystore " +
" ,cout_system_configuration.get_configuration_item('G_SMIME_PASSWORD') password " +
" ,cout_system_configuration.get_configuration_item('SYSTEM_SMTP_SERVER') mailserver " +
"FROM messaging_log " +
"WHERE mslo_id = ?");
stmt.setString(1, mslo_id);
System.out.println("am_smime: " + "retrieving message" + ": " + Sysdate());
ResultSet rset = stmt.executeQuery();
while (rset.next())
{
//
// Set the default to be as returned from the db
//
mailFrom = rset.getString("from_name");
mailTo = rset.getString("to_names");
mailSubject = rset.getString("subject");
mailBody = rset.getString("message");
fileName = rset.getString("filename");
fileMimeType = rset.getString("file_mime_type");
filename = rset.getString("keystore");
password = rset.getString("password");
smtpServerHost = rset.getString("mailserver");
//
// Now return the blob - have to use a different method
//
Statement stmtb = conn.createStatement();
System.out.println("am_smime: " + "retrieving attachment" + ": " + Sysdate());
ResultSet blobdetails = stmtb.executeQuery("SELECT filecontents " +
"FROM messaging_log " +
"WHERE mslo_id = " + mslo_id +" FOR UPDATE ");
//
if (blobdetails.next() )
{
pBlob = (oracle.sql.BLOB) blobdetails.getBlob(1);
stmtb.close();
}
}
rset.close();
stmt.close();
}
System.out.println("am_smime: " + "setup security" + ": " + Sysdate());
//
// Add handler to mailcap
//
MailcapCommandMap _mailcap = (MailcapCommandMap)CommandMap.getDefaultCommandMap();
//
_mailcap.addMailcap("application/pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_signature");
_mailcap.addMailcap("application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime");
_mailcap.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_signature");
_mailcap.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");
_mailcap.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed");
//
CommandMap.setDefaultCommandMap(_mailcap);
//
// Set mail server details
//
String smtpUsername = "";//gilberta";
String smtpPassword = "";//password";
//
String defaultCharset = "iso-8859-2";
//
// Initialise security and keystore
//
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
KeyStore ks = KeyStore.getInstance("pkcs12", "BC");
System.out.println("am_smime: " + "load keystore and apply password" + ": " + Sysdate());
//
// Load the keystore
//
try {
ks.load( new FileInputStream(filename), password.toCharArray());
}
catch (Exception ex) { System.out.println("Error: Problem loading keystore"); throw ex;}
//
System.out.println("am_smime: " + "loaded, extract certificates" + ": " + Sysdate());
//
// Find the parts we need
//
Enumeration e = ks.aliases();
String keyAlias = null;
String alias = null;
while (e.hasMoreElements()) {
alias = (String) e.nextElement();
if (ks.isKeyEntry(alias)) {
keyAlias = alias;
}
}
if (keyAlias == null) {
System.err.println("can't find a private key!");
System.exit(0);
}
//
PrivateKey smimeSigningKey = (PrivateKey)ks.getKey(alias,password.toCharArray());
java.security.cert.Certificate smimeCertChain[] = ks.getCertificateChain(alias);
//
// Setup the ASN1 stuff
//
ASN1EncodableVector signedAttrs = new ASN1EncodableVector();
SMIMECapabilityVector caps = new SMIMECapabilityVector();
//
caps.addCapability(SMIMECapability.dES_EDE3_CBC);
caps.addCapability(SMIMECapability.rC2_CBC, 128);
caps.addCapability(SMIMECapability.dES_CBC);
//
signedAttrs.add(new SMIMECapabilitiesAttribute(caps));
//
// Initialise the S/MIME generator
//
System.out.println("am_smime: " + "init SMIME generator" + ": " + Sysdate());
//
SMIMESignedGenerator gen = new SMIMESignedGenerator();
//
// Add the signer
//
gen.addSigner( smimeSigningKey, (X509Certificate) smimeCertChain[0], SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
//
// put the certificates into an array
//
ArrayList certList = new ArrayList();
for (int i = 0; i < smimeCertChain.length; i++) {
certList.add(smimeCertChain[i]);
}
//
CertStore certsAndcrls = CertStore.getInstance("Collection", new CollectionCertStoreParameters(certList), "BC");
gen.addCertificatesAndCRLs(certsAndcrls);
//
// Now start building the message
//
System.out.println("am_smime: " + "build message" + ": " + Sysdate());
MimeBodyPart msg1 = new MimeBodyPart();
msg1.setText(mailBody, defaultCharset);
//
// And the attachment
//
MimeBodyPart msg2 = new MimeBodyPart();
//
// Create the multipart
//
MimeMultipart mp = new MimeMultipart();
//
// Create the body
//
MimeBodyPart msg = new MimeBodyPart();
//
if (pBlob != null) {
//
// We have an attachement
//
InputStream inputstream = pBlob.getBinaryStream();
DataHandler dh = new DataHandler(new ByteArrayDataSource(inputstream, fileMimeType));
msg2.setDataHandler(dh);
msg2.setFileName(fileName);
//
// Add the parts
//
mp.addBodyPart(msg1);
mp.addBodyPart(msg2);
//
// Set the content of the message to the multipart
//
msg.setContent(mp);
} else
{
//
// No attachment, set the content of the message to the first part
//
msg.setText(mailBody, defaultCharset);
}
//
// extract the multipart object from the SMIMESigned object.
//
MimeMultipart mm = gen.generate(msg, "BC");
//
// Inititialise mail authenticator
//
authenticator = new DefaultAuthenticator(smtpUsername, smtpPassword);
//
// Set the properties
//
Properties props = new Properties();
props.put("mail.smtp.host", smtpServerHost);
props.put("mail.smtp.user", smtpUsername);
//
// Get a Session object and create the mail message
//
Session session = Session.getDefaultInstance(props, authenticator);
//
// Set from and to
//
Address fromUser = new InternetAddress(mailFrom);
Address toUser = new InternetAddress(mailTo);
//
// Construct the message
//
MimeMessage body = new MimeMessage(session);
body.setFrom(fromUser);
body.setRecipient(Message.RecipientType.TO, toUser);
body.setSubject(mailSubject, defaultCharset);
body.setContent(mm, mm.getContentType());
body.saveChanges();
//
// Send
//
System.out.println("am_smime: " + "send message" + ": " + Sysdate());
Transport.send(body);
//
// Close the database connection
//
if (conn != null || !conn.isClosed()) {
conn.close(); // Close the database connection
conn = null;
System.out.println("am_smime: " + "connection closed" + ": " + Sysdate());
}
}
//
// Standard connection routine - try internal first, otherwise try with above details
//
public static Connection getConnection() throws SQLException {
if ( conn == null ) {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
try {
conn = DriverManager.getConnection("jdbc:default:connection:");
} catch ( Exception e ){}
}
if ( conn == null ) {
conn = DriverManager.getConnection(connection,username,password);
}
conn.setAutoCommit(false); // this is needed to write in update mode to BLOB
return conn;
}
//
// Default authenticator for SMTP passwords
//
private static class DefaultAuthenticator extends Authenticator {
//
// Password authentication instance
//
private PasswordAuthentication auth = null;
//
// CTOR with username and password
//
// @param username
// @param password
//
public DefaultAuthenticator (String username, String password) {
this.auth = new PasswordAuthentication(username, password);
}
//
// Overridden method returning password authentication
//
// @return PasswordAuthentication
//
public PasswordAuthentication getPasswordAuthentication() {
return this.auth;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
* TSException.java
*
* Created on 2007. janu<6E>r 21., 17:46
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package tsdemo;
/**
*
* @author root
*/
public class TSException extends Exception {
/** Creates a new instance of TSException */
public TSException() {
}
public TSException(String message) {
super(message);
}
public TSException(String message, Throwable cause) {
super(message, cause);
}
public TSException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,157 @@
/*
* TimeStamp.java
*
* Created on 2007. March 26
*
* Adapted from code supplied by MAV Informatika by Advantica Ltd.
*/
package tsdemo;
import org.bouncycastle.tsp.TimeStampRequestGenerator;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.contrib.ssl.AuthSSLProtocolSocketFactory;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import org.bouncycastle.tsp.*;
import java.security.MessageDigest;
import java.net.URL;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;
/**
*
* @author root
*/
public class TimeStamp {
private String KeystoreFile;
private String KeystorePassword;
private String URL;
private String time;
private boolean l_return;
//
public static byte[] TSRespByte;
//
private final TimeStampRequestGenerator TSReqGen;
/** Creates a new instance of TimeStamp */
public TimeStamp() {
TSReqGen = new TimeStampRequestGenerator();
TSReqGen.setCertReq(true);
}
public void setKeystoreFile(String KeystoreFile) {
this.KeystoreFile = KeystoreFile;
//System.out.println("genTS KeystoreFile " + this.KeystoreFile);
}
public void setKeystorePassword(String KeystorePassword) {
this.KeystorePassword = KeystorePassword;
//System.out.println("genTS KeystorePassword " + this.KeystorePassword);
}
public void setURL(String URL) {
this.URL = URL;
//System.out.println("genTS URL " + this.URL);
}
//
public static byte[] getResp() {
//
return TSRespByte;
}
//
public String generateTimestamp(byte[] hash,int portNumber) throws TSException { // Timestamp creation
//
// Code to produce a String java timestamp from a TSA source.
//
System.out.println("Entered generateTimestamp with: " + hash + " port: " + portNumber);
try {
TimeStampRequest TSReq = TSReqGen.generate("1.3.14.3.2.26", hash); // Setting hash algorithm to SHA-1, creating the TimeStamp Rrequest
//
//System.out.println("Got here 1");
ProtocolSocketFactory authfact = new AuthSSLProtocolSocketFactory( // This Factory helps httpclien to handle https with client side certificate authentication
new URL("file:" + KeystoreFile), KeystorePassword, // keystore that stores the client certificate
new URL("file:" + KeystoreFile), KeystorePassword); // keystore that stores the Root certificate of the server
//
//System.out.println("Got here 2");
Protocol authhttps = new Protocol("https", authfact, 443); // registering SSL/TLS handler for https protocol, default port 443
Protocol.registerProtocol("https", authhttps);
//
//System.out.println("Got here 3");
PostMethod post = new PostMethod(URL); // HTTP POST initialization, configuration
//
post.setRequestHeader("Content-type", "application/timestamp-query"); // We send a timestamp request
post.setRequestHeader("Accept", "application/timestamp-reply"); // and want a timestamp reply in exchange
//
//System.out.println("Got here 4");
post.setRequestEntity(new ByteArrayRequestEntity(TSReq.getEncoded())); // Loading the Timestamp request into the POST method
post.getParams().setParameter("http.socket.timeout", new Integer(60000)); // in milliseconds (1 min)
//
new HttpClient().executeMethod(post); // executing the HTTP POST operation, actual network traffic happens here
//System.out.println("Got here 5");
//
if (post.getStatusCode() != HttpStatus.SC_OK) // If we dont get a normal response, throw an exception
throw new TSException("unexpected status code: " + post.getStatusCode());
//
InputStream in = post.getResponseBodyAsStream(); // transfer the HTTP reply into a managable byte[]
//System.out.println("Got here 6");
//
// New code from Verify routine to produce the timestamp from the InoutStream.
//
TimeStampResponse TSResp = new TimeStampResponse(in); // Generate a TimeStampResponse object from the raw data
//System.out.println("Got here 7");
TimeStampTokenInfo tsinfo = TSResp.getTimeStampToken().getTimeStampInfo(); // Get the valuable data from the timestamp
//System.out.println("Got here 8");
time = tsinfo.getGenTime().toString(); // Translate Timestamp date into a readable form
//
// Get the byte[] response from the TSResp object so we can return it to amTimestamp.
//
TSRespByte = TSResp.getEncoded();
in.close();
return time; // return the timestamp response if no exception occured
} catch (Exception e) {
e.printStackTrace();
throw new TSException(e.getMessage()); // we got an exception, throw it up
}
}
public boolean verifyTimeStamp(byte[] hash, String Algorithm, InputStream tsdata) throws TSException { // Basic TimeStamp verification
try {
System.out.println("Verify hash is : " + hash + " Algorithm " + Algorithm + " Data: " + tsdata.toString());
TimeStampResponse TSResp = new TimeStampResponse(tsdata); // Generate a TimeStampResponse object from the raw data
TimeStampTokenInfo tsinfo = TSResp.getTimeStampToken().getTimeStampInfo(); // Get the valuable data from the timestamp
System.out.println("Verify 2");
time = tsinfo.getGenTime().toString(); // Translate Timestamp date into a readable form
// Optimistic!
System.out.println("Time: " + time);
//
MessageDigest d = MessageDigest.getInstance(Algorithm); // Get an SHA-1 handler
return d.isEqual(hash, tsinfo.getMessageImprintDigest()); // Return if the provided hash and the hash in the Timestamp is identical
} catch (Exception e) {
e.printStackTrace();
throw new TSException(e.getMessage()); // some expection occured, throw up
}
}
public String getTime() {
return time;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,32 @@
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>0</headerType>
<jar>C:\Subversion\eft\nominations\java\Timestamp Util\ts\build\amtsauth.jar</jar>
<outfile>C:\Subversion\eft\nominations\java\Timestamp Util\ts\build\amtsauth.exe</outfile>
<errTitle>amtsauth: Error</errTitle>
<jarArgs></jarArgs>
<chdir></chdir>
<customProcName>true</customProcName>
<stayAlive>false</stayAlive>
<icon>C:\Subversion\eft\nominations\java\Timestamp Util\ts\launch4j\favicon.ico</icon>
<jre>
<path></path>
<minVersion>1.3.0</minVersion>
<maxVersion></maxVersion>
<initialHeapSize>0</initialHeapSize>
<maxHeapSize>50</maxHeapSize>
<args></args>
</jre>
<versionInfo>
<fileVersion>2.7.2.1</fileVersion>
<txtFileVersion>2.7.2</txtFileVersion>
<fileDescription>Access Manager Timestamp Authentication</fileDescription>
<copyright>Copyright (C) 2008, Advantica Ltd</copyright>
<productVersion>2.7.2.1</productVersion>
<txtProductVersion>2.7.2</txtProductVersion>
<productName>Access Manager Timestamp Authentication</productName>
<companyName>http://www.advanticagroup.com</companyName>
<internalName>amtsauth</internalName>
<originalFilename>amtsauth.exe</originalFilename>
</versionInfo>
</launch4jConfig>

View File

@@ -0,0 +1,4 @@
src - contains the java source code, two projects, main being a dummy calling class. Also includes the BC jar files
build - containts the one-jar setup and jar file
launch4j - contains the setup file and icon for the build
exe - contains the latest exe

View File

@@ -0,0 +1,38 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<simple-archive-deployment nselem="simple-archive-deployment" class="oracle.jdeveloper.deploy.jar.ArchiveProfile" xmlns="http://xmlns.oracle.com/jdeveloper/10120/deploy/jar">
<archiveOptions>
<additionalManifests/>
<compressed>false</compressed>
<hasManifest>true</hasManifest>
<mainClass>AccessManager.amTSAuthenticate</mainClass>
</archiveOptions>
<fileGroups>
<groups>
<Item class="oracle.jdeveloper.deploy.common.PackagingFileGroup" internalName="project-output">
<contributors>
<Item type="2"/>
<Item type="7"/>
</contributors>
<displayName>amtsauth</displayName>
<filters>
<rules>
<Item type="1" pattern="META-INF/"/>
<Item type="1" pattern="AccessManager/.svn/"/>
<Item type="1" pattern=".svn/"/>
<Item type="1" pattern="AccessManager/amresourcebundle_hu.properties.OLD"/>
<Item type="1" pattern="**/CVS/"/>
<Item type="1" pattern="**.cdi"/>
<Item type="1" pattern="**.contrib"/>
<Item type="1" pattern="**.keep"/>
<Item type="1" pattern="**.rvi"/>
<Item type="1" pattern=".jsps/"/>
<Item type="0" pattern="**"/>
</rules>
</filters>
<targetWithinJar/>
</Item>
</groups>
</fileGroups>
<jarURL path="deploy/amtsauth.jar"/>
<profileDeps/>
</simple-archive-deployment>

View File

@@ -0,0 +1,323 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<project nselem="project" class="oracle.jdeveloper.model.JProject" xmlns="http://xmlns.oracle.com/jdeveloper/10120/jproject">
<defaultPackage>AccessManager</defaultPackage>
<defaultPackages class="java.util.ArrayList">
<Item class="java.lang.String">AccessManager</Item>
<Item class="java.lang.String">mypackage1</Item>
</defaultPackages>
<dependencyList/>
<htmlRootDirectory path="public_html/"/>
<j2eeWebAppName>Application1-amtsauthenticate-webapp</j2eeWebAppName>
<j2eeWebContextRoot>Application1-amtsauthenticate-context-root</j2eeWebContextRoot>
<listOfChildren class="oracle.ide.model.DataList">
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/amresourcebundle_en.properties"/>
<nodeClass>oracle.ide.model.DeployableTextNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/amresourcebundle_hu.properties"/>
<nodeClass>oracle.ide.model.DeployableTextNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/amresourcebundle.properties"/>
<nodeClass>oracle.ide.model.DeployableTextNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="amtsauth.deploy"/>
<nodeClass>oracle.ide.model.XMLDataNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/amTSAuthenticate.java"/>
<nodeClass>oracle.jdeveloper.model.JavaSourceNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/favicon.gif"/>
<nodeClass>oracle.jdeveloper.model.GifImageNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/hashFile.java"/>
<nodeClass>oracle.jdeveloper.model.JavaSourceNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/mainFrame_AboutBoxPanel1.java"/>
<nodeClass>oracle.jdeveloper.model.JavaSourceNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/mainFrame.java"/>
<nodeClass>oracle.jdeveloper.model.JavaSourceNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/TimeStamp.java"/>
<nodeClass>oracle.jdeveloper.model.JavaSourceNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/AccessManager/TSException.java"/>
<nodeClass>oracle.jdeveloper.model.JavaSourceNode</nodeClass>
</Item>
</listOfChildren>
<ownerMap/>
<projectDocPath>
<entries class="[Ljava.net.URL;"/>
</projectDocPath>
<projectLibraryList class="oracle.jdeveloper.library.JProjectLibraryList">
<jdkList class="java.util.ArrayList"/>
<libraryList class="java.util.ArrayList"/>
</projectLibraryList>
<projectSettings>
<activeConfigName>Development</activeConfigName>
<commonData class="java.util.HashMap">
<Item>
<Key>oracle.bm.commonIde.data.project.ModelerProjectSettings</Key>
<Value class="oracle.bm.commonIde.data.project.ModelerProjectSettings">
<modelersPath>
<entries>
<Item path="model/"/>
</entries>
</modelersPath>
<modelersVersion>10.12</modelersVersion>
</Value>
</Item>
<Item>
<Key>oracle.jdeveloper.compiler.ant.AntConfiguration</Key>
<Value class="oracle.jdeveloper.compiler.ant.AntConfiguration">
<arguments class="java.lang.String"/>
<makeTarget/>
<projectBuildfile/>
<rebuildTarget/>
<showOutput>true</showOutput>
</Value>
</Item>
<Item>
<Key>oracle.jdeveloper.offlinedb.OfflineDBProjectSettings</Key>
<Value class="oracle.jdeveloper.offlinedb.OfflineDBProjectSettings">
<databasePath>
<entries>
<Item path="database/"/>
</entries>
</databasePath>
</Value>
</Item>
</commonData>
<configurations class="java.util.TreeMap">
<Item>
<Key>Development</Key>
<Value class="oracle.jdeveloper.model.JProjectConfiguration">
<configData class="java.util.HashMap">
<Item>
<Key>oracle.jdeveloper.compiler.OjcConfiguration</Key>
<Value class="oracle.jdeveloper.compiler.OjcConfiguration">
<assertionsEnabled>false</assertionsEnabled>
<copyRes>
<Item>.gif</Item>
<Item>.properties</Item>
<Item>.jpg</Item>
<Item>.jpeg</Item>
<Item>.xml</Item>
<Item>-apf.xml</Item>
<Item>.xcfg</Item>
<Item>.cpx</Item>
<Item>.css</Item>
<Item>.js</Item>
<Item>.png</Item>
<Item>.tld</Item>
</copyRes>
<debugInformation>true</debugInformation>
<excludedClasses class="[Ljava.lang.String;"/>
<internalEncoding>Cp1252</internalEncoding>
<obfuscate>false</obfuscate>
<reverseCopyRes>false</reverseCopyRes>
<showDeprecations>true</showDeprecations>
<showObjectDotStaticWarnings>false</showObjectDotStaticWarnings>
<showPartialImportWarnings>false</showPartialImportWarnings>
<showSelfDeprecations>true</showSelfDeprecations>
<showUnusedImportWarnings>false</showUnusedImportWarnings>
<showWarnings>true</showWarnings>
<target>Default</target>
<updateImports>false</updateImports>
<updateZipJarImports>false</updateZipJarImports>
</Value>
</Item>
<Item>
<Key>oracle.jdeveloper.javadoc.JProjectJavadoc</Key>
<Value class="oracle.jdeveloper.javadoc.JProjectJavadoc">
<embedDiagram>5</embedDiagram>
<genDiagramDoc>true</genDiagramDoc>
<generateAuthor>false</generateAuthor>
<generateDeprecated>true</generateDeprecated>
<generateIndex>true</generateIndex>
<generateNavbar>true</generateNavbar>
<generateSince>true</generateSince>
<generateTree>true</generateTree>
<generateVersion>false</generateVersion>
<heapSize>32</heapSize>
<imageFormat>1</imageFormat>
<miscOptions class="java.lang.String"/>
<oneOneFormat>false</oneOneFormat>
<outputDirectory path="javadoc/"/>
<scope>-protected</scope>
</Value>
</Item>
<Item>
<Key>oracle.jdeveloper.runner.RunConfiguration</Key>
<Value class="oracle.jdeveloper.runner.RunConfiguration">
<VMName>client</VMName>
<XSLTInputFileURL/>
<XSLTOutputFileURL/>
<allowInput>false</allowInput>
<alwaysUseTarget>false</alwaysUseTarget>
<clearLogBeforeRun>true</clearLogBeforeRun>
<compileBeforeRun>true</compileBeforeRun>
<connectionName/>
<javaOptions class="java.lang.String"/>
<logCommand>true</logCommand>
<logError>true</logError>
<logExit>true</logExit>
<logOutput>true</logOutput>
<programArguments class="java.lang.String"/>
<runActiveFile>true</runActiveFile>
<runDirectoryURL/>
<targetURL path="src/AccessManager/amTSAuthenticate.java"/>
<useProxy>true</useProxy>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.config.JProjectLibraries</Key>
<Value class="oracle.jdevimpl.config.JProjectLibraries">
<jdkName>1.4.2_06</jdkName>
<jdkVersionNumber>1.4.2_06</jdkVersionNumber>
<libraries>BouncyCastleTimestamp</libraries>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.config.JProjectPaths</Key>
<Value class="oracle.jdevimpl.config.JProjectPaths">
<additionalClassPath>
<entries class="[Ljava.net.URL;"/>
</additionalClassPath>
<outputDirectory path="classes/"/>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.codecoach.CCConfiguration</Key>
<Value class="oracle.jdevimpl.runner.codecoach.CCConfiguration">
<advices>ALL</advices>
<exclude>com;java;javax;sun;sunw;org;oracle</exclude>
<include class="java.lang.String"/>
<level>4</level>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.debug.DebugConfiguration</Key>
<Value class="oracle.jdevimpl.runner.debug.DebugConfiguration">
<JPDAClassicDebugArguments>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=&lt;port></JPDAClassicDebugArguments>
<JPDADebugArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=&lt;port></JPDADebugArguments>
<OJVMDebugArguments>-XXdebug,quiet,port&lt;port></OJVMDebugArguments>
<breakpointScope>workspace</breakpointScope>
<remoteDebugging>false</remoteDebugging>
<remoteDebuggingParameters class="java.util.HashMap"/>
<remoteDebuggingParametersSaved>false</remoteDebuggingParametersSaved>
<remoteDebuggingProtocol>ojvm</remoteDebuggingProtocol>
<startOption>running</startOption>
<tracingDisabled>java;javax;sun;sunw;apple;com.apple;com.evermind;com.oracle;com.orionserver;com.sun;EDU.oswego;oracle.core;oracle.dms;oracle.ide;oracle.j2ee;oracle.jdbc;oracle.jdevimpl;oracle.jsp;oracle.oc4j;oracle.ojc;oracle.security;oracle.xml;org.omg;org.w3c;org.xml</tracingDisabled>
<tracingEnabled class="java.lang.String"/>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.profile.ProfileConfiguration</Key>
<Value class="oracle.jdevimpl.runner.profile.ProfileConfiguration">
<DMSstartID>20000</DMSstartID>
<DMSstate>0</DMSstate>
<eventColumnVisible>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
</eventColumnVisible>
<events>G(All events;(G(VM Events;(E(0;GC;-16776961;1);E(10;Wait;-65485;0);E(11;Synch Blocks 0;-39322;0);E(12;Synch Blocks 1;-39322;0);E(13;Synch Blocks 2;-39322;0);E(20;Prepare Class;-16751002;0);E(21;Load Class;-16724992;0);E(22;Resolve Class;-16737997;0);));G(BC4J Events;(E(1000;JBO_MISCELLANEOUS;-4144960;1);E(1001;JDBC_SELECT;-256;1);E(1002;JDBC_CREATE_STATEMENT;-256;1);E(1003;JDBC_CONNECT;-256;1);E(1004;JDBC_CREATE_PREPARED_STATEMENT;-256;1);E(1005;JDBC_EXECUTE;-256;1);E(1006;METAOBJECT_LOAD;-65281;1);E(1007;EXECUTE_QUERY;-16776961;1);E(1008;BC4J_CREATE_COMPOBJ;-65281;0);E(1009;BC4J_CREATE_ROOTAM;-65281;1);E(1010;BC4J_CREATE_VIEWOBJECT;-65281;0);E(1011;BC4J_CREATE_AM;-65281;0);E(1012;BC4J_CREATE_VIEWLINK;-65281;0);E(1013;SQLB_DOENTITYDML;-16776961;1);E(1014;SQLB_DOENTITYSELECT;-16776961;1);E(1015;VIEWOBJECT_GETSTATEMENT;-16776961;1);E(1016;REMOTE_METHOD_CALL;-65536;1);));));</events>
<excludedClasses>java;javax;sun;sunw;com;oracle</excludedClasses>
<excludedInstances class="java.lang.String"/>
<includedClasses class="java.lang.String"/>
<includedInstances class="java.lang.String"/>
<localProfiling>true</localProfiling>
<memColumnVisible>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
</memColumnVisible>
<memoryUpdateInterval>10</memoryUpdateInterval>
<remoteHost class="java.lang.String"/>
<remoteParametersSaved>false</remoteParametersSaved>
<remotePort>4000</remotePort>
<sampleColumnVisible>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
</sampleColumnVisible>
<sampleInterval>5</sampleInterval>
<sliderDepth>20</sliderDepth>
<useAPI>false</useAPI>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.xslt.XSLTConfiguration</Key>
<Value class="oracle.jdevimpl.runner.xslt.XSLTConfiguration">
<inputFileURL/>
<outputFileURL/>
<showInputFile>true</showInputFile>
<showOutputFile>true</showOutputFile>
<sourcePath>
<entries class="[Ljava.net.URL;"/>
</sourcePath>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.sqlj.config.SqljConfiguration</Key>
<Value class="oracle.jdevimpl.sqlj.config.SqljConfiguration">
<additionalParameters class="java.lang.String"/>
<checkSemantics>false</checkSemantics>
<codegen>oracle</codegen>
<contextConnectionMap class="java.util.HashMap"/>
<contextName>&lt;none></contextName>
<useCache>false</useCache>
<warnAll>false</warnAll>
<warnNull>false</warnNull>
<warnPortable>false</warnPortable>
<warnPrecision>false</warnPrecision>
<warnStrict>false</warnStrict>
<warnVerbose>false</warnVerbose>
</Value>
</Item>
<Item>
<Key>WebappJspCompilerOptions</Key>
<Value class="oracle.jdevimpl.webapp.jsp.JspCompilerOptions">
<forgiveDuplicateDirectiveAttributes>false</forgiveDuplicateDirectiveAttributes>
<requestTimeIntrospection>false</requestTimeIntrospection>
<validate>true</validate>
<validateTLD>true</validateTLD>
</Value>
</Item>
</configData>
</Value>
</Item>
</configurations>
</projectSettings>
<projectSourcePath>
<entries>
<Item path="src/"/>
</entries>
</projectSourcePath>
<properties/>
</project>

View File

@@ -0,0 +1,25 @@
filebox1=Please select a file...
filebox2=Please select a file...
conffile=Confirmation File
timefile=Timestamp File
verify=Verify
title=Authenticate Timestamp
file=File
exit=Exit
help=Help
about=About
openconf=Open Confirmation File
opentime=Open Timestamp File
validts=Valid: timestamp is identical
invalidts=Invalid: file does not match timestamp
tsdetails=Timestamp:
exception=Exception occured.
about1=Authenticate Timestamp Utility
about2=Copyright Advantica Ltd 2008
fileopen=Open
filecancel=Cancel
filename=File Name
filelookin=Look In
filetype=Files Of Type
fileallfiles=All Files
dateformat=dd/MM/yyyy HH:mm:ss

View File

@@ -0,0 +1,25 @@
filebox1=Please select a file...
filebox2=Please select a file...
conffile=Confirmation File
timefile=Timestamp File
verify=Verify
title=Authenticate Timestamp
file=File
exit=Exit
help=Help
about=About
openconf=Open Confirmation File
opentime=Open Timestamp File
validts=Valid: timestamp is identical
invalidts=Invalid: file does not match timestamp
tsdetails=Timestamp:
exception=Exception occured.
about1=Authenticate Timestamp Utility
about2=Copyright Advantica Ltd 2008
fileopen=Open
filecancel=Cancel
filename=File Name
filelookin=Look In
filetype=Files Of Type
fileallfiles=All Files
dateformat=dd/MM/yyyy HH:mm:ss

View File

@@ -0,0 +1,25 @@
filebox1=K<EFBFBD>rem, v<>lasszon egy f<>jlt...
filebox2=K<EFBFBD>rem, v<>lasszon egy f<>jlt...
conffile=Visszaigazol<EFBFBD>s F<>jl
timefile=Id\u0151b<31>lyeg f<>jl
verify=Ellen\u0151rz<72>s
title=Id\u0151b<31>lyeg hiteles<65>t<EFBFBD>se
file=F<EFBFBD>jl
exit=Kil<EFBFBD>p<EFBFBD>s
help=S<EFBFBD>g<EFBFBD>
about=N<EFBFBD>vjegy
openconf=Visszaigazol<EFBFBD>s f<>jl megnyit<69>sa
opentime=Id\u0151b<31>lyeg f<>jl megnyit<69>sa
validts=<EFBFBD>rv<EFBFBD>nyes: Az id\u0151b<31>lyeg hiteles
invalidts=<EFBFBD>rv<EFBFBD>nytelen: A f<>jl nem egyezik az id\u0151b<31>lyeggel
tsdetails=Id\u0151b<31>lyeg:
exception=Probl<EFBFBD>ma l<>pett fel.
about1=Id\u0151b<31>lyeg hiteles<65>t\u0151 program
about2=Minden jog fenntartva, Advantica Ltd 2008
fileopen=Megnyit<EFBFBD>s
filecancel=M<EFBFBD>gsem
filename=F<EFBFBD>jln<EFBFBD>v
filelookin=Hely
filetype=F<EFBFBD>jlt<EFBFBD>pusok
fileallfiles=Minden f<>jl
dateformat=yyyy.MM.dd. HH:mm:ss

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 B

View File

@@ -0,0 +1,5 @@
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE application-client PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN" "http://java.sun.com/dtd/application-client_1_3.dtd">
<application-client>
<display-name>amtsauthenticate-app-client</display-name>
</application-client>

View File

@@ -0,0 +1,20 @@
package AccessManager;
public class TSException extends Exception {
/** Creates a new instance of TSException */
public TSException() {
}
public TSException(String message) {
super(message);
}
public TSException(String message, Throwable cause) {
super(message, cause);
}
public TSException(Throwable cause) {
super(cause);
}
}

View File

@@ -0,0 +1,38 @@
package AccessManager;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.bouncycastle.tsp.*;
import org.bouncycastle.asn1.tsp.TimeStampResp;
import java.security.MessageDigest;
import java.io.InputStream;
public class TimeStamp {
private String time;
private Date date;
public TimeStamp() { }
public boolean verifyTimeStamp(byte[] hash, String Algorithm, InputStream tsdata, String dateFormatMask) throws TSException { // Basic TimeStamp verification
try {
TimeStampResponse TSResp = new TimeStampResponse(tsdata); // Generate a TimeStampResponse object from the raw data
TimeStampTokenInfo tsinfo = TSResp.getTimeStampToken().getTimeStampInfo(); // Get the valuable data from the timestamp
date = tsinfo.getGenTime();
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatMask);
time = formatter.format(date);
MessageDigest d = MessageDigest.getInstance(Algorithm); // Get an SHA-1 handler
return d.isEqual(hash, tsinfo.getMessageImprintDigest()); // Return if the provided hash and the hash in the Timestamp is identical
} catch (Exception e) {
throw new TSException(e.getMessage()); // some expection occured, throw up
}
}
public String getTime() {
return time;
}
}

View File

@@ -0,0 +1,52 @@
package AccessManager;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.UIManager;
import java.awt.Dimension;
import java.awt.Toolkit;
public class amTSAuthenticate
{
public amTSAuthenticate()
{
Frame frame = new mainFrame();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height)
{
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width)
{
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
frame.setVisible(true);
}
/**
*
* @param args
*/
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch(Exception e)
{
e.printStackTrace();
}
new amTSAuthenticate();
}
}

View File

@@ -0,0 +1,25 @@
filebox1=Please select a file...
filebox2=Please select a file...
conffile=Confirmation File
timefile=Timestamp File
verify=Verify
title=Authenticate Timestamp
file=File
exit=Exit
help=Help
about=About
openconf=Open Confirmation File
opentime=Open Timestamp File
validts=Valid: timestamp is identical
invalidts=Invalid: file does not match timestamp
tsdetails=Timestamp:
exception=Exception occured.
about1=Authenticate Timestamp Utility
about2=Copyright Advantica Ltd 2008
fileopen=Open
filecancel=Cancel
filename=File Name
filelookin=Look In
filetype=Files Of Type
fileallfiles=All Files
dateformat=dd/MM/yyyy HH:mm:ss

View File

@@ -0,0 +1,25 @@
filebox1=Please select a file...
filebox2=Please select a file...
conffile=Confirmation File
timefile=Timestamp File
verify=Verify
title=Authenticate Timestamp
file=File
exit=Exit
help=Help
about=About
openconf=Open Confirmation File
opentime=Open Timestamp File
validts=Valid: timestamp is identical
invalidts=Invalid: file does not match timestamp
tsdetails=Timestamp:
exception=Exception occured.
about1=Authenticate Timestamp Utility
about2=Copyright Advantica Ltd 2008
fileopen=Open
filecancel=Cancel
filename=File Name
filelookin=Look In
filetype=Files Of Type
fileallfiles=All Files
dateformat=dd/MM/yyyy HH:mm:ss

View File

@@ -0,0 +1,25 @@
filebox1=K<EFBFBD>rem, v<>lasszon egy f<>jlt...
filebox2=K<EFBFBD>rem, v<>lasszon egy f<>jlt...
conffile=Visszaigazol<EFBFBD>s F<>jl
timefile=Id\u0151b<31>lyeg f<>jl
verify=Ellen\u0151rz<72>s
title=Id\u0151b<31>lyeg hiteles<65>t<EFBFBD>se
file=F<EFBFBD>jl
exit=Kil<EFBFBD>p<EFBFBD>s
help=S<EFBFBD>g<EFBFBD>
about=N<EFBFBD>vjegy
openconf=Visszaigazol<EFBFBD>s f<>jl megnyit<69>sa
opentime=Id\u0151b<31>lyeg f<>jl megnyit<69>sa
validts=<EFBFBD>rv<EFBFBD>nyes: Az id\u0151b<31>lyeg hiteles
invalidts=<EFBFBD>rv<EFBFBD>nytelen: A f<>jl nem egyezik az id\u0151b<31>lyeggel
tsdetails=Id\u0151b<31>lyeg:
exception=Probl<EFBFBD>ma l<>pett fel.
about1=Id\u0151b<31>lyeg hiteles<65>t\u0151 program
about2=Minden jog fenntartva, Advantica Ltd 2008
fileopen=Megnyit<EFBFBD>s
filecancel=M<EFBFBD>gsem
filename=F<EFBFBD>jln<EFBFBD>v
filelookin=Hely
filetype=F<EFBFBD>jlt<EFBFBD>pusok
fileallfiles=Minden f<>jl
dateformat=yyyy.MM.dd. HH:mm:ss

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 B

View File

@@ -0,0 +1,25 @@
package AccessManager;
import java.security.MessageDigest;
import java.io.FileInputStream;
public class hashFile {
/* Creates a new instance of HashFile */
public hashFile() { }
public static byte[] getHash(String Filename, String Algorithm) {
try {
MessageDigest d = MessageDigest.getInstance(Algorithm); // Get a hash handler
FileInputStream f = new FileInputStream(Filename); // open file for hashing
byte[] b = new byte[1];
while ( -1 != f.read(b, 0, 1)) // feed the message digester
d.update(b);
f.close();
return d.digest(); // get the final hash and return it
} catch (Exception e) {
return null;
}
}
}

View File

@@ -0,0 +1,229 @@
package AccessManager;
import java.awt.Image;
import java.text.DateFormat;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.io.FileFilter;
import javax.swing.JFormattedTextField;
import java.awt.Rectangle;
import javax.swing.JButton;
import java.awt.Font;
import java.io.File;
import java.io.FileInputStream;
import java.security.MessageDigest;
import javax.swing.UIManager;
public class mainFrame extends JFrame
{
private JLabel statusBar = new JLabel();
private JMenuItem menuHelpAbout = new JMenuItem();
private JMenu menuHelp = new JMenu();
private JMenuItem menuFileExit = new JMenuItem();
private JMenu menuFile = new JMenu();
private JMenuBar menuBar = new JMenuBar();
private JPanel panelCenter = new JPanel();
private BorderLayout layoutMain = new BorderLayout();
private JFormattedTextField l_conf_file = new JFormattedTextField();
private JFormattedTextField l_time_file = new JFormattedTextField();
private JButton l_conf_button = new JButton();
private JButton l_time_button = new JButton();
private JLabel d_conf_label = new JLabel();
private JLabel d_time_label = new JLabel();
private JButton l_verify_button = new JButton();
private JLabel d_hash_result = new JLabel();
private JLabel d_time_result = new JLabel();
private ResourceBundle rb = ResourceBundle.getBundle("AccessManager.amresourcebundle", Locale.getDefault());
public mainFrame()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
Locale.setDefault(new Locale(System.getProperty("user.language"), System.getProperty("user.language")));
this.setJMenuBar(menuBar);
this.getContentPane().setLayout(layoutMain);
panelCenter.setLayout(null);
l_conf_file.setText(rb.getString("filebox1"));
l_conf_file.setBounds(new Rectangle(125, 20, 185, 20));
l_conf_file.setEnabled(false);
l_conf_file.setFocusable(false);
l_time_file.setText(rb.getString("filebox2"));
l_time_file.setBounds(new Rectangle(125, 55, 185, 20));
l_time_file.setEnabled(false);
l_time_file.setFocusable(false);
l_conf_button.setText("jButton1");
l_conf_button.setBounds(new Rectangle(310, 20, 20, 20));
l_conf_button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
showFilelistConf(e);
}
});
l_time_button.setText("jButton2");
l_time_button.setBounds(new Rectangle(310, 55, 20, 20));
l_time_button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
showFilelistTime(e);
}
});
d_conf_label.setText(rb.getString("conffile"));
d_conf_label.setBounds(new Rectangle(10, 20, 110, 20));
d_conf_label.setFont(new Font("SansSerif", 1, 12));
d_time_label.setText(rb.getString("timefile"));
d_time_label.setBounds(new Rectangle(10, 55, 110, 20));
d_time_label.setFont(new Font("SansSerif", 1, 12));
l_verify_button.setText(rb.getString("verify"));
l_verify_button.setBounds(new Rectangle(215, 90, 115, 25));
l_verify_button.setEnabled(false);
l_verify_button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
verifyTimestamp(e);
}
});
d_hash_result.setBounds(new Rectangle(10, 90, 230, 15));
d_time_result.setBounds(new Rectangle(10, 110, 235, 15));
this.setSize(new Dimension(348, 186));
this.setTitle(rb.getString("title"));
//this.setIconImage(new ImageIcon("favicon.gif").getImage());
menuFile.setText(rb.getString("file"));
menuFileExit.setText(rb.getString("exit"));
menuFileExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
fileExit_ActionPerformed(ae);
}
});
menuHelp.setText(rb.getString("help"));
menuHelpAbout.setText(rb.getString("about"));
menuHelpAbout.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
helpAbout_ActionPerformed(ae);
}
});
statusBar.setText("");
menuFile.add(menuFileExit);
menuBar.add(menuFile);
menuHelp.add(menuHelpAbout);
menuBar.add(menuHelp);
this.getContentPane().add(statusBar, BorderLayout.SOUTH);
this.getContentPane().add(panelCenter, BorderLayout.CENTER);
panelCenter.add(d_time_result, null);
panelCenter.add(d_hash_result, null);
panelCenter.add(l_verify_button, null);
panelCenter.add(d_time_label, null);
panelCenter.add(d_conf_label, null);
panelCenter.add(l_time_button, null);
panelCenter.add(l_conf_button, null);
panelCenter.add(l_time_file, null);
panelCenter.add(l_conf_file, null);
UIManager.put("FileChooser.openButtonText", rb.getString("fileopen"));
UIManager.put("FileChooser.openButtonText", rb.getString("fileopen"));
UIManager.put("FileChooser.cancelButtonText", rb.getString("filecancel"));
UIManager.put("FileChooser.fileNameLabelText", rb.getString("filename"));
UIManager.put("FileChooser.lookInLabelText", rb.getString("filelookin"));
UIManager.put("FileChooser.filesOfTypeLabelText", rb.getString("filetype"));
}
void fileExit_ActionPerformed(ActionEvent e)
{
System.exit(0);
}
void helpAbout_ActionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(this, new mainFrame_AboutBoxPanel1(), rb.getString("about"), JOptionPane.PLAIN_MESSAGE);
}
private void checkVerify()
{
if ((l_conf_file.getText().compareTo(rb.getString("filebox1")) != 0 ) && (l_time_file.getText().compareTo(rb.getString("filebox1")) != 0))
{
l_verify_button.setEnabled(true);
}
}
private void showFilelistConf(ActionEvent e)
{
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setDialogTitle(rb.getString("openconf"));
jFileChooser.removeChoosableFileFilter(jFileChooser.getFileFilter());
int ret = jFileChooser.showOpenDialog(this);
if (ret == javax.swing.JFileChooser.APPROVE_OPTION) {
File f = jFileChooser.getSelectedFile();
l_conf_file.setText(f.getAbsolutePath());
l_conf_file.setToolTipText(f.getAbsolutePath());
checkVerify();
}
}
private void showFilelistTime(ActionEvent e)
{
JComponent.setDefaultLocale(Locale.getDefault());
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.removeChoosableFileFilter(jFileChooser.getFileFilter());
jFileChooser.setDialogTitle(rb.getString("opentime"));
int ret = jFileChooser.showOpenDialog(this);
if (ret == javax.swing.JFileChooser.APPROVE_OPTION) {
File f = jFileChooser.getSelectedFile();
l_time_file.setText(f.getAbsolutePath());
l_time_file.setToolTipText(f.getAbsolutePath());
checkVerify();
}
}
private void verifyTimestamp(ActionEvent e)
{
byte[] hash = hashFile.getHash(l_conf_file.getText(), "SHA-1");
TimeStamp ts = new TimeStamp();
try {
FileInputStream in = new FileInputStream(l_time_file.getText());
if (ts.verifyTimeStamp(hash, "SHA-1", in, rb.getString("dateformat")))
d_hash_result.setText(rb.getString("validts"));
else
d_hash_result.setText(rb.getString("invalidts"));
d_time_result.setText(rb.getString("tsdetails") + " " + ts.getTime());
in.close();
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(this, rb.getString("exception") + "\n" + ex.getMessage());
}
}
}

View File

@@ -0,0 +1,48 @@
package AccessManager;
import java.util.ResourceBundle;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.border.Border;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import java.util.Locale;
public class mainFrame_AboutBoxPanel1 extends JPanel
{
private Border border = BorderFactory.createEtchedBorder();
private GridBagLayout layoutMain = new GridBagLayout();
private JLabel labelCompany = new JLabel();
private JLabel labelCopyright = new JLabel();
private JLabel labelAuthor = new JLabel();
private JLabel labelTitle = new JLabel();
private ResourceBundle rb = ResourceBundle.getBundle("AccessManager.amresourcebundle", Locale.getDefault());
public mainFrame_AboutBoxPanel1()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
this.setLayout(layoutMain);
this.setBorder(border);
labelTitle.setText(rb.getString("about1"));
labelAuthor.setText(rb.getString("about2"));
labelCopyright.setText(System.getProperty("user.language"));
labelCompany.setText(Locale.getDefault().getDisplayName());
this.add(labelTitle, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 15, 0, 15), 0, 0));
this.add(labelAuthor, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 15, 0, 15), 0, 0));
this.add(labelCopyright, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 15, 0, 15), 0, 0));
this.add(labelCompany, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 15, 5, 15), 0, 0));
}
}

View File

@@ -0,0 +1,7 @@
title=Exemple
r0=Etats-Unis
r1=France
r2=Allemagne
rDefault=r1
btnQuit=Quitte
today=(fr) {0,date, dd/MM/yyyy}

View File

@@ -0,0 +1,36 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<simple-archive-deployment nselem="simple-archive-deployment" class="oracle.jdeveloper.deploy.jar.ArchiveProfile" xmlns="http://xmlns.oracle.com/jdeveloper/10120/deploy/jar">
<archiveOptions>
<additionalManifests/>
<compressed>false</compressed>
<hasManifest>true</hasManifest>
<mainClass>mypackage.Main</mainClass>
</archiveOptions>
<fileGroups>
<groups>
<Item class="oracle.jdeveloper.deploy.common.PackagingFileGroup" internalName="project-output">
<contributors>
<Item type="2"/>
<Item type="7"/>
</contributors>
<displayName>Project Output</displayName>
<filters>
<rules>
<Item type="1" pattern="AccessMsanager/"/>
<Item type="1" pattern="AccessManager/"/>
<Item type="1" pattern="**/CVS/"/>
<Item type="1" pattern="**.cdi"/>
<Item type="1" pattern="**.contrib"/>
<Item type="1" pattern="**.keep"/>
<Item type="1" pattern="**.rvi"/>
<Item type="1" pattern=".jsps/"/>
<Item type="0" pattern="**"/>
</rules>
</filters>
<targetWithinJar/>
</Item>
</groups>
</fileGroups>
<jarURL path="deploy/main.jar.jar"/>
<profileDeps/>
</simple-archive-deployment>

View File

@@ -0,0 +1,282 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<project nselem="project" class="oracle.jdeveloper.model.JProject" xmlns="http://xmlns.oracle.com/jdeveloper/10120/jproject">
<defaultPackage>mypackage</defaultPackage>
<defaultPackages class="java.util.ArrayList">
<Item class="java.lang.String">mypackage</Item>
</defaultPackages>
<dependencyList class="java.util.ArrayList">
<Item class="oracle.jdeveloper.library.ProjectLibrary">
<locked>true</locked>
<sourceOwnerURL path="../Application1.jws"/>
<sourceURL path="../amtsauthenticate/amtsauthenticate.jpr"/>
</Item>
</dependencyList>
<htmlRootDirectory path="public_html/"/>
<j2eeWebAppName>mainproject</j2eeWebAppName>
<j2eeWebContextRoot>mainproject</j2eeWebContextRoot>
<listOfChildren class="oracle.ide.model.DataList">
<Item class="oracle.ide.model.Reference">
<URL path="main.jar.deploy"/>
<nodeClass>oracle.ide.model.XMLDataNode</nodeClass>
</Item>
<Item class="oracle.ide.model.Reference">
<URL path="src/mypackage/Main.java"/>
<nodeClass>oracle.jdeveloper.model.JavaSourceNode</nodeClass>
</Item>
</listOfChildren>
<ownerMap/>
<projectDocPath>
<entries class="[Ljava.net.URL;"/>
</projectDocPath>
<projectLibraryList class="oracle.jdeveloper.library.JProjectLibraryList">
<jdkList class="java.util.ArrayList"/>
<libraryList class="java.util.ArrayList"/>
</projectLibraryList>
<projectSettings>
<activeConfigName>Development</activeConfigName>
<commonData class="java.util.HashMap">
<Item>
<Key>oracle.bm.commonIde.data.project.ModelerProjectSettings</Key>
<Value class="oracle.bm.commonIde.data.project.ModelerProjectSettings">
<modelersPath>
<entries>
<Item path="model/"/>
</entries>
</modelersPath>
<modelersVersion>10.12</modelersVersion>
</Value>
</Item>
<Item>
<Key>oracle.jdeveloper.compiler.ant.AntConfiguration</Key>
<Value class="oracle.jdeveloper.compiler.ant.AntConfiguration">
<arguments class="java.lang.String"/>
<makeTarget/>
<projectBuildfile/>
<rebuildTarget/>
<showOutput>true</showOutput>
</Value>
</Item>
</commonData>
<configurations class="java.util.TreeMap">
<Item>
<Key>Development</Key>
<Value class="oracle.jdeveloper.model.JProjectConfiguration">
<configData class="java.util.HashMap">
<Item>
<Key>oracle.jdeveloper.compiler.OjcConfiguration</Key>
<Value class="oracle.jdeveloper.compiler.OjcConfiguration">
<assertionsEnabled>false</assertionsEnabled>
<copyRes>
<Item>.gif</Item>
<Item>.properties</Item>
<Item>.jpg</Item>
<Item>.jpeg</Item>
<Item>.xml</Item>
<Item>-apf.xml</Item>
<Item>.xcfg</Item>
<Item>.cpx</Item>
<Item>.css</Item>
<Item>.js</Item>
<Item>.png</Item>
<Item>.tld</Item>
</copyRes>
<debugInformation>true</debugInformation>
<excludedClasses class="[Ljava.lang.String;"/>
<internalEncoding>Default</internalEncoding>
<obfuscate>false</obfuscate>
<reverseCopyRes>false</reverseCopyRes>
<showDeprecations>true</showDeprecations>
<showObjectDotStaticWarnings>false</showObjectDotStaticWarnings>
<showPartialImportWarnings>false</showPartialImportWarnings>
<showSelfDeprecations>true</showSelfDeprecations>
<showUnusedImportWarnings>false</showUnusedImportWarnings>
<showWarnings>true</showWarnings>
<target>Default</target>
<updateImports>false</updateImports>
<updateZipJarImports>false</updateZipJarImports>
</Value>
</Item>
<Item>
<Key>oracle.jdeveloper.javadoc.JProjectJavadoc</Key>
<Value class="oracle.jdeveloper.javadoc.JProjectJavadoc">
<embedDiagram>5</embedDiagram>
<genDiagramDoc>true</genDiagramDoc>
<generateAuthor>false</generateAuthor>
<generateDeprecated>true</generateDeprecated>
<generateIndex>true</generateIndex>
<generateNavbar>true</generateNavbar>
<generateSince>true</generateSince>
<generateTree>true</generateTree>
<generateVersion>false</generateVersion>
<heapSize>32</heapSize>
<imageFormat>1</imageFormat>
<miscOptions class="java.lang.String"/>
<oneOneFormat>false</oneOneFormat>
<outputDirectory path="javadoc/"/>
<scope>-protected</scope>
</Value>
</Item>
<Item>
<Key>oracle.jdeveloper.runner.RunConfiguration</Key>
<Value class="oracle.jdeveloper.runner.RunConfiguration">
<VMName>ojvm</VMName>
<XSLTInputFileURL/>
<XSLTOutputFileURL/>
<allowInput>false</allowInput>
<alwaysUseTarget>false</alwaysUseTarget>
<clearLogBeforeRun>true</clearLogBeforeRun>
<compileBeforeRun>true</compileBeforeRun>
<connectionName/>
<javaOptions class="java.lang.String"/>
<logCommand>true</logCommand>
<logError>true</logError>
<logExit>true</logExit>
<logOutput>true</logOutput>
<programArguments class="java.lang.String"/>
<runActiveFile>true</runActiveFile>
<runDirectoryURL/>
<targetURL/>
<useProxy>true</useProxy>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.config.JProjectLibraries</Key>
<Value class="oracle.jdevimpl.config.JProjectLibraries">
<jdkName>1.4.2_06</jdkName>
<jdkVersionNumber>1.4.2_06</jdkVersionNumber>
<libraries class="java.lang.String"/>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.config.JProjectPaths</Key>
<Value class="oracle.jdevimpl.config.JProjectPaths">
<additionalClassPath>
<entries class="[Ljava.net.URL;"/>
</additionalClassPath>
<outputDirectory path="classes/"/>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.codecoach.CCConfiguration</Key>
<Value class="oracle.jdevimpl.runner.codecoach.CCConfiguration">
<advices>ALL</advices>
<exclude>com;java;javax;sun;sunw;org;oracle</exclude>
<include class="java.lang.String"/>
<level>4</level>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.debug.DebugConfiguration</Key>
<Value class="oracle.jdevimpl.runner.debug.DebugConfiguration">
<JPDAClassicDebugArguments>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=&lt;port></JPDAClassicDebugArguments>
<JPDADebugArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=&lt;port></JPDADebugArguments>
<OJVMDebugArguments>-XXdebug,quiet,port&lt;port></OJVMDebugArguments>
<breakpointScope>workspace</breakpointScope>
<remoteDebugging>false</remoteDebugging>
<remoteDebuggingParameters class="java.util.HashMap"/>
<remoteDebuggingParametersSaved>false</remoteDebuggingParametersSaved>
<remoteDebuggingProtocol>ojvm</remoteDebuggingProtocol>
<startOption>running</startOption>
<tracingDisabled>java;javax;sun;sunw;apple;com.apple;com.evermind;com.oracle;com.orionserver;com.sun;EDU.oswego;oracle.core;oracle.dms;oracle.ide;oracle.j2ee;oracle.jdbc;oracle.jdevimpl;oracle.jsp;oracle.oc4j;oracle.ojc;oracle.security;oracle.xml;org.omg;org.w3c;org.xml</tracingDisabled>
<tracingEnabled class="java.lang.String"/>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.profile.ProfileConfiguration</Key>
<Value class="oracle.jdevimpl.runner.profile.ProfileConfiguration">
<DMSstartID>20000</DMSstartID>
<DMSstate>0</DMSstate>
<eventColumnVisible>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
</eventColumnVisible>
<events>G(All events;(G(VM Events;(E(0;GC;-16776961;1);E(10;Wait;-65485;0);E(11;Synch Blocks 0;-39322;0);E(12;Synch Blocks 1;-39322;0);E(13;Synch Blocks 2;-39322;0);E(20;Prepare Class;-16751002;0);E(21;Load Class;-16724992;0);E(22;Resolve Class;-16737997;0);));G(BC4J Events;(E(1000;JBO_MISCELLANEOUS;-4144960;1);E(1001;JDBC_SELECT;-256;1);E(1002;JDBC_CREATE_STATEMENT;-256;1);E(1003;JDBC_CONNECT;-256;1);E(1004;JDBC_CREATE_PREPARED_STATEMENT;-256;1);E(1005;JDBC_EXECUTE;-256;1);E(1006;METAOBJECT_LOAD;-65281;1);E(1007;EXECUTE_QUERY;-16776961;1);E(1008;BC4J_CREATE_COMPOBJ;-65281;0);E(1009;BC4J_CREATE_ROOTAM;-65281;1);E(1010;BC4J_CREATE_VIEWOBJECT;-65281;0);E(1011;BC4J_CREATE_AM;-65281;0);E(1012;BC4J_CREATE_VIEWLINK;-65281;0);E(1013;SQLB_DOENTITYDML;-16776961;1);E(1014;SQLB_DOENTITYSELECT;-16776961;1);E(1015;VIEWOBJECT_GETSTATEMENT;-16776961;1);E(1016;REMOTE_METHOD_CALL;-65536;1);));));</events>
<excludedClasses>java;javax;sun;sunw;com;oracle</excludedClasses>
<excludedInstances class="java.lang.String"/>
<includedClasses class="java.lang.String"/>
<includedInstances class="java.lang.String"/>
<localProfiling>true</localProfiling>
<memColumnVisible>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
</memColumnVisible>
<memoryUpdateInterval>10</memoryUpdateInterval>
<remoteHost class="java.lang.String"/>
<remoteParametersSaved>false</remoteParametersSaved>
<remotePort>4000</remotePort>
<sampleColumnVisible>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
<Item>true</Item>
</sampleColumnVisible>
<sampleInterval>5</sampleInterval>
<sliderDepth>20</sliderDepth>
<useAPI>false</useAPI>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.runner.xslt.XSLTConfiguration</Key>
<Value class="oracle.jdevimpl.runner.xslt.XSLTConfiguration">
<inputFileURL/>
<outputFileURL/>
<showInputFile>true</showInputFile>
<showOutputFile>true</showOutputFile>
<sourcePath>
<entries class="[Ljava.net.URL;"/>
</sourcePath>
</Value>
</Item>
<Item>
<Key>oracle.jdevimpl.sqlj.config.SqljConfiguration</Key>
<Value class="oracle.jdevimpl.sqlj.config.SqljConfiguration">
<additionalParameters class="java.lang.String"/>
<checkSemantics>false</checkSemantics>
<codegen>oracle</codegen>
<contextConnectionMap class="java.util.HashMap"/>
<contextName>&lt;none></contextName>
<useCache>false</useCache>
<warnAll>false</warnAll>
<warnNull>false</warnNull>
<warnPortable>false</warnPortable>
<warnPrecision>false</warnPrecision>
<warnStrict>false</warnStrict>
<warnVerbose>false</warnVerbose>
</Value>
</Item>
<Item>
<Key>WebappJspCompilerOptions</Key>
<Value class="oracle.jdevimpl.webapp.jsp.JspCompilerOptions">
<forgiveDuplicateDirectiveAttributes>false</forgiveDuplicateDirectiveAttributes>
<requestTimeIntrospection>false</requestTimeIntrospection>
<validate>true</validate>
<validateTLD>true</validateTLD>
</Value>
</Item>
</configData>
</Value>
</Item>
</configurations>
</projectSettings>
<projectSourcePath>
<entries>
<Item path="src/"/>
</entries>
</projectSourcePath>
<properties/>
</project>

View File

@@ -0,0 +1,17 @@
package mypackage;
public class Main
{
public Main()
{
}
/**
*
* @param args
*/
public static void main(String[] args)
{
new AccessManager.amTSAuthenticate();
}
}

View File

@@ -0,0 +1,40 @@
package tsdemo;
/*
* amHashFile.java
*
* Created on 2007. March 22
*
*/
import java.security.MessageDigest;
import java.io.InputStream;
import oracle.sql.BLOB;
public class amHashFile
{
/** Creates a new instance of HashFile */
public amHashFile() {
}
public static byte[] getHash(oracle.sql.BLOB blobFile, String Algorithm) {
try {
MessageDigest d = MessageDigest.getInstance(Algorithm); // Get a hash handler
//FileInputStream f = new FileInputStream(Filename); // open file for hashing
/* get the blob from the documents table as a binary input stream */
//oracle.sql.BLOB blob = blobFile;
InputStream f = blobFile.getBinaryStream ();
//
byte[] b = new byte[1];
while ( -1 != f.read(b, 0, 1)) // feed the message digester
d.update(b);
f.close();
return d.digest(); // get the final hash and return it
} catch (Exception e) {
System.out.println("Hashing Error " + e.getMessage());
return null;
}
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,149 @@
package tsdemo;
// Class to alow Access manager to interface with the timestamp classes.
import oracle.sql.BLOB;
//import oracle.sql.*;
import oracle.jdbc.*;
import java.sql.*;
import java.io.*;
//
public class amTimestamp{
//
public static byte[] hash;
//
public static String fileName;
//
public static String timestamp;
//
public static oracle.sql.BLOB blobResponse;
//
public static String getHash() {
//
String stringHash;
//System.out.println("Class Hash: " + hash);
stringHash = hash.toString();
//
return stringHash;
}
//
/* Private Declaration */
private static Connection conn = null;
/* Procedural Declaration */
public static Connection getConnection() throws SQLException {
if ( conn == null ) {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
try {
conn = DriverManager.getConnection("jdbc:default:connection:");
System.out.println("connection=default");
} catch ( Exception e ){}
}
if ( conn == null ) {
conn = DriverManager.getConnection("jdbc:oracle:thin:@loordv01:1521:dev10g","eft_nom","eft_nom");
System.out.println("connection=thin");
}
conn.setAutoCommit(false); // this is needed to write in update mode to BLOB
return conn;
}
//
public static oracle.sql.BLOB getRespBlob() throws SQLException,IOException {
//
// Returning a BLOB seems to be more tricky than expected
// If you return the original BLOB you will get an error
// from oracle, however loading it as a binary stream
// returns the value rather than a reference so works.
//
// Connection os required to create a temporary BLOB.
//
conn = getConnection();
BLOB tmpBlob = BLOB.createTemporary(conn, false,BLOB.DURATION_SESSION);
//
// Parameter to tmpBlob.setBinaryStream() is odd, got from a example and
// as it works I've left it as is.
//
OutputStream os = tmpBlob.setBinaryStream(0L);
//
os.write(blobResponse.getBytes());
os.flush();
os.close();
//
return tmpBlob;
}
//
public static String amTimestamp(oracle.sql.BLOB blobFile,
String URL,
String password,
String keystore) throws Exception {
//
//System.out.println(" URL: " + URL + " password: " + password + "keystore: " + keystore);
//
// Declare an Oracle BLOB type so we can pass this back to the PLSQL to allow the entire
// timestamp response to be stored in the database (using the getRespBlob method)
//
blobResponse = oracle.sql.BLOB.empty_lob();
timestamp = null;
//
// Get the hash value for the entered file
//
hash = amHashFile.getHash(blobFile, "SHA-1");
//System.out.println("Hash: " + hash);
//
// Instantiate a TimeStamp instance
//
TimeStamp ts = new TimeStamp();
//
//set the variables via the set methods
//
ts.setKeystoreFile(keystore);
ts.setKeystorePassword(password);
ts.setURL(URL);
// generate the timestamp
try {
//
timestamp = ts.generateTimestamp(hash,1318);
//
//System.out.println("Got Timestamp : " + timestamp);
//
} catch (Exception e) {
//
throw new TSException(e.getMessage());
//System.out.println("Exception occured.\n" + e.getMessage());
}
//
byte[] TSResp = ts.getResp();
//
// Retrieve the timesatmp response array from the timestamp class
//
blobResponse.setBytes(TSResp);
//
//System.out.println("BLOB length is : " + blobResponse.getLength());
//
return timestamp;
}
/**
*
* @param args
*/
public static void main(String[] args)
{
// Created for testing from JAVA rather than for actual use.
//System.out.println("Got here 1");
//String errMsg = "We";
amTimestamp theTimestamp = new amTimestamp();
//
oracle.sql.BLOB emptyBlob = null;
//
try {
//
String timeVal = theTimestamp.amTimestamp(emptyBlob,"https://tsa.trust-sign.hu:1318/","almafa","C:\\EFT_Noms\\keystore.jks");
//
System.out.println(" TimeVal: " + timeVal);
}
catch (Exception e) {
//
//if (e.getMessage() != null)
System.out.println(e.getMessage());
//
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,15 @@
echo uploading java to database
set PATH=C:\Work\oracle\product\11.1.0\client_1\BIN;c:\oracle\DevSuite10g\jre\1.4.2\bin;c:\oracle\DevSuite10g\jlib;%PATH%
set ORACLE_HOME=C:\Work\oracle\product\11.1.0\client_1
set ORACLE_SID=dev10g
set ORACLE_USER=eft_nom_test/eft_nom_test
call %ORACLE_HOME%\bin\loadjava -user %ORACLE_USER%@%ORACLE_SID% -grant public -order -resolve -force -synonym -verbose -genmissing poi-scratchpad-2.5.1-final-20040804.jar 2>> load1.log
call %ORACLE_HOME%\bin\loadjava -user %ORACLE_USER%@%ORACLE_SID% -grant public -order -resolve -force -synonym -verbose -genmissing poi-2.5.1-final-20040804.jar 2>> load2.log
call %ORACLE_HOME%\bin\loadjava -user %ORACLE_USER%@%ORACLE_SID% -grant public -order -resolve -force -synonym -verbose -genmissing poi-contrib-2.5.1-final-20040804.jar 2>> load3.log
call %ORACLE_HOME%\bin\loadjava -user %ORACLE_USER%@%ORACLE_SID% -order -resolve -force -synonym -verbose -genmissing amfr_excel_j.class 2>> load4.log
call %ORACLE_HOME%\bin\loadjava -user %ORACLE_USER%@%ORACLE_SID% -nativecompile -verbose -resolve amfr_excel_j.java 2>> load5.log

View File

@@ -0,0 +1,772 @@
/*
* @author : Advantica
* @Version 0.1
*
*/
package advantica.oracle.accessmanager.amfr_excel_j;
/* Standard IO */
import java.io.*;
/* JDBC classes */
import java.io.IOException;
import java.sql.*;
/* Oracle Extensions to JDBC */
import java.util.Calendar;
import oracle.jdbc.*;
/* Oracle BLOB handler */
import oracle.sql.BLOB;
/* Spreadsheet class */
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.Region;
/* Numberformat */
import java.text.NumberFormat;
/* Main Class */
public class amfr_excel_j {
public static void main(String[] args) throws SQLException {
amfr_excel_j aej = new amfr_excel_j();
aej.writeWorkBook("1", "Sheet 1");
//aej.readWorkBook("81");
}
/* Private Declaration */
private static Connection conn = null;
/* Procedural Declaration */
public static Connection getConnection() throws SQLException {
if ( conn == null ) {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
try {
conn = DriverManager.getConnection("jdbc:default:connection:");
///ystem.out.println("connection=default");
} catch ( Exception e ){}
}
if ( conn == null ) {
conn = DriverManager.getConnection("jdbc:oracle:thin:@loordv01:1521:dev10g","gilberta","gilberta");
//System.out.println("connection=thin");
}
conn.setAutoCommit(false); // this is needed to write in update mode to BLOB
return conn;
}
public static short getcolorindex( String colour )
{
short coloridx;
if (colour.equals("AQUA"))
{
coloridx = HSSFColor.AQUA.index;
}
else if (colour.equals("BLACK"))
{
coloridx= HSSFColor.BLACK.index;
}
else if (colour.equals("BLUE"))
{
coloridx= HSSFColor.BLUE.index;
}
else if (colour.equals("BLUE_GREY"))
{
coloridx= HSSFColor.BLUE_GREY.index;
}
else if (colour.equals("BRIGHT_GREEN"))
{
coloridx= HSSFColor.BRIGHT_GREEN.index;
}
else if (colour.equals("BROWN"))
{
coloridx= HSSFColor.BROWN.index;
}
else if (colour.equals("CORAL"))
{
coloridx= HSSFColor.CORAL.index;
}
else if (colour.equals("CORNFLOWER_BLUE"))
{
coloridx= HSSFColor.CORNFLOWER_BLUE.index;
}
else if (colour.equals("DARK_BLUE"))
{
coloridx= HSSFColor.DARK_BLUE.index;
}
else if (colour.equals("DARK_GREEN"))
{
coloridx= HSSFColor.DARK_GREEN.index;
}
else if (colour.equals("DARK_RED"))
{
coloridx= HSSFColor.DARK_RED.index;
}
else if (colour.equals("DARK_TEAL"))
{
coloridx= HSSFColor.DARK_TEAL.index;
}
else if (colour.equals("DARK_YELLOW"))
{
coloridx= HSSFColor.DARK_YELLOW.index;
}
else if (colour.equals("GOLD"))
{
coloridx= HSSFColor.GOLD.index;
}
else if (colour.equals("GREEN"))
{
coloridx= HSSFColor.GREEN.index;
}
else if (colour.equals("GREY_25_PERCENT"))
{
coloridx= HSSFColor.GREY_25_PERCENT.index;
}
else if (colour.equals("GREY_40_PERCENT"))
{
coloridx= HSSFColor.GREY_40_PERCENT.index;
}
else if (colour.equals("GREY_50_PERCENT"))
{
coloridx= HSSFColor.GREY_50_PERCENT.index;
}
else if (colour.equals("GREY_80_PERCENT"))
{
coloridx= HSSFColor.GREY_80_PERCENT.index;
}
else if (colour.equals("INDIGO"))
{
coloridx= HSSFColor.INDIGO.index;
}
else if (colour.equals("LAVENDER"))
{
coloridx= HSSFColor.LAVENDER.index;
}
else if (colour.equals("LEMON_CHIFFON"))
{
coloridx= HSSFColor.LEMON_CHIFFON.index;
}
else if (colour.equals("LIGHT_BLUE"))
{
coloridx= HSSFColor.LIGHT_BLUE.index;
}
else if (colour.equals("LIGHT_CORNFLOWER_BLUE"))
{
coloridx= HSSFColor.LIGHT_CORNFLOWER_BLUE.index;
}
else if (colour.equals("LIGHT_GREEN"))
{
coloridx= HSSFColor.LIGHT_GREEN.index;
}
else if (colour.equals("LIGHT_ORANGE"))
{
coloridx= HSSFColor.LIGHT_ORANGE.index;
}
else if (colour.equals("LIGHT_TURQUOISE"))
{
coloridx= HSSFColor.LIGHT_TURQUOISE.index;
}
else if (colour.equals("LIGHT_YELLOW"))
{
coloridx= HSSFColor.LIGHT_YELLOW.index;
}
else if (colour.equals("LIME"))
{
coloridx= HSSFColor.LIME.index;
}
else if (colour.equals("MAROON"))
{
coloridx= HSSFColor.MAROON.index;
}
else if (colour.equals("OLIVE_GREEN"))
{
coloridx= HSSFColor.OLIVE_GREEN.index;
}
else if (colour.equals("ORANGE"))
{
coloridx= HSSFColor.ORANGE.index;
}
else if (colour.equals("ORCHID"))
{
coloridx= HSSFColor.ORCHID.index;
}
else if (colour.equals("PALE_BLUE"))
{
coloridx= HSSFColor.PALE_BLUE.index;
}
else if (colour.equals("PINK"))
{
coloridx= HSSFColor.PINK.index;
}
else if (colour.equals("PLUM"))
{
coloridx= HSSFColor.PLUM.index;
}
else if (colour.equals("RED"))
{
coloridx= HSSFColor.RED.index;
}
else if (colour.equals("ROSE"))
{
coloridx= HSSFColor.ROSE.index;
}
else if (colour.equals("ROYAL_BLUE"))
{
coloridx= HSSFColor.ROYAL_BLUE.index;
}
else if (colour.equals("SEA_GREEN"))
{
coloridx= HSSFColor.SEA_GREEN.index;
}
else if (colour.equals("SKY_BLUE"))
{
coloridx= HSSFColor.SKY_BLUE.index;
}
else if (colour.equals("TAN"))
{
coloridx= HSSFColor.TAN.index;
}
else if (colour.equals("TEAL"))
{
coloridx= HSSFColor.TEAL.index;
}
else if (colour.equals("TURQUOISE"))
{
coloridx= HSSFColor.TURQUOISE.index;
}
else if (colour.equals("VIOLET"))
{
coloridx= HSSFColor.VIOLET.index;
}
else if (colour.equals("WHITE"))
{
coloridx= HSSFColor.WHITE.index;
}
else if (colour.equals("YELLOW"))
{
coloridx= HSSFColor.YELLOW.index;
}
else
{
coloridx = HSSFColor.WHITE.index;
}
return coloridx;
}
public static short getalignindex( String alignment )
{
short alignidx;
if (alignment.equals("LEFT"))
{
alignidx = HSSFCellStyle.ALIGN_LEFT;
}
else if (alignment.equals("RIGHT"))
{
alignidx = HSSFCellStyle.ALIGN_RIGHT;
}
else if (alignment.equals("CENTER"))
{
alignidx = HSSFCellStyle.ALIGN_CENTER;
}
else if (alignment.equals("JUSTIFY"))
{
alignidx = HSSFCellStyle.ALIGN_JUSTIFY;
}
else if (alignment.equals("SELECTION"))
{
alignidx = HSSFCellStyle.ALIGN_CENTER_SELECTION;
}
else
{
alignidx = HSSFCellStyle.ALIGN_GENERAL;
}
return alignidx;
}
public static long writeWorkBook(String spreadsheetId
,String worksheetName
) {
/* start the spreadsheet at row 0 */
short current_row = 0;
long docu_id = 0;
String got_style = "N";
//System.out.println("writeWorkBook: Started with spreadsheetId: "+spreadsheetId);
try {
/* get a JDBC connection */
conn = getConnection();
//System.out.println("connection opened");
} catch(SQLException ex){
ex.printStackTrace();
}
if (spreadsheetId != null)
try {
//System.out.println("Point 1");
/* build the spreadsheet */
HSSFWorkbook wb = new HSSFWorkbook();
//System.out.println("Point 2");
/* build the worksheet */
HSSFSheet sheet1 = wb.createSheet(worksheetName);
//System.out.println("Point 3");
/* create the first row */
HSSFRow row = sheet1.createRow(current_row);
//System.out.println("Point 4");
/* create me a cell ref */
HSSFCell cell;
//System.out.println("Point 5");
/* initialize the cell style */
HSSFCellStyle style, default_style;
//System.out.println("Point 6");
/* init the font */
HSSFFont font, default_font;
//System.out.println("Point 7");
style = wb.createCellStyle();
font = wb.createFont();
/* now create some default styles and fonts, we'll leave them be... */
default_style = wb.createCellStyle();
default_font = wb.createFont();
/* prepare sql ready for binding */
PreparedStatement stmt = conn.prepareStatement
("SELECT amfr_excel.convert_x(x_axis) AS x_axis " +
",amfr_excel.convert_y(y_axis) AS y_axis " +
",cell_value " +
",cell_datatype " +
",cell_format_mask " +
",cell_border " +
",cell_background " +
",cell_merge " +
",cell_font " +
",cell_fontsize " +
",cell_align " +
",col_width " +
",row_height " +
",cell_wrap " +
"FROM gtt_spreadsheet gtsp " +
"WHERE gtsp.spreadsheet_id = ? " +
"ORDER BY x_axis, y_axis ");
//System.out.println("Point 8");
stmt.setString(1, spreadsheetId); /* bind spreadsheet identifier */
//System.out.println("Point 9");
ResultSet rset = stmt.executeQuery(); /* exec the query into rset */
//System.out.println("Point 10");
/* loop around the record set */
while (rset.next())
{
//System.out.println("Point 12");
if (current_row != rset.getShort("y_axis"))
{
current_row = rset.getShort("y_axis");
row = sheet1.createRow(current_row);
}
//System.out.println("Point 13");
cell = row.createCell((short)rset.getShort("x_axis"));
cell.setEncoding( HSSFCell.ENCODING_UTF_16 ); //ENCODING_COMPRESSED_UNICODE );
//System.out.println("Point 14");
if (rset.getString("cell_datatype") != null)
{
String datatype = rset.getString("cell_datatype");
if (datatype.toUpperCase().equals("N"))
{
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
//cell.setCellValue(rset.getFloat("cell_value"));
cell.setCellValue(rset.getDouble("cell_value"));
}
else if (datatype.toUpperCase().equals("D"))
{
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(rset.getDate("cell_value"));
}
else
{
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(rset.getString("cell_value"));
}
}
else
{
/* No datatype specified, just treat it as a string */
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(rset.getString("cell_value"));
}
if (rset.getString("col_width") != null)
{
//System.out.println("Point 14.1");
sheet1.setColumnWidth((short)rset.getShort("x_axis"),(short)rset.getShort("col_width"));
}
if (rset.getString("row_height") != null)
{
//System.out.println("Point 14.2");
row.setHeight((short)rset.getShort("row_height"));
}
//System.out.println("Point 14.3");
/* check to see if we need to merge any cells */
if (rset.getString("cell_merge") != null)
{
sheet1.addMergedRegion(new Region(current_row, (short)rset.getShort("x_axis"), current_row, (short)(rset.getShort("x_axis")+rset.getShort("cell_merge"))));
}
/* init the style */
//style = wb.createCellStyle();
//System.out.println("Point 15");
/* init the font */
//font = wb.createFont();
//System.out.println("Point 16");
/* have we got a forat mask */
if (rset.getString("cell_format_mask") != null)
{
if (got_style=="N") {
style = wb.createCellStyle();
font = wb.createFont();
got_style="Y";
}
style.setDataFormat(HSSFDataFormat.getBuiltinFormat(rset.getString("cell_format_mask")));
}
/* lets look and see if we need to do anything to the style */
if (rset.getString("cell_background") != null) {
//System.out.println("Point 17");
if (got_style=="N") {
style = wb.createCellStyle();
font = wb.createFont();
got_style="Y";
}
short coloridx = getcolorindex(rset.getString("cell_background").toUpperCase());
style.setFillForegroundColor((short) coloridx);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
//System.out.println("Point 18");
}
if (rset.getString("cell_fontsize") != null)
{
if (got_style=="N") {
style = wb.createCellStyle();
font = wb.createFont();
got_style="Y";
}
font.setFontHeightInPoints(Short.parseShort(rset.getString("cell_fontsize")));
}
//System.out.println("Point 18.5");
if (rset.getString("cell_font") != null)
{
//System.out.println("Point 18.8.1");
if (got_style=="N") {
style = wb.createCellStyle();
font = wb.createFont();
got_style="Y";
}
font.setFontName(rset.getString("cell_font"));
}
//System.out.println("Point 19");
/* apply font to style */
//style.setFont(font);
//System.out.println("Point 20");
/* do we need a border */
if (rset.getString("cell_border") != null) {
if (got_style=="N") {
style = wb.createCellStyle();
font = wb.createFont();
got_style="Y";
}
/* if a color is passed in, it means we do */
short coloridx = getcolorindex(rset.getString("cell_border").toUpperCase());
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(coloridx);
style.setTopBorderColor(coloridx);
style.setLeftBorderColor(coloridx);
style.setRightBorderColor(coloridx);
}
//System.out.println("Point 22");
/* perform any alignment */
if (rset.getString("cell_align") != null)
{
if (got_style=="N") {
style = wb.createCellStyle();
font = wb.createFont();
got_style="Y";
}
short alignidx = getalignindex(rset.getString("cell_align").toUpperCase());
style.setAlignment(alignidx);
}
/* cell wrapping */
if (rset.getString("cell_wrap") != null)
{
if (got_style=="N") {
style = wb.createCellStyle();
font = wb.createFont();
got_style="Y";
}
if (rset.getString("cell_wrap").toUpperCase() == "Y")
{
style.setWrapText( Boolean.TRUE.booleanValue());
}
else
{
style.setWrapText(Boolean.FALSE.booleanValue());
}
}
//System.out.println("Point 19");
if (got_style == "Y") {
/* apply font to style */
style.setFont(font);
/* now apply the style */
cell.setCellStyle(style);
/* reset the indicator */
got_style = "N";
}
else
{
/* apply font to style */
default_style.setFont(default_font);
/* now apply the style */
cell.setCellStyle(default_style);
}
} /* rset loop */
//System.out.println("Point 23");
/* close resultset and prepared statement */
rset.close();
stmt.close();
/* create a holder to put the blob in */
String insblobquery = "BEGIN " +
"INSERT INTO documents (name, blob_content, content_type, mime_type ) " +
"VALUES (?, EMPTY_BLOB(), 'BLOB', 'application/vnd.ms-excel') " +
"RETURNING docu_id INTO ?;"+
"END;";
/* the being and end statements are key, do not remove */
OracleCallableStatement cs = (OracleCallableStatement) conn.prepareCall (insblobquery);
cs.setString(1, spreadsheetId+".xls");
cs.registerOutParameter(2, OracleTypes.NUMBER );
cs.execute();
/* now get the returned document identifier */
docu_id = cs.getLong(2);
cs.close();
//System.out.println("Document: "+docu_id);
/* now get the row back we've just created and lock it */
Statement stmtb = conn.createStatement();
ResultSet blobdetails = stmtb.executeQuery("SELECT blob_content " +
"FROM documents " +
"WHERE docu_id = " + docu_id +" FOR UPDATE ");
/* if we find the above record - we should, we've just insertted it */
if (blobdetails.next() )
{
//System.out.println("populating the blob");
/* setup the output streams to point to the blob, write the file and close the stream */
oracle.sql.BLOB spreadblob = (oracle.sql.BLOB) blobdetails.getBlob(1);
OutputStream output_stream = spreadblob.getBinaryOutputStream();
wb.write(output_stream);
output_stream.flush();
output_stream.close();
stmtb.close();
}
//System.out.println("done");
}
catch (IOException ioex)
{
ioex.printStackTrace();
}
catch (SQLException ex) { // Trap SQL Errors
ex.printStackTrace();
} finally {
try{
if (conn != null || !conn.isClosed())
conn.close(); // Close the database connection
conn = null;
} catch(SQLException ex){
ex.printStackTrace();
}
}
return docu_id;
}
public static String readWorkBook(String docu_id) throws SQLException {
try {
/* get a JDBC connection */
conn = getConnection();
//System.out.println("connection opened");
} catch(SQLException ex){
ex.printStackTrace();
}
/* Holder for the spreadsheet Identifier */
int spreadsheetId = 0;
/* get the blob from the documents table as a binary input stream */
Statement stmt = conn.createStatement();
java.sql.ResultSet rs = stmt.executeQuery("SELECT blob_content FROM documents WHERE docu_id = " + docu_id);
rs.next();
oracle.sql.BLOB blob = (oracle.sql.BLOB)rs.getBlob(1);
InputStream is = blob.getBinaryStream ();
try {
HSSFWorkbook wb = new HSSFWorkbook(is);
HSSFSheet ws = wb.getSheetAt(0);
HSSFFont hf;
String cellcolor;
int fr = ws.getFirstRowNum();
int lr = ws.getLastRowNum();
/* get the next sequence number to use */
Statement seqstmt = conn.createStatement();
ResultSet seqrset = seqstmt.executeQuery("SELECT gtsp_seq.NEXTVAL FROM dual");
while (seqrset.next())
spreadsheetId = seqrset.getInt(1);
seqrset.close();
seqstmt.close();
/* prepare the insert */
PreparedStatement inspstmt = conn.prepareStatement("INSERT INTO gtt_spreadsheet gtsp (spreadsheet_id, x_axis, y_axis, cell_value, cell_background, cell_border, cell_merge, cell_font, cell_fontsize, col_width, row_height, cell_wrap ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
String cellval = null;
String cell_border = null;
String cell_merge = null;
String cell_font = null;
String cell_fontsize = null;
String col_width = null;
String row_height = null;
String cell_wrap = null;
/* start */
for (int r=fr;r<=lr;r++)
{
HSSFRow rw = ws.getRow(r);
/* avoid null pointer exceptions for empty rows */
if (rw != null)
{
int fc = rw.getFirstCellNum();
int lc = rw.getLastCellNum()-1;
////System.out.println("Min col: "+fc+" Max: "+lc);
for (int c=fc;c<=lc;c++)
{
HSSFCell cell = rw.getCell((short) c);
int colcode = c+65;
char col = (char) colcode;
//System.out.println("Getting Cell: "+col+r);
/* avoid null pointer by checking for null object */
if (cell != null)
{
////System.out.println("Get Cell Type: " + cell.getCellType());
switch (cell.getCellType())
{
case HSSFCell.CELL_TYPE_BOOLEAN:
cellval = Boolean.toString(cell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_NUMERIC:
/* see if a date format applies */
double d = cell.getNumericCellValue();
if (HSSFDateUtil.isCellDateFormatted(cell)) {
Calendar cal = Calendar.getInstance();
cal.setTime(HSSFDateUtil.getJavaDate(d));
cellval = (String.valueOf(cal.get(Calendar.YEAR))).substring(2);
cellval = cal.get(Calendar.DAY_OF_MONTH) + "/" +
(cal.get(Calendar.MONTH) + 1) + "/" +
"20" + cellval;
}
else
/* Must be a number */
{
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumIntegerDigits(99);
format.setGroupingUsed(false);
cellval = format.format(d);
/*cellval = String.valueOf(cell.getNumericCellValue());*/
}
break;
case HSSFCell.CELL_TYPE_STRING:
cellval = cell.getStringCellValue();
break;
default: /* no default */
}
////System.out.println("Get the cell colour");
cellcolor = Short.toString(cell.getCellStyle().getFillForegroundColor());
cell_border = Short.toString(cell.getCellStyle().getBottomBorderColor());
cell_merge = "0";
hf = wb.getFontAt(cell.getCellStyle().getFontIndex());
cell_font = hf.getFontName();
cell_fontsize = Short.toString(hf.getFontHeight());
col_width = Short.toString(ws.getColumnWidth((short)c));
row_height = Short.toString(rw.getHeight());
cell_wrap = Boolean.toString(cell.getCellStyle().getWrapText()).substring(0,1);
//
if (cellval != null)
{
//System.out.println("Value is: "+java.lang.Character.toString((char) col) + r + ":" + cellval);
inspstmt.setInt(1, spreadsheetId);
inspstmt.setString(2, java.lang.Character.toString((char) col));
inspstmt.setInt(3, r);
inspstmt.setString(4, cellval);
inspstmt.setString(5, cellcolor);
inspstmt.setString(6, cell_border);
inspstmt.setString(7, cell_merge);
inspstmt.setString(8, cell_font);
inspstmt.setString(9, cell_fontsize);
inspstmt.setString(10, col_width);
inspstmt.setString(11, row_height);
inspstmt.setString(12, cell_wrap);
inspstmt.executeUpdate();
}
cellval = null;
}
else
{
////System.out.println("Null object");
}
}
}
}
inspstmt.close();
} catch (IOException e)
{
System.err.println("ERROR: "+e.toString());
}
conn.close();
conn = null;
//System.out.println("connection closed");
return String.valueOf(spreadsheetId);
}
}

View File

@@ -0,0 +1,450 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<jpr:project xmlns:jpr="http://xmlns.oracle.com/ide/project">
<hash n="component-versions">
<value n="oracle.adfdt.controller.adfc.source.migration.AdfControllerSchemaMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdt.controller.adfc.source.migration.MoveMetadataResourcesAgainMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdt.controller.common.migrator.ProjectMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdt.controller.jsf2.diagram.migrate.JsfNodeMigratorHelper" v="11.1.1.1.0"/>
<value n="oracle.adfdt.controller.struts.addin.db.ADFStrutsProjectMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdt.controller.struts.addin.StrutsProjectMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdtinternal.dvt.datapresdt.migration.DVTDataMapMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdtinternal.model.ide.migration.ProjectMigrator" v="11.1.1.1.0.11.1.1"/>
<value n="oracle.adfdtinternal.model.ide.security.wizard.FormPageMigrator" v="11.1.1.0.0"/>
<value n="oracle.adfdtinternal.model.ide.security.wizard.JpsFilterMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdtinternal.model.ide.xmled.migration.ADFNodeMigrator" v="11.1.1.1.0.5"/>
<value n="oracle.adfdtinternal.model.ide.xmled.migration.PageDefinitionParameterValueMigrator" v="11.1.1.1.0.5"/>
<value n="oracle.adfdtinternal.model.ide.xmled.migration.WebXmlMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdtinternal.view.common.migration.wizards.MigrationHelper" v="11.1.1.1.0.3"/>
<value n="oracle.adfdtinternal.view.rich.binding.migration.JarResourceMigrator" v="11.1.1.1.0"/>
<value n="oracle.adfdtinternal.view.rich.migration.ComponentIdNodeMigratorHelper" v="11.1.1.1.0.01"/>
<value n="oracle.adfdtinternal.view.rich.migration.LibraryVersionMigrator" v="11.1.1.1.0"/>
<value n="oracle.bm.commonIde.ProjectUpgrader" v="11.1.1.1.0"/>
<value n="oracle.bm.migration.project.MigratorRegistryProjectUpgradeAdapter" v="11.1.1.1.0"/>
<value n="oracle.ide.model.Project" v="11.1.1.1.0"/>
<value n="oracle.ide.model.ResourcePathsMigrator" v="11.1.1.1.0"/>
<value n="oracle.jbo.dt.jclient.migrator.JCProjectMigrator" v="11.1.1.1.0"/>
<value n="oracle.jbo.dt.jdevx.deployment.JbdProjectMigrator" v="11.1.1.1.0"/>
<value n="oracle.jbo.dt.jdevx.ui.appnav.APProjectMigrator" v="11.1.1.0.1.5"/>
<value n="oracle.jbo.dt.migrate.ResourceBundlePathMigrator" v="11.1.1.1.0.5"/>
<value n="oracle.jbo.dt.migration.ServiceInterfaceMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdeveloper.ejb.EjbMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdeveloper.library.ProjectLibraryMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdeveloper.model.OutputDirectoryMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.deploy.DeploymentProfilesMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.deploy.jps.JpsDataMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.jsp.JspMigrator" v="11.1.1"/>
<value n="oracle.jdevimpl.offlinedb.migration.OfflineDBProjectMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.offlinedb.migration.OfflineTransferMigrator" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.resourcebundle.XliffAddin$XliffMigratorHelper" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.webapp.jsp.libraries.JspLibraryMigrator" v="11.1.1.1.4"/>
<value n="oracle.jdevimpl.webapp.WebAppContentSetNodeMigratorHelper" v="11.1.1"/>
<value n="oracle.jdevimpl.webapp.WebAppNodeMigratorHelper" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.webservices.WebServicesMigratorHelper" v="11.1.1.1.0"/>
<value n="oracle.jdevimpl.xml.wl.WeblogicMigratorHelper" v="11.1.1.1.0"/>
<value n="oracle.modeler.bmmigrate.management.Migration" v="11.1.1.1.0"/>
<value n="oracle.toplink.workbench.addin.migration.PersistenceProjectMigrator" v="11.1.1.1.1"/>
<value n="oracle.toplink.workbench.addin.migration.TopLinkProjectMigrator" v="11.1.1.1.0"/>
</hash>
<list n="contentSets">
<string v="oracle.jdeveloper.model.PathsConfiguration/javaContentSet"/>
<string v="oracle.ide.model.ResourcePaths/resourcesContentSet"/>
<string v="oracle.jdeveloper.offlinedb.model.OfflineDBProjectSettings/offlineDBContentSet"/>
<string v="oracle.jdeveloper.model.J2eeSettings/webContentSet"/>
<string v="oracle.mds.internal.dt.ide.MDSLibraryCustCSProvider/mdsContentSet"/>
<string v="oracle.bm.commonIde.data.project.ModelerProjectSettings/modelersContentSet"/>
<string v="oracle.toplink.workbench.addin/toplinkContentSet"/>
<string v="oracle.adfdtinternal.model.ide.settings.ADFMSettings/adfmContentSet"/>
</list>
<value n="defaultPackage" v="eft_nom_xml"/>
<hash n="oracle.adfdtinternal.model.ide.settings.ADFMSettings">
<hash n="adfmContentSet">
<list n="pattern-filters">
<string v="+**"/>
</list>
<list n="url-path">
<url path="adfmsrc/"/>
</list>
</hash>
</hash>
<hash n="oracle.bm.commonIde.data.project.ModelerProjectSettings">
<hash n="modelersContentSet">
<list n="url-path">
<url path="model/"/>
</list>
</hash>
</hash>
<hash n="oracle.ide.model.ResourcePaths">
<hash n="resourcesContentSet">
<list n="pattern-filters">
<string v="+*"/>
</list>
<list n="url-path">
<url path="."/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.compiler.OjcConfiguration">
<value n="internalEncoding" v="Cp1252"/>
<list n="Javac.commandline.optionlist">
<string v="-g"/>
<string v="-Xlint:all"/>
<string v="-Xlint:-cast"/>
<string v="-Xlint:-empty"/>
<string v="-Xlint:-fallthrough"/>
<string v="-Xlint:-path"/>
<string v="-Xlint:-serial"/>
<string v="-Xlint:-unchecked"/>
</list>
<list n="Ojc.commandline.optionlist">
<string v="-g"/>
<string v="-warn"/>
<string v="-nowarn:320"/>
<string v="-nowarn:372"/>
<string v="-nowarn:412"/>
<string v="-nowarn:413"/>
<string v="-nowarn:415"/>
<string v="-nowarn:486"/>
<string v="-nowarn:487"/>
<string v="-nowarn:489"/>
<string v="-nowarn:556"/>
<string v="-nowarn:558"/>
<string v="-nowarn:560"/>
<string v="-nowarn:561"/>
<string v="-nowarn:705"/>
<string v="-Xlint:-fallthrough"/>
<string v="-Xlint:-serial"/>
<string v="-Xlint:-unchecked"/>
</list>
</hash>
<hash n="oracle.jdeveloper.deploy.dt.DeploymentProfiles">
<hash n="profileDefinitions">
<hash n="eft_nom_xml">
<hash n="appletArchives"/>
<hash n="appletFiles">
<value n="autoInclude" v="true"/>
<list n="selectionFilters">
<string v="oracle.jdevimpl.deploy.common.JavaSelectionFilter"/>
</list>
</hash>
<hash n="archiveOptions">
<value n="hasManifest" v="false"/>
</hash>
<value n="defaultConnection" v="loordv01_tomcat"/>
<url n="earURL" path="deploy/eft_nom_xml.ear"/>
<value n="enterpriseAppName" v="eft_nom_xml"/>
<hash n="fileGroups">
<list n="groups">
<hash>
<list n="contributors">
<hash>
<value n="type" v="5"/>
</hash>
</list>
<value n="displayName" v="Web Files"/>
<hash n="filters">
<list n="rules">
<hash>
<value n="pattern" v="WEB-INF/temp/**"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="WEB-INF/classes/jsp_servlet/**"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".wlsjsps/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".wlLibs/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/.svn/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/CVS/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/.ade_path"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/.data/**"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.cdi"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.contrib"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.keep"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.rvi"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".jsps/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".tags/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".dtags/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/*.jht"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/*.jjt"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/*.jxt"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**"/>
</hash>
</list>
</hash>
<value n="internalName" v="web-files"/>
<value n="type" v="1"/>
</hash>
<hash>
<list n="contributors">
<hash>
<value n="type" v="2"/>
</hash>
<hash>
<value n="type" v="7"/>
</hash>
</list>
<value n="displayName" v="WEB-INF/classes"/>
<hash n="filters">
<list n="rules">
<hash>
<value n="pattern" v="eft_nom_xml/ProcessRequest.class"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="WEB-INF/temp/**"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="WEB-INF/classes/jsp_servlet/**"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".wlsjsps/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".wlLibs/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/.svn/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/CVS/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/.ade_path"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/.data/**"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.cdi"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.contrib"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.keep"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**.rvi"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".jsps/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".tags/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v=".dtags/"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/*.jht"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/*.jjt"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**/*.jxt"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="pattern" v="**"/>
</hash>
</list>
</hash>
<value n="internalName" v="project-output"/>
<value n="targetWithinJar" v="WEB-INF/classes"/>
<value n="type" v="1"/>
</hash>
<hash>
<value n="displayName" v="WEB-INF/lib"/>
<hash n="filters">
<list n="rules">
<hash>
<value n="pattern" v="**"/>
</hash>
</list>
</hash>
<value n="internalName" v="libraries"/>
<list n="selectedLibraries">
<string v="Oracle JDBC"/>
</list>
<value n="targetWithinJar" v="WEB-INF/lib"/>
<value n="type" v="3"/>
</hash>
</list>
</hash>
<url n="jarURL" path="deploy/eftnom.war"/>
<value n="platformType" v="TOMCAT"/>
<value n="platformVersion" v="6.0"/>
<value n="profileClass" v="oracle.jdeveloper.deploy.war.WarProfile"/>
<value n="profileName" v="eft_nom_xml"/>
</hash>
</hash>
<list n="profileList">
<string v="eft_nom_xml"/>
</list>
</hash>
<hash n="oracle.jdeveloper.model.J2eeSettings">
<value n="j2eeWebAppName" v="Application1-eft_nom_xml-webapp"/>
<value n="j2eeWebContextRoot" v="Application1-eft_nom_xml-context-root"/>
<hash n="webContentSet">
<list n="pattern-filters">
<string v="-WEB-INF/temp/"/>
<string v="-WEB-INF/classes/"/>
<string v="+**"/>
</list>
<list n="url-path">
<url path="public_html/"/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.model.PathsConfiguration">
<hash n="javaContentSet">
<list n="pattern-filters">
<string v="-eft_nom_xml/ProcessRequest.java"/>
<string v="-eft_nom_xml/Copy of ProcessRequest.java"/>
<string v="-eft_nom_xml/process_request.java"/>
<string v="+**"/>
</list>
<list n="url-path">
<url path="src/"/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.offlinedb.model.OfflineDBProjectSettings">
<hash n="offlineDBContentSet">
<list n="pattern-filters">
<string v="+**"/>
</list>
<list n="url-path">
<url path="database/"/>
</list>
</hash>
</hash>
<hash n="oracle.jdeveloper.runner.RunConfigurations">
<hash n="runConfigurationDefinitions">
<hash n="Default">
<value n="custom" v="false"/>
<value n="name" v="Default"/>
<url n="targetURL" path="src/eft_nom_xml/listener.java"/>
</hash>
</hash>
<list n="runConfigurationList">
<string v="Default"/>
</list>
</hash>
<hash n="oracle.jdevimpl.config.JProjectLibraries">
<list n="exportedReferences">
<hash>
<value n="id" v="Servlet Runtime"/>
<value n="isJDK" v="false"/>
</hash>
<hash>
<value n="id" v="Oracle JDBC"/>
<value n="isJDK" v="false"/>
</hash>
</list>
<list n="libraryReferences">
<hash>
<value n="id" v="Servlet Runtime"/>
<value n="isJDK" v="false"/>
</hash>
<hash>
<value n="id" v="Oracle JDBC"/>
<value n="isJDK" v="false"/>
</hash>
</list>
</hash>
<hash n="oracle.jdevimpl.config.JProjectPaths">
<url n="outputDirectory" path="classes/"/>
</hash>
<hash n="oracle.mds.internal.dt.ide.MDSLibraryCustCSProvider">
<hash n="mdsContentSet">
<list n="pattern-filters">
<string v="+**/mdssys/cust/**"/>
<string v="+mdssys/cust/**"/>
</list>
<list n="url-path">
<url path="libraryCustomizations/"/>
</list>
</hash>
</hash>
<hash n="oracle.toplink.workbench.addin">
<hash n="toplinkContentSet">
<list n="pattern-filters">
<string v="+**"/>
</list>
<list n="url-path">
<url path="toplink/"/>
</list>
</hash>
</hash>
<hash n="ResourceBundleOptions">
<list n="RegisteredResourceBundles"/>
</hash>
</jpr:project>

View File

@@ -0,0 +1,32 @@
<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
<distributable/>
<servlet>
<servlet-name>servlet_name</servlet-name>
<servlet-class>eft_nom_xml.listener</servlet-class>
<init-param>
<description>The database connection username</description>
<param-name>username</param-name>
<param-value>eft_nom</param-value>
</init-param>
<init-param>
<description>The database connection password</description>
<param-name>password</param-name>
<param-value>eft_nom</param-value>
</init-param>
<init-param>
<description>The database connection string</description>
<param-name>connection</param-name>
<param-value>jdbc:oracle:thin:@loordv01:1521:dev10g</param-value>
</init-param>
<init-param>
<description>Whether to output debug or not - should be N</description>
<param-name>debug</param-name>
<param-value>N</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>servlet_name</servlet-name>
<url-pattern>/!amfr_message_handler.service_request</url-pattern>
</servlet-mapping>
</web-app>

View File

@@ -0,0 +1,275 @@
package eft_nom_xml;
//
// Servlet imports
//
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
//
// Java JDBC
//
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.DriverManager;
import java.sql.CallableStatement;
//
// Oracle JDBC
//
import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleTypes;
import oracle.sql.CLOB;
public class listener extends HttpServlet {
//
// Global vars from the properties file
//
static String g_db_username = null;
static String g_db_password = null;
static String g_db_conn = null;
static String g_debug = null;
//
// Connection handle
//
static Connection conn = null;
//
// Returned value
//
static oracle.sql.CLOB g_clob = null;
static String g_clobString = null;
//
// Servlet response type, could set to XML?
//
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
public void init(ServletConfig config) throws ServletException {
super.init(config);
//
// Get the configuration details from web.xml
//
getConf();
}
public static void myPrintln(String p_text) {
if (g_debug.equals("Y")) {
System.out.println("eft_nom_xml: " + p_text + " " + System.currentTimeMillis());
}
}
/**Process the HTTP doGet request.
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
// The request ID, should always be 60
String p_request_id = "";
// The username to authenticate with
String p_user = "";
// The password to authenticate with
String p_password = "";
// the XML data stream
String p_xmldata = "";
try {
p_request_id = request.getParameter("request_id");
p_user = request.getParameter("user");
p_password = request.getParameter("password");
p_xmldata = request.getParameter("xmldata");
} catch (Exception e) {
e.printStackTrace();
}
if (p_request_id == null) {
p_request_id = "0";
}
String dbResponse = null;
if (p_request_id.equals("60")) {
dbResponse = getResponse(p_request_id, p_user, p_password, p_xmldata);
}
else {
myPrintln("No valid reponse string passed");
dbResponse = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<response>\n" +
"<error>Invalid or missing request_id</error>\n" +
"<error_code>3940</error_code>\n" +
"</response>";
}
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println(dbResponse);
out.close();
}
/**Process the HTTP doPost request.
*/
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
// The request ID, should always be 60
String p_request_id = "";
// The username to authenticate with
String p_user = "";
// The password to authenticate with
String p_password = "";
// the XML data stream
String p_xmldata = "";
try {
p_request_id = request.getParameter("request_id");
p_user = request.getParameter("user");
p_password = request.getParameter("password");
p_xmldata = request.getParameter("xmldata");
} catch (Exception e) {
e.printStackTrace();
}
if (p_request_id == null) {
p_request_id = "0";
}
String dbResponse = null;
if (p_request_id.equals("60")) {
dbResponse = getResponse(p_request_id, p_user, p_password, p_xmldata);
}
else {
myPrintln("No valid reponse string passed");
dbResponse = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<response>\n" +
"<error>Invalid or missing request_id</error>\n" +
"<error_code>3940</error_code>\n" +
"</response>";
}
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println(dbResponse);
out.close();
}
public void getConnection() throws SQLException{
// Load Oracle driver.
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
try {
// Connect to the database.
conn = DriverManager.getConnection(g_db_conn,g_db_username, g_db_password);
} catch (SQLException sqlex) {
myPrintln("SQLException while getting db connection: "+sqlex);
if (conn != null) {
conn.close();
}
} catch (Exception ex) {
myPrintln("Exception while getting db connection: "+ex);
if (conn != null) {
conn.close();
}
}
}
public static void closeConnection() {
try {
if (conn != null || !conn.isClosed()) { // Close the database connection
conn.close();
}
conn = null;
DriverManager.deregisterDriver (new oracle.jdbc.OracleDriver());
} catch (SQLException sqlex) {
myPrintln("SQLException while closing db connection: "+sqlex);
} catch (Exception ex) {
myPrintln("Exception while closing db connection: "+ex);
}
}
public void getConf() {
//
// get the default properties
//
g_db_username = (getServletConfig().getInitParameter("username") == null)?"eft_nom":getServletConfig().getInitParameter("username");
g_db_password = (getServletConfig().getInitParameter("password") == null)?"eft_nom":getServletConfig().getInitParameter("password");
g_db_conn = (getServletConfig().getInitParameter("connection") == null)?"jdbc:oracle:thin:@loordv01:1521:dev10g":getServletConfig().getInitParameter("connection");
g_debug = (getServletConfig().getInitParameter("debug") == null)?"N":getServletConfig().getInitParameter("debug");
myPrintln("Parameters: " + g_db_username + " " + g_db_password + " " + g_db_conn + " " + g_debug);
}
public void callDatabase(String p_username, String p_password, String p_xmldata) {
//
// Open the database connection
//
try {
getConnection();
myPrintln("connection opened");
} catch(Exception ex){
ex.printStackTrace();
}
//
// Connected, now call the statement
//
try {
myPrintln("Begin call statement");
conn.setAutoCommit(false);
CallableStatement cs = null;
myPrintln("Build statement");
// Call Stored DB procedure for updating clob column
cs = (OracleCallableStatement)
conn.prepareCall( "begin efno_java_xml_interface.process_60_xml_message(?,?,?,?); end;" );
myPrintln("Statement built");
//
// Set the in/out parameters
//
myPrintln("Bind Parameters");
//
cs.setObject(1, p_username );
cs.setObject(2, p_password );
cs.setObject(3, p_xmldata);
cs.registerOutParameter(4,OracleTypes.CLOB);
//
// Execute the prepared statement
//
myPrintln("Pre execute");
cs.execute();
myPrintln("Post execute");
//
// Get the return value
//
g_clob = (oracle.sql.CLOB)cs.getClob(4);
myPrintln("Clob Returned");
g_clobString = g_clob.getSubString(1,(int)g_clob.length());
myPrintln("Clob converted - length = "+ g_clob.length());
g_clob.free();
myPrintln("Clob Free");
//
// Set autocommit back
//
conn.setAutoCommit(true);
//
} catch ( SQLException sqlex ) {
myPrintln("SQLException in callDatabase method " +
" of given status : " + sqlex.getMessage() );
} finally {
closeConnection();
}
}
public String getResponse(String request, String username, String password, String xmldata ) {
//
// Get the configuration details
//
getConf();
//
// Output what has been passed
//
myPrintln("Passed request: "+request);
myPrintln("Passed username: "+username);
myPrintln("Passed password: "+password);
myPrintln("Passed xmldata: "+xmldata);
//
// Call the database routine
//
callDatabase(username, password, xmldata);
//
// Return the value from the database
//
return g_clobString;
}
}