diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-01-20 17:01:09 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-01-20 17:01:09 +0000 |
commit | a7d404cd6db2724d36523e59c87c3007fa86a258 (patch) | |
tree | e938b10cccf606c062fdb4cf569b8245a83b8a37 | |
parent | c97c49eb4399829603816e4b3e47c74b67d0f27b (diff) | |
parent | ce598ba5142ff7673085dd90865f9323d69574be (diff) | |
download | mocca-1.0.2.tar.gz mocca-1.0.2.tar.bz2 mocca-1.0.2.zip |
[maven-release-plugin] copy for tag mocca-1.0.2mocca-1.0.2
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/tags/mocca-1.0.2@276 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
173 files changed, 7807 insertions, 2845 deletions
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java index 03e4b7c9..3903bf10 100644 --- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java +++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java @@ -35,10 +35,11 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; /** - * + * * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> */ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { @@ -47,8 +48,10 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { protected AppletParameterProvider params; protected String sessionId; protected STALPortType stalPort; + private ObjectFactory stalObjFactory = new ObjectFactory(); - public AppletBKUWorker(BKUGUIFacade gui, AppletContext ctx, AppletParameterProvider paramProvider) { + public AppletBKUWorker(BKUGUIFacade gui, AppletContext ctx, + AppletParameterProvider paramProvider) { super(gui); if (ctx == null) { throw new NullPointerException("Applet context not provided"); @@ -88,11 +91,16 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { try { registerSignRequestHandler(); - ObjectFactory of = new ObjectFactory(); - GetNextRequestResponseType nextRequestResp = stalPort.connect(sessionId); do { - List<RequestType> requests = nextRequestResp.getInfoboxReadRequestOrSignRequestOrQuitRequest(); + List<JAXBElement<? extends RequestType>> requests = nextRequestResp.getInfoboxReadRequestOrSignRequestOrQuitRequest(); + + // (rather use validator) + if (requests.size() == 0) { + log.error("Received empty NextRequestResponse: no STAL requests to handle. (STAL-X requests might not have gotten unmarshalled)"); + throw new Exception("No STAL requests to handle."); + } + List<STALRequest> stalRequests = STALTranslator.translateRequests(requests); if (log.isInfoEnabled()) { @@ -114,13 +122,13 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { String domainId = r.getDomainIdentifier(); if ("IdentityLink".equals(infoboxId) && domainId == null) { if (!InternalSSLSocketFactory.getInstance().isEgovAgency()) { - handle = false; + handle = false; } } } } - List<ResponseType> responses; + List<JAXBElement<? extends ResponseType>> responses; if (handle) { List<STALResponse> stalResponses = handleRequest(stalRequests); if (log.isInfoEnabled()) { @@ -134,16 +142,17 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { } responses = STALTranslator.fromSTAL(stalResponses); } else { - responses = new ArrayList<ResponseType>(1); - ErrorResponseType err = of.createErrorResponseType(); + log.error("Insufficient rights to execute command InfoboxReadRequest for Infobox IdentityLink, return Error 6002"); + responses = new ArrayList<JAXBElement<? extends ResponseType>>(1); + ErrorResponseType err = stalObjFactory.createErrorResponseType(); err.setErrorCode(6002); // err.setErrorMessage(); - responses.add(err); + responses.add(stalObjFactory.createGetNextRequestTypeErrorResponse(err)); } if (!finished) { log.info("Not finished yet (BKUWorker: " + this + "), sending responses"); - GetNextRequestType nextRequest = of.createGetNextRequestType(); + GetNextRequestType nextRequest = stalObjFactory.createGetNextRequestType(); nextRequest.setSessionId(sessionId); nextRequest.getInfoboxReadResponseOrSignResponseOrErrorResponse().addAll(responses); nextRequestResp = stalPort.getNextRequest(nextRequest); @@ -158,16 +167,17 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { } catch (InterruptedException e) { log.error(e); } - } - if (signatureCard != null) { - signatureCard.disconnect(false); + if (signatureCard != null) { + signatureCard.disconnect(false); + } } sendRedirect(); } protected void sendRedirect() { try { - URL redirectURL = params.getURLParameter(BKUApplet.REDIRECT_URL, sessionId); + URL redirectURL = params.getURLParameter(BKUApplet.REDIRECT_URL, + sessionId); String redirectTarget = params.getAppletParameter(BKUApplet.REDIRECT_TARGET); if (redirectTarget == null) { log.info("Done. Redirecting to " + redirectURL + " ..."); @@ -185,7 +195,8 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { private STALPortType getSTALPort() throws MalformedURLException { URL wsdlURL = params.getURLParameter(BKUApplet.WSDL_URL); log.debug("STAL WSDL at " + wsdlURL); - QName endpointName = new QName(BKUApplet.STAL_WSDL_NS, BKUApplet.STAL_SERVICE); + QName endpointName = new QName(BKUApplet.STAL_WSDL_NS, + BKUApplet.STAL_SERVICE); STALService stal = new STALService(wsdlURL, endpointName); return stal.getSTALPort(); } @@ -193,13 +204,16 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { private void registerSignRequestHandler() throws MalformedURLException { String hashDataDisplayStyle = params.getAppletParameter(BKUApplet.HASHDATA_DISPLAY); if (BKUApplet.HASHDATA_DISPLAY_BROWSER.equals(hashDataDisplayStyle)) { - URL hashDataURL = params.getURLParameter(BKUApplet.HASHDATA_URL, sessionId); + URL hashDataURL = params.getURLParameter(BKUApplet.HASHDATA_URL, + sessionId); log.debug("register SignRequestHandler for HashDataURL " + hashDataURL); - addRequestHandler(SignRequest.class, new BrowserHashDataDisplay(ctx, hashDataURL)); + addRequestHandler(SignRequest.class, new BrowserHashDataDisplay(ctx, + hashDataURL)); } else { - //BKUApplet.HASHDATA_DISPLAY_FRAME + // BKUApplet.HASHDATA_DISPLAY_FRAME log.debug("register SignRequestHandler for STAL port " + BKUApplet.WSDL_URL); - AppletHashDataDisplay handler = new AppletHashDataDisplay(stalPort, sessionId); + AppletHashDataDisplay handler = new AppletHashDataDisplay(stalPort, + sessionId); addRequestHandler(SignRequest.class, handler); } } diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java index d0eed607..d0f6d489 100644 --- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java +++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java @@ -75,7 +75,7 @@ public class BKUApplet extends JApplet implements AppletParameterProvider { /** * Factory method to create and wire HelpListener, GUI and BKUWorker. - * (Config via applet parameters as constants BKUApplet.*) + * (Config via applet parameters, see BKUApplet.* constants) */ @Override public void init() { @@ -83,7 +83,7 @@ public class BKUApplet extends JApplet implements AppletParameterProvider { log.debug("Called init()"); HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance()); - + String locale = getAppletParameter(LOCALE); if (locale != null) { this.setLocale(new Locale(locale)); diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java index c3417d63..a02e56eb 100644 --- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java +++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/InternalSSLSocketFactory.java @@ -36,121 +36,122 @@ import org.apache.commons.logging.LogFactory; public class InternalSSLSocketFactory extends SSLSocketFactory { - private final static String GOV_DOMAIN = ".gv.at"; - - private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory(); - - private final static Log log = LogFactory - .getLog(InternalSSLSocketFactory.class); - - private SSLSocket sslSocket; - - private SSLSocketFactory proxy; - - private InternalSSLSocketFactory() { - proxy = HttpsURLConnection.getDefaultSSLSocketFactory(); - } - - public static InternalSSLSocketFactory getInstance() { - return instance; - } - - @Override - public Socket createSocket() throws IOException { - sslSocket = (SSLSocket) proxy.createSocket(); - return sslSocket; - } - - @Override - public Socket createSocket(String arg0, int arg1) throws IOException, - UnknownHostException { - sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1); - - return sslSocket; - } - - @Override - public Socket createSocket(InetAddress arg0, int arg1) throws IOException { - sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1); - return sslSocket; - } - - @Override - public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) - throws IOException, UnknownHostException { - sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3); - return sslSocket; - } - - @Override - public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, - int arg3) throws IOException { - sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3); - return sslSocket; - } - - @Override - public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3) - throws IOException { - sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3); - return sslSocket; - } - - @Override - public String[] getDefaultCipherSuites() { - return proxy.getDefaultCipherSuites(); - } - - @Override - public String[] getSupportedCipherSuites() { - return proxy.getSupportedCipherSuites(); - } - - public boolean isEgovAgency() { - log.info("Checking if server is egov agency"); - if (sslSocket != null) { - try { - X509Certificate cert = (X509Certificate) sslSocket.getSession() - .getPeerCertificates()[0]; - log.info("Server cert: " + cert); - return isGovAgency(cert); - } catch (SSLPeerUnverifiedException e) { - log.error(e); - return false; - } - } - log.info("Not a SSL connection"); - return false; - } - - public static boolean isGovAgency(X509Certificate cert) { - String[] rdns = (cert.getSubjectX500Principal().getName()).split(","); - for (String rdn : rdns) { - if (rdn.startsWith("CN=")) { - String dns = rdn.split("=")[1]; - if (dns.endsWith(GOV_DOMAIN)) { - return true; - } - } - } - try { - Collection<List<?>> sanList = cert.getSubjectAlternativeNames(); - if (sanList != null) { - for (List<?> san : sanList) { - if ((Integer) san.get(0) == 2) { - String dns = (String) san.get(1); - if (dns.endsWith(GOV_DOMAIN)) { - return true; - } - } - } - } - } catch (CertificateParsingException e) { - log.error(e); - } - if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) { - return true; - } - return false; - } + private final static String GOV_DOMAIN = ".gv.at"; + + private static InternalSSLSocketFactory instance = new InternalSSLSocketFactory(); + + private final static Log log = LogFactory + .getLog(InternalSSLSocketFactory.class); + + private SSLSocket sslSocket; + + private SSLSocketFactory proxy; + + private InternalSSLSocketFactory() { + proxy = HttpsURLConnection.getDefaultSSLSocketFactory(); + } + + public static InternalSSLSocketFactory getInstance() { + return instance; + } + + @Override + public Socket createSocket() throws IOException { + sslSocket = (SSLSocket) proxy.createSocket(); + return sslSocket; + } + + @Override + public Socket createSocket(String arg0, int arg1) throws IOException, + UnknownHostException { + sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1); + + return sslSocket; + } + + @Override + public Socket createSocket(InetAddress arg0, int arg1) throws IOException { + sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1); + return sslSocket; + } + + @Override + public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) + throws IOException, UnknownHostException { + sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3); + return sslSocket; + } + + @Override + public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, + int arg3) throws IOException { + sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3); + return sslSocket; + } + + @Override + public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3) + throws IOException { + sslSocket = (SSLSocket) proxy.createSocket(arg0, arg1, arg2, arg3); + return sslSocket; + } + + @Override + public String[] getDefaultCipherSuites() { + return proxy.getDefaultCipherSuites(); + } + + @Override + public String[] getSupportedCipherSuites() { + return proxy.getSupportedCipherSuites(); + } + + public boolean isEgovAgency() { + log.info("Checking if server is egov agency"); + if (sslSocket != null) { + try { + X509Certificate cert = (X509Certificate) sslSocket.getSession() + .getPeerCertificates()[0]; + log.info("Server cert: " + cert); + return isGovAgency(cert); + } catch (SSLPeerUnverifiedException e) { + log.error(e); + return false; + } + } + log.info("Not a SSL connection"); + return false; + } + + public static boolean isGovAgency(X509Certificate cert) { + String[] rdns = (cert.getSubjectX500Principal().getName()).split(","); + for (String rdn : rdns) { + if (rdn.startsWith("CN=")) { + String dns = rdn.split("=")[1]; + if (dns.endsWith(GOV_DOMAIN)) { + return true; + } + } + } + try { + Collection<List<?>> sanList = cert.getSubjectAlternativeNames(); + if (sanList != null) { + for (List<?> san : sanList) { + if ((Integer) san.get(0) == 2) { + String dns = (String) san.get(1); + if (dns.endsWith(GOV_DOMAIN)) { + return true; + } + } + } + } + } catch (CertificateParsingException e) { + log.error(e); + } + if ((cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) + || (cert.getExtensionValue("1.2.40.0.10.1.1.2") != null)) { + return true; + } + return false; + } } diff --git a/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java b/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java index 63da8225..74017c22 100644 --- a/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java +++ b/BKUApplet/src/test/java/at/gv/egiz/stal/client/STALServiceTest.java @@ -41,6 +41,7 @@ import at.gv.egiz.stal.service.types.GetNextRequestResponseType; import at.gv.egiz.stal.service.types.GetNextRequestType; import at.gv.egiz.stal.service.types.InfoboxReadRequestType; import at.gv.egiz.stal.service.types.RequestType; +import javax.xml.bind.JAXBElement; /** * @@ -51,7 +52,7 @@ public class STALServiceTest { // @Test public void callSTAL() { try { - URL endpointURL = new URL("http://localhost:8080/bkuonline/stal?wsdl"); + URL endpointURL = new URL("http://localhost:3495/bkuonline/stal?wsdl"); QName endpointName = new QName("http://www.egiz.gv.at/wsdl/stal", "STALService"); STALService stal = new STALService(endpointURL, endpointName); // stal = new STALService(); @@ -63,7 +64,8 @@ public class STALServiceTest { GetNextRequestResponseType nrResp = port.getNextRequest(nrReq); assertNotNull(nrResp); System.out.println("got response: " + nrResp.getInfoboxReadRequestOrSignRequestOrQuitRequest().size()); - for (RequestType stalReq : nrResp.getInfoboxReadRequestOrSignRequestOrQuitRequest()) { + for (JAXBElement<? extends RequestType> stalReqElt : nrResp.getInfoboxReadRequestOrSignRequestOrQuitRequest()) { + RequestType stalReq = stalReqElt.getValue(); if (stalReq instanceof InfoboxReadRequestType) { String ibid = ((InfoboxReadRequestType) stalReq).getInfoboxIdentifier(); String did = ((InfoboxReadRequestType) stalReq).getDomainIdentifier(); diff --git a/BKUApplet/src/test/resources/appletTest.html b/BKUApplet/src/test/resources/appletTest.html index cc7c2bd7..b3f68a91 100644 --- a/BKUApplet/src/test/resources/appletTest.html +++ b/BKUApplet/src/test/resources/appletTest.html @@ -18,10 +18,10 @@ <body> <center> <applet code="at.gv.egiz.bku.online.applet.BKUApplet.class" - archive="../BKUApplet-1.0.jar, ../test-libs/commons-logging-1.1.1.jar , ../test-libs/iaik_jce_me4se-3.04.jar" + archive="../BKUApplet-1.0.2-SNAPSHOT.jar, ../test-libs/commons-logging-1.1.1.jar , ../test-libs/iaik_jce_me4se-3.04.jar" width=300 height=200> <param name="GuiStyle" value="advanced"/> - <param name="Locale" value="de"/> + <param name="Locale" value="en_US"/> <!--param name="Background" value="jar:file:/home/clemens/workspace/mocca/BKUApplet/target/BKUApplet-1.0-SNAPSHOT.jar!/images/help.png"/--> <param name="Background" value="http://localhost:3495/img/BackgroundChipperling.png"/> <param name="WSDL_URL" value="http://localhost:3495/stal?wsdl"/> diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java index f46f5227..b871263e 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java @@ -30,6 +30,9 @@ import org.apache.commons.logging.LogFactory; * This class does not keep a GUI reference and subclasses should not interfere with the GUI. * Therefore, any errors occurring in showDocument() should be handled/displayed within * showDocument() and exceptions thrown from showDocument() are logged, not displayed in the GUI. + * <br/> + * The help URL is build as [baseURL]/[locale]/[helpTopic].html + * (note that no session information is contained). * * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> */ @@ -41,7 +44,7 @@ public abstract class AbstractHelpListener implements ActionListener { protected ResourceBundle messages; public AbstractHelpListener(URL baseURL, Locale locale) { - if (baseURL == null || "".equals(baseURL)) { + if (baseURL == null || "".equals(baseURL.toString())) { throw new RuntimeException("no help URL provided"); } this.baseURL = baseURL; diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java index c786a291..d61c9a03 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java @@ -58,9 +58,6 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -117,7 +114,9 @@ public class BKUGUIImpl implements BKUGUIFacade { this.contentPane = contentPane; if (locale != null) { - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, locale); + Locale lang = new Locale(locale.getLanguage().substring(0,2)); + log.debug("loading applet resources for language: " + lang.toString()); + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); } else { messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); } diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java index 3c8c7d6c..c8594fe1 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java @@ -57,10 +57,10 @@ public class DefaultHelpListener extends AbstractHelpListener { /** * blocks until help viewer returns (is closed) * @param helpURL - * @param helpTopic + * @param helpTopic ignored */ @Override - public void showDocument(final URL helpURL, final String helpTopic) { + public void showDocument(final URL helpURL, final String helpTopic) { // try { log.debug("schedule help dialog"); @@ -72,9 +72,9 @@ public class DefaultHelpListener extends AbstractHelpListener { log.debug("show help dialog"); if (ctx == null) { - HelpViewer.showHelpDialog(helpURL, helpTopic, messages); + HelpViewer.showHelpDialog(helpURL, messages); // helpTopic, messages); } else { - HelpViewer.showHelpDialog(ctx, helpURL, helpTopic, messages); + HelpViewer.showHelpDialog(ctx, helpURL, messages); //helpTopic, messages); } } }); diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java index 0fef3f75..364da6ec 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java @@ -32,7 +32,6 @@ import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JEditorPane; -import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -64,45 +63,44 @@ public class HelpViewer extends JDialog */ public static void showHelpDialog(AppletContext ctx, URL helpURL, - String helpTopic, +// String helpTopic, ResourceBundle messages) { - showHelpDialog(null, ctx, helpURL, helpTopic, messages); + showHelpDialog(null, ctx, helpURL, messages); //helpTopic, messages); } public static void showHelpDialog(URL helpURL, - String helpTopic, +// String helpTopic, ResourceBundle messages) { - showHelpDialog(null, null, helpURL, helpTopic, messages); + showHelpDialog(null, null, helpURL, messages); // helpTopic, messages); } public static void showHelpDialog(Component owner, AppletContext ctx, URL helpURL, - String helpTopic, +// String helpTopic, ResourceBundle messages) { Frame frame = null; if (owner != null) { JOptionPane.getFrameForComponent(owner); } - dialog = new HelpViewer(frame, messages, ctx, helpURL, helpTopic); + dialog = new HelpViewer(frame, messages, ctx, helpURL); //, helpTopic); dialog.setVisible(true); } private HelpViewer(Frame frame, ResourceBundle messages, AppletContext ctx, - URL helpURL, - String helpTopic) { + URL helpURL) { //, String helpTopic) { super(frame, messages.getString(BKUGUIFacade.WINDOWTITLE_HELP), true); this.messages = messages; this.ctx = ctx; - String p = messages.getString(BKUGUIFacade.MESSAGE_HELP); - String helpItem = messages.getString(helpTopic); - String viewerLabel = MessageFormat.format(p, new Object[]{helpItem}); +// String p = messages.getString(BKUGUIFacade.MESSAGE_HELP); +// String helpItem = messages.getString(helpTopic); +// String viewerLabel = MessageFormat.format(p, new Object[]{helpItem}); - JPanel helpPanel = createViewerPanel(viewerLabel, helpURL); + JPanel helpPanel = createViewerPanel(helpURL); //viewerLabel, helpURL); JPanel buttonPanel = createButtonPanel(); initContentPane(new Dimension(600, 600), helpPanel, buttonPanel); @@ -128,7 +126,7 @@ public class HelpViewer extends JDialog mainLayout.createSequentialGroup().addContainerGap().addComponent(viewerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(buttonPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addContainerGap()); } - private JPanel createViewerPanel(String viewerLabelText, URL helpURL) { + private JPanel createViewerPanel(URL helpURL) { //String viewerLabelText, log.debug("viewer dialog: " + helpURL.toString()); final JEditorPane viewer = new JEditorPane(); @@ -170,19 +168,24 @@ public class HelpViewer extends JDialog scrollPane.setAlignmentX(LEFT_ALIGNMENT); viewer.setCaretPosition(0); - JLabel viewerLabel = new JLabel(); - viewerLabel.setText(viewerLabelText); - viewerLabel.setFont(viewerLabel.getFont().deriveFont(viewerLabel.getFont().getStyle() | java.awt.Font.BOLD)); - viewerLabel.setLabelFor(viewer); +// JLabel viewerLabel = new JLabel(); +// viewerLabel.setText(viewerLabelText); +// viewerLabel.setFont(viewerLabel.getFont().deriveFont(viewerLabel.getFont().getStyle() | java.awt.Font.BOLD)); +// viewerLabel.setLabelFor(viewer); JPanel viewerPanel = new JPanel(); GroupLayout viewerPanelLayout = new GroupLayout(viewerPanel); viewerPanel.setLayout(viewerPanelLayout); viewerPanelLayout.setHorizontalGroup( - viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(viewerLabel).addComponent(scrollPane)); + viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addComponent(viewerLabel) + .addComponent(scrollPane)); viewerPanelLayout.setVerticalGroup( - viewerPanelLayout.createSequentialGroup().addComponent(viewerLabel).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(scrollPane)); + viewerPanelLayout.createSequentialGroup() +// .addComponent(viewerLabel) +// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scrollPane)); return viewerPanel; } diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties index a7363421..e560ca98 100644 --- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties +++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties @@ -26,8 +26,8 @@ title.hashdata=<html>Signaturdaten</html> windowtitle.save=Signaturdaten speichern windowtitle.savedir=Signaturdaten in Verzeichnis speichern windowtitle.overwrite=Datei \u00FCberschreiben? -windowtitle.viewer=Signaturedaten -windowtitle.help=Hilfe +windowtitle.viewer=Signaturdaten +windowtitle.help=Hilfe zur B\u00FCrgerkarte message.wait=<html>Bitte warten...</html> message.insertcard=<html>Bitte die B\u00FCrgerkarte in den Kartenleser stecken</html> message.enterpin=<html>{0} eingeben</html> diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties index 7aae8eae..96f99a8a 100644 --- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties +++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties @@ -14,7 +14,7 @@ # limitations under the License. title.welcome=<html>Welcome</html> -title.insertcard=<html>No citizencard found</html> +title.insertcard=<html>No citizen card found</html> title.cardnotsupported=<html>This card is not supported</html> #title.cardpin=<html>Enter {0}</html> title.cardpin=<html>Reading card</html> @@ -27,9 +27,9 @@ windowtitle.save=Save signature data windowtitle.savedir=Save signature data to directory windowtitle.overwrite=Overwrite file? windowtitle.viewer=Signature data -windowtitle.help=Help +windowtitle.help=Citizen card help message.wait=<html>Please wait...</html> -message.insertcard=<html>Please insert your citizencard into the reader</html> +message.insertcard=<html>Please insert your citizen card into the reader</html> message.enterpin=<html>Enter {0}</html> message.hashdatalink=<html><a href=\"anzeige\">Display signature data</a></html> #message.hashdata=<html>Remark: This is a preview of the data to-be signed. For standards compliant display see help.</html> @@ -65,16 +65,16 @@ error.pcsc=<html>No PC/SC interface for smartcard access provided</html> error.cardterminal=<html>Could not find smartcard reader</html> error.unknown=<html>An error occured: {0}</html> error.test=<html>Error1 {0} - Error2 {1}</html> -error.card.locked=<html>Citizencard is locked</html> -error.card.notactivated=<html>Citizencard not activated</html> +error.card.locked=<html>Citizen card is locked</html> +error.card.notactivated=<html>Citizen card not activated</html> error.viewer=Failed to display contents: {0} error.external.link=<html>Externer Link {0} wird nicht ge\u00F6ffnet</html> # Help Topics help.welcome=Welcome page help.wait=Wait screen -help.cardnotsupported=Unsupported citizencard -help.insertcard=No citizencard found +help.cardnotsupported=Unsupported citizen card +help.insertcard=No citizen card found help.cardpin=Pin entry help.signpin=Signature pin entry help.retry=Wrong Pin diff --git a/BKULocal/pom.xml b/BKULocal/pom.xml index 0d175a7c..e147a6ad 100644 --- a/BKULocal/pom.xml +++ b/BKULocal/pom.xml @@ -9,7 +9,7 @@ <artifactId>BKULocal</artifactId> <packaging>war</packaging> <name>BKU Local</name> - <version>1.0.2</version> + <version>1.0.1</version> <scm> <developerConnection>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2/BKULocal</developerConnection> diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java index eaa4d6ad..a28ee1eb 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/BKUGuiProxy.java @@ -1,13 +1,6 @@ package at.gv.egiz.bku.local.stal;
-import java.awt.Container;
-import java.awt.EventQueue;
-import java.awt.Toolkit;
import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.WindowEvent;
-import java.net.URL;
import java.util.List;
import java.util.Locale;
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java index 10fb3e60..91d0aba0 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalBKUWorker.java @@ -18,6 +18,14 @@ package at.gv.egiz.bku.local.stal; import at.gv.egiz.bku.gui.BKUGUIFacade; import at.gv.egiz.bku.smccstal.AbstractBKUWorker; +import at.gv.egiz.stal.QuitRequest; +import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.SignRequest; +import at.gv.egiz.stal.ext.APDUScriptRequest; + +import java.util.List; +import javax.swing.JDialog; /** * @@ -25,7 +33,27 @@ import at.gv.egiz.bku.smccstal.AbstractBKUWorker; */ public class LocalBKUWorker extends AbstractBKUWorker { - public LocalBKUWorker(BKUGUIFacade gui) { + private JDialog container; + + public LocalBKUWorker(BKUGUIFacade gui, JDialog container) { super(gui); + this.container = container; + addRequestHandler(SignRequest.class, new LocalSignRequestHandler()); + } + + @Override + public List<STALResponse> handleRequest(List<? extends STALRequest> requestList) { + signatureCard = null; + List<STALResponse> responses = super.handleRequest(requestList); + // container.setVisible(false); + return responses; + } + + @Override + public STALResponse handleRequest(STALRequest request) { + if (request instanceof QuitRequest) { + container.setVisible(false); + } + return null; } } diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java index 3ae739d9..c2548cd5 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/LocalSTALFactory.java @@ -34,16 +34,16 @@ import java.net.URL; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -public class SMCCSTALFactory implements STALFactory { +public class LocalSTALFactory implements STALFactory { - protected static final Log log = LogFactory.getLog(SMCCSTALFactory.class); + protected static final Log log = LogFactory.getLog(LocalSTALFactory.class); protected String helpURL; protected Locale locale; @Override public STAL createSTAL() { - SMCCSTAL stal; + LocalBKUWorker stal; JDialog dialog = new JDialog(); if (locale != null) { dialog.setLocale(locale); @@ -64,7 +64,7 @@ public class SMCCSTALFactory implements STALFactory { BKUGUIFacade.Style.advanced, null, helpListener); - stal = new SMCCSTAL(new BKUGuiProxy(dialog, gui), dialog); + stal = new LocalBKUWorker(new BKUGuiProxy(dialog, gui), dialog); dialog.setPreferredSize(new Dimension(400, 200)); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setTitle("MOCCA"); diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java deleted file mode 100644 index 716050d6..00000000 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java +++ /dev/null @@ -1,40 +0,0 @@ -package at.gv.egiz.bku.local.stal;
-
-import java.util.List;
-
-import javax.swing.JDialog;
-
-import at.gv.egiz.bku.gui.BKUGUIFacade;
-import at.gv.egiz.bku.smccstal.AbstractBKUWorker;
-import at.gv.egiz.stal.QuitRequest;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
-import at.gv.egiz.stal.SignRequest;
-
-public class SMCCSTAL extends AbstractBKUWorker {
-
- private JDialog container;
-
- public SMCCSTAL(BKUGUIFacade gui, JDialog container) {
- super(gui);
- this.container = container;
- addRequestHandler(SignRequest.class, new LocalSignRequestHandler());
- }
-
- @Override
- public List<STALResponse> handleRequest(List<STALRequest> requestList) {
- signatureCard = null;
- List<STALResponse> responses = super.handleRequest(requestList);
- // container.setVisible(false);
- return responses;
- }
-
- @Override
- public STALResponse handleRequest(STALRequest request) {
- if (request instanceof QuitRequest) {
- container.setVisible(false);
- }
- return null;
- }
-
-}
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/CACerts/A-CERT GLOBALTRUST.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/CACerts/A-CERT GLOBALTRUST.cer Binary files differnew file mode 100644 index 00000000..9a25e57d --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/CACerts/A-CERT GLOBALTRUST.cer diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT ADVANCED.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT ADVANCED.cer Binary files differnew file mode 100644 index 00000000..66ff251b --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT ADVANCED.cer diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT GLOBALTRUST.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT GLOBALTRUST.cer Binary files differnew file mode 100644 index 00000000..9a25e57d --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-CERT GLOBALTRUST.cer diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-01a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-01a.cer Binary files differnew file mode 100644 index 00000000..f9fef65f --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-01a.cer diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-02a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-02a.cer Binary files differnew file mode 100644 index 00000000..36a442b8 --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-02a.cer diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-03a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-03a.cer Binary files differnew file mode 100644 index 00000000..ab9e0cd7 --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-Qual-03a.cer diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-01a.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-01a.cer Binary files differnew file mode 100644 index 00000000..efa28178 --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-01a.cer diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-03.cer b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-03.cer Binary files differnew file mode 100644 index 00000000..33e77636 --- /dev/null +++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/conf/certs/certStore/A-Trust-nQual-03.cer diff --git a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml index 3191f82f..2ddd46a1 100644 --- a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml +++ b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml @@ -18,7 +18,7 @@ <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
- <bean id="STALFactory" class="at.gv.egiz.bku.local.stal.SMCCSTALFactory"
+ <bean id="STALFactory" class="at.gv.egiz.bku.local.stal.LocalSTALFactory"
scope="singleton">
<property name="helpURL" value="http://localhost:3495/help"/>
</bean>
@@ -48,6 +48,46 @@ <bean id="commandInvoker" class="at.gv.egiz.bku.binding.SLCommandInvokerImpl">
<property name="securityManager" ref="accessController" />
</bean>
+
+ <bean id="slCommandFactory" class="at.gv.egiz.bku.slcommands.SLCommandFactory"
+ factory-method="getInstance">
+ <property name="commandImpl">
+ <map>
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:NullOperationRequest"
+ value="at.gv.egiz.bku.slcommands.impl.NullOperationCommandImpl" />
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:InfoboxReadRequest"
+ value="at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl" />
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:InfoboxUpdateRequest"
+ value="at.gv.egiz.bku.slcommands.impl.InfoboxUpdateCommandImpl" />
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:CreateXMLSignatureRequest"
+ value="at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl" />
+ </map>
+ </property>
+ </bean>
+
+ <bean id="infoboxFactory" class="at.gv.egiz.bku.slcommands.impl.InfoboxFactory"
+ factory-method="getInstance">
+ <property name="infoboxImpl">
+ <map>
+ <entry
+ key="Certificates"
+ value="at.gv.egiz.bku.slcommands.impl.CertificatesInfoboxImpl" />
+ <entry
+ key="IdentityLink"
+ value="at.gv.egiz.bku.slcommands.impl.IdentityLinkInfoboxImpl" />
+ <entry
+ key="CardChannel"
+ value="at.gv.egiz.bku.slcommands.impl.CardChannelInfoboxImpl" />
+ <entry
+ key="SV-Personendaten"
+ value="at.gv.egiz.bku.slcommands.impl.SVPersonendatenInfoboxImpl" />
+ </map>
+ </property>
+ </bean>
<!-- Configure Configuration -->
<bean id="certValidator" class="at.gv.egiz.bku.conf.CertValidatorImpl"></bean>
diff --git a/BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java b/BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java index 51e7ff7d..2108d2b3 100644 --- a/BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java +++ b/BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java @@ -14,42 +14,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package at.gv.egiz.bku.local.stal;
-
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Ignore;
-
-import at.gv.egiz.bku.utils.StreamUtil;
-import at.gv.egiz.smcc.SignatureCard;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.SignRequest;
-
-@Ignore
-public class TestSignRequest {
-
- public void test() throws Exception {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- StreamUtil.copyStream(getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/local/stal/sigInfo.xml"), os);
- byte[] signedInfo = os.toByteArray();
- SignRequest sr = new SignRequest();
- sr.setSignedInfo(signedInfo);
- sr.setKeyIdentifier(SignatureCard.KeyboxName.SECURE_SIGNATURE_KEYPAIR.getKeyboxName());
- List<STALRequest> reqList = new ArrayList<STALRequest>(1);
- reqList.add(sr);
- System.out.println((new SMCCSTALFactory()).createSTAL().handleRequest(reqList));
- }
-
- public static void main(String[] args) {
- TestSignRequest tsr = new TestSignRequest();
- try {
- tsr.test();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-}
+package at.gv.egiz.bku.local.stal; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Ignore; + +import at.gv.egiz.bku.utils.StreamUtil; +import at.gv.egiz.smcc.SignatureCard; +import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.SignRequest; + +@Ignore +public class TestSignRequest { + + public void test() throws Exception { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + StreamUtil.copyStream(getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/local/stal/sigInfo.xml"), os); + byte[] signedInfo = os.toByteArray(); + SignRequest sr = new SignRequest(); + sr.setSignedInfo(signedInfo); + sr.setKeyIdentifier(SignatureCard.KeyboxName.SECURE_SIGNATURE_KEYPAIR.getKeyboxName()); + List<STALRequest> reqList = new ArrayList<STALRequest>(1); + reqList.add(sr); + System.out.println((new LocalSTALFactory()).createSTAL().handleRequest(reqList)); + } + + public static void main(String[] args) { + TestSignRequest tsr = new TestSignRequest(); + try { + tsr.test(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/BKULocalApp/pom.xml b/BKULocalApp/pom.xml index e4bbbdf9..e253ab46 100644 --- a/BKULocalApp/pom.xml +++ b/BKULocalApp/pom.xml @@ -8,7 +8,7 @@ <groupId>at.gv.egiz.bku</groupId> <artifactId>BKULocalApp</artifactId> <name>BKU Local App</name> - <version>1.0.2</version> + <version>1.0.1</version> <description /> <build> <pluginManagement> @@ -76,7 +76,7 @@ <dependency> <groupId>at.gv.egiz</groupId> <artifactId>BKULocal</artifactId> - <version>1.0.2</version> + <version>1.0.1</version> <type>war</type> </dependency> <dependency> diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java index a8a6431a..f56bbb86 100644 --- a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java +++ b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/Container.java @@ -56,7 +56,7 @@ public class Container { webappcontext.setContextPath("/");
webappcontext.setExtractWAR(false);
System.out.println(getClass().getClassLoader().getResource("log4j.properties"));
- webappcontext.setWar("BKULocal-1.0-SNAPSHOT.war");
+ webappcontext.setWar("BKULocal-1.0.2-SNAPSHOT.war");
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
diff --git a/BKUOnline/pom.xml b/BKUOnline/pom.xml index c6164540..cfc5507e 100644 --- a/BKUOnline/pom.xml +++ b/BKUOnline/pom.xml @@ -1,110 +1,128 @@ + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <artifactId>bku</artifactId> - <groupId>at.gv.egiz</groupId> - <version>1.0.2</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <groupId>at.gv.egiz</groupId> - <artifactId>BKUOnline</artifactId> - <packaging>war</packaging> - <name>BKU Online</name> - <version>1.0.2</version> + <parent> + <artifactId>bku</artifactId> + <groupId>at.gv.egiz</groupId> + <version>1.0.2</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>at.gv.egiz</groupId> + <artifactId>BKUOnline</artifactId> + <packaging>war</packaging> + <name>BKU Online</name> + <version>1.0.2</version> - <pluginRepositories> - <pluginRepository> - <id>tlc</id> - <name>TLC Repository</name> - <url>http://commons.ucalgary.ca/pub/m2</url> - </pluginRepository> - </pluginRepositories> + <pluginRepositories> + <pluginRepository> + <id>tlc</id> + <name>TLC Repository</name> + <url>http://commons.ucalgary.ca/pub/m2</url> + </pluginRepository> + </pluginRepositories> - <dependencies> - <dependency> - <groupId>at.gv.egiz</groupId> - <artifactId>bkucommon</artifactId> - <version>1.0.2</version> - </dependency> - <dependency> - <groupId>at.gv.egiz</groupId> - <artifactId>BKUViewer</artifactId> - <version>1.0.2</version> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <version>2.5.5</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - <version>2.5.5</version> - </dependency> - <dependency> - <groupId>at.gv.egiz</groupId> - <artifactId>STALService</artifactId> - <version>1.0.2</version> - <scope>compile</scope> - </dependency> - <!-- build BKUApplet prior to BKUOnline --> + <dependencies> <dependency> - <groupId>at.gv.egiz</groupId> - <artifactId>BKUApplet</artifactId> - <version>1.0.2</version> - <scope>provided</scope> + <groupId>at.gv.egiz</groupId> + <artifactId>bkucommon</artifactId> + <version>1.0.2</version> </dependency> <dependency> - <groupId>at.gv.egiz</groupId> - <artifactId>STALService</artifactId> - <version>1.0.2</version> + <groupId>at.gv.egiz</groupId> + <artifactId>BKUViewer</artifactId> + <version>1.0.2</version> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>2.5.5</version> + </dependency> + <dependency> + <groupId>at.gv.egiz</groupId> + <artifactId>STALService</artifactId> + <version>1.0.2</version> + <scope>compile</scope> </dependency> - + <!-- build BKUApplet prior to BKUOnline --> + <dependency> + <groupId>at.gv.egiz</groupId> + <artifactId>BKUApplet</artifactId> + <version>1.0.2</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>at.gv.egiz</groupId> + <artifactId>STALService</artifactId> + <version>1.0.2</version> + </dependency> + <!-- TODO move at.buergerkarte.namespaces.cardchannel.service out from STALXService + | so that BKUOnline does not have to depend on STALXService + <dependency> + <groupId>at.gv.egiz</groupId> + <artifactId>STALXService</artifactId> + <version>1.0.2-SNAPSHOT</version> + </dependency--> <!-- - | see https://wsit.dev.java.net/issues/show_bug.cgi?id=970 + | see https://wsit.dev.java.net/issues/show_bug.cgi?id=970 --> - <dependency> - <groupId>com.sun.xml.ws</groupId> - <artifactId>jaxws-rt</artifactId> - <version>2.1.4</version> - <!--scope>provided</scope--> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-rt</artifactId> + <version>2.1.5</version> + <!-- use JAX-WS RI with SJSXP instead of Woodstox --> + <exclusions> + <exclusion> + <groupId>woodstox</groupId> + <artifactId>wstx-asl</artifactId> + </exclusion> + </exclusions> <!-- conflict with SAAJ from java 6 ? <exclusions> <exclusion> <groupId>javax.xml.soap</groupId> <artifactId>saaj-api</artifactId> </exclusion> <exclusion> <groupId>com.sun.xml.messaging.saaj</groupId> <artifactId>saaj-impl</artifactId> </exclusion> </exclusions --> - </dependency> - </dependencies> - <properties> - <netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server> - </properties> - <scm> - <developerConnection>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2/BKUOnline</developerConnection> - <connection>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2/BKUOnline</connection> - <url>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2/BKUOnline</url> - </scm> - <build> - <plugins> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copyapplet-dependencies</id> - <goals> - <goal>copy-dependencies</goal> - </goals> - <configuration> - <outputDirectory>${project.build.directory}/${project.build.finalName}/applet</outputDirectory> + </dependency> + <!-- use JAX-WS RI with SJSXP instead of Woodstox --> + <dependency> + <artifactId>sjsxp</artifactId> + <groupId>com.sun.xml.stream</groupId> + <version>1.0.1</version> + </dependency> + </dependencies> + <properties> + <netbeans.hint.deploy.server>Tomcat60</netbeans.hint.deploy.server> + </properties> + <scm> + <developerConnection>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2/BKUOnline</developerConnection> + <connection>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2/BKUOnline</connection> + <url>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2/BKUOnline</url> + </scm> + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copyapplet-dependencies</id> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/${project.build.finalName}/applet</outputDirectory> <!--<artifactItems> <artifactItem> <groupId>at.gv.egiz</groupId> @@ -120,32 +138,33 @@ <artifactId>iaik_jce_me4se</artifactId> </artifactItem> </artifactItems>--> - <includeGroupIds>at.gv.egiz</includeGroupIds> - <includeArtifactIds>BKUApplet</includeArtifactIds> - <excludeTransitive>true</excludeTransitive> - </configuration> - </execution> - <execution> - <id>copyapplet</id> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <outputDirectory>${project.build.directory}/${project.build.finalName}/applet</outputDirectory> - <artifactItems> - <artifactItem> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </artifactItem> - <artifactItem> - <groupId>iaik</groupId> - <artifactId>iaik_jce_me4se</artifactId> - </artifactItem> - </artifactItems> - </configuration> - </execution> - </executions> - </plugin> + <includeGroupIds>at.gv.egiz</includeGroupIds> + <includeArtifactIds>BKUApplet</includeArtifactIds> + <stripVersion>true</stripVersion> + <excludeTransitive>true</excludeTransitive> + </configuration> + </execution> + <execution> + <id>copyapplet</id> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/${project.build.finalName}/applet</outputDirectory> + <artifactItems> + <artifactItem> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </artifactItem> + <artifactItem> + <groupId>iaik</groupId> + <artifactId>iaik_jce_me4se</artifactId> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> <!--plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> @@ -153,67 +172,77 @@ <skip>true</skip> </configuration> </plugin--> - <!--plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>jaxws-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>wsimport</goal> - </goals> - </execution> - </executions> - <configuration> - <target>2.0</target> - <verbose>true</verbose> - <bindingDirectory>${basedir}/src/main/custom-binding</bindingDirectory> - <bindingFiles> - <bindingFile>stalservice-custom.xml</bindingFile> - <bindingFile>staltypes-custom.xml</bindingFile> - </bindingFiles> - <wsdlDirectory>${basedir}/src/main/webapp/WEB-INF/wsdl</wsdlDirectory> - <wsdlFiles> - <wsdlFile>stal.wsdl</wsdlFile> - </wsdlFiles> - <sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir> - <staleFile>${project.build.directory}/generated-sources/wsimport/.staleFlag</staleFile> - </configuration> - </plugin--> - <plugin> - <artifactId>maven-war-plugin</artifactId> - <version>2.0.2</version> - <configuration> - <manifest> - <addDefaultImplementationEntries> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <manifest> + <addDefaultImplementationEntries> true - </addDefaultImplementationEntries> - </manifest> - <archive> - <manifestEntries> - <Implementation-Build> + </addDefaultImplementationEntries> + </manifest> + <archive> + <manifestEntries> + <Implementation-Build> ${project.version}-r${buildNumber} - </Implementation-Build> - </manifestEntries> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>maven-buildnumber-plugin</artifactId> - <version>0.9.6</version> - <executions> - <execution> - <phase>validate</phase> - <goals> - <goal>create</goal> - </goals> - </execution> - </executions> - <configuration> - <doCheck>false</doCheck> - <doUpdate>false</doUpdate> - </configuration> - </plugin> - </plugins> - </build> + </Implementation-Build> + </manifestEntries> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>maven-buildnumber-plugin</artifactId> + <version>0.9.6</version> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>create</goal> + </goals> + </execution> + </executions> + <configuration> + <doCheck>false</doCheck> + <doUpdate>false</doUpdate> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>jaxb-generate</id> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxws-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>wsimport</goal> + </goals> + </execution> + </executions> + <configuration> + <verbose>true</verbose> + <bindingDirectory>${basedir}/src/main/custom-binding</bindingDirectory> + <bindingFiles> + <bindingFile>stalservice-custom.xml</bindingFile> + <bindingFile>staltypes-custom.xml</bindingFile> + <bindingFile>cardchannel-custom.xml</bindingFile> + </bindingFiles> + <wsdlDirectory>${basedir}/src/main/webapp/WEB-INF/wsdl</wsdlDirectory> + <wsdlDirectory>${basedir}/src/main/wsdl</wsdlDirectory> + <wsdlFiles> + <wsdlFile>stal-service.wsdl</wsdlFile> + </wsdlFiles> + <sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir> + <staleFile>${project.build.directory}/generated-sources/wsimport/.staleFlag</staleFile> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project>
\ No newline at end of file diff --git a/BKUOnline/src/main/custom-binding/cardchannel-custom.xml b/BKUOnline/src/main/custom-binding/cardchannel-custom.xml new file mode 100644 index 00000000..b46aa6a8 --- /dev/null +++ b/BKUOnline/src/main/custom-binding/cardchannel-custom.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2008 Federal Chancellery Austria and + Graz University of Technology + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- + Binding customization for STAL schema (stal.xsd) + Use JAXB version 2.1 which supports "schema component designator" (SCD, http://www.w3.org/TR/xmlschema-ref/) + + All request/response types are generated to at.gv.egiz.stal + and renamed (...Type suffix removed), + except for the base types of the modified implClasses ErrorResponse and SignRequest + + IMPORTANT: WHEN REGENERATING CLASSES MAKE SURE TO BACKUP MODIFIED IMPLCLASSES (ErrorResponse and SignRequest) +--> +<bindings xmlns='http://java.sun.com/xml/ns/jaxb' version='2.1' + xmlns:xs='http://www.w3.org/2001/XMLSchema' + xmlns:xjc='http://java.sun.com/xml/ns/jaxb/xjc' + xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' + schemaLocation='../wsdl/CardChannel.xsd' + xsi:schemaLocation='http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd + http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd'> + + <!-- cannot use scd, CardChannel.xsd has no namespace?! --> + <schemaBindings> + <package name="at.buergerkarte.namespaces.cardchannel.service"/> + </schemaBindings> +</bindings> diff --git a/BKUOnline/src/main/custom-binding/stalservice-custom.xml b/BKUOnline/src/main/custom-binding/stalservice-custom.xml index 9c35cbdf..7c5f604d 100644 --- a/BKUOnline/src/main/custom-binding/stalservice-custom.xml +++ b/BKUOnline/src/main/custom-binding/stalservice-custom.xml @@ -23,7 +23,7 @@ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" - wsdlLocation="../webapp/WEB-INF/wsdl/stal.wsdl"> + wsdlLocation="../wsdl/stal-service.wsdl"> <!-- default settings diff --git a/BKUOnline/src/main/custom-binding/staltypes-custom.xml b/BKUOnline/src/main/custom-binding/staltypes-custom.xml index 3e150363..2925fb91 100644 --- a/BKUOnline/src/main/custom-binding/staltypes-custom.xml +++ b/BKUOnline/src/main/custom-binding/staltypes-custom.xml @@ -27,7 +27,7 @@ --> <bindings xmlns='http://java.sun.com/xml/ns/jaxb' version='2.1' xmlns:xs='http://www.w3.org/2001/XMLSchema' - xmlns:stal="http://www.egiz.gv.at/stal" + xmlns:stal="http://www.egiz.gv.at/stal" xmlns:xjc='http://java.sun.com/xml/ns/jaxb/xjc' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java index 660fee78..d9be0981 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/BKURequestHandler.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -32,6 +33,7 @@ import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import at.gv.egiz.bku.binding.BindingProcessor; import at.gv.egiz.bku.binding.HTTPBindingProcessor; import at.gv.egiz.bku.binding.HttpUtil; import at.gv.egiz.bku.binding.IdFactory; @@ -43,14 +45,16 @@ import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage; * */ public class BKURequestHandler extends SpringBKUServlet { + public static final String BKU_APPLET_JSP = "BKUApplet"; private static final long serialVersionUID = 1L; - public final static String REDIRECT_URL = "appletPage.jsp"; + public final static String REDIRECT_URL_SESSION_ATTRIBUTE="redirectUrl"; protected Log log = LogFactory.getLog(BKURequestHandler.class); - private static String getStringFromStream(InputStream is, String encoding) throws IOException { + private static String getStringFromStream(InputStream is, String encoding) + throws IOException { if (is == null) { return null; } @@ -61,28 +65,41 @@ public class BKURequestHandler extends SpringBKUServlet { StreamUtil.copyStream(is, os); return new String(os.toByteArray(), encoding); } - - + + @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { - log.debug("Got new request"); - HttpSession session = req.getSession(); - String lang = req.getHeader("Accept-Language"); - Locale locale = AcceptLanguage.getLocale(lang); - log.debug("Using locale: " + locale); - + log.debug("Received new request"); + + HttpSession session = req.getSession(false); if (session != null) { log.warn("Already a session with id: " + session.getId() - + " active, deleting this one"); - getBindingProcessorManager().removeBindingProcessor( + + " active, trying to get Bindingprocessor"); + BindingProcessor bp = getBindingProcessorManager().getBindingProcessor( IdFactory.getInstance().createId(session.getId())); + if (bp != null) { + log.debug("Found binding processor, using this one"); + RequestDispatcher dispatcher = getServletContext().getNamedDispatcher( + BKU_APPLET_JSP); + log.debug("forward to applet"); + dispatcher.forward(req, resp); + return; + } + log.debug("Did not find a binding processor, creating new ..."); } - String id = req.getSession(true).getId(); - log.debug("Using session id: " + id); - HTTPBindingProcessor bindingProcessor; + session = req.getSession(true); + if (log.isDebugEnabled()) { + log.debug("Using session id: " + session.getId()); + } + + String acceptLanguage = req.getHeader("Accept-Language"); + Locale locale = AcceptLanguage.getLocale(acceptLanguage); + log.debug("Accept-Language locale: " + locale); + HTTPBindingProcessor bindingProcessor; bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager() - .createBindingProcessor(req.getRequestURL().toString(), id, locale); + .createBindingProcessor(req.getRequestURL().toString(), + session.getId(), locale); Map<String, String> headerMap = new HashMap<String, String>(); for (Enumeration<String> headerName = req.getHeaderNames(); headerName @@ -102,13 +119,20 @@ public class BKURequestHandler extends SpringBKUServlet { bindingProcessor.consumeRequestStream(req.getInputStream()); req.getInputStream().close(); getBindingProcessorManager().process(bindingProcessor); - + log.trace("Trying to find applet parameters in request"); - String width = getStringFromStream(bindingProcessor.getFormData("appletWidth"), charset); - String height = getStringFromStream(bindingProcessor.getFormData("appletHeight"), charset); - String background = getStringFromStream(bindingProcessor.getFormData("appletBackground"), charset); - String guiStyle = getStringFromStream(bindingProcessor.getFormData("appletGuiStyle"), charset); - String hashDataDisplay = getStringFromStream(bindingProcessor.getFormData("appletHashDataDisplay"), charset); + String width = getStringFromStream(bindingProcessor + .getFormData("appletWidth"), charset); + String height = getStringFromStream(bindingProcessor + .getFormData("appletHeight"), charset); + String background = getStringFromStream(bindingProcessor + .getFormData("appletBackground"), charset); + String guiStyle = getStringFromStream(bindingProcessor + .getFormData("appletGuiStyle"), charset); + String hashDataDisplay = getStringFromStream(bindingProcessor + .getFormData("appletHashDataDisplay"), charset); + String localeFormParam = getStringFromStream(bindingProcessor + .getFormData("locale"), charset); if (width != null) { try { log.trace("Found applet width parameter: " + width); @@ -139,11 +163,30 @@ public class BKURequestHandler extends SpringBKUServlet { log.trace("Found applet hash data display parameter: " + hashDataDisplay); session.setAttribute("appletHashDataDisplay", hashDataDisplay); } - String redirectUrl = REDIRECT_URL+";jsessionid="+session.getId(); - log.debug("Redirecting to: "+redirectUrl); - resp.sendRedirect(redirectUrl); + if (localeFormParam != null) { + log.debug("overrule accept-language locale " + locale + + " with form param " + localeFormParam); + locale = new Locale(localeFormParam); + } + if (locale != null) { + log.debug("Using locale " + locale); + session.setAttribute("locale", locale.toString()); + } + + // handle server side redirect url after processing + String redirectUrl = bindingProcessor.getRedirectURL(); + if ( redirectUrl != null) { + log.debug("Got redirect URL "+redirectUrl+". Deferring browser redirect."); + session.setAttribute(REDIRECT_URL_SESSION_ATTRIBUTE, redirectUrl); + } + // TODO error if no dispatcher found + RequestDispatcher dispatcher = getServletContext().getNamedDispatcher( + BKU_APPLET_JSP); + log.debug("forward to applet"); + dispatcher.forward(req, resp); } + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { doPost(req, resp); diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java deleted file mode 100644 index c095fcc8..00000000 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/HashDataInputServlet.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2008 Federal Chancellery Austria and - * Graz University of Technology - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package at.gv.egiz.bku.online.webapp; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import at.gv.egiz.bku.binding.BindingProcessor; -import at.gv.egiz.bku.binding.Id; -import at.gv.egiz.bku.binding.IdFactory; -import at.gv.egiz.bku.slexceptions.SLRuntimeException; -import at.gv.egiz.bku.utils.StreamUtil; -import at.gv.egiz.stal.HashDataInput; -import at.gv.egiz.stal.STAL; -import at.gv.egiz.stal.service.impl.STALRequestBroker; - -public class HashDataInputServlet extends SpringBKUServlet { - - private static Log log = LogFactory.getLog(HashDataInputServlet.class); - - public HashDataInputServlet() { - - } - - private STALRequestBroker getSTAL(Id id) { - BindingProcessor bp = getBindingProcessorManager().getBindingProcessor(id); - if (bp == null) { - return null; - } - STAL stal = bp.getSTAL(); - if (stal instanceof STALRequestBroker) { - return (STALRequestBroker) stal; - } else { - throw new SLRuntimeException("Unexpected STAL type"); - } - } - - private static boolean isMSIE(HttpServletRequest req) { - String useragent = req.getHeader("User-Agent"); - String user = useragent.toLowerCase(); - return (user.indexOf("msie") != -1); - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - if ((req.getSession() == null) && (req.getSession().getId() != null)) { - log.warn("Got request for hashdatainput without session info"); - resp.sendRedirect("expired.html"); - return; - } - Id sessionId = IdFactory.getInstance().createId(req.getSession().getId()); - log.debug("Got request for hashdata for session " + sessionId); - STALRequestBroker rb = getSTAL(sessionId); - if (rb == null) { - log.info("STAL instance not found for session: " + sessionId); - resp.sendRedirect("expired.html"); - return; - } - List<HashDataInput> hdi = rb.getHashDataInput(); - log.debug("Got hashdata list with " + hdi.size() + " entries"); - String param = req.getParameter("refId"); - log.debug("Got request for refId:" + param); - if ((param == null) && (hdi.size() > 1)) { - resp.sendRedirect("multiHashDataInput.html"); - return; - } - - if ((param == null) && (hdi.size() == 1)) { - param = hdi.get(0).getReferenceId(); - log.debug("Request parameter not set, setting to: " + param); - } - for (HashDataInput hd : hdi) { - if (hd.getReferenceId().equals(param)) { - log.debug("Found hashdatainput for refId:" + param); - resp.setContentType(hd.getMimeType()); - - String charSet = hd.getEncoding(); - if (charSet == null) { - charSet = "UTF-8"; - } - resp.setCharacterEncoding(charSet); - if (isMSIE(req)) { - String fileExt = hd.getMimeType().equalsIgnoreCase("text/plain") ? ".txt" - : ".xhtml"; - if (fileExt.equals(".xhtml")) { - if (req.getParameter("ieCType") == null) { - resp.sendRedirect("ieView.html"); - return; - } else { - resp.setContentType(req.getParameter("ieCType")); - if (req.getParameter("ieCType").equals("application/xhtml+xml")) { - resp.addHeader("content-disposition", "attachment; filename=" - + param + ".xhtml"); - } - } - } - } - Reader r = new InputStreamReader(hd.getHashDataInput(), charSet); - Writer w = new OutputStreamWriter(resp.getOutputStream(), charSet); - StreamUtil.copyStream(r, w); - w.flush(); - return; - - } - } - log.error("Cannot find hashdata for id:" + param); - resp.sendError(404); - return; - } - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - doGet(req, resp); - } - -} diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java index 9e69099d..f271dfc9 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java @@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.bku.binding.HTTPBindingProcessor; import at.gv.egiz.bku.binding.HttpUtil; import at.gv.egiz.bku.binding.IdFactory; -import at.gv.egiz.bku.conf.Configurator; +import at.gv.egiz.bku.utils.NullOutputStream; /** * Delivers the result to the browser @@ -99,9 +99,20 @@ public class ResultServlet extends SpringBKUServlet { resp.sendRedirect(expiredPage); return; } - - if (bp.getRedirectURL() != null) { - resp.sendRedirect(bp.getRedirectURL()); + String redirectUrl = (String) session + .getAttribute(BKURequestHandler.REDIRECT_URL_SESSION_ATTRIBUTE); + if (redirectUrl == null) { + redirectUrl = bp.getRedirectURL(); + } + if (redirectUrl != null) { + try { + bp.writeResultTo(new NullOutputStream(), encoding); + getBindingProcessorManager().removeBindingProcessor(bp.getId()); + } finally { + log.debug("Executing deferred browser redirect to: " + redirectUrl); + resp.sendRedirect(redirectUrl); + session.invalidate(); + } return; } resp.setStatus(bp.getResponseCode()); @@ -109,8 +120,8 @@ public class ResultServlet extends SpringBKUServlet { resp.setHeader("Pragma", "no-cache"); // HTTP 1.0
resp.setDateHeader("Expires", 0); if (configurator.getProperty(USER_AGENT_PROPERTY_KEY) != null) { - resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, configurator.getProperty( - USER_AGENT_PROPERTY_KEY)); + resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, configurator + .getProperty(USER_AGENT_PROPERTY_KEY)); } else { resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, "citizen-card-environment/1.2 MOCCA Unknown"); diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java index d1fe045a..b77f7660 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBroker.java @@ -22,6 +22,7 @@ import at.gv.egiz.stal.STAL; import at.gv.egiz.stal.service.types.RequestType; import at.gv.egiz.stal.service.types.ResponseType; import java.util.List; +import javax.xml.bind.JAXBElement; /** * @@ -32,9 +33,9 @@ public interface STALRequestBroker extends STAL { public static final int ERR_4500 = 4500; public static final long DEFAULT_TIMEOUT_MS = 1000*60*5; //5mn - public List<RequestType> connect(); + public List<JAXBElement<? extends RequestType>> connect(); - public List<RequestType> nextRequest(List<ResponseType> response); + public List<JAXBElement<? extends RequestType>> nextRequest(List<JAXBElement<? extends ResponseType>> responses); public List<HashDataInput> getHashDataInput(); } diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java index e7fb928a..252327d3 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALRequestBrokerImpl.java @@ -25,6 +25,7 @@ import at.gv.egiz.stal.STALRequest; import at.gv.egiz.stal.STALResponse; import at.gv.egiz.stal.SignRequest; import at.gv.egiz.stal.service.types.InfoboxReadRequestType; +import at.gv.egiz.stal.service.types.ObjectFactory; import at.gv.egiz.stal.service.types.QuitRequestType; import at.gv.egiz.stal.service.types.RequestType; import at.gv.egiz.stal.service.types.ResponseType; @@ -34,6 +35,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; +import javax.xml.bind.JAXBElement; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -52,14 +54,12 @@ public class STALRequestBrokerImpl implements STALRequestBroker { private static final Log log = LogFactory.getLog(STALRequestBrokerImpl.class); -// private boolean expectingResponse = false; + private ObjectFactory stalObjFactory = new ObjectFactory(); + private boolean interrupted = false; -// private final RequestsMonitor reqMon = new RequestsMonitor(); -// private final ResponsesMonitor respMon = new ResponsesMonitor(); - - protected ArrayList<RequestType> requests; - protected ArrayList<ResponseType> responses; + protected final ArrayList<JAXBElement<? extends RequestType>> requests; + protected final ArrayList<JAXBElement<? extends ResponseType>> responses; protected ArrayList<HashDataInput> hashDataInputs; @@ -69,8 +69,8 @@ public class STALRequestBrokerImpl implements STALRequestBroker { if (timeoutMillisec <= 0) timeoutMillisec = DEFAULT_TIMEOUT_MS; timeout = timeoutMillisec; - requests = new ArrayList<RequestType>(); - responses = new ArrayList<ResponseType>(); + requests = new ArrayList<JAXBElement<? extends RequestType>>(); + responses = new ArrayList<JAXBElement<? extends ResponseType>>(); hashDataInputs = new ArrayList<HashDataInput>(); } @@ -85,7 +85,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker { * @pre requests: either single SignRequest, QuitRequest or multiple ReadInfoboxRequests */ @Override - public List<STALResponse> handleRequest(List<STALRequest> stalRequests) { + public List<STALResponse> handleRequest(List<? extends STALRequest> stalRequests) { if (interrupted) { return null; } @@ -95,36 +95,39 @@ public class STALRequestBrokerImpl implements STALRequestBroker { requests.clear(); hashDataInputs.clear(); -// reqMon.produce(requests); -// reqMon.setHashDataInput(null); for (STALRequest stalRequest : stalRequests) { if (stalRequest instanceof SignRequest) { log.trace("Received SignRequest, keep HashDataInput."); - SignRequestType req = new SignRequestType(); - req.setKeyIdentifier(((SignRequest) stalRequest).getKeyIdentifier()); - req.setSignedInfo(((SignRequest) stalRequest).getSignedInfo()); + SignRequestType reqT = stalObjFactory.createSignRequestType(); + reqT.setKeyIdentifier(((SignRequest) stalRequest).getKeyIdentifier()); + reqT.setSignedInfo(((SignRequest) stalRequest).getSignedInfo()); + JAXBElement<SignRequestType> req = stalObjFactory.createGetNextRequestResponseTypeSignRequest(reqT); requests.add(req); //DataObjectHashDataInput with reference caching enabled DataObject hashDataInputs.addAll(((SignRequest) stalRequest).getHashDataInput()); break; } else if (stalRequest instanceof InfoboxReadRequest) { log.trace("Received InfoboxReadRequest"); - InfoboxReadRequestType req = new InfoboxReadRequestType(); - req.setInfoboxIdentifier(((InfoboxReadRequest) stalRequest).getInfoboxIdentifier()); - req.setDomainIdentifier(((InfoboxReadRequest) stalRequest).getDomainIdentifier()); + InfoboxReadRequestType reqT = new InfoboxReadRequestType(); + reqT.setInfoboxIdentifier(((InfoboxReadRequest) stalRequest).getInfoboxIdentifier()); + reqT.setDomainIdentifier(((InfoboxReadRequest) stalRequest).getDomainIdentifier()); + JAXBElement<InfoboxReadRequestType> req = stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(reqT); requests.add(req); } else if (stalRequest instanceof QuitRequest) { log.trace("Received QuitRequest, do not wait for responses."); - requests.add(new QuitRequestType()); + QuitRequestType reqT = stalObjFactory.createQuitRequestType(); + JAXBElement<QuitRequestType> req = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(reqT); + requests.add(req); log.trace("notifying request consumers"); requests.notify(); -// reqMon.notify(); return new ArrayList<STALResponse>(); } else { log.error("Received unsupported STAL request: " + stalRequest.getClass().getName() + ", send QUIT"); requests.clear(); - requests.add(new QuitRequestType()); + QuitRequestType reqT = stalObjFactory.createQuitRequestType(); + JAXBElement<QuitRequestType> req = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(reqT); + requests.add(req); log.trace("notifying request consumers"); requests.notify(); return new ArrayList<STALResponse>(); @@ -132,32 +135,25 @@ public class STALRequestBrokerImpl implements STALRequestBroker { } log.trace("notifying request consumers"); requests.notify(); -// reqMon.notify(); } - synchronized (responses) { //respMon) { + synchronized (responses) { long beforeWait = System.currentTimeMillis(); -// while (respMon.responses == null) { while (responses.isEmpty()) { log.trace("waiting to consume response"); -// respMon.wait(timeout); responses.wait(timeout); if (System.currentTimeMillis() - beforeWait >= timeout) { log.warn("timeout while waiting to consume response, cleanup requests"); -// reqMon.consume(); //TODO check deadlock? -// reqMon.setHashDataInput(null); - requests.clear(); //TODO sync on requests? + requests.clear(); hashDataInputs.clear(); return Collections.singletonList((STALResponse) new ErrorResponse(ERR_4500)); } } log.trace("consuming responses"); -// List<STALResponse> responses = respMon.consume(); List<STALResponse> resps = STALTranslator.toSTAL(responses); responses.clear(); log.trace("notifying response producers"); responses.notify(); -// respMon.notify(); return resps; } @@ -169,7 +165,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker { } @Override - public List<RequestType> connect() { + public List<JAXBElement<? extends RequestType>> connect() { if (interrupted) { return null; } @@ -181,15 +177,9 @@ public class STALRequestBrokerImpl implements STALRequestBroker { requests.wait(timeout); if (System.currentTimeMillis() - beforeWait >= timeout) { log.warn("timeout while waiting to consume request"); - return Collections.singletonList((RequestType) new QuitRequestType()); + return createSingleQuitRequest(); } } - -// log.trace("consume request"); -// List<RequestType> reqs = new ArrayList<RequestType>(); -// reqs.addAll(requests); -// requests.clear(); -// return reqs; log.trace("don't consume request now, leave for further connect calls"); return requests; } @@ -212,7 +202,7 @@ public class STALRequestBrokerImpl implements STALRequestBroker { * @return QUIT if expected responses are not provided */ @Override - public List<RequestType> nextRequest(List<ResponseType> resps) { + public List<JAXBElement<? extends RequestType>> nextRequest(List<JAXBElement<? extends ResponseType>> resps) { if (interrupted) { return null; } @@ -227,69 +217,43 @@ public class STALRequestBrokerImpl implements STALRequestBroker { } } - synchronized (responses) { //respMon) { + synchronized (responses) { if (resps != null && resps.size() > 0) { -// if (!expectingResponse) { -// log.warn("Received unexpected response in nextRequest(), return QUIT"); -// return Collections.singletonList((RequestType) new QuitRequestType()); -// } long beforeWait = System.currentTimeMillis(); -// while (respMon.responses != null) { while (!responses.isEmpty()) { log.trace("waiting to produce response"); -// respMon.wait(timeout); responses.wait(timeout); if (System.currentTimeMillis() - beforeWait >= timeout) { log.warn("timeout while waiting to produce response"); - return Collections.singletonList((RequestType) new QuitRequestType()); + return createSingleQuitRequest(); } } log.trace("produce response"); -// respMon.produce(resps); responses.addAll(resps); //reset HashDataInputCallback iff SignResponse if (log.isTraceEnabled()) { - for (ResponseType response : resps) { - log.trace("Received STAL response: " + response.getClass().getName()); + for (JAXBElement<? extends ResponseType> response : resps) { + log.trace("Received STAL response: " + response.getValue().getClass().getName()); } } log.trace("notifying response consumers"); -// respMon.notify(); responses.notify(); } else { -// if (expectingResponse) { -// log.warn("Did not receive expected response(s) in nextRequest(), return QUIT"); -// return Collections.singletonList((RequestType) new QuitRequestType()); -// } -// log.trace("expecting non-null response in next nextRequest(response)"); -// expectingResponse = true; log.error("Received NextRequest without responses, return QUIT"); - return Collections.singletonList((RequestType) new QuitRequestType()); + return createSingleQuitRequest(); } } - synchronized (requests) { //reqMon) { + synchronized (requests) { long beforeWait = System.currentTimeMillis(); -// while (reqMon.requests == null) { while (requests.isEmpty()) { log.trace("waiting to consume request"); -// reqMon.wait(timeout); requests.wait(timeout); if (System.currentTimeMillis() - beforeWait >= timeout) { log.warn("timeout while waiting to consume request"); - return Collections.singletonList((RequestType) new QuitRequestType()); + return createSingleQuitRequest(); } } -// log.trace("consume request"); -// List<RequestType> reqs = new ArrayList<RequestType>(); // reqMon.consume(); -// reqs.addAll(requests); -// -//// if (requests.size() > 0 && requests.get(0) instanceof QuitRequestType) { -//// log.trace("expecting no response in next nextRequest()"); -//// expectingResponse = false; -//// } -// requests.clear(); -// return reqs; log.trace("don't consume request now, but on next response delivery"); return requests; } @@ -304,92 +268,19 @@ public class STALRequestBrokerImpl implements STALRequestBroker { public List<HashDataInput> getHashDataInput() { synchronized (requests) { log.trace("return " + hashDataInputs.size() + " current HashDataInput(s) "); - return hashDataInputs; //reqMon.getHashDataInput(); + return hashDataInputs; } } @Override public void setLocale(Locale locale) { } - -// class RequestsMonitor { -// List<STALRequest> requests; -// List<HashDataInput> hashDataInput; -// -// void produce(List<STALRequest> req) { -// requests = req; -// } -// -// synchronized List<at.gv.egiz.stal.service.types.STALRequest> consume() { -// List<at.gv.egiz.stal.service.types.STALRequest> reqs = new ArrayList<at.gv.egiz.stal.service.types.STALRequest>(); -// for (STALRequest request : requests) { -// if (request instanceof SignRequest) { -// at.gv.egiz.stal.service.types.SignRequest r = new at.gv.egiz.stal.service.types.SignRequest(); -// r.setKeyIdentifier(((SignRequest) request).getKeyIdentifier()); -// r.setSignedInfo(((SignRequest) request).getSignedInfo()); -// reqs.add(r); -// } else if (request instanceof InfoboxReadRequest) { -// at.gv.egiz.stal.service.types.InfoboxReadRequest r = new at.gv.egiz.stal.service.types.InfoboxReadRequest(); -// r.setDomainIdentifier(((InfoboxReadRequest) request).getDomainIdentifier()); -// r.setInfoboxIdentifier(((InfoboxReadRequest) request).getInfoboxIdentifier()); -// reqs.add(r); -// } else if (request instanceof QuitRequest) { -// at.gv.egiz.stal.service.types.QuitRequest r = new at.gv.egiz.stal.service.types.QuitRequest(); -// reqs.add(r); -// } else { -// log.error("unknown STAL request type: " + request.getClass()); -// requests = null; -// return Collections.singletonList((at.gv.egiz.stal.service.types.STALRequest) new at.gv.egiz.stal.service.types.QuitRequest()); -// } -// } -// requests = null; -// return reqs; -// } -// -// void setHashDataInput(List<HashDataInput> hdi) { -// hashDataInput = hdi; -// } -// -// List<HashDataInput> getHashDataInput() { -// return hashDataInput; -// } -// } -// -// /** TODO: now, that responses are not nulled, synchronize directly on responses? */ -// class ResponsesMonitor { -// List<at.gv.egiz.stal.service.types.STALResponse> responses; -// -// void produce(List<at.gv.egiz.stal.service.types.STALResponse> resp) { -// responses = resp; -// } -// -// synchronized List<STALResponse> consume() { -// List<STALResponse> resps = new ArrayList<STALResponse>(); -// -// for (at.gv.egiz.stal.service.types.STALResponse response : responses) { -// if (response instanceof at.gv.egiz.stal.service.types.InfoboxReadResponse) { -// InfoboxReadResponse r = new InfoboxReadResponse(); -// r.setInfoboxValue(((at.gv.egiz.stal.service.types.InfoboxReadResponse) response).getInfoboxValue()); -// resps.add(r); -// } else if (response instanceof at.gv.egiz.stal.service.types.SignResponse) { -// SignResponse r = new SignResponse(); -// r.setSignatureValue(((at.gv.egiz.stal.service.types.SignResponse) response).getSignatureValue()); -// resps.add(r); -// } else if (response instanceof at.gv.egiz.stal.service.types.ErrorResponse) { -// ErrorResponse r = new ErrorResponse(); -// r.setErrorCode(((at.gv.egiz.stal.service.types.ErrorResponse) response).getErrorCode()); -// r.setErrorMessage(((at.gv.egiz.stal.service.types.ErrorResponse) response).getErrorMessage()); -// resps.add(r); -// } else { -// log.error("unknown STAL response type: " + response.getClass()); -// ErrorResponse r = new ErrorResponse(4000); -// r.setErrorMessage("unknown STAL response type: " + response.getClass()); -// responses = null; -// return Collections.singletonList((STALResponse) r); -// } -// } -// responses = null; -// return resps; -// } -// } + + private List<JAXBElement<? extends RequestType>> createSingleQuitRequest() { + QuitRequestType quitT = stalObjFactory.createQuitRequestType(); + JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT); + ArrayList<JAXBElement<? extends RequestType>> l = new ArrayList<JAXBElement<? extends RequestType>>(); + l.add(quit); + return l; + } } diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java index 05a3f5e5..45629869 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALServiceImpl.java @@ -14,9 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package at.gv.egiz.stal.service.impl; +//import at.buergerkarte.namespaces.cardchannel.service.CommandAPDUType; +//import at.buergerkarte.namespaces.cardchannel.service.ScriptType; import at.gv.egiz.bku.binding.BindingProcessor; import at.gv.egiz.bku.binding.BindingProcessorManager; import at.gv.egiz.bku.binding.Id; @@ -36,6 +37,7 @@ import at.gv.egiz.stal.service.types.QuitRequestType; import at.gv.egiz.stal.service.types.RequestType; import at.gv.egiz.stal.service.types.ResponseType; import at.gv.egiz.stal.service.types.SignRequestType; +import com.sun.xml.ws.developer.UsesJAXBContext; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -46,6 +48,7 @@ import java.util.Map; import javax.annotation.Resource; import javax.jws.WebService; import javax.servlet.ServletContext; +import javax.xml.bind.JAXBElement; import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.MessageContext; import org.apache.commons.logging.Log; @@ -56,46 +59,45 @@ import org.apache.commons.logging.LogFactory; * @author clemens */ @WebService(endpointInterface = "at.gv.egiz.stal.service.STALPortType") +@UsesJAXBContext(STALXJAXBContextFactory.class) public class STALServiceImpl implements STALPortType { public static final String BINDING_PROCESSOR_MANAGER = "bindingProcessorManager"; public static final Id TEST_SESSION_ID = IdFactory.getInstance().createId("TestSession"); - protected static final Log log = LogFactory.getLog(STALServiceImpl.class); - + + static { - if (log.isTraceEnabled()) { log.trace("enabling webservice communication dump"); System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true"); } else { System.setProperty("com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace", "false"); } - } - @Resource - WebServiceContext wsContext; + protected WebServiceContext wsContext; protected IdFactory idF = IdFactory.getInstance(); + private at.gv.egiz.stal.service.types.ObjectFactory stalObjFactory = new at.gv.egiz.stal.service.types.ObjectFactory(); +// private at.buergerkarte.namespaces.cardchannel.service.ObjectFactory ccObjFactory = new at.buergerkarte.namespaces.cardchannel.service.ObjectFactory(); - @Override public GetNextRequestResponseType connect(String sessId) { - + if (sessId == null) { throw new NullPointerException("No session id provided"); } - + Id sessionId = idF.createId(sessId); if (log.isDebugEnabled()) { log.debug("Received Connect [" + sessionId + "]"); } - + if (TEST_SESSION_ID.equals(sessionId)) { return getTestSessionNextRequestResponse(null); } - + GetNextRequestResponseType response = new GetNextRequestResponseType(); response.setSessionId(sessionId.toString()); @@ -103,7 +105,7 @@ public class STALServiceImpl implements STALPortType { if (stal != null) { - List<RequestType> requestsOut = ((STALRequestBroker) stal).connect(); + List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).connect(); response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut); if (log.isDebugEnabled()) { @@ -112,29 +114,32 @@ public class STALServiceImpl implements STALPortType { sb.append("] containing "); sb.append(requestsOut.size()); sb.append(" requests: "); - for (RequestType reqOut : requestsOut) { - sb.append(reqOut.getClass()); + for (JAXBElement<? extends RequestType> reqOut : requestsOut) { + sb.append(reqOut.getValue().getClass()); sb.append(' '); } log.debug(sb.toString()); } } else { log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest"); - response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType()); + QuitRequestType quitT = stalObjFactory.createQuitRequestType(); + JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit); } return response; } - + @Override public GetNextRequestResponseType getNextRequest(GetNextRequestType request) { if (request.getSessionId() == null) { throw new NullPointerException("No session id provided"); } - + Id sessionId = idF.createId(request.getSessionId()); - List<ResponseType> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();//getResponse(); + List<JAXBElement<? extends ResponseType>> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse(); +// List<ResponseType> responsesIn = request.getInfoboxReadResponseOrSignResponseOrErrorResponse();//getResponse(); if (log.isDebugEnabled()) { StringBuilder sb = new StringBuilder("Received GetNextRequest ["); @@ -142,25 +147,25 @@ public class STALServiceImpl implements STALPortType { sb.append("] containing "); sb.append(responsesIn.size()); sb.append(" responses: "); - for (ResponseType respIn : responsesIn) { + for (Object respIn : responsesIn) { sb.append(respIn.getClass()); sb.append(' '); } log.debug(sb.toString()); } - + if (TEST_SESSION_ID.equals(sessionId)) { return getTestSessionNextRequestResponse(responsesIn); } GetNextRequestResponseType response = new GetNextRequestResponseType(); response.setSessionId(sessionId.toString()); - + STALRequestBroker stal = getStal(sessionId); if (stal != null) { - List<RequestType> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn); + List<JAXBElement<? extends RequestType>> requestsOut = ((STALRequestBroker) stal).nextRequest(responsesIn); response.getInfoboxReadRequestOrSignRequestOrQuitRequest().addAll(requestsOut); if (log.isDebugEnabled()) { @@ -169,15 +174,17 @@ public class STALServiceImpl implements STALPortType { sb.append("] containing "); sb.append(requestsOut.size()); sb.append(" requests: "); - for (RequestType reqOut : requestsOut) { - sb.append(reqOut.getClass()); + for (JAXBElement<? extends RequestType> reqOut : requestsOut) { + sb.append(reqOut.getValue().getClass()); sb.append(' '); } log.debug(sb.toString()); } } else { log.error("Failed to get STAL for session " + sessionId + ", returning QuitRequest"); - response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType()); + QuitRequestType quitT = stalObjFactory.createQuitRequestType(); + JAXBElement<QuitRequestType> quit = stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT); + response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(quit); } return response; } @@ -188,7 +195,7 @@ public class STALServiceImpl implements STALPortType { if (request.getSessionId() == null) { throw new NullPointerException("No session id provided"); } - + Id sessionId = idF.createId(request.getSessionId()); if (log.isDebugEnabled()) { @@ -197,13 +204,13 @@ public class STALServiceImpl implements STALPortType { GetHashDataInputResponseType response = new GetHashDataInputResponseType(); response.setSessionId(sessionId.toString()); - + if (TEST_SESSION_ID.equals(sessionId)) { log.debug("Received GetHashDataInput for session " + TEST_SESSION_ID + ", return DummyHashDataInput"); GetHashDataInputResponseType.Reference ref = new GetHashDataInputResponseType.Reference(); ref.setID("signed-data-reference-0-1214921968-27971781-24309"); //Reference-" + TEST_SESSION_ID + "-001"); ref.setMimeType("text/plain"); - + Charset charset; try { charset = Charset.forName("iso-8859-15"); @@ -316,30 +323,52 @@ public class STALServiceImpl implements STALPortType { return (bp == null) ? null : (bp.isFinished() ? null : (STALRequestBroker) bp.getSTAL()); } - private GetNextRequestResponseType getTestSessionNextRequestResponse(List<ResponseType> responsesIn) { + private GetNextRequestResponseType getTestSessionNextRequestResponse(List<JAXBElement<? extends ResponseType>> responsesIn) { GetNextRequestResponseType response = new GetNextRequestResponseType(); response.setSessionId(TEST_SESSION_ID.toString()); - - if (responsesIn != null && responsesIn.size() > 0 && responsesIn.get(0) instanceof ErrorResponseType) { - log.info("Received TestSession GetNextRequest(ErrorResponse), returning QuitRequest"); - response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(new QuitRequestType()); + + List<JAXBElement<? extends RequestType>> reqs = response.getInfoboxReadRequestOrSignRequestOrQuitRequest(); + + if (responsesIn == null) { + log.info("[TestSession] received CONNECT, return dummy requests "); +// ScriptType scriptT = ccObjFactory.createScriptType(); +// CommandAPDUType cmd = ccObjFactory.createCommandAPDUType(); +// cmd.setValue("TestSession CardChannelCMD 1234".getBytes()); +// scriptT.getResetOrCommandAPDUOrVerifyAPDU().add(cmd); +// reqs.add(ccObjFactory.createScript(scriptT)); + addDummyRequests(reqs); + } else if (responsesIn != null && responsesIn.size() > 0 && responsesIn.get(0).getValue() instanceof ErrorResponseType) { + log.info("[TestSession] received ErrorResponse, return QUIT request"); + QuitRequestType quitT = stalObjFactory.createQuitRequestType(); + reqs.add(stalObjFactory.createGetNextRequestResponseTypeQuitRequest(quitT)); } else { - log.info("Received TestSession GetNextRequest, returning SignRequest and 3 InfoboxReadRequests "); - InfoboxReadRequestType req = new InfoboxReadRequestType(); - req.setInfoboxIdentifier("IdentityLink"); - req.setDomainIdentifier("hansiwurzel"); - response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req); - SignRequestType sig = new SignRequestType(); - sig.setKeyIdentifier("SecureSignatureKeypair"); - sig.setSignedInfo("<dsig:SignedInfo xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\"><dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /> <dsig:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1\" /> <dsig:Reference Id=\"signed-data-reference-0-1214921968-27971781-24309\" URI=\"#signed-data-object-0-1214921968-27971781-13578\"><dsig:Transforms> <dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\"> <xpf:XPath xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">id('signed-data-object-0-1214921968-27971781-13578')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /> <dsig:DigestValue>H1IePEEfGQ2SG03H6LTzw1TpCuM=</dsig:DigestValue></dsig:Reference><dsig:Reference Id=\"etsi-data-reference-0-1214921968-27971781-25439\" Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921968-27971781-3095')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)\"><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><dsig:DigestValue>yV6Q+I60buqR4mMaxA7fi+CV35A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>".getBytes()); - response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(sig); - req = new InfoboxReadRequestType(); - req.setInfoboxIdentifier("CertifiedKeypair"); - response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req); - req = new InfoboxReadRequestType(); - req.setInfoboxIdentifier("SecureSignatureKeypair"); - response.getInfoboxReadRequestOrSignRequestOrQuitRequest().add(req); + log.info("[TestSession] received " + responsesIn.size() + " response(s), return dummy requests" ); + addDummyRequests(reqs); } return response; } + + private void addDummyRequests(List<JAXBElement<? extends RequestType>> reqs) { +// log.info("[TestSession] add READ request for Infobox IdentityLink"); +// InfoboxReadRequestType ibrT1 = stalObjFactory.createInfoboxReadRequestType(); +// ibrT1.setInfoboxIdentifier("IdentityLink"); +// reqs.add(stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(ibrT1)); + + log.info("[TestSession] add READ request for Infobox CertifiedKeypair"); + InfoboxReadRequestType ibrT2 = stalObjFactory.createInfoboxReadRequestType(); + ibrT2.setInfoboxIdentifier("CertifiedKeypair"); + reqs.add(stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(ibrT2)); + + log.info("[TestSession] add READ request for Infobox SecureSignatureKeypair"); + InfoboxReadRequestType ibrT3 = stalObjFactory.createInfoboxReadRequestType(); + ibrT3.setInfoboxIdentifier("SecureSignatureKeypair"); + reqs.add(stalObjFactory.createGetNextRequestResponseTypeInfoboxReadRequest(ibrT3)); + + log.info("[TestSession] add SIGN request"); + SignRequestType sigT1 = stalObjFactory.createSignRequestType(); + sigT1.setKeyIdentifier("SecureSignatureKeypair"); + sigT1.setSignedInfo("<dsig:SignedInfo xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\"><dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /> <dsig:SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1\" /> <dsig:Reference Id=\"signed-data-reference-0-1214921968-27971781-24309\" URI=\"#signed-data-object-0-1214921968-27971781-13578\"><dsig:Transforms> <dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\"> <xpf:XPath xmlns:xpf=\"http://www.w3.org/2002/06/xmldsig-filter2\" Filter=\"intersect\">id('signed-data-object-0-1214921968-27971781-13578')/node()</xpf:XPath></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /> <dsig:DigestValue>H1IePEEfGQ2SG03H6LTzw1TpCuM=</dsig:DigestValue></dsig:Reference><dsig:Reference Id=\"etsi-data-reference-0-1214921968-27971781-25439\" Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921968-27971781-3095')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)\"><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><dsig:DigestValue>yV6Q+I60buqR4mMaxA7fi+CV35A=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo>".getBytes()); + reqs.add(stalObjFactory.createGetNextRequestResponseTypeSignRequest(sigT1)); + } + } diff --git a/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java new file mode 100644 index 00000000..92559254 --- /dev/null +++ b/BKUOnline/src/main/java/at/gv/egiz/stal/service/impl/STALXJAXBContextFactory.java @@ -0,0 +1,61 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package at.gv.egiz.stal.service.impl; + +import com.sun.xml.bind.api.JAXBRIContext; +import com.sun.xml.bind.api.TypeReference; +import com.sun.xml.ws.api.model.SEIModel; +import com.sun.xml.ws.developer.JAXBContextFactory; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.JAXBException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> + */ +public class STALXJAXBContextFactory implements JAXBContextFactory { + + private static final Log log = LogFactory.getLog(STALXJAXBContextFactory.class); + + @Override + public JAXBRIContext createJAXBContext(SEIModel sei, List<Class> classesToBind, List<TypeReference> typeReferences) throws JAXBException { + if (log.isTraceEnabled()) { + log.trace("JAXBContext seed for SEI " + sei.getTargetNamespace() + ":"); + for (Class class1 : classesToBind) { + log.trace(" " + class1); + } + for (TypeReference typeReference : typeReferences) { + log.trace(" typeRef " + typeReference.tagName + " -> " + typeReference.type); + } + } + List<Class> classes = new ArrayList<Class>(); + classes.addAll(classesToBind); +// Class ccOF = at.buergerkarte.namespaces.cardchannel.service.ObjectFactory.class; +// if (!classes.contains(ccOF)) { +// log.debug("adding " + ccOF + " to JAXBContext seed"); +// classes.add(ccOF); +// } + + //TODO add typeReference? + + return JAXBRIContext.newInstance(classes.toArray(new Class[classes.size()]), + typeReferences, null, sei.getTargetNamespace(), false, null); + } +} diff --git a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml index 4069cdc9..321e1e98 100644 --- a/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml +++ b/BKUOnline/src/main/webapp/WEB-INF/applicationContext.xml @@ -18,15 +18,50 @@ <bean id="STALFactory" class="at.gv.egiz.stal.service.impl.RequestBrokerSTALFactory"
scope="singleton" />
- <bean id="accessController" class="at.gv.egiz.bku.online.accesscontroller.SpringSecurityManager"
+ <bean id="accessController"
+ class="at.gv.egiz.bku.online.accesscontroller.SpringSecurityManager"
scope="singleton" init-method="init">
- <property name="config" ref="configurator"/>
- </bean>
+ <property name="config" ref="configurator" />
+ </bean>
<bean id="commandInvoker" class="at.gv.egiz.bku.binding.SLCommandInvokerImpl">
<property name="securityManager" ref="accessController" />
</bean>
+ <bean id="slCommandFactory" class="at.gv.egiz.bku.slcommands.SLCommandFactory"
+ factory-method="getInstance">
+ <property name="commandImpl">
+ <map>
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:NullOperationRequest"
+ value="at.gv.egiz.bku.slcommands.impl.NullOperationCommandImpl" />
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:InfoboxReadRequest"
+ value="at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl" />
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:CreateXMLSignatureRequest"
+ value="at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl" />
+ </map>
+ </property>
+ </bean>
+
+ <bean id="infoboxFactory" class="at.gv.egiz.bku.slcommands.impl.InfoboxFactory"
+ factory-method="getInstance">
+ <property name="infoboxImpl">
+ <map>
+ <entry
+ key="Certificates"
+ value="at.gv.egiz.bku.slcommands.impl.CertificatesInfoboxImpl" />
+ <entry
+ key="IdentityLink"
+ value="at.gv.egiz.bku.slcommands.impl.IdentityLinkInfoboxImpl" />
+<!-- <entry-->
+<!-- key="CardChannel"-->
+<!-- value="at.gv.egiz.bku.slcommands.impl.CardChannelInfoboxImpl" />-->
+ </map>
+ </property>
+ </bean>
+
<bean id="bindingProcessorManager" class="at.gv.egiz.bku.binding.BindingProcessorManagerImpl"
scope="singleton">
<constructor-arg ref="STALFactory"></constructor-arg>
@@ -46,16 +81,17 @@ <!-- Configure Configuration -->
<bean id="certValidator" class="at.gv.egiz.bku.conf.CertValidatorImpl"></bean>
-
-
+
+
<bean id="configurator" class="at.gv.egiz.bku.online.conf.SpringConfigurator"
- init-method="configure" scope="singleton">
- <property name="resource" value="classpath:at/gv/egiz/bku/online/conf/defaultConf.properties"/>
+ init-method="configure" scope="singleton">
+ <property name="resource"
+ value="classpath:at/gv/egiz/bku/online/conf/defaultConf.properties" />
<property name="certValidator" ref="certValidator"></property>
</bean>
-
+
<!-- Shutdown Event handler -->
- <bean id="shutdown" class="at.gv.egiz.bku.online.webapp.ShutdownHandler">
- <property name="bindingProcessorManager" ref="bindingProcessorManager"></property>
- </bean>
+ <bean id="shutdown" class="at.gv.egiz.bku.online.webapp.ShutdownHandler">
+ <property name="bindingProcessorManager" ref="bindingProcessorManager"></property>
+ </bean>
</beans>
\ No newline at end of file diff --git a/BKUOnline/src/main/webapp/WEB-INF/web.xml b/BKUOnline/src/main/webapp/WEB-INF/web.xml index f6fdbefc..cc37b782 100644 --- a/BKUOnline/src/main/webapp/WEB-INF/web.xml +++ b/BKUOnline/src/main/webapp/WEB-INF/web.xml @@ -48,10 +48,10 @@ <param-value>expired.html</param-value> </init-param> </servlet> - <servlet> - <servlet-name>HashDataInputServlet</servlet-name> - <servlet-class>at.gv.egiz.bku.online.webapp.HashDataInputServlet</servlet-class> - </servlet> + <servlet> + <servlet-name>BKUApplet</servlet-name> + <jsp-file>/applet.jsp</jsp-file> + </servlet> <servlet> <servlet-name>help</servlet-name> <jsp-file>/help.jsp</jsp-file> @@ -68,10 +68,6 @@ <servlet-name>ResultServlet</servlet-name> <url-pattern>/bkuResult</url-pattern> </servlet-mapping> - <servlet-mapping> - <servlet-name>HashDataInputServlet</servlet-name> - <url-pattern>/hashDataInput</url-pattern> - </servlet-mapping> <servlet-mapping> <servlet-name>help</servlet-name> <url-pattern>/help/*</url-pattern> diff --git a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl index 344e5ce2..9ef43f39 100644 --- a/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl +++ b/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal.wsdl @@ -18,29 +18,37 @@ <definitions name="stal" targetNamespace="http://www.egiz.gv.at/wsdl/stal" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.egiz.gv.at/wsdl/stal" xmlns:ns="http://www.egiz.gv.at/stal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://www.egiz.gv.at/wsdl/stal" + xmlns:stal="http://www.egiz.gv.at/stal" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <types> <xsd:schema targetNamespace="http://www.egiz.gv.at/wsdl/stal"> - <xsd:import namespace="http://www.egiz.gv.at/stal" schemaLocation="stal.xsd"/> + <xsd:import namespace="http://www.egiz.gv.at/stal" schemaLocation="stal-service.xsd"/> + <!--xsd:import namespace="http://www.egiz.gv.at/stal" schemaLocation="stal-extended.xsd"/--> </xsd:schema> + <!-- test + <xsd:schema targetNamespace="http://www.egiz.gv.at/wsdl/stal-extended"> + <xsd:import namespace="http://www.buergerkarte.at/cardchannel" schemaLocation="CardChannel.xsd"/> + </xsd:schema--> </types> <message name="ConnectRequest"> - <part name="part1" element="ns:SessionId"/> + <part name="part1" element="stal:SessionId"/> </message> <message name="NextRequestRequest"> - <part name="part1" element="ns:GetNextRequest"/> + <part name="part1" element="stal:GetNextRequest"/> </message> <message name="NextRequestResponse"> - <part name="part1" element="ns:GetNextRequestResponse"/> + <part name="part1" element="stal:GetNextRequestResponse"/> </message> <message name="GetHashDataInputRequest"> - <part name="part1" element="ns:GetHashDataInput"/> + <part name="part1" element="stal:GetHashDataInput"/> </message> <message name="GetHashDataInputResponse"> - <part name="part1" element="ns:GetHashDataInputResponse"/> + <part name="part1" element="stal:GetHashDataInputResponse"/> </message> <message name="GetHashDataInputFault"> - <part name="part1" element="ns:GetHashDataInputFault"/> + <part name="part1" element="stal:GetHashDataInputFault"/> </message> <portType name="STALPortType"> <operation name="connect"> diff --git a/BKUOnline/src/main/webapp/applet.jsp b/BKUOnline/src/main/webapp/applet.jsp new file mode 100644 index 00000000..44d9347c --- /dev/null +++ b/BKUOnline/src/main/webapp/applet.jsp @@ -0,0 +1,70 @@ +<!-- + Copyright 2008 Federal Chancellery Austria and + Graz University of Technology + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>MOCCA Applet</title> + <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"> + <script type="text/javascript" src="js/deployJava.js"></script> + <style type="text/css" media="all">@import "css/login.css";</style> + + <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> + <META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT"> + <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> + </head> + <% + int width = session.getAttribute("appletWidth") == null ? 190 + : (Integer) session.getAttribute("appletWidth"); //230 for workshop demo integration + int height = session.getAttribute("appletHeight") == null ? 130 + : (Integer) session.getAttribute("appletHeight"); + String backgroundImg = (String) session.getAttribute("appletBackground"); + String guiStyle = (String) session.getAttribute("appletGuiStyle"); + String locale = (String) session.getAttribute("locale"); + %> + <body id="appletpage" style="width:<%=width%>"> + <script> + if (!deployJava.versionCheck('1.6.0_04+')) { + document + .write('<b>Diese Anwendung benötigt die Java Platform Version 1.6.0_04 oder höher.</b>' + '<input type="submit" value="Java Platform 1.6.0_02 installieren" onclick="deployJava.installLatestJRE();">'); + } else { + var attributes = { + codebase :'applet', + code :'at.gv.egiz.bku.online.applet.BKUApplet.class', + archive :'BKUApplet.jar, commons-logging-1.1.1.jar, iaik_jce_me4se-3.04.jar', + width : <%=width%>, + height :<%=height%> + }; + var parameters = { + GuiStyle : '<%=guiStyle%>', + Locale : '<%=locale%>', + Background : '<%=backgroundImg%>', + WSDL_URL :'../stal;jsessionid=<%=session.getId()%>?wsdl', + HelpURL : '../help/', + SessionID : '<%=session.getId()%>', + RedirectURL : '../bkuResult', + RedirectTarget: '_parent' + }; + var version = '1.6.0_04'; + deployJava.runApplet(attributes, parameters, version); + } + </script> + </body> +</html> diff --git a/BKUOnline/src/main/webapp/appletPage.jsp b/BKUOnline/src/main/webapp/appletPage.jsp deleted file mode 100644 index b2fcf4a4..00000000 --- a/BKUOnline/src/main/webapp/appletPage.jsp +++ /dev/null @@ -1,71 +0,0 @@ -<!-- - Copyright 2008 Federal Chancellery Austria and - Graz University of Technology - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<title>MOCCA Applet</title> -<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"> -<script type="text/javascript" src="js/deployJava.js"></script> -<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> -<META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT"> -<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> -</head> -<body> -<% - int width = session.getAttribute("appletWidth") == null ? 190 - : (Integer) session.getAttribute("appletWidth"); - int height = session.getAttribute("appletHeight") == null ? 130 - : (Integer) session.getAttribute("appletHeight"); - String backgroundImg = (String) session.getAttribute("appletBackground"); - String guiStyle = (String) session.getAttribute("appletGuiStyle"); - String hashDataDisplay = (String) session.getAttribute("appletHashDataDisplay"); -%> -<script> - if (!deployJava.versionCheck('1.6.0_04+')) { - document - .write('<b>Diese Anwendung benötigt die Java Platform Version 1.6.0_04 oder höher.</b>' + '<input type="submit" value="Java Platform 1.6.0_02 installieren" onclick="deployJava.installLatestJRE();">'); - } else { - var attributes = { - codebase :'applet', - code :'at.gv.egiz.bku.online.applet.BKUApplet.class', - archive :'BKUApplet-1.0.2, commons-logging-1.1.1.jar, iaik_jce_me4se-3.04.jar', - width : <%=width%>, - height :<%=height%> - }; - var parameters = { - GuiStyle : '<%=guiStyle%>', - Background : '<%=backgroundImg%>', - WSDL_URL :'../stal?wsdl', - HelpURL : '../help/', - HashDataDisplay : '<%=hashDataDisplay%>', - HashDataURL : '../hashDataInput', - SessionID : '<%=session.getId()%>', - RedirectURL : '../bkuResult', - RedirectTarget: '_parent' - }; - var version = '1.6.0_04'; - deployJava.runApplet(attributes, parameters, version); - } -</script> -<!--br /> -<hr/> -Powered by <img src="img/mocca-t_s.png" alt="mocca-logo" width="100"--> -</body> -</html> diff --git a/BKUOnline/src/main/webapp/css/login.css b/BKUOnline/src/main/webapp/css/login.css new file mode 100644 index 00000000..4bfbd77d --- /dev/null +++ b/BKUOnline/src/main/webapp/css/login.css @@ -0,0 +1,16 @@ + +root { + display: block; +} + +body { + background: #ffffff; + /*background-image: url(../img/mocca-t_s.png);*/ + padding: 0; + margin: 0; + border-style: none; + /* + width:<%=width%> + */ +} + diff --git a/BKUOnline/src/main/webapp/help.jsp b/BKUOnline/src/main/webapp/help.jsp index 72781e38..d7dbf0ef 100644 --- a/BKUOnline/src/main/webapp/help.jsp +++ b/BKUOnline/src/main/webapp/help.jsp @@ -16,14 +16,20 @@ --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> -<%@ page import="java.util.Locale"%> +<%@ page import="java.io.File"%> <% - String pathInfo[] = (request.getPathInfo() != null) ? request + String pathInfo[] = (request.getPathInfo() != null) ? request .getPathInfo().split("/") : new String[] {}; - String language = pathInfo[1].split("_")[0]; - String filename = pathInfo[2]; - String path = "/helpfiles/" + language.toLowerCase() + "/" + filename; - System.out.println(path); + String language = pathInfo[1].split("_")[0]; + String filename = pathInfo[2]; + String helpDir = "/helpfiles"; + String path; + if ((new File(helpDir + "/" + language.toLowerCase())).isDirectory()) { + path = helpDir + "/" + language.toLowerCase() + "/" + filename; + } else { + path = helpDir + "/de/" + filename; + } + System.out.println(path); %> <jsp:include page="<%=path%>" flush="true"/> diff --git a/BKUOnline/src/main/webapp/helpfiles/de/error.pcsc.html b/BKUOnline/src/main/webapp/helpfiles/de/error.pcsc.html index 209ae6fa..d38e77ca 100644 --- a/BKUOnline/src/main/webapp/helpfiles/de/error.pcsc.html +++ b/BKUOnline/src/main/webapp/helpfiles/de/error.pcsc.html @@ -26,8 +26,18 @@ <!-- end #sidebar1 --></div> <div id="mainContent"> <h1> Fehler: Es konnte keine PC/SC-Schnittstelle gefunden werden</h1> - <p>Die Software für den Zugriff auf die Bürgerkarte konnte keine PC/SC-Schnittstelle für den Zugriff auf Kartenleser erkennen. Das Betriebssystem scheint keine PC/SC-Schnittstelle zur Verfügung zu stellen.</p> - <p>Unter Betriebssystemen die PCSC-Lite verwenden (Linux u.a.) tritt dieses Problem auch auf, wenn kein Kartenleser angeschlossen ist und daher der entsprechende Dienst nicht gestartet wurde oder wenn die entsprechende Bibliothek nicht zur Verfügung steht (<a href="http://java.sun.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunPCSCProvider">weitere Informationen</a>).<br class="clearfloat" /> + <p>Die Software für den Zugriff auf die Bürgerkarte konnte keine PC/SC-Schnittstelle für den Zugriff auf Kartenleser erkennen. + Das Betriebssystem scheint keine PC/SC-Schnittstelle zur Verfügung zu stellen.</p> + <p>Häufige Ursachen für dieses Problem sind + <ul> + <li>Der PC/SC Dienst läuft nicht</li> + <li>Die entsprechende PC/SC Bibliothek kann von Java nicht gefunden werden + (<a href="http://java.sun.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunPCSCProvider">weitere Informationen</a>).</li> + </ul> + </p> + <p>Unter Betriebssystemen die PCSC-Lite verwenden (Linux u.a.) tritt dieses Problem auch auf, + wenn kein Kartenleser angeschlossen ist und daher der entsprechende Dienst nicht gestartet wurde. + <br class="clearfloat" /> </p> <p><br class="clearfloat" /></p> </div> diff --git a/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html b/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html index f7cf15df..eb1a35d6 100644 --- a/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html +++ b/BKUOnline/src/main/webapp/helpfiles/de/help.hashdataviewer.html @@ -28,6 +28,7 @@ <h1> Anzeige der Signaturdaten </h1>
<p>Dieses Fenster zeigt die zu signierenden Daten an. Dies können entweder reine Textdaten oder XHTML sein. Im Falle von XHML erhalten Sie den Hinweis, dass es sich bei den dargestellten Daten nur um eine Voransicht handelt. Um die Daten standardkonform darzustellen, müssen diese abgespeichert und mit einem geeigneten XHTML Betrachter geöffnen werden.</p>
<p>In jedem Fall können die zu signierenden abgespeichert werden.</p>
+ <p><br class="clearfloat" /></p>
</div>
<div id="footer">
<p>
diff --git a/BKUOnline/src/main/webapp/ieView.html b/BKUOnline/src/main/webapp/ieView.html deleted file mode 100644 index 71f76eec..00000000 --- a/BKUOnline/src/main/webapp/ieView.html +++ /dev/null @@ -1,31 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>Anzeige</title>
-<style type="text/css">
-body {
- font-size: 15px;
- font-weight: 500;
- font-family: Helvetica, Arial, sans-serif;
- background-color: DarkOrange;
- padding:1em 2em 0em 2em;
-}
-
-h1 {
- font-size: 20px;
-}
-</style>
-</head>
-<body>
-<h1>Achtung: Ihr Browser unterstützt dieses Anzeigeformat (XHTML) nicht.</h1> Die unten
-dargestellten Daten können von den tatsächlichen Signaturdaten abweichen.
-<a href="hashDataInput?ieCType=application%2Fxhtml%2Bxml">Hier</a>
-können Sie die Signaturdaten herunterladen.
-<br>
-<div style="height:700px; margin: 2em 0em 1em 0em">
-<iframe src="hashDataInput?ieCType=text/html" width="100%" height="100%" marginwidth="0"
-marginheight="0" frameborder="1" scrolling="auto">Ihr Browser unterstütz leider keine Iframes</iframe>
-</div>
-</body>
-</html>
\ No newline at end of file diff --git a/BKUOnline/src/main/webapp/img/BackgroundEcard.png b/BKUOnline/src/main/webapp/img/BackgroundEcard.png Binary files differnew file mode 100644 index 00000000..11ba891e --- /dev/null +++ b/BKUOnline/src/main/webapp/img/BackgroundEcard.png diff --git a/BKUOnline/src/main/webapp/index.html b/BKUOnline/src/main/webapp/index.html index 8f1a338e..94e2890f 100644 --- a/BKUOnline/src/main/webapp/index.html +++ b/BKUOnline/src/main/webapp/index.html @@ -48,7 +48,7 @@ <div id="animDiv" class="box"> <p> <h1>TestRequest</h1> -<a href="HTTP-ohne.html">Security Layer Request</a> +<a href="slRequestForm.html">Security Layer Request</a> <h1>STAL Service</h1> <a href="stal">STAL Service Endpoint Information</a> </p> diff --git a/BKUOnline/src/main/webapp/js/deployJava.js b/BKUOnline/src/main/webapp/js/deployJava.js index 4d8a0ca3..5466cbdd 100644 --- a/BKUOnline/src/main/webapp/js/deployJava.js +++ b/BKUOnline/src/main/webapp/js/deployJava.js @@ -40,7 +40,7 @@ * http://java.com/js/deployJava.js. * You are encouraged to link directly to the live copy of the file. * - * @version @(#)deployJava.js 1.11 08/07/11 + * @version @(#)deployJava.js 1.13 08/10/28 */ var deployJava = { @@ -88,7 +88,7 @@ var deployJava = { } } else { var browser = deployJava.getBrowser(); - + if (browser == 'MSIE') { if (deployJava.testUsingActiveX('1.8.0')) { list[0] = '1.8.0'; @@ -319,11 +319,18 @@ var deployJava = { document.write(s); if (parameters != 'undefined' && parameters != null) { + var codebaseParam = false; for (var parameter in parameters) { + if (parameter == 'codebase_lookup') { + codebaseParam = true; + } s = '<param name="' + parameter + '" value="' + parameters[parameter] + '">'; document.write(s); } + if (!codebaseParam) { + document.write('<param name="codebase_lookup" value="false">'); + } } document.write('<' + '/' + 'applet' + '>'); }, @@ -630,6 +637,10 @@ var deployJava = { alert('We claim to have detected "IE".'); } return 'MSIE'; +// } else if ((browser.indexOf('konqueror') != -1)) { +// if (deployJava.debug) { +// alert('We claim to have detected "Konqueror".'); +// } } else if ((browser.indexOf('mozilla') != -1) || (browser.indexOf('firefox') != -1)) { if (deployJava.debug) { diff --git a/BKUOnline/src/main/webapp/multiHashDataInput.html b/BKUOnline/src/main/webapp/multiHashDataInput.html deleted file mode 100644 index bb03f8ce..00000000 --- a/BKUOnline/src/main/webapp/multiHashDataInput.html +++ /dev/null @@ -1,37 +0,0 @@ -<!--
- Copyright 2008 Federal Chancellery Austria and
- Graz University of Technology
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Mehrere Signaturedaten</title>
-<style type="text/css">
-h1 {
- color: red;
- font-size: 15px;
- font-weight: 500;
- font-family: Helvetica, Arial, sans-serif;
-}
-</style>
-</head>
-<body>
-<div style="width:300px; padding:20px; border:5px solid #ff0000;text-align: center">
-<h1>Diese Signatur enthält mehrere Datenobjekte. <br>
-Die Anzeige dieser wird derzeit nicht unterstützt !</h1>
-</div>
-</body>
-</html>
\ No newline at end of file diff --git a/BKUOnline/src/main/webapp/HTTP-ohne.html b/BKUOnline/src/main/webapp/slRequestForm.html index 607fa5d4..9a96e9be 100644 --- a/BKUOnline/src/main/webapp/HTTP-ohne.html +++ b/BKUOnline/src/main/webapp/slRequestForm.html @@ -17,11 +17,11 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> -<title>Infobox Requests</title> +<title>Security-Layer v1.2 Request Formular</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> -<h1>Securitykapsel - HTTP-Bindung</h1> +<h1>Security-Layer v1.2 Request Formular</h1> <style type="text/css"> fieldset { padding: 1em; @@ -59,6 +59,7 @@ legend { <p> <form action="./http-security-layer-request" method="Post" enctype="application/x-www-form-urlencoded"> + <!--input name="locale" value="es_MX" type="hidden" /--> <fieldset><legend>Enter XML Request</legend> <p><label for="XMLRequest">XML Request</label> <textarea name="XMLRequest" rows=15 cols="60" id="XMLRequest"> @@ -97,12 +98,6 @@ legend { <input type="radio" name="appletGuiStyle" value="simple" checked="checked">simple <input type="radio" name="appletGuiStyle" value="advanced">advanced </p> -<p> - <label for="appletHashDataDisplay">HashData Display</label> - <input type="radio" name="appletHashDataDisplay" value="frame" checked="checked">Frame - <input type="radio" name="appletHashDataDisplay" value="browser">Browser - <!--input type="radio" name="appletHashDataDisplay" value="internal">Applet--> -</p> <!-- <p><label for="RedirectURL">RedirectURL</label> <input diff --git a/BKUOnline/src/main/wsdl/CardChannel.xsd b/BKUOnline/src/main/wsdl/CardChannel.xsd new file mode 100644 index 00000000..81fd85db --- /dev/null +++ b/BKUOnline/src/main/wsdl/CardChannel.xsd @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.buergerkarte.at/cardchannel" + xmlns:tns="http://www.buergerkarte.at/cardchannel" + elementFormDefault="qualified" + xmlns:stal="http://www.egiz.gv.at/stal"> + + <xs:import namespace="http://www.egiz.gv.at/stal" schemaLocation="stal-service.xsd"/> + + <xs:annotation> + <xs:documentation>Schema for transparent access to cards using a BKU and the CardChannel + infobox</xs:documentation> + </xs:annotation> + + <xs:element name="Script" type="tns:ScriptType" substitutionGroup="stal:OtherRequest"/> + <xs:element name="Response" type="tns:ResponseType" substitutionGroup="stal:OtherResponse"/> + <xs:element name="Grunddaten" type="tns:AttributeList"/> + <xs:element name="EHIC" type="tns:AttributeList"/> + <xs:element name="Status" type="tns:AttributeList"/> + <xs:element name="SV-Personenbindung" type="xs:hexBinary"/> + + <xs:complexType name="ScriptType"> + <xs:annotation> + <xs:documentation>extends abstract stal:RequestType</xs:documentation> + </xs:annotation> + <xs:complexContent> + <xs:extension base="stal:RequestType"> + <xs:annotation> + <xs:documentation>Contains the script to be executed by the BKU</xs:documentation> + </xs:annotation> + <xs:choice maxOccurs="unbounded" minOccurs="1"> + <xs:element name="Reset" type="tns:ResetType"/> + <xs:element name="CommandAPDU" type="tns:CommandAPDUType"/> + <xs:element name="VerifyAPDU" type="tns:VerifyAPDUType"/> + </xs:choice> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="ResponseType"> + <xs:annotation> + <xs:documentation>extends abstract stal:ResponseType</xs:documentation> + </xs:annotation> + <xs:complexContent> + <xs:extension base="stal:ResponseType"> + <xs:annotation> + <xs:documentation>Contains the result of the script executed by the + BKU</xs:documentation> + </xs:annotation> + <xs:choice maxOccurs="unbounded" minOccurs="1"> + <xs:element name="ATR" type="tns:ATRType"/> + <xs:element name="ResponseAPDU" type="tns:ResponseAPDUType"/> + </xs:choice> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="ResetType"> + <xs:annotation> + <xs:documentation>Reset the icc and sequence counter</xs:documentation> + </xs:annotation> + <xs:attribute name="cold" type="xs:boolean" default="true"/> + </xs:complexType> + + <xs:complexType name="CommandAPDUType"> + <xs:annotation> + <xs:documentation>Contains a sequence of bytes send as command APDU to the + icc</xs:documentation> + </xs:annotation> + <xs:simpleContent> + <xs:extension base="xs:hexBinary"> + <xs:attribute name="sequence" type="xs:positiveInteger" use="required"/> + <xs:attribute name="of" type="xs:positiveInteger" use="required"/> + <xs:attribute name="expectedSW" type="xs:hexBinary"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="VerifyAPDUType"> + <xs:annotation> + <xs:documentation>Contains a sequence of bytes send as command APDU to the icc after a + PIN entered by the user has been incorporated into the APDU</xs:documentation> + </xs:annotation> + <xs:simpleContent> + <xs:extension base="xs:hexBinary"> + <xs:attribute name="sequence" type="xs:positiveInteger" use="required"/> + <xs:attribute name="of" type="xs:positiveInteger" use="required"/> + <xs:attribute name="expectedSW" type="xs:hexBinary"/> + <xs:attribute name="message" type="xs:string" use="required"/> + <xs:attribute name="format" type="xs:hexBinary" use="required"/> + <xs:attribute name="offset" type="xs:nonNegativeInteger" use="required"/> + <xs:attribute name="timeout" type="xs:nonNegativeInteger" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="ATRType"> + <xs:annotation> + <xs:documentation>Contains the ATR received as reponse to a Reset + command</xs:documentation> + </xs:annotation> + <xs:simpleContent> + <xs:extension base="xs:hexBinary"> + <xs:attribute name="rc" type="xs:integer" default="0"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="ResponseAPDUType"> + <xs:annotation> + <xs:documentation>Contains a sequence of bytes received from the card as response + APDU</xs:documentation> + </xs:annotation> + <xs:simpleContent> + <xs:extension base="xs:hexBinary"> + <xs:attribute name="sequence" type="xs:positiveInteger" use="required"/> + <xs:attribute name="rc" type="xs:integer" default="0"/> + <xs:attribute name="SW" type="xs:hexBinary" default="9000"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="AttributeList"> + <xs:annotation> + <xs:documentation>Contains a list of attributes</xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="Attribute" type="tns:AttributeType" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="AttributeType"> + <xs:annotation> + <xs:documentation>Contains an attribute converted from ASN.1</xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="Integer" type="xs:integer" minOccurs="0" maxOccurs="1"/> + <xs:element name="Latin1String" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="UTF8String" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="NumericString" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="PrintableString" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="GeneralizedTime" type="xs:dateTime" minOccurs="0" maxOccurs="1"/> + <xs:element name="Date" type="xs:string" minOccurs="0" maxOccurs="1"/> + </xs:sequence> + <xs:attribute name="oid" type="xs:string" use="required"/> + </xs:complexType> + +</xs:schema> diff --git a/BKUOnline/src/main/wsdl/stal-service.wsdl b/BKUOnline/src/main/wsdl/stal-service.wsdl new file mode 100644 index 00000000..3e6f5730 --- /dev/null +++ b/BKUOnline/src/main/wsdl/stal-service.wsdl @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2008 Federal Chancellery Austria and + Graz University of Technology + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + | This WSDL contains the original WSDL that was used to generate all classes in the STALService module + |--> +<definitions name="stal" targetNamespace="http://www.egiz.gv.at/wsdl/stal" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://www.egiz.gv.at/wsdl/stal" + xmlns:stal="http://www.egiz.gv.at/stal" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:cc="http://www.buergerkarte.at/cardchannel"> + <types> + <xsd:schema targetNamespace="http://www.egiz.gv.at/wsdl/stal"> + <xsd:import namespace="http://www.egiz.gv.at/stal" schemaLocation="stal-service.xsd"/> + </xsd:schema> + <xsd:schema targetNamespace="http://www.egiz.gv.at/wsdl/stal-extended"> + <xsd:import namespace="http://www.buergerkarte.at/cardchannel" schemaLocation="CardChannel.xsd"/> + </xsd:schema> + </types> + <message name="ConnectRequest"> + <part name="part1" element="stal:SessionId"/> + </message> + <message name="NextRequestRequest"> + <part name="part1" element="stal:GetNextRequest"/> + </message> + <message name="NextRequestResponse"> + <part name="part1" element="stal:GetNextRequestResponse"/> + </message> + <message name="GetHashDataInputRequest"> + <part name="part1" element="stal:GetHashDataInput"/> + </message> + <message name="GetHashDataInputResponse"> + <part name="part1" element="stal:GetHashDataInputResponse"/> + </message> + <message name="GetHashDataInputFault"> + <part name="part1" element="stal:GetHashDataInputFault"/> + </message> + + <!-- + | Comment out the remainder of this WSDL + | if placing it into webapp/WEB-INF/wsdl/ + | in order not to interfere with the actual WSDL stal.wsdl + |--> + <portType name="STALPortType"> + <operation name="connect"> + <input name="input3" message="tns:ConnectRequest"/> + <output name="output3" message="tns:NextRequestResponse"/> + </operation> + <operation name="nextRequest"> + <input name="input1" message="tns:NextRequestRequest"/> + <output name="output1" message="tns:NextRequestResponse"/> + </operation> + <operation name="getHashDataInput"> + <input name="input2" message="tns:GetHashDataInputRequest"/> + <output name="output2" message="tns:GetHashDataInputResponse"/> + <fault name="fault1" message="tns:GetHashDataInputFault"/> + </operation> + </portType> + <binding name="STALBinding" type="tns:STALPortType"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <operation name="connect"> + <input name="input3"> + <soap:body use="literal"/> + </input> + <output name="output3"> + <soap:body use="literal"/> + </output> + </operation> + <operation name="nextRequest"> + <soap:operation/> + <input name="input1"> + <soap:body use="literal"/> + </input> + <output name="output1"> + <soap:body use="literal"/> + </output> + </operation> + <operation name="getHashDataInput"> + <soap:operation/> + <input name="input2"> + <soap:body use="literal"/> + </input> + <output name="output2"> + <soap:body use="literal"/> + </output> + <fault name="fault1"> + <soap:fault name="fault1"/> + </fault> + </operation> + </binding> + <service name="STALService"> + <port name="STALPort" binding="tns:STALBinding"> + <soap:address location="http://localhost:${HttpDefaultPort}/stal"/> + </port> + </service> +</definitions> diff --git a/BKUOnline/src/main/wsdl/stal-service.xsd b/BKUOnline/src/main/wsdl/stal-service.xsd new file mode 100644 index 00000000..450c8146 --- /dev/null +++ b/BKUOnline/src/main/wsdl/stal-service.xsd @@ -0,0 +1,168 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2008 Federal Chancellery Austria and + Graz University of Technology + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.egiz.gv.at/stal" + xmlns:tns="http://www.egiz.gv.at/stal" + xmlns:cc="http://www.buergerkarte.at/cardchannel" + elementFormDefault="qualified"> + + <import namespace="http://www.buergerkarte.at/cardchannel" schemaLocation="CardChannel.xsd"/> + + <element name="SessionId" type="string"/> + <element name="GetNextRequest" type="tns:GetNextRequestType"/> + <element name="GetNextRequestResponse" type="tns:GetNextRequestResponseType"/> + <element name="GetHashDataInput" type="tns:GetHashDataInputType"/> + <element name="GetHashDataInputResponse" type="tns:GetHashDataInputResponseType"/> + <element name="GetHashDataInputFault" type="tns:GetHashDataInputFaultType"/> + + <!-- Abstract Request/Response to be substituted by extending schemata --> + <element name="OtherRequest" type="tns:RequestType" abstract="true"/> + <element name="OtherResponse" type="tns:ResponseType" abstract="true"/> + + <complexType name="GetNextRequestType"> + <!-- abstract Request/Response type not supported by JAX-WS 2.0 (jdk < 1.6.0_04) + <sequence> + <element name="Response" type="tns:ResponseType" minOccurs="0" maxOccurs="unbounded"/> + </sequence--> + <choice maxOccurs="unbounded"> + <element name="InfoboxReadResponse" type="tns:InfoboxReadResponseType"/> + <element name="SignResponse" type="tns:SignResponseType"/> + <element name="ErrorResponse" type="tns:ErrorResponseType"/> + <element ref="tns:OtherResponse"/> + <!-- do not list cc:Script here, JAXB knows about substitution groups + <element ref="cc:Script"/--> + </choice> + <attribute name="SessionId" type="string"/> + </complexType> + <complexType name="ResponseType" abstract="true" /> + <complexType name="InfoboxReadResponseType"> + <complexContent> + <extension base="tns:ResponseType"> + <sequence> + <element name="InfoboxValue" type="base64Binary"/> + </sequence> + </extension> + </complexContent> + </complexType> + <complexType name="SignResponseType"> + <complexContent> + <extension base="tns:ResponseType"> + <sequence> + <element name="SignatureValue" type="base64Binary"/> + </sequence> + </extension> + </complexContent> + </complexType> + <complexType name="ErrorResponseType"> + <complexContent> + <extension base="tns:ResponseType"> + <sequence> + <element name="ErrorCode" type="int"/> + <element name="ErrorMessage" type="string"/> + </sequence> + </extension> + </complexContent> + </complexType> + <complexType name="GetNextRequestResponseType"> + <!-- abstract Request/Response type not supported by JAX-WS 2.0 (jdk < 1.6.0_04) + <sequence> + <element name="Request" type="tns:RequestType" minOccurs="0" maxOccurs="unbounded"/> + </sequence--> + <choice maxOccurs="unbounded"> + <element name="InfoboxReadRequest" type="tns:InfoboxReadRequestType"/> + <element name="SignRequest" type="tns:SignRequestType"/> + <element name="QuitRequest" type="tns:QuitRequestType"/> + <element ref="tns:OtherRequest"/> + <!-- do not list cc:Response here, JAXB knows about substitution groups + <element ref="cc:Response"/--> + </choice> + <attribute name="SessionId" type="string"/> + </complexType> + <complexType name="RequestType" abstract="true"/> + <complexType name="InfoboxReadRequestType"> + <complexContent> + <extension base="tns:RequestType"> + <sequence> + <element name="InfoboxIdentifier"> + <simpleType> + <restriction base="string"> + <enumeration value="Certificates"/> + <enumeration value="IdentityLink"/> + <enumeration value="Mandates"/> + </restriction> + </simpleType> + </element> + <element name="DomainIdentifier" type="anyURI" minOccurs="0"/> + </sequence> + </extension> + </complexContent> + </complexType> + <complexType name="SignRequestType"> + <complexContent> + <extension base="tns:RequestType"> + <sequence> + <element name="KeyIdentifier"> + <simpleType> + <restriction base="string"> + <enumeration value="SecureSignatureKeypair"/> + <enumeration value="CertifiedKeypair"/> + </restriction> + </simpleType> + </element> + <element name="SignedInfo" type="base64Binary"/> + </sequence> + </extension> + </complexContent> + </complexType> + <complexType name="QuitRequestType"> + <complexContent> + <extension base="tns:RequestType"/> + </complexContent> + </complexType> + <complexType name="GetHashDataInputType"> + <sequence> + <element name="Reference" maxOccurs="unbounded"> + <complexType> + <attribute name="ID" type="string"/> + </complexType> + </element> + </sequence> + <attribute name="SessionId" type="string"/> + </complexType> + <complexType name="GetHashDataInputResponseType"> + <sequence> + <element name="Reference" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="base64Binary"> + <attribute name="ID" type="string"/> + <attribute name="MimeType" type="string" use="optional"/> + <attribute name="Encoding" type="string" use="optional"/> + </extension> + </simpleContent> + </complexType> + </element> + </sequence> + <attribute name="SessionId" type="string"/> + </complexType> + <complexType name="GetHashDataInputFaultType"> + <sequence> + <element name="ErrorCode" type="int"/> + <element name="ErrorMessage" type="string"/> + </sequence> + </complexType> +</schema> diff --git a/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java index 8830a81c..9d77e53e 100644 --- a/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java +++ b/BKUOnline/src/test/java/at/gv/egiz/stal/service/STALRequestBrokerTest.java @@ -34,6 +34,7 @@ import at.gv.egiz.stal.SignResponse; import at.gv.egiz.stal.SignRequest; import at.gv.egiz.stal.service.types.InfoboxReadRequestType; import at.gv.egiz.stal.service.types.InfoboxReadResponseType; +import at.gv.egiz.stal.service.types.ObjectFactory; import at.gv.egiz.stal.service.types.QuitRequestType; import at.gv.egiz.stal.service.types.RequestType; import at.gv.egiz.stal.service.types.ResponseType; @@ -45,6 +46,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.xml.bind.JAXBElement; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.BeforeClass; @@ -283,19 +285,25 @@ public class STALRequestBrokerTest { @Override public void run() { try { + ObjectFactory of= new ObjectFactory(); + log.debug("calling stal.nextRequest(oldResponse)"); - ResponseType oldResp = new InfoboxReadResponseType(); - List<RequestType> requests = stal.nextRequest(Collections.singletonList(oldResp)); + InfoboxReadResponseType oldResp = of.createInfoboxReadResponseType(); + ArrayList<JAXBElement<? extends ResponseType>> oldResponses = new ArrayList<JAXBElement<? extends ResponseType>>(); + oldResponses.add(of.createGetNextRequestTypeInfoboxReadResponse(oldResp)); + + List<JAXBElement<? extends RequestType>> requests = stal.nextRequest(oldResponses); log.debug("got " + requests.size() + " requests. processing..."); Thread.sleep(1); - List<ResponseType> responses = new ArrayList<ResponseType>(); - for (RequestType request : requests) { + List<JAXBElement<? extends ResponseType>> responses = new ArrayList<JAXBElement<? extends ResponseType>>(); + for (JAXBElement<? extends RequestType> requestElt : requests) { + RequestType request = requestElt.getValue(); if (request instanceof InfoboxReadRequestType) { log.debug("received UNEXPECTED READINFOBOX request"); - InfoboxReadResponseType r = new InfoboxReadResponseType(); + InfoboxReadResponseType r = of.createInfoboxReadResponseType(); r.setInfoboxValue("dummyInfobox".getBytes()); - responses.add(r); + responses.add(of.createGetNextRequestTypeInfoboxReadResponse(r)); } else if (request instanceof SignRequestType) { log.debug("received UNEXPECTED SIGN request"); @@ -311,9 +319,9 @@ public class STALRequestBrokerTest { log.debug("got HashDataInput " + new String(data)); - SignResponseType r = new SignResponseType(); + SignResponseType r = of.createSignResponseType(); r.setSignatureValue("dummySignature".getBytes()); - responses.add(r); + responses.add(of.createGetNextRequestTypeSignResponse(r)); } else if (request instanceof QuitRequestType) { log.debug("received EXPECTED QUIT request"); return; @@ -326,7 +334,8 @@ public class STALRequestBrokerTest { // } log.debug("calling stal.nextRequest with " + responses.size() + " responses"); requests = stal.nextRequest(responses); - for (RequestType request : requests) { + for (JAXBElement<? extends RequestType> requestElt : requests) { + RequestType request = requestElt.getValue(); if (request instanceof QuitRequestType) { log.debug("got QUIT request"); } else { @@ -347,17 +356,19 @@ public class STALRequestBrokerTest { @Override public void run() { try { + ObjectFactory of = new ObjectFactory(); // first call w/ empty response list log.debug("calling stal.nextRequest"); - List<RequestType> requests = stal.nextRequest(null); //new ArrayList<ResponseType>()); + List<JAXBElement<? extends RequestType>> requests = stal.nextRequest(null); //new ArrayList<ResponseType>()); log.debug("got " + requests.size() + " requests. processing..."); Thread.sleep(1); - List<ResponseType> responses = new ArrayList<ResponseType>(); - for (RequestType request : requests) { + List<JAXBElement<? extends ResponseType>> responses = new ArrayList<JAXBElement<? extends ResponseType>>(); + for (JAXBElement<? extends RequestType> requestElt : requests) { + RequestType request = requestElt.getValue(); if (request instanceof InfoboxReadRequestType) { - InfoboxReadResponseType r = new InfoboxReadResponseType(); + InfoboxReadResponseType r = of.createInfoboxReadResponseType(); r.setInfoboxValue("dummyInfobox".getBytes()); - responses.add(r); + responses.add(of.createGetNextRequestTypeInfoboxReadResponse(r)); } else if (request instanceof SignRequestType) { log.debug("calling stal.getCurrentHashDataInputCallback"); @@ -371,9 +382,9 @@ public class STALRequestBrokerTest { log.debug("got HashDataInput " + new String(data)); - SignResponseType r = new SignResponseType(); + SignResponseType r = of.createSignResponseType(); r.setSignatureValue("dummySignature".getBytes()); - responses.add(r); + responses.add(of.createGetNextRequestTypeSignResponse(r)); } else if (request instanceof QuitRequestType) { log.debug("received UNEXPECTED QUIT request"); return; @@ -386,7 +397,8 @@ public class STALRequestBrokerTest { // } log.debug("calling stal.nextRequest with " + responses.size() + " responses"); requests = stal.nextRequest(responses); - for (RequestType request : requests) { + for (JAXBElement<? extends RequestType> requestElt : requests) { + RequestType request = requestElt.getValue(); if (request instanceof QuitRequestType) { log.debug("got QUIT request"); } else { @@ -408,10 +420,11 @@ public class STALRequestBrokerTest { try { // first call w/ empty response list log.debug("calling stal.nextRequest"); - List<RequestType> requests = stal.nextRequest(null); //new ArrayList<ResponseType>()); + List<JAXBElement<? extends RequestType>> requests = stal.nextRequest(null); //new ArrayList<ResponseType>()); log.debug("got " + requests.size() + " requests. processing..."); Thread.sleep(1); - for (RequestType request : requests) { + for (JAXBElement<? extends RequestType> requestElt : requests) { + RequestType request = requestElt.getValue(); // if (request instanceof InfoboxReadRequest) { if (request instanceof SignRequestType) { log.debug("calling stal.getCurrentHashDataInputCallback"); diff --git a/STAL/src/main/java/at/gv/egiz/stal/STAL.java b/STAL/src/main/java/at/gv/egiz/stal/STAL.java index de29de9a..7015ec29 100644 --- a/STAL/src/main/java/at/gv/egiz/stal/STAL.java +++ b/STAL/src/main/java/at/gv/egiz/stal/STAL.java @@ -14,30 +14,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package at.gv.egiz.stal;
-
-import java.util.List;
-import java.util.Locale;
-
-/**
- * Interface for all implementations of the Security Tokean Abstraction Layer.
- * This interface is used by the BKU to handle all security token related parts.
- *
- *
- */
-public interface STAL {
-
- /**
- * Handles a list of security token commands.
- * @param aRequestList
- * @return
- */
- public List<STALResponse> handleRequest(List<STALRequest> aRequestList);
-
- /**
- * Sets the preferred locale for userinteraction (e.g. PIN dialogs).
- * If the locale is not set the default locale will be used.
- * @param locale must not be null.
- */
- public void setLocale(Locale locale);
+package at.gv.egiz.stal; + +import java.util.List; +import java.util.Locale; + +/** + * Interface for all implementations of the Security Tokean Abstraction Layer. + * This interface is used by the BKU to handle all security token related parts. + * + * + */ +public interface STAL { + + /** + * Handles a list of security token commands. + * @param aRequestList + * @return + */ + public List<STALResponse> handleRequest(List<? extends STALRequest> aRequestList); + + /** + * Sets the preferred locale for userinteraction (e.g. PIN dialogs). + * If the locale is not set the default locale will be used. + * @param locale must not be null. + */ + public void setLocale(Locale locale); }
\ No newline at end of file diff --git a/STALExt/pom.xml b/STALExt/pom.xml new file mode 100644 index 00000000..9c4f159d --- /dev/null +++ b/STALExt/pom.xml @@ -0,0 +1,20 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <artifactId>bku</artifactId> + <groupId>at.gv.egiz</groupId> + <version>1.0.2</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>at.gv.egiz</groupId> + <artifactId>STALExt</artifactId> + <name>STAL Extension</name> + <version>1.0.1</version> + <description /> + <dependencies> + <dependency> + <groupId>at.gv.egiz</groupId> + <artifactId>STAL</artifactId> + <version>1.0.2</version> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/STALExt/src/main/java/META-INF/MANIFEST.MF b/STALExt/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5e949512 --- /dev/null +++ b/STALExt/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0
+Class-Path:
+
diff --git a/STALExt/src/main/java/at/gv/egiz/stal/ext/APDUScriptRequest.java b/STALExt/src/main/java/at/gv/egiz/stal/ext/APDUScriptRequest.java new file mode 100644 index 00000000..89e459ac --- /dev/null +++ b/STALExt/src/main/java/at/gv/egiz/stal/ext/APDUScriptRequest.java @@ -0,0 +1,72 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.stal.ext; + +import java.util.List; + +import at.gv.egiz.stal.STALRequest; + +public class APDUScriptRequest extends STALRequest { + + public static abstract class RequestScriptElement { + + } + + public static class Reset extends RequestScriptElement { + + } + + public static class Command extends RequestScriptElement { + + private int sequence; + + private byte[] commandAPDU; + + private byte[] expectedSW; + + public Command(int sequence, byte[] commandAPDU, byte[] expectedSW) { + this.sequence = sequence; + this.commandAPDU = commandAPDU; + this.expectedSW = expectedSW; + } + + public int getSequence() { + return sequence; + } + + public byte[] getCommandAPDU() { + return commandAPDU; + } + + public byte[] getExpectedSW() { + return expectedSW; + } + + } + + private List<RequestScriptElement> script; + + public APDUScriptRequest(List<RequestScriptElement> script) { + super(); + this.script = script; + } + + public List<RequestScriptElement> getScript() { + return script; + } + +} diff --git a/STALExt/src/main/java/at/gv/egiz/stal/ext/APDUScriptResponse.java b/STALExt/src/main/java/at/gv/egiz/stal/ext/APDUScriptResponse.java new file mode 100644 index 00000000..dd59f0bf --- /dev/null +++ b/STALExt/src/main/java/at/gv/egiz/stal/ext/APDUScriptResponse.java @@ -0,0 +1,91 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.stal.ext; + +import java.util.List; + +import at.gv.egiz.stal.STALResponse; + +public class APDUScriptResponse extends STALResponse { + + public static abstract class ResponseScriptElement { + + } + + public static class ATR extends ResponseScriptElement { + + private byte[] atr; + + public ATR(byte[] atr) { + this.atr = atr; + } + + public byte[] getAtr() { + return atr; + } + + } + + public static class Response extends ResponseScriptElement { + + public static final int RC_UNSPECIFIED = -1; + + private int sequence; + + private byte[] apdu; + + private byte[] sw; + + private int rc; + + public Response(int sequence, byte[] apdu, byte[] sw, int rc) { + this.sequence = sequence; + this.apdu = apdu; + this.sw = sw; + this.rc = rc; + } + + public int getSequence() { + return sequence; + } + + public byte[] getApdu() { + return apdu; + } + + public byte[] getSw() { + return sw; + } + + public int getRc() { + return rc; + } + + } + + private List<ResponseScriptElement> script; + + public APDUScriptResponse(List<ResponseScriptElement> script) { + super(); + this.script = script; + } + + public List<ResponseScriptElement> getScript() { + return script; + } + +} diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/GetHashDataInputFault.java b/STALService/src/main/java/at/gv/egiz/stal/service/GetHashDataInputFault.java index df42ab47..2f08350c 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/GetHashDataInputFault.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/GetHashDataInputFault.java @@ -8,7 +8,7 @@ import at.gv.egiz.stal.service.types.GetHashDataInputFaultType; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.1.3-b02- - * Generated source version: 2.0 + * Generated source version: 2.1 * */ @WebFault(name = "GetHashDataInputFault", targetNamespace = "http://www.egiz.gv.at/stal") diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/STALPortType.java b/STALService/src/main/java/at/gv/egiz/stal/service/STALPortType.java index 6ac6b10a..436ee7f1 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/STALPortType.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/STALPortType.java @@ -6,6 +6,7 @@ import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; import at.gv.egiz.stal.service.types.GetHashDataInputResponseType; import at.gv.egiz.stal.service.types.GetHashDataInputType; import at.gv.egiz.stal.service.types.GetNextRequestResponseType; @@ -15,11 +16,15 @@ import at.gv.egiz.stal.service.types.GetNextRequestType; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.1.3-b02- - * Generated source version: 2.0 + * Generated source version: 2.1 * */ @WebService(name = "STALPortType", targetNamespace = "http://www.egiz.gv.at/wsdl/stal") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +@XmlSeeAlso({ + at.gv.egiz.stal.service.types.ObjectFactory.class +// at.buergerkarte.namespaces.cardchannel.ObjectFactory.class +}) public interface STALPortType { diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/STALService.java b/STALService/src/main/java/at/gv/egiz/stal/service/STALService.java index d4b58af9..ba4b541e 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/STALService.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/STALService.java @@ -1,31 +1,52 @@ package at.gv.egiz.stal.service; +import java.net.MalformedURLException; import java.net.URL; import java.util.logging.Logger; import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.ws.WebEndpoint; import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceFeature; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.1.3-b02- - * Generated source version: 2.0 + * Generated source version: 2.1 * */ @WebServiceClient(name = "STALService", targetNamespace = "http://www.egiz.gv.at/wsdl/stal") +//, wsdlLocation = "file:/home/clemens/workspace/mocca/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal-service.wsdl") public class STALService extends Service { +// private final static URL STALSERVICE_WSDL_LOCATION; private final static Logger logger = Logger.getLogger(at.gv.egiz.stal.service.STALService.class.getName()); +// static { +// URL url = null; +// try { +// URL baseUrl; +// baseUrl = at.gv.egiz.stal.service.STALService.class.getResource("."); +// url = new URL(baseUrl, "file:/home/clemens/workspace/mocca/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal-service.wsdl"); +// } catch (MalformedURLException e) { +// logger.warning("Failed to create URL for the wsdl Location: 'file:/home/clemens/workspace/mocca/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal-service.wsdl', retrying as a local file"); +// logger.warning(e.getMessage()); +// } +// STALSERVICE_WSDL_LOCATION = url; +// } + public STALService(URL wsdlLocation, QName serviceName) { super(wsdlLocation, serviceName); } +// public STALService() { +// super(STALSERVICE_WSDL_LOCATION, new QName("http://www.egiz.gv.at/wsdl/stal", "STALService")); +// } + /** * * @return @@ -36,4 +57,16 @@ public class STALService return super.getPort(new QName("http://www.egiz.gv.at/wsdl/stal", "STALPort"), STALPortType.class); } + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. + * @return + * returns STALPortType + */ +// @WebEndpoint(name = "STALPort") +// public STALPortType getSTALPort(WebServiceFeature... features) { +// return super.getPort(new QName("http://www.egiz.gv.at/wsdl/stal", "STALPort"), STALPortType.class, features); +// } + } diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestResponseType.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestResponseType.java index 6f8204cc..0f56c3ce 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestResponseType.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestResponseType.java @@ -3,12 +3,14 @@ package at.gv.egiz.stal.service.types; import java.util.ArrayList; import java.util.List; +import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlType; +//import at.buergerkarte.namespaces.cardchannel.ScriptType; /** @@ -24,6 +26,7 @@ import javax.xml.bind.annotation.XmlType; * <element name="InfoboxReadRequest" type="{http://www.egiz.gv.at/stal}InfoboxReadRequestType"/> * <element name="SignRequest" type="{http://www.egiz.gv.at/stal}SignRequestType"/> * <element name="QuitRequest" type="{http://www.egiz.gv.at/stal}QuitRequestType"/> + * <element ref="{http://www.egiz.gv.at/stal}OtherRequest"/> * </choice> * <attribute name="SessionId" type="{http://www.w3.org/2001/XMLSchema}string" /> * </restriction> @@ -39,12 +42,13 @@ import javax.xml.bind.annotation.XmlType; }) public class GetNextRequestResponseType { - @XmlElements({ - @XmlElement(name = "InfoboxReadRequest", type = InfoboxReadRequestType.class), - @XmlElement(name = "QuitRequest", type = QuitRequestType.class), - @XmlElement(name = "SignRequest", type = SignRequestType.class) + @XmlElementRefs({ + @XmlElementRef(name = "SignRequest", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class), + @XmlElementRef(name = "QuitRequest", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class), + @XmlElementRef(name = "OtherRequest", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class), + @XmlElementRef(name = "InfoboxReadRequest", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class) }) - protected List<RequestType> infoboxReadRequestOrSignRequestOrQuitRequest; + protected List<JAXBElement<? extends RequestType>> infoboxReadRequestOrSignRequestOrQuitRequest; @XmlAttribute(name = "SessionId") protected String sessionId; @@ -66,15 +70,17 @@ public class GetNextRequestResponseType { * * <p> * Objects of the following type(s) are allowed in the list - * {@link InfoboxReadRequestType } - * {@link QuitRequestType } - * {@link SignRequestType } + * {@link JAXBElement }{@code <}{@link QuitRequestType }{@code >} + * {@link JAXBElement }{@code <}{@link RequestType }{@code >} + * {@link JAXBElement }{@code <}{@link ScriptType }{@code >} + * {@link JAXBElement }{@code <}{@link InfoboxReadRequestType }{@code >} + * {@link JAXBElement }{@code <}{@link SignRequestType }{@code >} * * */ - public List<RequestType> getInfoboxReadRequestOrSignRequestOrQuitRequest() { + public List<JAXBElement<? extends RequestType>> getInfoboxReadRequestOrSignRequestOrQuitRequest() { if (infoboxReadRequestOrSignRequestOrQuitRequest == null) { - infoboxReadRequestOrSignRequestOrQuitRequest = new ArrayList<RequestType>(); + infoboxReadRequestOrSignRequestOrQuitRequest = new ArrayList<JAXBElement<? extends RequestType>>(); } return this.infoboxReadRequestOrSignRequestOrQuitRequest; } diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestType.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestType.java index eab3d40b..320d9136 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestType.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/GetNextRequestType.java @@ -3,11 +3,12 @@ package at.gv.egiz.stal.service.types; import java.util.ArrayList; import java.util.List; +import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlType; @@ -24,6 +25,7 @@ import javax.xml.bind.annotation.XmlType; * <element name="InfoboxReadResponse" type="{http://www.egiz.gv.at/stal}InfoboxReadResponseType"/> * <element name="SignResponse" type="{http://www.egiz.gv.at/stal}SignResponseType"/> * <element name="ErrorResponse" type="{http://www.egiz.gv.at/stal}ErrorResponseType"/> + * <element ref="{http://www.egiz.gv.at/stal}OtherResponse"/> * </choice> * <attribute name="SessionId" type="{http://www.w3.org/2001/XMLSchema}string" /> * </restriction> @@ -39,12 +41,13 @@ import javax.xml.bind.annotation.XmlType; }) public class GetNextRequestType { - @XmlElements({ - @XmlElement(name = "SignResponse", type = SignResponseType.class), - @XmlElement(name = "InfoboxReadResponse", type = InfoboxReadResponseType.class), - @XmlElement(name = "ErrorResponse", type = ErrorResponseType.class) + @XmlElementRefs({ + @XmlElementRef(name = "ErrorResponse", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class), + @XmlElementRef(name = "SignResponse", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class), + @XmlElementRef(name = "OtherResponse", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class), + @XmlElementRef(name = "InfoboxReadResponse", namespace = "http://www.egiz.gv.at/stal", type = JAXBElement.class) }) - protected List<ResponseType> infoboxReadResponseOrSignResponseOrErrorResponse; + protected List<JAXBElement<? extends at.gv.egiz.stal.service.types.ResponseType>> infoboxReadResponseOrSignResponseOrErrorResponse; @XmlAttribute(name = "SessionId") protected String sessionId; @@ -66,15 +69,17 @@ public class GetNextRequestType { * * <p> * Objects of the following type(s) are allowed in the list - * {@link SignResponseType } - * {@link InfoboxReadResponseType } - * {@link ErrorResponseType } + * {@link JAXBElement }{@code <}{@link SignResponseType }{@code >} + * {@link JAXBElement }{@code <}{@link at.buergerkarte.namespaces.cardchannel.ResponseType }{@code >} + * {@link JAXBElement }{@code <}{@link ErrorResponseType }{@code >} + * {@link JAXBElement }{@code <}{@link at.gv.egiz.stal.service.types.ResponseType }{@code >} + * {@link JAXBElement }{@code <}{@link InfoboxReadResponseType }{@code >} * * */ - public List<ResponseType> getInfoboxReadResponseOrSignResponseOrErrorResponse() { + public List<JAXBElement<? extends at.gv.egiz.stal.service.types.ResponseType>> getInfoboxReadResponseOrSignResponseOrErrorResponse() { if (infoboxReadResponseOrSignResponseOrErrorResponse == null) { - infoboxReadResponseOrSignResponseOrErrorResponse = new ArrayList<ResponseType>(); + infoboxReadResponseOrSignResponseOrErrorResponse = new ArrayList<JAXBElement<? extends at.gv.egiz.stal.service.types.ResponseType>>(); } return this.infoboxReadResponseOrSignResponseOrErrorResponse; } diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java index d485f1e1..8b6fb76a 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/ObjectFactory.java @@ -24,12 +24,20 @@ import javax.xml.namespace.QName; @XmlRegistry public class ObjectFactory { - private final static QName _GetHashDataInputFault_QNAME = new QName("http://www.egiz.gv.at/stal", "GetHashDataInputFault"); private final static QName _GetHashDataInput_QNAME = new QName("http://www.egiz.gv.at/stal", "GetHashDataInput"); - private final static QName _GetNextRequestResponse_QNAME = new QName("http://www.egiz.gv.at/stal", "GetNextRequestResponse"); private final static QName _GetHashDataInputResponse_QNAME = new QName("http://www.egiz.gv.at/stal", "GetHashDataInputResponse"); + private final static QName _OtherRequest_QNAME = new QName("http://www.egiz.gv.at/stal", "OtherRequest"); private final static QName _GetNextRequest_QNAME = new QName("http://www.egiz.gv.at/stal", "GetNextRequest"); + private final static QName _OtherResponse_QNAME = new QName("http://www.egiz.gv.at/stal", "OtherResponse"); private final static QName _SessionId_QNAME = new QName("http://www.egiz.gv.at/stal", "SessionId"); + private final static QName _GetHashDataInputFault_QNAME = new QName("http://www.egiz.gv.at/stal", "GetHashDataInputFault"); + private final static QName _GetNextRequestResponse_QNAME = new QName("http://www.egiz.gv.at/stal", "GetNextRequestResponse"); + private final static QName _GetNextRequestResponseTypeQuitRequest_QNAME = new QName("http://www.egiz.gv.at/stal", "QuitRequest"); + private final static QName _GetNextRequestResponseTypeInfoboxReadRequest_QNAME = new QName("http://www.egiz.gv.at/stal", "InfoboxReadRequest"); + private final static QName _GetNextRequestResponseTypeSignRequest_QNAME = new QName("http://www.egiz.gv.at/stal", "SignRequest"); + private final static QName _GetNextRequestTypeErrorResponse_QNAME = new QName("http://www.egiz.gv.at/stal", "ErrorResponse"); + private final static QName _GetNextRequestTypeSignResponse_QNAME = new QName("http://www.egiz.gv.at/stal", "SignResponse"); + private final static QName _GetNextRequestTypeInfoboxReadResponse_QNAME = new QName("http://www.egiz.gv.at/stal", "InfoboxReadResponse"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: at.gv.egiz.stal.service.types @@ -39,6 +47,22 @@ public class ObjectFactory { } /** + * Create an instance of {@link GetHashDataInputType } + * + */ + public GetHashDataInputType createGetHashDataInputType() { + return new GetHashDataInputType(); + } + + /** + * Create an instance of {@link GetHashDataInputResponseType.Reference } + * + */ + public GetHashDataInputResponseType.Reference createGetHashDataInputResponseTypeReference() { + return new GetHashDataInputResponseType.Reference(); + } + + /** * Create an instance of {@link GetNextRequestType } * */ @@ -47,19 +71,19 @@ public class ObjectFactory { } /** - * Create an instance of {@link InfoboxReadRequestType } + * Create an instance of {@link SignRequestType } * */ - public InfoboxReadRequestType createInfoboxReadRequestType() { - return new InfoboxReadRequestType(); + public SignRequestType createSignRequestType() { + return new SignRequestType(); } /** - * Create an instance of {@link GetHashDataInputResponseType.Reference } + * Create an instance of {@link GetHashDataInputType.Reference } * */ - public GetHashDataInputResponseType.Reference createGetHashDataInputResponseTypeReference() { - return new GetHashDataInputResponseType.Reference(); + public GetHashDataInputType.Reference createGetHashDataInputTypeReference() { + return new GetHashDataInputType.Reference(); } /** @@ -71,27 +95,43 @@ public class ObjectFactory { } /** - * Create an instance of {@link GetHashDataInputType } + * Create an instance of {@link QuitRequestType } * */ - public GetHashDataInputType createGetHashDataInputType() { - return new GetHashDataInputType(); + public QuitRequestType createQuitRequestType() { + return new QuitRequestType(); } /** - * Create an instance of {@link SignRequestType } + * Create an instance of {@link InfoboxReadResponseType } * */ - public SignRequestType createSignRequestType() { - return new SignRequestType(); + public InfoboxReadResponseType createInfoboxReadResponseType() { + return new InfoboxReadResponseType(); } /** - * Create an instance of {@link GetHashDataInputFaultType } + * Create an instance of {@link InfoboxReadRequestType } * */ - public GetHashDataInputFaultType createGetHashDataInputFaultType() { - return new GetHashDataInputFaultType(); + public InfoboxReadRequestType createInfoboxReadRequestType() { + return new InfoboxReadRequestType(); + } + + /** + * Create an instance of {@link GetNextRequestResponseType } + * + */ + public GetNextRequestResponseType createGetNextRequestResponseType() { + return new GetNextRequestResponseType(); + } + + /** + * Create an instance of {@link GetHashDataInputResponseType } + * + */ + public GetHashDataInputResponseType createGetHashDataInputResponseType() { + return new GetHashDataInputResponseType(); } /** @@ -103,61 +143,74 @@ public class ObjectFactory { } /** - * Create an instance of {@link GetHashDataInputType.Reference } + * Create an instance of {@link GetHashDataInputFaultType } * */ - public GetHashDataInputType.Reference createGetHashDataInputTypeReference() { - return new GetHashDataInputType.Reference(); + public GetHashDataInputFaultType createGetHashDataInputFaultType() { + return new GetHashDataInputFaultType(); } /** - * Create an instance of {@link GetHashDataInputResponseType } + * Create an instance of {@link JAXBElement }{@code <}{@link GetHashDataInputType }{@code >}} * */ - public GetHashDataInputResponseType createGetHashDataInputResponseType() { - return new GetHashDataInputResponseType(); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetHashDataInput") + public JAXBElement<GetHashDataInputType> createGetHashDataInput(GetHashDataInputType value) { + return new JAXBElement<GetHashDataInputType>(_GetHashDataInput_QNAME, GetHashDataInputType.class, null, value); } /** - * Create an instance of {@link InfoboxReadResponseType } + * Create an instance of {@link JAXBElement }{@code <}{@link GetHashDataInputResponseType }{@code >}} * */ - public InfoboxReadResponseType createInfoboxReadResponseType() { - return new InfoboxReadResponseType(); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetHashDataInputResponse") + public JAXBElement<GetHashDataInputResponseType> createGetHashDataInputResponse(GetHashDataInputResponseType value) { + return new JAXBElement<GetHashDataInputResponseType>(_GetHashDataInputResponse_QNAME, GetHashDataInputResponseType.class, null, value); } /** - * Create an instance of {@link QuitRequestType } + * Create an instance of {@link JAXBElement }{@code <}{@link RequestType }{@code >}} * */ - public QuitRequestType createQuitRequestType() { - return new QuitRequestType(); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "OtherRequest") + public JAXBElement<RequestType> createOtherRequest(RequestType value) { + return new JAXBElement<RequestType>(_OtherRequest_QNAME, RequestType.class, null, value); } /** - * Create an instance of {@link GetNextRequestResponseType } + * Create an instance of {@link JAXBElement }{@code <}{@link GetNextRequestType }{@code >}} * */ - public GetNextRequestResponseType createGetNextRequestResponseType() { - return new GetNextRequestResponseType(); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetNextRequest") + public JAXBElement<GetNextRequestType> createGetNextRequest(GetNextRequestType value) { + return new JAXBElement<GetNextRequestType>(_GetNextRequest_QNAME, GetNextRequestType.class, null, value); } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GetHashDataInputFaultType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link ResponseType }{@code >}} * */ - @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetHashDataInputFault") - public JAXBElement<GetHashDataInputFaultType> createGetHashDataInputFault(GetHashDataInputFaultType value) { - return new JAXBElement<GetHashDataInputFaultType>(_GetHashDataInputFault_QNAME, GetHashDataInputFaultType.class, null, value); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "OtherResponse") + public JAXBElement<ResponseType> createOtherResponse(ResponseType value) { + return new JAXBElement<ResponseType>(_OtherResponse_QNAME, ResponseType.class, null, value); } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GetHashDataInputType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} * */ - @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetHashDataInput") - public JAXBElement<GetHashDataInputType> createGetHashDataInput(GetHashDataInputType value) { - return new JAXBElement<GetHashDataInputType>(_GetHashDataInput_QNAME, GetHashDataInputType.class, null, value); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "SessionId") + public JAXBElement<String> createSessionId(String value) { + return new JAXBElement<String>(_SessionId_QNAME, String.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetHashDataInputFaultType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetHashDataInputFault") + public JAXBElement<GetHashDataInputFaultType> createGetHashDataInputFault(GetHashDataInputFaultType value) { + return new JAXBElement<GetHashDataInputFaultType>(_GetHashDataInputFault_QNAME, GetHashDataInputFaultType.class, null, value); } /** @@ -170,30 +223,57 @@ public class ObjectFactory { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GetHashDataInputResponseType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link QuitRequestType }{@code >}} * */ - @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetHashDataInputResponse") - public JAXBElement<GetHashDataInputResponseType> createGetHashDataInputResponse(GetHashDataInputResponseType value) { - return new JAXBElement<GetHashDataInputResponseType>(_GetHashDataInputResponse_QNAME, GetHashDataInputResponseType.class, null, value); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "QuitRequest", scope = GetNextRequestResponseType.class) + public JAXBElement<QuitRequestType> createGetNextRequestResponseTypeQuitRequest(QuitRequestType value) { + return new JAXBElement<QuitRequestType>(_GetNextRequestResponseTypeQuitRequest_QNAME, QuitRequestType.class, GetNextRequestResponseType.class, value); } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GetNextRequestType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link InfoboxReadRequestType }{@code >}} * */ - @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "GetNextRequest") - public JAXBElement<GetNextRequestType> createGetNextRequest(GetNextRequestType value) { - return new JAXBElement<GetNextRequestType>(_GetNextRequest_QNAME, GetNextRequestType.class, null, value); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "InfoboxReadRequest", scope = GetNextRequestResponseType.class) + public JAXBElement<InfoboxReadRequestType> createGetNextRequestResponseTypeInfoboxReadRequest(InfoboxReadRequestType value) { + return new JAXBElement<InfoboxReadRequestType>(_GetNextRequestResponseTypeInfoboxReadRequest_QNAME, InfoboxReadRequestType.class, GetNextRequestResponseType.class, value); } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link SignRequestType }{@code >}} * */ - @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "SessionId") - public JAXBElement<String> createSessionId(String value) { - return new JAXBElement<String>(_SessionId_QNAME, String.class, null, value); + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "SignRequest", scope = GetNextRequestResponseType.class) + public JAXBElement<SignRequestType> createGetNextRequestResponseTypeSignRequest(SignRequestType value) { + return new JAXBElement<SignRequestType>(_GetNextRequestResponseTypeSignRequest_QNAME, SignRequestType.class, GetNextRequestResponseType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link ErrorResponseType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "ErrorResponse", scope = GetNextRequestType.class) + public JAXBElement<ErrorResponseType> createGetNextRequestTypeErrorResponse(ErrorResponseType value) { + return new JAXBElement<ErrorResponseType>(_GetNextRequestTypeErrorResponse_QNAME, ErrorResponseType.class, GetNextRequestType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link SignResponseType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "SignResponse", scope = GetNextRequestType.class) + public JAXBElement<SignResponseType> createGetNextRequestTypeSignResponse(SignResponseType value) { + return new JAXBElement<SignResponseType>(_GetNextRequestTypeSignResponse_QNAME, SignResponseType.class, GetNextRequestType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link InfoboxReadResponseType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.egiz.gv.at/stal", name = "InfoboxReadResponse", scope = GetNextRequestType.class) + public JAXBElement<InfoboxReadResponseType> createGetNextRequestTypeInfoboxReadResponse(InfoboxReadResponseType value) { + return new JAXBElement<InfoboxReadResponseType>(_GetNextRequestTypeInfoboxReadResponse_QNAME, InfoboxReadResponseType.class, GetNextRequestType.class, value); } } diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/RequestType.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/RequestType.java index 32b7894f..9e5ebf59 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/types/RequestType.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/RequestType.java @@ -3,7 +3,9 @@ package at.gv.egiz.stal.service.types; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; +//import at.buergerkarte.namespaces.cardchannel.ScriptType; /** @@ -24,6 +26,12 @@ import javax.xml.bind.annotation.XmlType; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "RequestType") +@XmlSeeAlso({ + SignRequestType.class, + InfoboxReadRequestType.class, + QuitRequestType.class +// ScriptType.class +}) public abstract class RequestType { diff --git a/STALService/src/main/java/at/gv/egiz/stal/service/types/ResponseType.java b/STALService/src/main/java/at/gv/egiz/stal/service/types/ResponseType.java index c94bcbe8..e9b732fe 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/service/types/ResponseType.java +++ b/STALService/src/main/java/at/gv/egiz/stal/service/types/ResponseType.java @@ -3,6 +3,7 @@ package at.gv.egiz.stal.service.types; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; @@ -24,6 +25,12 @@ import javax.xml.bind.annotation.XmlType; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "ResponseType") +@XmlSeeAlso({ + ErrorResponseType.class, + InfoboxReadResponseType.class, + SignResponseType.class +// at.buergerkarte.namespaces.cardchannel.ResponseType.class +}) public abstract class ResponseType { diff --git a/STALService/src/main/java/at/gv/egiz/stal/util/STALTranslator.java b/STALService/src/main/java/at/gv/egiz/stal/util/STALTranslator.java index b8681084..6bbd7301 100644 --- a/STALService/src/main/java/at/gv/egiz/stal/util/STALTranslator.java +++ b/STALService/src/main/java/at/gv/egiz/stal/util/STALTranslator.java @@ -16,6 +16,7 @@ import at.gv.egiz.stal.service.types.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.xml.bind.JAXBElement; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -27,9 +28,10 @@ public class STALTranslator { protected static final Log log = LogFactory.getLog(STALTranslator.class); - public static List<STALRequest> translateRequests(List<RequestType> requests) { + public static List<STALRequest> translateRequests(List<JAXBElement<? extends RequestType>> requests) { List<STALRequest> stalRequests = new ArrayList<STALRequest>(requests.size()); - for (RequestType request : requests) { + for (JAXBElement<? extends RequestType> requestElt : requests) { + RequestType request = requestElt.getValue(); if (request instanceof InfoboxReadRequestType) { InfoboxReadRequest stalReq = new InfoboxReadRequest(); stalReq.setDomainIdentifier(((InfoboxReadRequestType) request).getDomainIdentifier()); @@ -51,37 +53,40 @@ public class STALTranslator { return stalRequests; } - public static List<ResponseType> fromSTAL(List<STALResponse> stalResponses) { - List<ResponseType> responses = new ArrayList<ResponseType>(stalResponses.size()); + public static List<JAXBElement<? extends ResponseType>> fromSTAL(List<STALResponse> stalResponses) { + ObjectFactory stalObjFactory = new ObjectFactory(); + List<JAXBElement<? extends ResponseType>> responses = new ArrayList<JAXBElement<? extends ResponseType>>(stalResponses.size()); for (STALResponse stalResp : stalResponses) { if (stalResp instanceof InfoboxReadResponse) { - InfoboxReadResponseType resp = new InfoboxReadResponseType(); + InfoboxReadResponseType resp = stalObjFactory.createInfoboxReadResponseType(); resp.setInfoboxValue(((InfoboxReadResponse) stalResp).getInfoboxValue()); - responses.add(resp); + responses.add(stalObjFactory.createGetNextRequestTypeInfoboxReadResponse(resp)); } else if (stalResp instanceof SignResponse) { - SignResponseType resp = new SignResponseType(); + SignResponseType resp = stalObjFactory.createSignResponseType(); resp.setSignatureValue(((SignResponse) stalResp).getSignatureValue()); - responses.add(resp); + responses.add(stalObjFactory.createGetNextRequestTypeSignResponse(resp)); } else if (stalResp instanceof ErrorResponse) { - ErrorResponseType resp = new ErrorResponseType(); + ErrorResponseType resp = stalObjFactory.createErrorResponseType(); resp.setErrorCode(((ErrorResponse) stalResp).getErrorCode()); resp.setErrorMessage(((ErrorResponse) stalResp).getErrorMessage()); - responses.add(resp); + responses.add(stalObjFactory.createGetNextRequestTypeErrorResponse(resp)); } else { log.error("unknown STAL response type: " + stalResp.getClass()); - ErrorResponseType resp = new ErrorResponseType(); + ErrorResponseType resp = stalObjFactory.createErrorResponseType(); resp.setErrorCode(4000); resp.setErrorMessage("unknown STAL response type: " + stalResp.getClass()); - responses = Collections.singletonList((ResponseType) resp); + responses.clear(); + responses.add(stalObjFactory.createGetNextRequestTypeErrorResponse(resp)); break; } } return responses; } - public static List<STALResponse> toSTAL(List<ResponseType> responses) { + public static List<STALResponse> toSTAL(List<JAXBElement<? extends ResponseType>> responses) { List<STALResponse> stalResponses = new ArrayList<STALResponse>(responses.size()); - for (ResponseType resp : responses) { + for (JAXBElement<? extends ResponseType> respElt : responses) { + ResponseType resp = respElt.getValue(); if (resp instanceof InfoboxReadResponseType) { InfoboxReadResponse stalResp = new InfoboxReadResponse(); stalResp.setInfoboxValue(((InfoboxReadResponseType) resp).getInfoboxValue()); diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml index 586ab493..2ecd3f12 100644 --- a/bkucommon/pom.xml +++ b/bkucommon/pom.xml @@ -19,8 +19,8 @@ </dependency> <dependency> <groupId>at.gv.egiz</groupId> - <artifactId>STAL</artifactId> - <version>1.0.2</version> + <artifactId>STALExt</artifactId> + <version>1.0.1</version> </dependency> <dependency> <groupId>commons-logging</groupId> @@ -57,6 +57,11 @@ <artifactId>iaik_pki</artifactId> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> <plugins> diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java index ed4b9bda..61d3d7a5 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/accesscontroller/AuthenticationClassifier.java @@ -65,7 +65,8 @@ public class AuthenticationClassifier { } catch (CertificateParsingException e) {
log.error(e);
}
- if (cert.getExtensionValue("1.2.40.0.10.1.1.1") != null) {
+ if ((cert.getExtensionValue("1.2.40.0.10.1.1.1") != null)
+ || (cert.getExtensionValue("1.2.40.0.10.1.1.2") != null)) {
return true;
}
return false;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java index 9757f7cc..5b061850 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/BindingProcessorManagerImpl.java @@ -49,9 +49,10 @@ public class BindingProcessorManagerImpl implements BindingProcessorManager { private static Log log = LogFactory.getLog(BindingProcessorManagerImpl.class); + protected STALFactory stalFactory; + protected SLCommandInvoker commandInvokerClass; + private RemovalStrategy removalStrategy; - private STALFactory stalFactory; - private SLCommandInvoker commandInvokerClass; private ExecutorService executorService; private Map<Id, ProcessingContext> contextMap = Collections.synchronizedMap(new HashMap<Id, ProcessingContext>()); // private Map<Id, MapEntityWrapper> bindingProcessorMap = Collections diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java index d462ac60..2e2cc38a 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrl.java @@ -20,6 +20,9 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Properties; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSocketFactory; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -32,7 +35,10 @@ import at.gv.egiz.bku.slexceptions.SLRuntimeException; public class DataUrl {
private static DataUrlConnectionSPI defaultDataUrlConnection = new DataUrlConnectionImpl();
private static Log log = LogFactory.getLog(DataUrl.class); - private static Properties configuration;
+ private static Properties configuration; + private static SSLSocketFactory sslSocketFactory;
+ private static HostnameVerifier hostNameVerifier; + private URL url;
@@ -44,7 +50,10 @@ public class DataUrl { if (dataUrlConnection == null) {
throw new NullPointerException("Default dataurlconnection must not be set to null");
}
- defaultDataUrlConnection = dataUrlConnection;
+ defaultDataUrlConnection = dataUrlConnection; + defaultDataUrlConnection.setConfiguration(configuration); + defaultDataUrlConnection.setSSLSocketFactory(sslSocketFactory); + defaultDataUrlConnection.setHostnameVerifier(hostNameVerifier);
}
public DataUrl(String aUrlString) throws MalformedURLException {
@@ -65,5 +74,16 @@ public class DataUrl { public static void setConfiguration(Properties props) { configuration = props; - }
+ defaultDataUrlConnection.setConfiguration(configuration); + } + + public static void setSSLSocketFactory(SSLSocketFactory socketFactory) { + sslSocketFactory = socketFactory; + defaultDataUrlConnection.setSSLSocketFactory(socketFactory); + } + + public static void setHostNameVerifier(HostnameVerifier hostNameVerifier) { + DataUrl.hostNameVerifier = hostNameVerifier; + defaultDataUrlConnection.setHostnameVerifier(hostNameVerifier); + }
}
\ No newline at end of file diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java index 6ad0bb78..57d89c89 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java @@ -31,7 +31,9 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLSocketFactory; import org.apache.commons.httpclient.methods.multipart.FilePart; import org.apache.commons.httpclient.methods.multipart.Part; @@ -51,11 +53,12 @@ import at.gv.egiz.bku.utils.binding.Protocol; * */ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { - + private final static Log log = LogFactory.getLog(DataUrlConnectionImpl.class); public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP, Protocol.HTTPS }; + protected X509Certificate serverCertificate; protected Protocol protocol; protected URL url; @@ -64,6 +67,8 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { protected ArrayList<Part> formParams; protected String boundary; protected Properties config = null; + protected SSLSocketFactory sslSocketFactory; + protected HostnameVerifier hostnameVerifier; protected DataUrlResponse result; @@ -84,6 +89,22 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { */ public void connect() throws SocketTimeoutException, IOException { connection = (HttpURLConnection) url.openConnection(); + if (connection instanceof HttpsURLConnection) { + log.trace("Detected ssl connection"); + HttpsURLConnection https = (HttpsURLConnection) connection; + if (sslSocketFactory != null) { + log.debug("Setting custom ssl socket factory for ssl connection"); + https.setSSLSocketFactory(sslSocketFactory); + } else { + log.trace("No custom socket factory set"); + } + if (hostnameVerifier != null) { + log.debug("Setting custom hostname verifier"); + https.setHostnameVerifier(hostnameVerifier); + } + } else { + log.trace("No secure connection with: "+url+ " class="+connection.getClass()); + } connection.setDoOutput(true); Set<String> headers = requestHttpHeaders.keySet(); Iterator<String> headerIt = headers.iterator(); @@ -91,13 +112,13 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { String name = headerIt.next(); connection.setRequestProperty(name, requestHttpHeaders.get(name)); } - log.trace("Connecting to: "+url); + log.trace("Connecting to: " + url); connection.connect(); if (connection instanceof HttpsURLConnection) { HttpsURLConnection ssl = (HttpsURLConnection) connection; X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates(); if ((certs != null) && (certs.length >= 1)) { - log.trace("Server certificate: "+certs[0]); + log.trace("Server certificate: " + certs[0]); serverCertificate = certs[0]; } } @@ -155,8 +176,9 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { } catch (IOException iox) { log.info(iox); } - log.trace("Reading response");
- result = new DataUrlResponse(url.toString(), connection.getResponseCode(), is); + log.trace("Reading response"); + result = new DataUrlResponse(url.toString(), connection.getResponseCode(), + is); Map<String, String> responseHttpHeaders = new HashMap<String, String>(); Map<String, List<String>> httpHeaders = connection.getHeaderFields(); for (Iterator<String> keyIt = httpHeaders.keySet().iterator(); keyIt @@ -227,6 +249,7 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { public DataUrlConnectionSPI newInstance() { DataUrlConnectionSPI uc = new DataUrlConnectionImpl(); uc.setConfiguration(config); + uc.setSSLSocketFactory(sslSocketFactory); return uc; } @@ -239,4 +262,14 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { public void setConfiguration(Properties config) { this.config = config; } + + @Override + public void setSSLSocketFactory(SSLSocketFactory socketFactory) { + this.sslSocketFactory = socketFactory; + } + + @Override + public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { + this.hostnameVerifier = hostnameVerifier; + } }
\ No newline at end of file diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java index 80cc3a0b..f838b919 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionSPI.java @@ -18,6 +18,9 @@ package at.gv.egiz.bku.binding; import java.net.URL;
import java.util.Properties; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSocketFactory; /**
* Prototype of a DataurlconnectionSPI
@@ -43,7 +46,19 @@ public interface DataUrlConnectionSPI extends DataUrlConnection { * Sets configuration parameters for this connection * @param config */ - public void setConfiguration(Properties config);
+ public void setConfiguration(Properties config); + + /** + * Sets the socketfactory to be used for ssl connections. + * @param socketFactory if null the socket factory will not be set explicitly + */ + public void setSSLSocketFactory(SSLSocketFactory socketFactory); + + /** + * Sets the hostname verifier to be used, + * @param hostnameVerifier if null the default hostname verifier will be used + */ + public void setHostnameVerifier(HostnameVerifier hostnameVerifier);
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java index 4a22874c..98b5b775 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java @@ -139,8 +139,8 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements srcContex.setSourceIsDataURL(false); } - //----------------------------------------------------------------------------
- // ----------- BEGIN CONVENIENCE METHODS -----------
+ //---------------------------------------------------------------------------- + // ----------- BEGIN CONVENIENCE METHODS ----------- protected void sendSTALQuit() { log.info("Sending QUIT command to STAL"); @@ -217,24 +217,24 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements } } - //----------------------------------------------------------------------------
- // ----------- END CONVENIENCE METHODS -----------
+ //---------------------------------------------------------------------------- + // ----------- END CONVENIENCE METHODS ----------- - //----------------------------------------------------------------------------
- // -- BEGIN Methods that handle the http binding activities as defined in the
- // activity diagram --
+ //---------------------------------------------------------------------------- + // -- BEGIN Methods that handle the http binding activities as defined in the + // activity diagram -- protected void init() { log.info("Starting Bindingprocessor in Thread: " + Thread.currentThread().getId()); if (bindingProcessorError != null) { log.debug("Detected binding processor error, sending quit command"); - // sendSTALQuit();
+ // sendSTALQuit(); currentState = State.FINISHED; } else if (slCommand == null) { log.error("SLCommand not set (consumeRequest not called ??)"); bindingProcessorError = new SLException(2000); - // sendSTALQuit();
+ // sendSTALQuit(); currentState = State.FINISHED; } else { currentState = State.PROCESS; @@ -270,7 +270,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements DataUrl dataUrl = new DataUrl(getDataUrl()); DataUrlConnection conn = dataUrl.openConnection(); - // set transfer headers
+ // set transfer headers for (FormParameter fp : getTransferHeaders()) { String paramString = getFormParameterAsString(fp); if (paramString == null) { @@ -288,7 +288,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements } } - // set transfer form parameters
+ // set transfer form parameters for (FormParameter fp : getTransferForms()) { String contentTransferEncoding = null; String contentType = fp.getFormParameterContentType(); @@ -311,18 +311,18 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements contentTransferEncoding); } - // connect
+ // connect conn.connect(); - // fetch and set SL result
+ // fetch and set SL result targetContext.setTargetIsDataURL(true); targetContext.setTargetCertificate(conn.getServerCertificate()); targetContext.setTargetUrl(conn.getUrl()); SLResult result = commandInvoker.getResult(targetContext); - // transfer result
+ // transfer result conn.transmit(result); - // process Dataurl response
+ // process Dataurl response dataUrlResponse = conn.getResponse(); log.debug("Received data url response code: " + dataUrlResponse.getResponseCode()); @@ -335,7 +335,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements if ((contentType.startsWith(HttpUtil.APPLICATION_URL_ENCODED)) || (contentType.startsWith(HttpUtil.MULTIPART_FOTMDATA))) { log.debug("Detected SL Request in dataurl response"); - // process headers and request
+ // process headers and request setHTTPHeaders(dataUrlResponse.getResponseHeaders()); consumeRequestStream(dataUrlResponse.getStream()); closeDataUrlConnection(); @@ -363,7 +363,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements srcContex.setSourceIsDataURL(true); srcContex.setSourceUrl(conn.getUrl()); currentState = State.PROCESS; - // just to be complete, actually not used
+ // just to be complete, actually not used srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders() .get(HttpUtil.HTTP_HEADER_REFERER)); } else { @@ -390,7 +390,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements .error("Did not get a location header for a 307 data url response"); throw new SLBindingException(2003); } - // consumeRequestStream(dataUrlResponse.getStream());
+ // consumeRequestStream(dataUrlResponse.getStream()); FormParameterStore fp = new FormParameterStore(); fp.init(location.getBytes(HttpUtil.DEFAULT_CHARSET), FixedFormParameters.DATAURL, null, null); @@ -403,7 +403,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements srcContex.setSourceIsDataURL(true); srcContex.setSourceUrl(conn.getUrl()); currentState = State.PROCESS; - // just to be complete, actually not used
+ // just to be complete, actually not used srcContex.setSourceHTTPReferer(dataUrlResponse.getResponseHeaders() .get(HttpUtil.HTTP_HEADER_REFERER)); @@ -427,7 +427,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements break; default: - // issue error
+ // issue error log.info("Unexpected response code from dataurl server: " + dataUrlResponse.getResponseCode()); throw new SLBindingException(2007); @@ -499,9 +499,9 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements finished = true; } - // -- END Methods that handle the http binding activities as defined in the
- // activity diagram --
- //----------------------------------------------------------------------------
+ // -- END Methods that handle the http binding activities as defined in the + // activity diagram -- + //---------------------------------------------------------------------------- /** * Sets the headers of the SL Request. IMPORTANT: make sure to set all headers @@ -512,7 +512,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements */ public void setHTTPHeaders(Map<String, String> aHeaderMap) { headerMap = new HashMap<String, String>(); - // ensure lowercase keys
+ // ensure lowercase keys if (aHeaderMap != null) { for (String s : aHeaderMap.keySet()) { if (s != null) { @@ -673,7 +673,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements FormParameterStore fps = new FormParameterStore(); fps.init(fp); if (!fps.isEmpty()) { - log.debug("Setting from parameter: " + fps.getFormParameterName()); + log.debug("Setting form parameter: " + fps.getFormParameterName()); formParameterMap.put(fps.getFormParameterName(), fps); } } @@ -683,7 +683,7 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements } if (is.read() != -1) { log.error("Request input stream not completely read"); - // consume rest of stream, should never occur
+ // consume rest of stream, should never occur throw new SLRuntimeException( "request input stream not consumed till end"); } @@ -761,15 +761,15 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements transformer.transform(new StreamSource(isr), new StreamResult(osw)); } catch (TransformerException e) { log.fatal("Exception occured during result transformation", e); - // bindingProcessorError = new SLException(2008);
- // handleBindingProcessorError(os, encoding, null);
+ // bindingProcessorError = new SLException(2008); + // handleBindingProcessorError(os, encoding, null); return; } } osw.flush(); isr.close(); } else if (slResult == null) { - // result not yet assigned -> must be a cancel
+ // result not yet assigned -> must be a cancel bindingProcessorError = new SLException(6001); handleBindingProcessorError(os, encoding, templates); return; diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java new file mode 100644 index 00000000..452c45e5 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/LegacyDataUrlConnectionImpl.java @@ -0,0 +1,257 @@ +package at.gv.egiz.bku.binding; + + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.net.URLEncoder; +import java.security.cert.X509Certificate; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLSocketFactory; +import javax.xml.transform.stream.StreamResult; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.gv.egiz.bku.slcommands.SLResult; +import at.gv.egiz.bku.slcommands.SLResult.SLResultType; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.bku.utils.binding.Protocol; + +/** + * not thread-safe thus newInsance always returns a new object + * + */ +public class LegacyDataUrlConnectionImpl implements DataUrlConnectionSPI { + + private final static Log log = LogFactory.getLog(DataUrlConnectionImpl.class); + + public final static Protocol[] SUPPORTED_PROTOCOLS = { Protocol.HTTP, + Protocol.HTTPS }; + protected X509Certificate serverCertificate; + protected Protocol protocol; + protected URL url; + private HttpURLConnection connection; + protected Map<String, String> requestHttpHeaders; + protected Map<String, String> formParams; + protected String boundary; + protected Properties config = null; + protected SSLSocketFactory sslSocketFactory; + protected HostnameVerifier hostnameVerifier; + + protected DataUrlResponse result; + + public String getProtocol() { + if (protocol == null) { + return null; + } + return protocol.toString(); + } + + /** + * opens a connection sets the headers gets the server certificate + * + * @throws java.net.SocketTimeoutException + * @throws java.io.IOException + * @pre url != null + * @pre httpHeaders != null + */ + public void connect() throws SocketTimeoutException, IOException { + connection = (HttpURLConnection) url.openConnection(); + if (connection instanceof HttpsURLConnection) { + HttpsURLConnection https = (HttpsURLConnection) connection; + if (sslSocketFactory != null) { + log.debug("Setting custom ssl socket factory for ssl connection"); + https.setSSLSocketFactory(sslSocketFactory); + } + if (hostnameVerifier != null) { + log.debug("Setting custom hostname verifier"); + https.setHostnameVerifier(hostnameVerifier); + } + } + connection.setDoOutput(true); + Set<String> headers = requestHttpHeaders.keySet(); + Iterator<String> headerIt = headers.iterator(); + while (headerIt.hasNext()) { + String name = headerIt.next(); + connection.setRequestProperty(name, requestHttpHeaders.get(name)); + } + log.trace("Connecting to: "+url); + connection.connect(); + if (connection instanceof HttpsURLConnection) { + HttpsURLConnection ssl = (HttpsURLConnection) connection; + X509Certificate[] certs = (X509Certificate[]) ssl.getServerCertificates(); + if ((certs != null) && (certs.length >= 1)) { + log.trace("Server certificate: "+certs[0]); + serverCertificate = certs[0]; + } + } + } + + public X509Certificate getServerCertificate() { + return serverCertificate; + } + + public void setHTTPHeader(String name, String value) { + if (name != null && value != null) { + requestHttpHeaders.put(name, value); + } + } + + public void setHTTPFormParameter(String name, InputStream data, + String contentType, String charSet, String transferEncoding) { + StringBuilder sb = new StringBuilder(); + try { + InputStreamReader reader = new InputStreamReader(data, (charSet != null) ? charSet : "UTF-8"); + char[] c = new char[512]; + for (int l; (l = reader.read(c)) != -1;) { + sb.append(c, 0, l); + } + } catch (IOException e) { + throw new SLRuntimeException("Failed to set HTTP form parameter.", e); + } + formParams.put(name, sb.toString()); + } + + /** + * send all formParameters + * + * @throws java.io.IOException + */ + public void transmit(SLResult slResult) throws IOException { + StringWriter writer = new StringWriter(); + slResult.writeTo(new StreamResult(writer)); + formParams.put( + (slResult.getResultType() == SLResultType.XML) + ? DataUrlConnection.FORMPARAM_XMLRESPONSE + : DataUrlConnection.FORMPARAM_BINARYRESPONSE, + writer.toString()); + + OutputStream os = connection.getOutputStream(); + OutputStreamWriter streamWriter = new OutputStreamWriter(os, HttpUtil.DEFAULT_CHARSET); + + log.trace("Sending data"); + Iterator<String> keys = formParams.keySet().iterator(); + while(keys.hasNext()) { + String key = keys.next(); + streamWriter.write(URLEncoder.encode(key, "UTF-8")); + streamWriter.write("="); + streamWriter.write(URLEncoder.encode(formParams.get(key), "UTF-8")); + if (keys.hasNext()) { + streamWriter.write("&"); + } + } + streamWriter.flush(); + os.close(); + + // MultipartRequestEntity PostMethod + InputStream is = null; + try { + is = connection.getInputStream(); + } catch (IOException iox) { + log.info(iox); + } + log.trace("Reading response");
+ result = new DataUrlResponse(url.toString(), connection.getResponseCode(), is); + Map<String, String> responseHttpHeaders = new HashMap<String, String>(); + Map<String, List<String>> httpHeaders = connection.getHeaderFields(); + for (Iterator<String> keyIt = httpHeaders.keySet().iterator(); keyIt + .hasNext();) { + String key = keyIt.next(); + StringBuffer value = new StringBuffer(); + for (String val : httpHeaders.get(key)) { + value.append(val); + value.append(HttpUtil.SEPERATOR[0]); + } + String valString = value.substring(0, value.length() - 1); + if ((key != null) && (value.length() > 0)) { + responseHttpHeaders.put(key, valString); + } + } + result.setResponseHttpHeaders(responseHttpHeaders); + } + + @Override + public DataUrlResponse getResponse() throws IOException { + return result; + } + + /** + * inits protocol, url, httpHeaders, formParams + * + * @param url + * must not be null + */ + @Override + public void init(URL url) { + + for (int i = 0; i < SUPPORTED_PROTOCOLS.length; i++) { + if (SUPPORTED_PROTOCOLS[i].toString().equalsIgnoreCase(url.getProtocol())) { + protocol = SUPPORTED_PROTOCOLS[i]; + break; + } + } + if (protocol == null) { + throw new SLRuntimeException("Protocol " + url.getProtocol() + + " not supported for data url"); + } + this.url = url; + requestHttpHeaders = new HashMap<String, String>(); + if ((config != null) + && (config.getProperty(USER_AGENT_PROPERTY_KEY) != null)) { + requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, config + .getProperty(USER_AGENT_PROPERTY_KEY)); + } else { + requestHttpHeaders + .put(HttpUtil.HTTP_HEADER_USER_AGENT, DEFAULT_USERAGENT); + + } + requestHttpHeaders.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, + HttpUtil.APPLICATION_URL_ENCODED); + + formParams = new HashMap<String, String>(); + } + + @Override + public DataUrlConnectionSPI newInstance() { + DataUrlConnectionSPI uc = new LegacyDataUrlConnectionImpl(); + uc.setConfiguration(config); + uc.setSSLSocketFactory(sslSocketFactory); + uc.setHostnameVerifier(hostnameVerifier); + return uc; + } + + @Override + public URL getUrl() { + return url; + } + + @Override + public void setConfiguration(Properties config) { + this.config = config; + } + + @Override + public void setSSLSocketFactory(SSLSocketFactory socketFactory) { + this.sslSocketFactory = socketFactory; + } + + @Override + public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { + this.hostnameVerifier = hostnameVerifier; + } +}
\ No newline at end of file diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java index ae7f01eb..913259f6 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/ProcessingContext.java @@ -1,6 +1,18 @@ /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package at.gv.egiz.bku.binding; @@ -8,32 +20,40 @@ package at.gv.egiz.bku.binding; import java.util.Hashtable; import java.util.Map; import java.util.concurrent.Future; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** - * BindingContext? - * RequestBindingContext? - * - * @author clemens + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> */ public class ProcessingContext { public static final String BINDING_PROCESSOR = "binding.processor"; public static final String FUTURE = "future"; - + + protected static final Log log = LogFactory.getLog(ProcessingContext.class); + protected Map<String, Object> properties = new Hashtable<String, Object>(); public ProcessingContext(BindingProcessor bp, Future future) { properties.put(BINDING_PROCESSOR, bp); properties.put(FUTURE, future); } - - - + public BindingProcessor getBindingProcessor() { return (BindingProcessor) properties.get(BINDING_PROCESSOR); } - + public Future getFuture() { - return (Future) properties.get(FUTURE); + return (Future) properties.get(FUTURE); + } + + public Object get(String key) { + return properties.get(key); + } + + public void put(String key, Object value) { + properties.put(key, value); } } diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java index 9ed99190..733b47dc 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java @@ -14,6 +14,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Security;
+import java.security.Provider.Service;
import java.security.cert.CertStore;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
@@ -24,6 +25,7 @@ import java.util.ArrayList; import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@@ -80,7 +82,7 @@ public abstract class Configurator { log.error("Cannot add trusted ca", e);
}
}
- return caCerts.toArray(new X509Certificate[caCerts.size()]);
+ return caCerts.toArray(new X509Certificate[caCerts.size()]);
} else {
log.warn("No CA certificates configured");
}
@@ -150,9 +152,21 @@ public abstract class Configurator { log.debug("Registering security providers");
Security.insertProviderAt(new IAIK(), 1);
Security.insertProviderAt(new ECCProvider(false), 2);
- Security.addProvider(new STALProvider());
- XSecProvider.addAsProvider(false);
+
+ // registering STALProvider as delegation provider for XSECT
+ STALProvider stalProvider = new STALProvider();
+ Set<Service> services = stalProvider.getServices();
StringBuilder sb = new StringBuilder();
+ for (Service service : services) {
+ String algorithm = service.getType() + "." + service.getAlgorithm();
+ XSecProvider.setDelegationProvider(algorithm, stalProvider.getName());
+ sb.append("\n" + algorithm);
+ }
+ log.debug("Registered STALProvider as XSecProvider delegation provider for the following services : " + sb.toString());
+
+ Security.addProvider(stalProvider);
+ XSecProvider.addAsProvider(false);
+ sb = new StringBuilder();
sb.append("Registered providers: ");
int i = 1;
for (Provider prov : Security.getProviders()) {
@@ -187,28 +201,28 @@ public abstract class Configurator { }
public void configureVersion() {
- Properties p = new Properties();
- try {
- InputStream is = getManifest();
- if (is != null) {
- p.load(getManifest());
- String version = p.getProperty("Implementation-Build");
- properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
- "citizen-card-environment/1.2 MOCCA " + version);
- DataUrl.setConfiguration(properties);
- log
- .debug("Setting user agent to: "
- + properties
- .getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
- } else {
- log.warn("Cannot read manifest");
- properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
- "citizen-card-environment/1.2 MOCCA UNKNOWN");
- DataUrl.setConfiguration(properties);
+ if (properties.getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY) == null) {
+ Properties p = new Properties();
+ try {
+ InputStream is = getManifest();
+ if (is != null) {
+ p.load(getManifest());
+ String version = p.getProperty("Implementation-Build");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
+ "citizen-card-environment/1.2 MOCCA " + version);
+ log.debug("Setting user agent to: "
+ + properties
+ .getProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY));
+ } else {
+ log.warn("Cannot read manifest");
+ properties.setProperty(DataUrlConnection.USER_AGENT_PROPERTY_KEY,
+ "citizen-card-environment/1.2 MOCCA UNKNOWN");
+ }
+ } catch (IOException e) {
+ log.error(e);
}
- } catch (IOException e) {
- log.error(e);
}
+ DataUrl.setConfiguration(properties);
}
public void configure() {
@@ -255,7 +269,7 @@ public abstract class Configurator { getCertDir(), getCADir(), caCerts);
sslCtx.init(km, new TrustManager[] { pkixTM }, null);
}
- HttpsURLConnection.setDefaultSSLSocketFactory(sslCtx.getSocketFactory());
+ DataUrl.setSSLSocketFactory(sslCtx.getSocketFactory());
} catch (Exception e) {
log.error("Cannot configure SSL", e);
}
@@ -263,7 +277,7 @@ public abstract class Configurator { log.warn("---------------------------------");
log.warn(" Disabling Hostname Verification ");
log.warn("---------------------------------");
- HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+ DataUrl.setHostNameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
@@ -272,8 +286,6 @@ public abstract class Configurator { }
}
-
-
public void setCertValidator(CertValidator certValidator) {
this.certValidator = certValidator;
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateCommand.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateCommand.java new file mode 100644 index 00000000..c2974785 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateCommand.java @@ -0,0 +1,23 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands; + +public interface InfoboxUpdateCommand extends SLCommand { + + public String getInfoboxIdentifier(); + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateResult.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateResult.java new file mode 100644 index 00000000..d180facf --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/InfoboxUpdateResult.java @@ -0,0 +1,21 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands; + +public interface InfoboxUpdateResult extends SLResult { + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java index e13b29a1..bec2b253 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java @@ -16,40 +16,40 @@ */ package at.gv.egiz.bku.slcommands;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.UnmarshalException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl;
-import at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl;
-import at.gv.egiz.bku.slcommands.impl.NullOperationCommandImpl;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLExceptionMessages;
-import at.gv.egiz.bku.slexceptions.SLRequestException;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.slbinding.RedirectEventFilter;
-import at.gv.egiz.slbinding.RedirectUnmarshallerListener;
+import java.io.IOException; +import java.io.Reader; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.UnmarshalException; +import javax.xml.bind.Unmarshaller; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import at.buergerkarte.namespaces.cardchannel.ObjectFactory; +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLExceptionMessages; +import at.gv.egiz.bku.slexceptions.SLRequestException; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.bku.utils.DebugReader; +import at.gv.egiz.slbinding.RedirectEventFilter; +import at.gv.egiz.slbinding.RedirectUnmarshallerListener; public class SLCommandFactory {
@@ -72,29 +72,30 @@ public class SLCommandFactory { /**
* Schema for Security Layer command validation.
*/
- private static Schema slSchema;
+ private Schema slSchema;
/**
* The JAXBContext.
*/
- private static JAXBContext jaxbContext;
+ private JAXBContext jaxbContext;
/**
* The map of <namespaceURI>:<localName> to implementation class of the
* corresponding {@link SLCommand}.
*/
- private static Map<String, Class<? extends SLCommand>> slRequestTypeMap = new HashMap<String, Class<? extends SLCommand>>();
-
-
- static {
-
- // TODO: implement dynamic registration
-
- // register all known implementation classes
- putImplClass(SLCommand.NAMESPACE_URI, "NullOperationRequest",
- NullOperationCommandImpl.class);
- putImplClass(SLCommand.NAMESPACE_URI, "InfoboxReadRequest",
- InfoboxReadCommandImpl.class);
- putImplClass(SLCommand.NAMESPACE_URI, "CreateXMLSignatureRequest",
- CreateXMLSignatureCommandImpl.class);
+ private Map<String, Class<? extends SLCommand>> slRequestTypeMap = new HashMap<String, Class<? extends SLCommand>>();
+ + /** + * Configures the singleton instance with command implementations + * @param commandImplMap + * @throws ClassNotFoundException + */ + @SuppressWarnings("unchecked") + public void setCommandImpl(Map<String, String> commandImplMap) throws ClassNotFoundException { + ClassLoader cl = getClass().getClassLoader(); + for (String key : commandImplMap.keySet()) { + Class<? extends SLCommand> impl = (Class<? extends SLCommand>) cl.loadClass(commandImplMap.get(key)); + log.debug("Registering sl command implementation for :"+key+ "; implementation class: "+impl.getCanonicalName()); + slRequestTypeMap.put(key, impl); + } }
/**
@@ -110,7 +111,7 @@ public class SLCommandFactory { * the implementation class, or <code>null</code> to deregister a
* currently registered class
*/
- public static void putImplClass(String namespaceUri, String localname,
+ public void setImplClass(String namespaceUri, String localname,
Class<? extends SLCommand> slCommandClass) {
if (slCommandClass != null) {
slRequestTypeMap.put(namespaceUri + ":" + localname, slCommandClass);
@@ -128,7 +129,7 @@ public class SLCommandFactory { * @return the implementation class, or <code>null</code> if no class is
* registered for the given <code>name</code>
*/
- public static Class<? extends SLCommand> getImplClass(QName name) {
+ public Class<? extends SLCommand> getImplClass(QName name) {
String namespaceURI = name.getNamespaceURI();
String localPart = name.getLocalPart();
return slRequestTypeMap.get(namespaceURI + ":" + localPart);
@@ -139,14 +140,14 @@ public class SLCommandFactory { *
* @param slSchema the schema to validate Security Layer commands with
*/
- public static void setSLSchema(Schema slSchema) {
- SLCommandFactory.slSchema = slSchema;
+ public void setSLSchema(Schema slSchema) {
+ this.slSchema = slSchema;
}
/**
* @return the jaxbContext
*/
- public static JAXBContext getJaxbContext() {
+ public JAXBContext getJaxbContext() {
ensureJaxbContext();
return jaxbContext;
}
@@ -154,19 +155,20 @@ public class SLCommandFactory { /**
* @param jaxbContext the jaxbContext to set
*/
- public static void setJaxbContext(JAXBContext jaxbContext) {
- SLCommandFactory.jaxbContext = jaxbContext;
+ public void setJaxbContext(JAXBContext jaxbContext) {
+ this.jaxbContext = jaxbContext;
}
/**
* Initialize the JAXBContext.
*/
- private synchronized static void ensureJaxbContext() {
+ private synchronized void ensureJaxbContext() {
if (jaxbContext == null) {
try {
String slPkg = at.buergerkarte.namespaces.securitylayer._1.ObjectFactory.class.getPackage().getName();
- String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName();
- setJaxbContext(JAXBContext.newInstance(slPkg + ":" + xmldsigPkg));
+ String xmldsigPkg = org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName(); + String cardChannelPkg = at.buergerkarte.namespaces.cardchannel.ObjectFactory.class.getPackage().getName(); + setJaxbContext(JAXBContext.newInstance(slPkg + ":" + xmldsigPkg + ":" + cardChannelPkg));
} catch (JAXBException e) {
log.error("Failed to setup JAXBContext security layer request.", e);
throw new SLRuntimeException(e);
@@ -177,7 +179,7 @@ public class SLCommandFactory { /**
* Initialize the security layer schema.
*/
- private synchronized static void ensureSchema() {
+ private synchronized void ensureSchema() {
if (slSchema == null) {
try {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -194,7 +196,7 @@ public class SLCommandFactory { }
Schema schema = schemaFactory.newSchema(sources);
log.debug("Schema successfully created.");
- SLCommandFactory.setSLSchema(schema);
+ setSLSchema(schema);
} catch (SAXException e) {
log.error("Failed to load security layer schema.", e);
throw new SLRuntimeException("Failed to load security layer schema.", e);
@@ -211,9 +213,9 @@ public class SLCommandFactory { */
public synchronized static SLCommandFactory getInstance() {
if (instance == null) {
- ensureJaxbContext();
- ensureSchema();
- instance = new SLCommandFactory();
+ instance = new SLCommandFactory();
+ instance.ensureJaxbContext();
+ instance.ensureSchema();
}
return instance;
}
@@ -327,12 +329,31 @@ public class SLCommandFactory { */
@SuppressWarnings("unchecked")
public SLCommand createSLCommand(Source source, SLCommandContext context)
- throws SLCommandException, SLRuntimeException, SLRequestException {
+ throws SLCommandException, SLRuntimeException, SLRequestException { + + DebugReader dr = null; + if (log.isTraceEnabled() && source instanceof StreamSource) { + StreamSource streamSource = (StreamSource) source; + if (streamSource.getReader() != null) { + dr = new DebugReader(streamSource.getReader(), "SLCommand unmarshalled from:\n"); + streamSource.setReader(dr); + } + }
- Object object = unmarshal(source);
+ Object object; + try { + object = unmarshal(source); + } catch (SLRequestException e) { + throw e; + } finally { + if (dr != null) { + log.trace(dr.getCachedString()); + } + } + if (!(object instanceof JAXBElement)) {
// invalid request
- log.info("Invalid security layer request. " + object.toString());
+ log.info("Invalid security layer request. " + object.toString()); throw new SLRequestException(3002, SLExceptionMessages.EC3002_INVALID,
new Object[]{object.toString()});
}
@@ -345,7 +366,9 @@ public class SLCommandFactory { throw new SLCommandException(4011,
SLExceptionMessages.EC4011_NOTIMPLEMENTED, new Object[]{qName.toString()});
}
-
+ + +
// try to instantiate
SLCommand slCommand;
try {
@@ -362,6 +385,7 @@ public class SLCommandFactory { e);
throw new SLRuntimeException(e);
}
+ slCommand.init(context, (JAXBElement) object);
return slCommand;
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java new file mode 100644 index 00000000..e7f96c06 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractAssocArrayInfobox.java @@ -0,0 +1,304 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package at.gv.egiz.bku.slcommands.impl; + +import java.io.ByteArrayOutputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.buergerkarte.namespaces.securitylayer._1.InfoboxAssocArrayPairType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType; +import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory; +import at.buergerkarte.namespaces.securitylayer._1.XMLContentType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadKeys; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadPairs; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadValue; +import at.gv.egiz.bku.slcommands.InfoboxReadResult; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slcommands.SLCommandFactory; +import at.gv.egiz.bku.slexceptions.SLCommandException; + +/** + * An abstract base class for {@link Infobox} implementations of type associative array. + * + * @author mcentner + */ +public abstract class AbstractAssocArrayInfobox extends AbstractInfoboxImpl + implements AssocArrayInfobox { + + /** + * Logging facility. + */ + private static Log log = LogFactory.getLog(AbstractAssocArrayInfobox.class); + + /** + * The search string pattern. + */ + public static final String SEARCH_STRING_PATTERN = "(.&&[^/])+(/.&&[^/])*"; + + /** + * @return the keys available in this infobox. + */ + public abstract String[] getKeys(); + + /** + * @return <code>true</code> if the values are XML entities, or <code>false</code> otherwise. + */ + public abstract boolean isValuesAreXMLEntities(); + + /** + * Returns a key to value mapping for the given <code>keys</code>. + * + * @param keys a list of keys + * @param cmdCtx the command context + * + * @return a key to value mapping for the given <code>keys</code>. + * + * @throws SLCommandException if obtaining the values fails + */ + public abstract Map<String, Object> getValues(List<String> keys, SLCommandContext cmdCtx) throws SLCommandException; + + /** + * Returns all keys that match the given <code>searchString</code>. + * + * @param searchString the search string + * + * @return all keys that match the given <code>searchString</code> + * + * @throws SLCommandException if the given search string is invalid + */ + protected List<String> selectKeys(String searchString) throws SLCommandException { + + if ("*".equals(searchString) || "**".equals(searchString)) { + return Arrays.asList(getKeys()); + } + + if (!searchString.contains("*")) { + Arrays.asList(getKeys()).contains(searchString); + return Collections.singletonList(searchString); + } + + if (Pattern.matches(SEARCH_STRING_PATTERN, searchString)) { + +// for (int i = 0; i < searchString.length(); i++) { +// int codePoint = searchString.codePointAt(i); +// +// } + + // TODO : build pattern + return Collections.emptyList(); + } else { + log.info("Got invalid search string '" + searchString + "'"); + throw new SLCommandException(4010); + } + + } + + /** + * Read all keys specified by <code>readKeys</code>. + * + * @param readKeys + * the ReadKeys element + * @param cmdCtx + * the command context + * @return a corresponding InfoboxReadResult + * + * @throws SLCommandException + * if the ReadKeys element is invalid or obtaining the corresponding + * values fails + */ + protected InfoboxReadResult readKeys(ReadKeys readKeys, SLCommandContext cmdCtx) throws SLCommandException { + + List<String> selectedKeys = selectKeys(readKeys.getSearchString()); + + if (readKeys.isUserMakesUnique() && selectedKeys.size() > 1) { + log.info("UserMakesUnique not supported"); + // TODO: give more specific error message + throw new SLCommandException(4010); + } + + ObjectFactory objectFactory = new ObjectFactory(); + + InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory + .createInfoboxReadDataAssocArrayType(); + + List<String> keys = infoboxReadDataAssocArrayType.getKey(); + keys.addAll(selectedKeys); + + return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType); + + } + + /** + * Read all pairs specified by <code>readPairs</code>. + * + * @param readPairs + * the readPairs element + * @param cmdCtx + * the command context + * @return a corresponding InfoboxReadResult + * + * @throws SLCommandException + * if the ReadPairs element is invalid or obtaining the corresponding + * values fails + */ + protected InfoboxReadResult readPairs(ReadPairs readPairs, SLCommandContext cmdCtx) throws SLCommandException { + + if (readPairs.isValuesAreXMLEntities() && !isValuesAreXMLEntities()) { + log.info("Got valuesAreXMLEntities=" + readPairs.isValuesAreXMLEntities() + " but infobox type is binary."); + throw new SLCommandException(4010); + } + + List<String> selectedKeys = selectKeys(readPairs.getSearchString()); + + if (readPairs.isUserMakesUnique() && selectedKeys.size() > 1) { + log.info("UserMakesUnique not supported"); + // TODO: give more specific error message + throw new SLCommandException(4010); + } + + return new InfoboxReadResultImpl(marshallPairs(selectedKeys, getValues( + selectedKeys, cmdCtx), readPairs.isValuesAreXMLEntities())); + } + + /** + * Read the value specified by <code>readPairs</code>. + * + * @param readValue + * the readValue element + * @param cmdCtx + * the command context + * @return a corresponding InfoboxReadResult + * + * @throws SLCommandException + * if the ReadValue element is invalid or obtaining the corresponding + * values fails + */ + protected InfoboxReadResult readValue(ReadValue readValue, SLCommandContext cmdCtx) throws SLCommandException { + + if (readValue.isValueIsXMLEntity() && !isValuesAreXMLEntities()) { + log.info("Got valuesAreXMLEntities=" + readValue.isValueIsXMLEntity() + " but infobox type is binary."); + throw new SLCommandException(4010); + } + + List<String> selectedKeys; + + if (Arrays.asList(getKeys()).contains(readValue.getKey())) { + selectedKeys = Collections.singletonList(readValue.getKey()); + } else { + selectedKeys = Collections.emptyList(); + } + + return new InfoboxReadResultImpl(marshallPairs(selectedKeys, getValues( + selectedKeys, cmdCtx), readValue.isValueIsXMLEntity())); + + } + + protected InfoboxReadDataAssocArrayType marshallPairs(List<String> selectedKeys, Map<String, Object> values, boolean areXMLEntities) throws SLCommandException { + + ObjectFactory objectFactory = new ObjectFactory(); + + InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory.createInfoboxReadDataAssocArrayType(); + + for (String key : selectedKeys) { + InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType(); + infoboxAssocArrayPairType.setKey(key); + + Object value = values.get(key); + if (areXMLEntities) { + if (value instanceof byte[]) { + log.info("Got valuesAreXMLEntities=" + areXMLEntities + " but infobox type is binary."); + throw new SLCommandException(4122); + } else { + XMLContentType contentType = objectFactory.createXMLContentType(); + contentType.getContent().add(value); + infoboxAssocArrayPairType.setXMLContent(contentType); + } + } else { + infoboxAssocArrayPairType.setBase64Content((value instanceof byte[]) ? (byte[]) value : marshallValue(value)); + } + + infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType); + } + + return infoboxReadDataAssocArrayType; + + } + + protected byte[] marshallValue(Object jaxbElement) throws SLCommandException { + SLCommandFactory commandFactory = SLCommandFactory.getInstance(); + JAXBContext jaxbContext = commandFactory.getJaxbContext(); + + ByteArrayOutputStream result; + try { + Marshaller marshaller = jaxbContext.createMarshaller(); + + result = new ByteArrayOutputStream(); + marshaller.marshal(jaxbElement, result); + } catch (JAXBException e) { + log.info("Failed to marshall infobox content.", e); + throw new SLCommandException(4122); + } + + return result.toByteArray(); + + } + + @Override + public InfoboxReadResult read(InfoboxReadRequestType req, + SLCommandContext cmdCtx) throws SLCommandException { + + InfoboxReadParamsAssocArrayType assocArrayParameters = req + .getAssocArrayParameters(); + + if (assocArrayParameters == null) { + log.info("Infobox type is AssocArray but got no AssocArrayParameters."); + throw new SLCommandException(4010); + } + + if (assocArrayParameters.getReadKeys() != null) { + return readKeys(assocArrayParameters.getReadKeys(), cmdCtx); + } + + if (assocArrayParameters.getReadPairs() != null) { + return readPairs(assocArrayParameters.getReadPairs(), cmdCtx); + } + + // ReadValue + if (assocArrayParameters.getReadValue() != null) { + return readValue(assocArrayParameters.getReadValue(), cmdCtx); + } + + log + .info("Infobox type is AssocArray but got invalid AssocArrayParameters."); + throw new SLCommandException(4010); + + } + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java new file mode 100644 index 00000000..23394bd5 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractBinaryFileInfobox.java @@ -0,0 +1,66 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType; + +/** + * An abstract base class for {@link Infobox} implementations of type binary file. + * + * @author mcentner + */ +public abstract class AbstractBinaryFileInfobox extends AbstractInfoboxImpl implements BinaryFileInfobox { + + /** + * Logging facility. + */ + private static Log log = LogFactory.getLog(AbstractBinaryFileInfobox.class); + + /** + * Is this infobox' content an XML entity? + */ + protected boolean isXMLEntity = false; + + /** + * @return <code>true</code> if this infobox' content is an XML entity or <code>false</code> otherwise. + */ + public boolean isXMLEntity() { + return isXMLEntity; + } + + /** + * Sets the value returned by {@link #isXMLEntity()} according to the given + * <code>request</code>. + * + * @param request the InfoboxReadRequest + */ + public void setIsXMLEntity(InfoboxReadRequestType request) { + + InfoboxReadParamsBinaryFileType binaryFileParameters = request.getBinaryFileParameters(); + if (binaryFileParameters != null) { + isXMLEntity = binaryFileParameters.isContentIsXMLEntity(); + log.debug("Got ContentIsXMLEntity=" + isXMLEntity + "."); + } + + } + + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java new file mode 100644 index 00000000..8a7edb71 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxCommandImpl.java @@ -0,0 +1,64 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; + +/** + * An abstract base class for implementations of security layer infobox requests. + * + * @author mcentner + * + * @param <T> + */ +public abstract class AbstractInfoboxCommandImpl<T> extends SLCommandImpl<T> { + + /** + * The infobox implementation. + */ + protected Infobox infobox; + + @Override + public void init(SLCommandContext ctx, Object request) + throws SLCommandException { + super.init(ctx, request); + + String infoboxIdentifier = getInfoboxIdentifier(getRequestValue()); + + infobox = InfoboxFactory.getInstance().createInfobox(infoboxIdentifier); + } + + /** + * Returns the infobox identifier given in <code>request</code>. + * + * @param request the request value + * + * @return the infobox identifier givne in <code>request</code> + */ + protected abstract String getInfoboxIdentifier(T request); + + + public String getInfoboxIdentifier() { + if (infobox != null) { + return infobox.getIdentifier(); + } else { + return null; + } + } + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java new file mode 100644 index 00000000..564cb8ff --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AbstractInfoboxImpl.java @@ -0,0 +1,45 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package at.gv.egiz.bku.slcommands.impl; + +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType; +import at.gv.egiz.bku.slcommands.InfoboxReadResult; +import at.gv.egiz.bku.slcommands.InfoboxUpdateResult; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; + +/** + * An abstract base class for {@link Infobox} implementations. + * + * @author mcentner + */ +public abstract class AbstractInfoboxImpl implements Infobox { + + @Override + public InfoboxReadResult read(InfoboxReadRequestType request, + SLCommandContext cmdCtx) throws SLCommandException { + throw new SLCommandException(4011); + } + + @Override + public InfoboxUpdateResult update(InfoboxUpdateRequestType request, + SLCommandContext cmdCtx) throws SLCommandException { + throw new SLCommandException(4011); + } + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AssocArrayInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AssocArrayInfobox.java new file mode 100644 index 00000000..908d95da --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/AssocArrayInfobox.java @@ -0,0 +1,27 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package at.gv.egiz.bku.slcommands.impl; + +/** + * An {@link Infobox} of type associative array as defined in Security Layer + * 1.2. + * + * @author mcentner + */ +public interface AssocArrayInfobox extends Infobox { + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/BinaryFileInfobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/BinaryFileInfobox.java new file mode 100644 index 00000000..c27f9446 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/BinaryFileInfobox.java @@ -0,0 +1,27 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +/** + * An {@link Infobox} of type binary file as defined in Security Layer + * 1.2. + * + * @author mcentner + */ +public interface BinaryFileInfobox extends Infobox { + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CardChannelInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CardChannelInfoboxImpl.java new file mode 100644 index 00000000..4b1cc779 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CardChannelInfoboxImpl.java @@ -0,0 +1,235 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.WeakHashMap; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.buergerkarte.namespaces.cardchannel.ATRType; +import at.buergerkarte.namespaces.cardchannel.CommandAPDUType; +import at.buergerkarte.namespaces.cardchannel.ObjectFactory; +import at.buergerkarte.namespaces.cardchannel.ResetType; +import at.buergerkarte.namespaces.cardchannel.ResponseAPDUType; +import at.buergerkarte.namespaces.cardchannel.ResponseType; +import at.buergerkarte.namespaces.cardchannel.ScriptType; +import at.buergerkarte.namespaces.cardchannel.VerifyAPDUType; +import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType; +import at.buergerkarte.namespaces.securitylayer._1.XMLContentType; +import at.gv.egiz.bku.slcommands.InfoboxReadResult; +import at.gv.egiz.bku.slcommands.InfoboxUpdateResult; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.ext.APDUScriptRequest; +import at.gv.egiz.stal.ext.APDUScriptResponse; +import at.gv.egiz.stal.ext.APDUScriptRequest.RequestScriptElement; +import at.gv.egiz.stal.ext.APDUScriptResponse.ResponseScriptElement; + +public class CardChannelInfoboxImpl extends AbstractBinaryFileInfobox { + + private static Log log = LogFactory.getLog(CardChannelInfoboxImpl.class); + + private static WeakHashMap<STAL, JAXBElement<ResponseType>> scriptResults = new WeakHashMap<STAL, JAXBElement<ResponseType>>(); + + private static JAXBContext jaxbContext; + + static { + try { + jaxbContext = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName()); + } catch (JAXBException e) { + throw new SLRuntimeException("Failed to initalize CardChannel infobox.", e); + } + } + + public CardChannelInfoboxImpl() { + isXMLEntity = true; + } + + @Override + public String getIdentifier() { + return "CardChannel"; + } + + @Override + public InfoboxReadResult read(InfoboxReadRequestType request, + SLCommandContext cmdCtx) throws SLCommandException { + + at.buergerkarte.namespaces.securitylayer._1.ObjectFactory objectFactory + = new at.buergerkarte.namespaces.securitylayer._1.ObjectFactory(); + + Base64XMLContentType content = objectFactory.createBase64XMLContentType(); + XMLContentType xmlContent = objectFactory.createXMLContentType(); + content.setXMLContent(xmlContent); + + JAXBElement<ResponseType> response = scriptResults.get(cmdCtx.getSTAL()); + if (response != null) { + xmlContent.getContent().add(response); + } + + return new InfoboxReadResultImpl(content); + + } + + @SuppressWarnings("unchecked") + @Override + public InfoboxUpdateResult update(InfoboxUpdateRequestType request, + SLCommandContext cmdCtx) throws SLCommandException { + + Base64XMLContentType binaryFileParameters = request.getBinaryFileParameters(); + + if (binaryFileParameters.getBase64Content() != null) { + log.info("Got Base64Content but ContentIsXMLEntity is true."); + throw new SLCommandException(4010); + } + + XMLContentType content = binaryFileParameters.getXMLContent(); + if (content instanceof at.gv.egiz.slbinding.impl.XMLContentType) { + + ByteArrayOutputStream redirectedStream = ((at.gv.egiz.slbinding.impl.XMLContentType) content).getRedirectedStream(); + if (redirectedStream != null) { + + if (log.isDebugEnabled()) { + + StringBuilder sb = new StringBuilder(); + sb.append("CardChannel script:\n"); + try { + sb.append(new String(redirectedStream.toByteArray(), "UTF-8")); + } catch (UnsupportedEncodingException e) { + sb.append(e.getMessage()); + } + log.debug(sb.toString()); + } + + Object object; + try { + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + object = unmarshaller.unmarshal(new ByteArrayInputStream(redirectedStream.toByteArray())); + } catch (JAXBException e) { + log.info("Failed to parse CardChannel script.", e); + throw new SLCommandException(4011); + } + + if (object instanceof JAXBElement) { + executeCardChannelScript(((JAXBElement<ScriptType>) object).getValue(), cmdCtx); + return new InfoboxUpdateResultImpl(); + } + + } + + + } + log.info("Infobox identifier is '" + getIdentifier() + "' but XMLContent does not contain 'Script'."); + throw new SLCommandException(4010); + + } + + protected void executeCardChannelScript(ScriptType script, + SLCommandContext cmdCtx) throws SLCommandException { + + List<Object> resetOrCommandAPDUOrVerifyAPDU = script.getResetOrCommandAPDUOrVerifyAPDU(); + List<RequestScriptElement> requestScript = new ArrayList<RequestScriptElement>(); + + for (Object element : resetOrCommandAPDUOrVerifyAPDU) { + + if (element instanceof ResetType) { + + requestScript.add(new APDUScriptRequest.Reset()); + + } else if (element instanceof CommandAPDUType) { + + CommandAPDUType commandAPDU = (CommandAPDUType) element; + int sequence = (commandAPDU.getSequence() != null) + ? commandAPDU.getSequence().intValue() + : 0; + + requestScript.add( + new APDUScriptRequest.Command( + sequence, + commandAPDU.getValue(), + commandAPDU.getExpectedSW())); + + } else if (element instanceof VerifyAPDUType) { + log.warn("CardChannel script command 'VerifyAPDU' not implemented."); + throw new SLCommandException(4011); + } + } + + APDUScriptRequest scriptRequest = new APDUScriptRequest(requestScript); + + STAL stal = cmdCtx.getSTAL(); + STALHelper helper = new STALHelper(stal); + + helper.transmitSTALRequest(Collections.singletonList(scriptRequest)); + + List<ResponseScriptElement> responseScript = ((APDUScriptResponse) helper + .nextResponse(APDUScriptResponse.class)).getScript(); + + ObjectFactory objectFactory = new ObjectFactory(); + + ResponseType responseType = objectFactory.createResponseType(); + + + for (ResponseScriptElement element : responseScript) { + + if (element instanceof APDUScriptResponse.ATR) { + + byte[] atr = ((APDUScriptResponse.ATR) element).getAtr(); + + ATRType atrType = objectFactory.createATRType(); + atrType.setValue(atr); + atrType.setRc(BigInteger.ZERO); + responseType.getATROrResponseAPDU().add(atrType); + + } else if (element instanceof APDUScriptResponse.Response) { + + APDUScriptResponse.Response response = (APDUScriptResponse.Response) element; + + ResponseAPDUType responseAPDUType = objectFactory.createResponseAPDUType(); + responseAPDUType.setSequence(BigInteger.valueOf(response.getSequence())); +// if (response.getRc() != 0) { + responseAPDUType.setRc(BigInteger.valueOf(response.getRc())); +// } + responseAPDUType.setSw(response.getSw()); + responseAPDUType.setValue(response.getApdu()); + + responseType.getATROrResponseAPDU().add(responseAPDUType); + } + + } + + scriptResults.put(stal, objectFactory.createResponse(responseType)); + } + + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CertificatesInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CertificatesInfoboxImpl.java new file mode 100644 index 00000000..0208f137 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CertificatesInfoboxImpl.java @@ -0,0 +1,112 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import java.security.cert.CertificateEncodingException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.stal.InfoboxReadRequest; +import at.gv.egiz.stal.STALRequest; + +/** + * An implementation of the {@link Infobox} <em>Certificates</em> as + * specified in Security Layer 1.2. + * + * @author mcentner + */ +public class CertificatesInfoboxImpl extends AbstractAssocArrayInfobox { + + /** + * Logging facility. + */ + private static Log log = LogFactory.getLog(CertificatesInfoboxImpl.class); + + /** + * The valid keys. + */ + public static final String[] CERTIFICATES_KEYS = new String[] { + "SecureSignatureKeypair", + "CertifiedKeypair" }; + + @Override + public String getIdentifier() { + return "Certificates"; + } + + @Override + public String[] getKeys() { + return CERTIFICATES_KEYS; + } + + @Override + public boolean isValuesAreXMLEntities() { + return false; + } + + @Override + public Map<String, Object> getValues(List<String> certificates, SLCommandContext cmdCtx) throws SLCommandException { + + STALHelper stalHelper = new STALHelper(cmdCtx.getSTAL()); + + if (certificates != null && !certificates.isEmpty()) { + + List<STALRequest> stalRequests = new ArrayList<STALRequest>(); + + // get certificates + InfoboxReadRequest infoboxReadRequest; + for (int i = 0; i < certificates.size(); i++) { + infoboxReadRequest = new InfoboxReadRequest(); + infoboxReadRequest.setInfoboxIdentifier(certificates.get(i)); + stalRequests.add(infoboxReadRequest); + } + + stalHelper.transmitSTALRequest(stalRequests); + + List<X509Certificate> x509Certs = stalHelper.getCertificatesFromResponses(); + + Map<String, Object> values = new HashMap<String, Object>(); + + for (int i = 0; i < certificates.size(); i++) { + try { + values.put(certificates.get(i), x509Certs.get(i).getEncoded()); + } catch (CertificateEncodingException e) { + log.error("Failed to encode certificate.", e); + throw new SLCommandException(4000); + } + } + + return values; + + } else { + + return new HashMap<String, Object>(); + + } + + + } + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java index b2e3b303..01686641 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureCommandImpl.java @@ -16,13 +16,11 @@ */ package at.gv.egiz.bku.slcommands.impl; -import java.io.ByteArrayInputStream; import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Collections; import java.util.Date; +import java.util.List; import javax.xml.crypto.MarshalException; import javax.xml.crypto.URIReferenceException; @@ -48,11 +46,8 @@ import at.gv.egiz.bku.slexceptions.SLException; import at.gv.egiz.bku.slexceptions.SLRequestException; import at.gv.egiz.bku.slexceptions.SLViewerException; import at.gv.egiz.dom.DOMUtils; -import at.gv.egiz.stal.ErrorResponse; import at.gv.egiz.stal.InfoboxReadRequest; -import at.gv.egiz.stal.InfoboxReadResponse; import at.gv.egiz.stal.STALRequest; -import at.gv.egiz.stal.STALResponse; /** * This class implements the security layer command @@ -147,33 +142,13 @@ public class CreateXMLSignatureCommandImpl extends InfoboxReadRequest stalRequest = new InfoboxReadRequest(); stalRequest.setInfoboxIdentifier(keyboxIdentifier); - requestSTAL(Collections.singletonList((STALRequest) stalRequest)); - - STALResponse stalResponse = stalResponses.next(); - - if (stalResponse instanceof InfoboxReadResponse) { - byte[] infobox = ((InfoboxReadResponse) stalResponse).getInfoboxValue(); - - try { - CertificateFactory certFactory = CertificateFactory.getInstance("X509"); - signingCertificate = (X509Certificate) certFactory - .generateCertificate(new ByteArrayInputStream(infobox)); - } catch (CertificateException e) { - log.info("Failed to decode signing certificate.", e); - // TODO: issue appropriate error
- throw new SLCommandException(4000); - } - - } else if (stalResponse instanceof ErrorResponse) { - ErrorResponse err = (ErrorResponse) stalResponse; - log.info("Received an error response from STAL with code: " - + err.getErrorCode()); - throw new SLCommandException(err.getErrorCode()); - - } else { - log.info("Failed to get signing certificate."); + stalHelper.transmitSTALRequest(Collections.singletonList((STALRequest) stalRequest)); + List<X509Certificate> certificates = stalHelper.getCertificatesFromResponses(); + if (certificates == null || certificates.size() != 1) { + log.info("Got an unexpected number of certificates from STAL."); throw new SLCommandException(4000); } + signingCertificate = certificates.get(0); } diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java index 092a13c4..4969c85a 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureResultImpl.java @@ -84,7 +84,7 @@ public class CreateXMLSignatureResultImpl extends SLResultImpl { DocumentFragment fragment = doc.createDocumentFragment();
- JAXBContext jaxbContext = SLCommandFactory.getJaxbContext();
+ JAXBContext jaxbContext = SLCommandFactory.getInstance().getJaxbContext();
try {
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.marshal(createCreateXMLSignatureResponse, fragment);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java new file mode 100644 index 00000000..20d20c9d --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java @@ -0,0 +1,291 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Result; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType; +import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType; +import at.gv.egiz.bku.slcommands.InfoboxReadResult; +import at.gv.egiz.bku.slcommands.SLCommand; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLExceptionMessages; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.idlink.CompressedIdentityLinkFactory; +import at.gv.egiz.idlink.IdentityLinkTransformer; +import at.gv.egiz.idlink.ans1.IdentityLink; +import at.gv.egiz.stal.InfoboxReadRequest; +import at.gv.egiz.stal.STALRequest; + +/** + * An implementation of the {@link Infobox} <em>IdentityLink</em> as + * specified in Security Layer 1.2 + * + * @author mcentner + */ +public class IdentityLinkInfoboxImpl extends AbstractBinaryFileInfobox { + + /** + * Logging facility. + */ + private static Log log = LogFactory.getLog(IdentityLinkInfoboxImpl.class); + + /** + * The box specific parameter <code>IdentityLinkDomainIdentifier</code>. + */ + public static final String BOX_SPECIFIC_PARAMETER_IDENTITY_LINK_DOMAIN_IDENTIFIER = "IdentityLinkDomainIdentifier"; + + /** + * The value of the box specific parameter <code>IdentityLinkDomainIdentifier</code>. + */ + private String domainIdentifier; + + @Override + public String getIdentifier() { + return "IdentityLink"; + } + + /** + * @return the value of the box specific parameter <code>IdentityLinkDomainIdentifier</code> + */ + public String getDomainIdentifier() { + return domainIdentifier; + } + + @Override + public InfoboxReadResult read(InfoboxReadRequestType req, SLCommandContext cmdCtx) throws SLCommandException { + + AnyChildrenType boxSpecificParameters = req.getBoxSpecificParameters(); + + if (boxSpecificParameters != null) { + // check BoxSpecificParameters + List<Object> parameter = boxSpecificParameters.getAny(); + JAXBElement<?> element; + if (parameter != null + && parameter.size() == 1 + && parameter.get(0) instanceof JAXBElement<?> + && SLCommand.NAMESPACE_URI.equals((element = (JAXBElement<?>) parameter.get(0)).getName().getNamespaceURI()) + && BOX_SPECIFIC_PARAMETER_IDENTITY_LINK_DOMAIN_IDENTIFIER.equals(element.getName().getLocalPart()) + && element.getValue() instanceof String) { + domainIdentifier = (String) element.getValue(); + log.debug("Got sl:IdentityLinkDomainIdentifier: " + domainIdentifier); + } else { + log.info("Got invalid BoxSpecificParameters."); + throw new SLCommandException(4010); + } + } + + setIsXMLEntity(req); + + STALHelper stalHelper = new STALHelper(cmdCtx.getSTAL()); + + List<STALRequest> stalRequests = new ArrayList<STALRequest>(); + + InfoboxReadRequest infoboxReadRequest; + // get raw identity link + infoboxReadRequest = new InfoboxReadRequest(); + infoboxReadRequest.setInfoboxIdentifier(getIdentifier()); + infoboxReadRequest.setDomainIdentifier(domainIdentifier); + stalRequests.add(infoboxReadRequest); + + // get certificates + infoboxReadRequest = new InfoboxReadRequest(); + infoboxReadRequest.setInfoboxIdentifier("SecureSignatureKeypair"); + stalRequests.add(infoboxReadRequest); + infoboxReadRequest = new InfoboxReadRequest(); + infoboxReadRequest.setInfoboxIdentifier("CertifiedKeypair"); + stalRequests.add(infoboxReadRequest); + + stalHelper.transmitSTALRequest(stalRequests); + log.trace("Got STAL response"); + + IdentityLink identityLink = stalHelper.getIdentityLinkFromResponses(); + List<X509Certificate> certificates = stalHelper.getCertificatesFromResponses(); + + + CompressedIdentityLinkFactory idLinkFactory = CompressedIdentityLinkFactory.getInstance(); + JAXBElement<CompressedIdentityLinkType> compressedIdentityLink = idLinkFactory + .createCompressedIdentityLink(identityLink, certificates, getDomainIdentifier()); + + IdentityLinkTransformer identityLinkTransformer = IdentityLinkTransformer.getInstance(); + String issuerTemplate = identityLink.getIssuerTemplate(); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db; + try { + db = dbf.newDocumentBuilder(); + } catch (ParserConfigurationException e) { + log.error("Failed to create XML document.", e); + throw new SLRuntimeException(e); + } + + Document document = db.newDocument(); + try { + idLinkFactory.marshallCompressedIdentityLink(compressedIdentityLink, document, null, true); + } catch (JAXBException e) { + log.info("Failed to marshall CompressedIdentityLink.", e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID, + new Object[] { getIdentifier() }); + } + + InfoboxReadResultFileImpl result = new InfoboxReadResultFileImpl(); + ByteArrayOutputStream resultBytes = null; + Result xmlResult = (isXMLEntity() || getDomainIdentifier() != null) + ? result.getXmlResult(true) + : new StreamResult((resultBytes = new ByteArrayOutputStream())); + try { + log.trace("Trying to transform identitylink"); + identityLinkTransformer.transformIdLink(issuerTemplate, new DOMSource(document), xmlResult); + } catch (MalformedURLException e) { + log.warn("Malformed issuer template URL '" + issuerTemplate + "'."); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } catch (IOException e) { + log.warn("Failed to dereferene issuer template URL '" + issuerTemplate + "'." ,e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } catch (TransformerConfigurationException e) { + log.warn("Failed to create transformation template from issuer template URL '" + issuerTemplate + "'", e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } catch (TransformerException e) { + log.info("Faild to transform CompressedIdentityLink.", e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } + + // TODO: Report BUG in IssuerTemplates + // Some IssuerTemplate stylesheets do not consider the pr:Type-Element of the CompressedIdentityLink ... + if (getDomainIdentifier() != null) { + if (xmlResult instanceof DOMResult) { + Node node = ((DOMResult) xmlResult).getNode(); + Node nextSibling = ((DOMResult) xmlResult).getNextSibling(); + Node idLinkNode; + if (nextSibling != null) { + idLinkNode = nextSibling.getPreviousSibling(); + } else if (node != null) { + idLinkNode = node.getFirstChild(); + } else { + log + .error("An IdentityLinkDomainIdentifier of '" + + getDomainIdentifier() + + "' has been given. However, it cannot be set, as the transformation result does not contain a node."); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } + IdentityLinkTransformer.setDomainIdentifier(idLinkNode, getDomainIdentifier()); + } else { + log + .error("An IdentityLinkDomainIdentifier of '" + + getDomainIdentifier() + + "' has been given. However, it cannot be set, as the transformation result is not of type DOM."); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } + } + + if (!isXMLEntity()) { + if (resultBytes == null) { + resultBytes = new ByteArrayOutputStream(); + + if (xmlResult instanceof DOMResult) { + Node node = ((DOMResult) xmlResult).getNode(); + Node nextSibling = ((DOMResult) xmlResult).getNextSibling(); + + DOMSource xmlSource; + if (nextSibling != null) { + xmlSource = new DOMSource(nextSibling.getPreviousSibling()); + } else if (node != null) { + xmlSource = new DOMSource(node.getFirstChild()); + } else { + log + .error("IssuerTemplate transformation returned no node."); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + try { + Transformer transformer = transformerFactory.newTransformer(); + transformer.transform(xmlSource, new StreamResult(resultBytes)); + } catch (TransformerConfigurationException e) { + log.error(e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } catch (TransformerException e) { + log.error(e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } + } else if (xmlResult instanceof StreamResult) { + OutputStream outputStream = ((StreamResult) xmlResult).getOutputStream(); + if (outputStream instanceof ByteArrayOutputStream) { + result.setResultBytes(((ByteArrayOutputStream) outputStream).toByteArray()); + } else { + log.error("ContentIsXMLEntity is set to 'false'. However, an XMLResult has already been set."); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, + new Object[] { issuerTemplate }); + } + } + } else { + result.setResultBytes(resultBytes.toByteArray()); + } + } + + return result; + + } + + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java new file mode 100644 index 00000000..99d62721 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/Infobox.java @@ -0,0 +1,70 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package at.gv.egiz.bku.slcommands.impl; + +import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType; +import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType; +import at.gv.egiz.bku.slcommands.InfoboxReadResult; +import at.gv.egiz.bku.slcommands.InfoboxUpdateResult; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; + +/** + * An implementation of this interface represents a infobox as defined in + * Security-Layer 1.2. + * + * @author mcentner + */ +public interface Infobox { + + /** + * @return the identifier of this infobox + */ + public String getIdentifier(); + + /** + * Read data from this infobox. + * + * @param request + * the InfoboxReadRequest + * @param cmdCtx + * the command context + * + * @return the data read from this infobox as InfoboxReadResult + * + * @throws SLCommandException + * + * if reading from this infobox fails + */ + public InfoboxReadResult read(InfoboxReadRequestType request, + SLCommandContext cmdCtx) throws SLCommandException; + + /** + * Update data in this infobox. + * + * @param request + * the InfoboxUpdateRequest + * @param cmdCtx + * the command context + * @return a corresponding InfoboxUpdateResult + * @throws SLCommandException + * if updating this infobox fails + */ + public InfoboxUpdateResult update(InfoboxUpdateRequestType request, + SLCommandContext cmdCtx) throws SLCommandException; + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxFactory.java new file mode 100644 index 00000000..e9736f6d --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxFactory.java @@ -0,0 +1,151 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLExceptionMessages; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; + +/** + * A factory for creating {@link Infobox}es. + * + * @author mcentner + */ +public class InfoboxFactory { + + /** + * Logging facility. + */ + private static Log log = LogFactory.getLog(InfoboxFactory.class); + + /** + * The singleton instance of this InfoboxFactory. + */ + private static InfoboxFactory instance; + + /** + * @return an instance of this InfoboxFactory + */ + public synchronized static InfoboxFactory getInstance() { + if (instance == null) { + instance = new InfoboxFactory(); + } + return instance; + } + + /** + * The mapping of infobox identifier to implementation class. + */ + private HashMap<String, Class<? extends Infobox>> implementations; + + /** + * Private constructor. + */ + private InfoboxFactory() { + } + + /** + * Sets the mapping of infobox identifier to implementation class name. + * + * @param infoboxImplMap + * a mapping of infobox identifiers to implementation class names + * + * @throws ClassNotFoundException + * if implementation class is not an instance of {@link Infobox} + */ + @SuppressWarnings("unchecked") + public void setInfoboxImpl(Map<String, String> infoboxImplMap) throws ClassNotFoundException { + HashMap<String, Class<? extends Infobox>> implMap = new HashMap<String, Class<? extends Infobox>>(); + ClassLoader cl = getClass().getClassLoader(); + for (String key : infoboxImplMap.keySet()) { + Class<? extends Infobox> impl = (Class<? extends Infobox>) cl.loadClass(infoboxImplMap.get(key)); + log.debug("Registering infobox '" + key + "' implementation '" + impl.getCanonicalName() + "'."); + implMap.put(key, impl); + } + implementations = implMap; + } + + /** + * Returns the configured implementation class for the given + * <code>infoboxIdentifier</code>. + * + * @param infoboxIdentifier + * the infobox identifier + * + * @return the implementation class for the given infobox identifier or + * <code>null</code> if there is no implementation class configured + */ + public Class<? extends Infobox> getImplClass(String infoboxIdentifier) { + if (implementations != null) { + return implementations.get(infoboxIdentifier); + } else { + return null; + } + } + + /** + * Create a new {@link Infobox} instance for the given + * <code>infoboxIdentifier</code>. + * + * @param infoboxIdentifier + * the infobox identifier + * + * @return an {@link Infobox} implementation for the given infobox identifier + * + * @throws SLCommandException + * if there is no implementation for the given infobox identifier + * @throws SLRuntimeException + * if creating an {@link Infobox} instance fails + */ + public Infobox createInfobox(String infoboxIdentifier) throws SLCommandException, SLRuntimeException { + + Class<? extends Infobox> implClass = getImplClass(infoboxIdentifier); + if (implClass == null) { + // infobox not supported + log.info("Unsupported infobox '" + infoboxIdentifier + "."); + throw new SLCommandException(4002, + SLExceptionMessages.EC4002_INFOBOX_UNKNOWN, + new Object[] { infoboxIdentifier }); + } + + // try to instantiate + Infobox infobox; + try { + infobox = implClass.newInstance(); + log.debug("Infobox '" + infobox.getIdentifier() + "' created."); + } catch (InstantiationException e) { + // unexpected error + log.error("Failed to instantiate infobox implementation.", e); + throw new SLRuntimeException(e); + } catch (IllegalAccessException e) { + // unexpected error + log.error("Failed to instantiate infobox implementation.", e); + throw new SLRuntimeException(e); + } + + return infobox; + + } + + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java index c7bb5205..693f444f 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadCommandImpl.java @@ -16,67 +16,14 @@ */ package at.gv.egiz.bku.slcommands.impl;
-import iaik.asn1.CodingException; -import iaik.asn1.DerCoder; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.regex.Pattern; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Result; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import at.buergerkarte.namespaces.personenbindung._20020506_.CompressedIdentityLinkType; -import at.buergerkarte.namespaces.securitylayer._1.AnyChildrenType; -import at.buergerkarte.namespaces.securitylayer._1.InfoboxAssocArrayPairType; -import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType; -import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType; -import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsBinaryFileType; import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadRequestType; -import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory; -import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadKeys; -import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadPairs; -import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadParamsAssocArrayType.ReadValue; import at.gv.egiz.bku.slcommands.InfoboxReadCommand; -import at.gv.egiz.bku.slcommands.SLCommand; import at.gv.egiz.bku.slcommands.SLCommandContext; import at.gv.egiz.bku.slcommands.SLResult; import at.gv.egiz.bku.slexceptions.SLCommandException; -import at.gv.egiz.bku.slexceptions.SLExceptionMessages; -import at.gv.egiz.bku.slexceptions.SLRuntimeException; -import at.gv.egiz.idlink.CompressedIdentityLinkFactory; -import at.gv.egiz.idlink.IdentityLinkTransformer; -import at.gv.egiz.idlink.ans1.IdentityLink; -import at.gv.egiz.stal.InfoboxReadRequest; -import at.gv.egiz.stal.InfoboxReadResponse; -import at.gv.egiz.stal.STALRequest; /**
* This class implements the security layer command
@@ -88,7 +35,7 @@ import at.gv.egiz.stal.STALRequest; *
* @author mcentner
*/
-public class InfoboxReadCommandImpl extends SLCommandImpl<InfoboxReadRequestType> implements
+public class InfoboxReadCommandImpl extends AbstractInfoboxCommandImpl<InfoboxReadRequestType> implements
InfoboxReadCommand {
/**
@@ -96,511 +43,54 @@ public class InfoboxReadCommandImpl extends SLCommandImpl<InfoboxReadRequestType */
protected static Log log = LogFactory.getLog(InfoboxReadCommandImpl.class); - public static final String SEARCH_STRING_PATTERN = ".&&[^/](/.&&[^/])*";
-
- public static final String INFOBOX_IDENTIFIER_CERTIFICATES = "Certificates"; - - public static final String BOX_SPECIFIC_PARAMETER_IDENTITY_LINK_DOMAIN_IDENTIFIER = "IdentityLinkDomainIdentifier"; - - public static final String INFOBOX_IDENTIFIER_IDENTITY_LINK = "IdentityLink"; - - public static final String[] INFOXBOX_CERTIFICATES_KEYS = new String[] { - "SecureSignatureKeypair", - "CertifiedKeypair" }; - - private static final int ASSOC_ARRAY_READ_KEYS = 1; - - private static final int ASSOC_ARRAY_READ_PAIRS = 2; - - private static final int ASSOC_ARRAY_READ_VALUE = 3;
- - /**
- * The <code>InfoboxIdentifier</code>
- */
- protected String infoboxIdentifier;
-
- /**
- * The <code>IdentityLinkDomainIdentifier</code> value of an <code>IdentyLink</code> infobox.
- */
- protected String identityLinkDomainIdentifier; - - /** - * The list of certificates to be read from an <code>Certificates</code> infobox. - */ - protected List<String> certificates; - - /** - * The result type. - */ - protected int assocArrayResult;
-
- /**
- * Is content XML entity?
- */
- protected boolean isXMLEntity;
-
@Override
public String getName() {
return "InfoboxReadRequest";
}
- /**
- * @return the infoboxIdentifier
- */
- public String getInfoboxIdentifier() {
- return infoboxIdentifier;
- }
-
+ @Override + protected String getInfoboxIdentifier(InfoboxReadRequestType request) { + return request.getInfoboxIdentifier(); + } + @Override
public void init(SLCommandContext ctx, Object request) throws SLCommandException {
super.init(ctx, request);
InfoboxReadRequestType req = getRequestValue();
-
- infoboxIdentifier = req.getInfoboxIdentifier();
-
- if (INFOBOX_IDENTIFIER_IDENTITY_LINK.equals(infoboxIdentifier)) {
-
- if (req.getAssocArrayParameters() != null) {
- log.info("Got AssocArrayParameters but Infobox type is BinaryFile.");
- throw new SLCommandException(4010);
- }
-
- InfoboxReadParamsBinaryFileType binaryFileParameters = req.getBinaryFileParameters(); - if (binaryFileParameters != null) { - isXMLEntity = binaryFileParameters.isContentIsXMLEntity(); - log.debug("Got ContentIsXMLEntity=" + isXMLEntity + "."); - } -
- AnyChildrenType boxSpecificParameters = req.getBoxSpecificParameters();
-
- if (boxSpecificParameters != null) {
- // check BoxSpecificParameters
- List<Object> parameter = boxSpecificParameters.getAny();
- JAXBElement<?> element;
- if (parameter != null
- && parameter.size() == 1
- && parameter.get(0) instanceof JAXBElement<?>
- && SLCommand.NAMESPACE_URI.equals((element = (JAXBElement<?>) parameter.get(0)).getName().getNamespaceURI())
- && BOX_SPECIFIC_PARAMETER_IDENTITY_LINK_DOMAIN_IDENTIFIER.equals(element.getName().getLocalPart())
- && element.getValue() instanceof String) {
- identityLinkDomainIdentifier = (String) element.getValue();
- log.debug("Got sl:IdentityLinkDomainIdentifier: " + identityLinkDomainIdentifier);
- } else {
- log.info("Got invalid BoxSpecificParameters.");
- throw new SLCommandException(4010);
- }
- }
- } else if (INFOBOX_IDENTIFIER_CERTIFICATES.equals(infoboxIdentifier)) { - - if (req.getBinaryFileParameters() != null) { - log.info("Got BinaryFileParameters but Infobox type is AssocArray."); - throw new SLCommandException(4010); - } - - if (req.getBoxSpecificParameters() != null) { - log.info("Got invalid BoxSpecificParameters."); - throw new SLCommandException(4010); - } - - InfoboxReadParamsAssocArrayType assocArrayParameters = req - .getAssocArrayParameters(); - if (assocArrayParameters == null) { - log.info("Infobox type is AssocArray but got no AssocArrayParameters."); - throw new SLCommandException(4010); - } - - // RreadKeys? - if (assocArrayParameters.getReadKeys() != null) { - assocArrayResult = ASSOC_ARRAY_READ_KEYS; - ReadKeys readKeys = assocArrayParameters.getReadKeys(); - certificates = findCertificates(readKeys.getSearchString()); - if (readKeys.isUserMakesUnique() && certificates.size() > 1) { - log.info("UserMakesUnique not supported"); - // TODO: give more specific error message - throw new SLCommandException(4010); - } - } - - // ReadPairs? - if (assocArrayParameters.getReadPairs() != null) { - assocArrayResult = ASSOC_ARRAY_READ_PAIRS; - ReadPairs readPairs = assocArrayParameters.getReadPairs(); - if (readPairs.isValuesAreXMLEntities()) { - log.info("Got valuesAreXMLEntities but infobox type is binary."); - throw new SLCommandException(4010); - } - certificates = findCertificates(readPairs.getSearchString()); - if (readPairs.isUserMakesUnique() && certificates.size() > 1) { - log.info("UserMakesUnique not supported"); - // TODO: give more specific error message - throw new SLCommandException(4010); - } - } - - // ReadValue - if (assocArrayParameters.getReadValue() != null) { - assocArrayResult = ASSOC_ARRAY_READ_VALUE; - ReadValue readValue = assocArrayParameters.getReadValue(); - if (readValue.isValueIsXMLEntity()) { - log.info("Got valuesAreXMLEntities but infobox type is binary."); - throw new SLCommandException(4010); - } - String key = readValue.getKey(); - if (Arrays.asList(INFOXBOX_CERTIFICATES_KEYS).contains(key)) { - certificates = Collections.singletonList(key); - } else { - certificates = Collections.emptyList(); - } - } - - if (assocArrayResult == 0) { - log.info("Infobox type is AssocArray but got invalid AssocArrayParameters."); - throw new SLCommandException(4010); - } -
- } else {
- throw new SLCommandException(4002,
- SLExceptionMessages.EC4002_INFOBOX_UNKNOWN,
- new Object[] { infoboxIdentifier });
- }
+ if (req.getAssocArrayParameters() != null && + !(infobox instanceof AssocArrayInfobox)) { + log.info("Got AssocArrayParameters but Infobox type is not AssocArray."); + throw new SLCommandException(4010); + } + + if (req.getBinaryFileParameters() != null && + !(infobox instanceof BinaryFileInfobox)) { + log.info("Got BinaryFileParameters but Infobox type is not BinaryFile."); + throw new SLCommandException(4010); + } }
@Override
public SLResult execute() { - try {
- if (INFOBOX_IDENTIFIER_IDENTITY_LINK.equals(infoboxIdentifier)) { - return readIdentityLink(); - } else if (INFOBOX_IDENTIFIER_CERTIFICATES.equals(infoboxIdentifier)) { - return readCertificates(); - } else { - throw new SLCommandException(4000); - } - } catch (SLCommandException e) {
- return new ErrorResultImpl(e, cmdCtx.getLocale());
- }
- }
-
- /**
- * Gets the IdentitiyLink form the next STAL response.
- *
- * @return the IdentityLink
- *
- * @throws SLCommandException if getting the IdentitiyLink fails
- */
- private IdentityLink getIdentityLinkFromResponses() throws SLCommandException {
-
- // IdentityLink
- InfoboxReadResponse response;
- if (hasNextResponse()) {
- response = (InfoboxReadResponse) nextResponse(InfoboxReadResponse.class);
- byte[] idLink = response.getInfoboxValue();
- try {
- return new IdentityLink(DerCoder.decode(idLink));
- } catch (CodingException e) {
- log.info("Failed to decode infobox '" + INFOBOX_IDENTIFIER_IDENTITY_LINK + "'.", e);
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID,
- new Object[] { INFOBOX_IDENTIFIER_IDENTITY_LINK });
- }
- } else {
- log.info("No infobox '" + INFOBOX_IDENTIFIER_IDENTITY_LINK + "' returned from STAL.");
- throw new SLCommandException(4000);
- }
-
- }
-
- /**
- * Gets the list of certificates from the next STAL responses.
- *
- * @return the list of certificates
- *
- * @throws SLCommandException if getting the list of certificates fails
- */
- private List<X509Certificate> getCertificatesFromResponses() throws SLCommandException {
-
- List<X509Certificate> certificates = new ArrayList<X509Certificate>();
-
- CertificateFactory certFactory;
- try {
- certFactory = CertificateFactory.getInstance("X509");
- } catch (CertificateException e) {
- // we should always be able to get an X509 certificate factory
- log.error("CertificateFactory.getInstance(\"X509\") failed.", e);
- throw new SLRuntimeException(e);
- }
-
- InfoboxReadResponse response;
- while(hasNextResponse()) {
- response = (InfoboxReadResponse) nextResponse(InfoboxReadResponse.class);
- byte[] cert = response.getInfoboxValue();
- try {
- certificates.add((X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(cert)));
- } catch (CertificateException e) {
- log.info("Failed to decode certificate.", e);
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID,
- new Object[] { INFOBOX_IDENTIFIER_CERTIFICATES });
- }
- }
-
- return certificates;
-
- }
-
- /**
- * Uses STAL to read the IdentityLink.
- *
- * @return the corresponding security layer result
- *
- * @throws SLCommandException if reading the IdentityLink fails
- */
- private SLResult readIdentityLink() throws SLCommandException {
-
- List<STALRequest> stalRequests = new ArrayList<STALRequest>();
-
- InfoboxReadRequest infoboxReadRequest;
- // get raw identity link
- infoboxReadRequest = new InfoboxReadRequest();
- infoboxReadRequest.setInfoboxIdentifier(INFOBOX_IDENTIFIER_IDENTITY_LINK);
- infoboxReadRequest.setDomainIdentifier(identityLinkDomainIdentifier);
- stalRequests.add(infoboxReadRequest);
-
- // get certificates
- infoboxReadRequest = new InfoboxReadRequest();
- infoboxReadRequest.setInfoboxIdentifier("SecureSignatureKeypair");
- stalRequests.add(infoboxReadRequest);
- infoboxReadRequest = new InfoboxReadRequest();
- infoboxReadRequest.setInfoboxIdentifier("CertifiedKeypair");
- stalRequests.add(infoboxReadRequest);
-
- requestSTAL(stalRequests);
- log.trace("Got STAL response");
-
- IdentityLink identityLink = getIdentityLinkFromResponses();
- List<X509Certificate> certificates = getCertificatesFromResponses();
-
-
- CompressedIdentityLinkFactory idLinkFactory = CompressedIdentityLinkFactory.getInstance();
- JAXBElement<CompressedIdentityLinkType> compressedIdentityLink = idLinkFactory
- .createCompressedIdentityLink(identityLink, certificates, identityLinkDomainIdentifier);
-
- IdentityLinkTransformer identityLinkTransformer = IdentityLinkTransformer.getInstance();
- String issuerTemplate = identityLink.getIssuerTemplate();
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db;
- try {
- db = dbf.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- log.error("Failed to create XML document.", e);
- throw new SLRuntimeException(e);
- }
-
- Document document = db.newDocument();
- try {
- idLinkFactory.marshallCompressedIdentityLink(compressedIdentityLink, document, null, true);
- } catch (JAXBException e) {
- log.info("Failed to marshall CompressedIdentityLink.", e);
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID,
- new Object[] { INFOBOX_IDENTIFIER_IDENTITY_LINK });
- }
-
- InfoboxReadResultFileImpl result = new InfoboxReadResultFileImpl();
- ByteArrayOutputStream resultBytes = null;
- Result xmlResult = (isXMLEntity || identityLinkDomainIdentifier != null)
- ? result.getXmlResult(true)
- : new StreamResult((resultBytes = new ByteArrayOutputStream()));
+ try { - log.trace("Trying to transform identitylink");
- identityLinkTransformer.transformIdLink(issuerTemplate, new DOMSource(document), xmlResult); - } catch (MalformedURLException e) { - log.warn("Malformed issuer template URL '" + issuerTemplate + "'."); - throw new SLCommandException(4000, - SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, - new Object[] { issuerTemplate }); - } catch (IOException e) {
- log.warn("Failed to dereferene issuer template URL '" + issuerTemplate + "'." ,e);
- throw new SLCommandException(4000, - SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, - new Object[] { issuerTemplate }); - } catch (TransformerConfigurationException e) { - log.warn("Failed to create transformation template from issuer template URL '" + issuerTemplate + "'", e); - throw new SLCommandException(4000, - SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED, - new Object[] { issuerTemplate }); - } catch (TransformerException e) {
- log.info("Faild to transform CompressedIdentityLink.", e);
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
-
- // TODO: Report BUG in IssuerTemplates
- // Some IssuerTemplate stylesheets do not consider the pr:Type-Element of the CompressedIdentityLink ...
- if (identityLinkDomainIdentifier != null) {
- if (xmlResult instanceof DOMResult) {
- Node node = ((DOMResult) xmlResult).getNode();
- Node nextSibling = ((DOMResult) xmlResult).getNextSibling();
- Node idLinkNode;
- if (nextSibling != null) {
- idLinkNode = nextSibling.getPreviousSibling();
- } else if (node != null) {
- idLinkNode = node.getFirstChild();
- } else {
- log
- .error("An IdentityLinkDomainIdentifier of '"
- + identityLinkDomainIdentifier
- + "' has been given. However, it cannot be set, as the transformation result does not contain a node.");
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
- IdentityLinkTransformer.setDomainIdentifier(idLinkNode, identityLinkDomainIdentifier);
- } else {
- log
- .error("An IdentityLinkDomainIdentifier of '"
- + identityLinkDomainIdentifier
- + "' has been given. However, it cannot be set, as the transformation result is not of type DOM.");
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
- }
-
- if (!isXMLEntity) {
- if (resultBytes == null) {
- resultBytes = new ByteArrayOutputStream();
-
- if (xmlResult instanceof DOMResult) {
- Node node = ((DOMResult) xmlResult).getNode();
- Node nextSibling = ((DOMResult) xmlResult).getNextSibling();
-
- DOMSource xmlSource;
- if (nextSibling != null) {
- xmlSource = new DOMSource(nextSibling.getPreviousSibling());
- } else if (node != null) {
- xmlSource = new DOMSource(node.getFirstChild());
- } else {
- log
- .error("IssuerTemplate transformation returned no node.");
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- try {
- Transformer transformer = transformerFactory.newTransformer();
- transformer.transform(xmlSource, new StreamResult(resultBytes));
- } catch (TransformerConfigurationException e) {
- log.error(e);
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- } catch (TransformerException e) {
- log.error(e);
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
- } else if (xmlResult instanceof StreamResult) {
- OutputStream outputStream = ((StreamResult) xmlResult).getOutputStream();
- if (outputStream instanceof ByteArrayOutputStream) {
- result.setResultBytes(((ByteArrayOutputStream) outputStream).toByteArray());
- } else {
- log.error("ContentIsXMLEntity is set to 'false'. However, an XMLResult has already been set.");
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
- }
- } else {
- result.setResultBytes(resultBytes.toByteArray());
- }
- }
-
-
- return result;
-
- } - - protected List<String> findCertificates(String searchString) throws SLCommandException { - - if ("*".equals(searchString) || "**".equals(searchString)) { - return Arrays.asList(INFOXBOX_CERTIFICATES_KEYS); + return infobox.read(getRequestValue(), getCmdCtx()); + } catch (SLCommandException e) { + return new ErrorResultImpl(e, getCmdCtx().getLocale()); } - if (Pattern.matches(SEARCH_STRING_PATTERN, searchString)) { - -// for (int i = 0; i < searchString.length(); i++) { -// int codePoint = searchString.codePointAt(i); -// -// } - - // TODO : build pattern - return Collections.emptyList(); + }
+
+ @Override + public String getIdentityLinkDomainId() { + if (infobox instanceof IdentityLinkInfoboxImpl) { + return ((IdentityLinkInfoboxImpl) infobox).getDomainIdentifier(); } else { - log.info("Got invalid search string '" + searchString + "'"); - throw new SLCommandException(4010); + return null; } - } - private SLResult readCertificates() throws SLCommandException { - - ObjectFactory objectFactory = new ObjectFactory(); - - InfoboxReadDataAssocArrayType infoboxReadDataAssocArrayType = objectFactory - .createInfoboxReadDataAssocArrayType(); - - if (assocArrayResult == ASSOC_ARRAY_READ_KEYS) { - - List<String> keys = infoboxReadDataAssocArrayType.getKey(); - keys.addAll(certificates); - - } else { - - if (certificates != null && !certificates.isEmpty()) { - - List<STALRequest> stalRequests = new ArrayList<STALRequest>(); - - // get certificates - InfoboxReadRequest infoboxReadRequest; - for (int i = 0; i < certificates.size(); i++) { - infoboxReadRequest = new InfoboxReadRequest(); - infoboxReadRequest.setInfoboxIdentifier(certificates.get(i)); - stalRequests.add(infoboxReadRequest); - } - - requestSTAL(stalRequests); - - List<X509Certificate> x509Certs = getCertificatesFromResponses(); - - for (int i = 0; i < certificates.size(); i++) { - InfoboxAssocArrayPairType infoboxAssocArrayPairType = objectFactory.createInfoboxAssocArrayPairType(); - infoboxAssocArrayPairType.setKey(certificates.get(i)); - try { - infoboxAssocArrayPairType.setBase64Content(x509Certs.get(i).getEncoded()); - } catch (CertificateEncodingException e) { - log.error("Failed to encode certificate.", e); - throw new SLCommandException(4000); - } - infoboxReadDataAssocArrayType.getPair().add(infoboxAssocArrayPairType); - } - - } - - } - - return new InfoboxReadResultImpl(infoboxReadDataAssocArrayType); - - } - - @Override - public String getIdentityLinkDomainId() { - return identityLinkDomainIdentifier; - } }
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java index 6f41b562..d8295227 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java @@ -29,6 +29,7 @@ import javax.xml.transform.dom.DOMResult; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType; @@ -56,7 +57,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements /**
* The XML document containing the infobox content.
*/
- Document xmlDocument;
+ protected Document xmlDocument;
/**
* Creates the response document from the given <code>binaryContent</code>.
@@ -95,7 +96,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements JAXBElement<InfoboxReadResponseType> infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
- JAXBContext context = SLCommandFactory.getJaxbContext();
+ JAXBContext context = SLCommandFactory.getInstance().getJaxbContext();
try {
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(infoboxReadResponse, doc);
@@ -112,22 +113,42 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements /**
* @return an XMLResult for marshalling the infobox to
*/
- Result getXmlResult(boolean preserveSpace) {
+ public Result getXmlResult(boolean preserveSpace) {
xmlDocument = createResponseDocument(null, preserveSpace);
NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
return new DOMResult(nodeList.item(0));
- }
-
+ } + + /** + * Creates a new <code>InfoboxReadResponse</code> document and appends + * the given <code>node</code> as child node of the <code>XMLContent</code> element. + * + * @param node the node to be appended as child node of the <code>XMLContnet</code> element + * @param preserveSpace if <code>true</code> the value of the <code>XMLContent</code>'s <code>space</code> + * attribute is set to <code>preserve</code>. + */ + public void setResultXMLContent(Node node, boolean preserveSpace) { + + xmlDocument = createResponseDocument(null, preserveSpace); + + NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent"); + if (node.getOwnerDocument() != xmlDocument) { + node = xmlDocument.importNode(node, true); + } + nodeList.item(0).appendChild(node); + + } + /**
* Creates a new result document for this <code>InfoboxReadResult</code>
* and sets the given <code>resultBytes</code> as content.
*
* @param resultBytes
*/
- void setResultBytes(byte[] resultBytes) {
+ public void setResultBytes(byte[] resultBytes) {
xmlDocument = createResponseDocument(resultBytes, false);
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java index 8904eac6..e508941d 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultImpl.java @@ -20,11 +20,13 @@ import javax.xml.bind.JAXBElement; import javax.xml.transform.Result; import javax.xml.transform.Templates; +import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType; import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadDataAssocArrayType; import at.buergerkarte.namespaces.securitylayer._1.InfoboxReadResponseType; import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory; +import at.gv.egiz.bku.slcommands.InfoboxReadResult; -public class InfoboxReadResultImpl extends SLResultImpl { +public class InfoboxReadResultImpl extends SLResultImpl implements InfoboxReadResult { /** * The <code>InfoboxReadResponse</code> @@ -40,6 +42,17 @@ public class InfoboxReadResultImpl extends SLResultImpl { this.infoboxReadResponse = infoboxReadResponseType; } + + public InfoboxReadResultImpl(Base64XMLContentType value) { + + ObjectFactory objectFactory = new ObjectFactory(); + InfoboxReadResponseType infoboxReadResponseType = objectFactory.createInfoboxReadResponseType(); + + infoboxReadResponseType.setBinaryFileData(value); + + this.infoboxReadResponse = infoboxReadResponseType; + + } @Override public void writeTo(Result result, Templates templates) { diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java new file mode 100644 index 00000000..1cdeda94 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateCommandImpl.java @@ -0,0 +1,74 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateRequestType; +import at.gv.egiz.bku.slcommands.InfoboxUpdateCommand; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slcommands.SLResult; +import at.gv.egiz.bku.slexceptions.SLCommandException; + +public class InfoboxUpdateCommandImpl extends + AbstractInfoboxCommandImpl<InfoboxUpdateRequestType> implements InfoboxUpdateCommand { + + private static Log log = LogFactory.getLog(InfoboxUpdateCommandImpl.class); + + @Override + public String getName() { + return "InfoboxUpdateRequest"; + } + + @Override + protected String getInfoboxIdentifier(InfoboxUpdateRequestType request) { + return request.getInfoboxIdentifier(); + } + + @Override + public void init(SLCommandContext ctx, Object request) throws SLCommandException { + super.init(ctx, request); + + InfoboxUpdateRequestType req = getRequestValue(); + + if (req.getAssocArrayParameters() != null && + !(infobox instanceof AssocArrayInfobox)) { + log.info("Got AssocArrayParameters but Infobox type is not AssocArray."); + throw new SLCommandException(4010); + } + + if (req.getBinaryFileParameters() != null && + !(infobox instanceof BinaryFileInfobox)) { + log.info("Got BinaryFileParameters but Infobox type is not BinaryFile."); + throw new SLCommandException(4010); + } + + } + + @Override + public SLResult execute() { + + try { + return infobox.update(getRequestValue(), getCmdCtx()); + } catch (SLCommandException e) { + return new ErrorResultImpl(e, getCmdCtx().getLocale()); + } + + } + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java new file mode 100644 index 00000000..15064756 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxUpdateResultImpl.java @@ -0,0 +1,43 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import javax.xml.bind.JAXBElement; +import javax.xml.transform.Result; +import javax.xml.transform.Templates; + +import at.buergerkarte.namespaces.securitylayer._1.InfoboxUpdateResponseType; +import at.buergerkarte.namespaces.securitylayer._1.ObjectFactory; +import at.gv.egiz.bku.slcommands.InfoboxUpdateResult; + +public class InfoboxUpdateResultImpl extends SLResultImpl implements + InfoboxUpdateResult { + + protected static JAXBElement<InfoboxUpdateResponseType> RESPONSE; + + static { + ObjectFactory factory = new ObjectFactory(); + InfoboxUpdateResponseType type = factory.createInfoboxUpdateResponseType(); + RESPONSE = factory.createInfoboxUpdateResponse(type); + } + + @Override + public void writeTo(Result result, Templates templates) { + writeTo(RESPONSE, result, templates); + } + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLCommandImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLCommandImpl.java index 9a3a2984..ed055b69 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLCommandImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLCommandImpl.java @@ -16,22 +16,11 @@ */ package at.gv.egiz.bku.slcommands.impl;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import javax.xml.bind.JAXBElement;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandContext;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.stal.ErrorResponse;
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.stal.STALRequest;
-import at.gv.egiz.stal.STALResponse;
+import javax.xml.bind.JAXBElement; + +import at.gv.egiz.bku.slcommands.SLCommand; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; /**
* This class serves as abstract base class for the implementation of a security
@@ -47,19 +36,18 @@ public abstract class SLCommandImpl<T> implements SLCommand { /**
* The <code>SLCommandContext</code> for this <code>SLCommand</code>.
*/
- protected SLCommandContext cmdCtx;
+ protected SLCommandContext cmdCtx; + + /** + * The STAL helper. + */ + protected STALHelper stalHelper;
/**
* The request element of this command.
*/
protected JAXBElement<T> request;
- /**
- * An iterator over the <code>STALResponse</code>s received in
- * {@link SLCommandImpl#requestSTAL(List)}.
- */
- protected Iterator<STALResponse> stalResponses;
-
@SuppressWarnings("unchecked")
@Override
public void init(SLCommandContext ctx, Object request)
@@ -67,8 +55,8 @@ public abstract class SLCommandImpl<T> implements SLCommand { this.request = (JAXBElement<T>) request;
- this.cmdCtx = ctx;
- assert this.cmdCtx != null;
+ this.cmdCtx = ctx; + stalHelper = new STALHelper(cmdCtx.getSTAL());
}
@@ -90,73 +78,4 @@ public abstract class SLCommandImpl<T> implements SLCommand { protected SLCommandContext getCmdCtx() {
return cmdCtx;
}
-
- /**
- * Calls {@link STAL#handleRequest(List)} with the given
- * <code>stalRequests</code>.
- *
- * @param stalRequests
- * @throws SLCommandException
- */
- protected void requestSTAL(List<STALRequest> stalRequests) throws SLCommandException {
- List<STALResponse> responses = cmdCtx.getSTAL().handleRequest(stalRequests);
- if (responses == null) {
- Log log = LogFactory.getLog(this.getClass());
- log.info("Received no responses from STAL.");
- throw new SLCommandException(4000);
- } else if (responses.size() != stalRequests.size()) {
- Log log = LogFactory.getLog(this.getClass());
- log.info("Received invalid count of responses from STAL. Expected "
- + stalRequests.size() + ", but got " + responses.size() + ".");
- // throw new SLCommandException(4000);
- }
- stalResponses = responses.iterator();
- }
-
- /**
- * @return <code>true</code> if there are more {@link STALResponse}s to be
- * fetched with {@link #nextResponse(Class)}, or <code>false</code>
- * otherwise.
- */
- protected boolean hasNextResponse() {
- return (stalResponses != null) ? stalResponses.hasNext() : false;
- }
-
- /**
- * Returns the next response of type <code>responseClass</code> that has been
- * received by {@link #requestSTAL(List)}.
- *
- * @param responseClass
- * the response must be an instance of
- * @return the next response of type <code>responseClass</code>
- *
- * @throws NoSuchElementException
- * if there is no more response
- * @throws SLCommandException
- * if the next response is of type {@link ErrorResponse} or not of
- * type <code>responseClass</code>
- */
- protected STALResponse nextResponse(
- Class<? extends STALResponse> responseClass) throws SLCommandException {
-
- if (stalResponses == null) {
- throw new NoSuchElementException();
- }
-
- STALResponse response = stalResponses.next();
-
- if (response instanceof ErrorResponse) {
- throw new SLCommandException(((ErrorResponse) response).getErrorCode());
- }
-
- if (!(responseClass.isAssignableFrom(response.getClass()))) {
- Log log = LogFactory.getLog(this.getClass());
- log.info("Received " + response.getClass() + " from STAL but expected "
- + responseClass);
- throw new SLCommandException(4000);
- }
-
- return response;
-
- }
}
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java index 7306b237..99a3b119 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SLResultImpl.java @@ -16,6 +16,7 @@ */ package at.gv.egiz.bku.slcommands.impl; +import java.io.UnsupportedEncodingException; import java.util.Locale; import javax.xml.bind.JAXBContext; @@ -32,6 +33,7 @@ import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXTransformerFactory; import javax.xml.transform.sax.TransformerHandler; +import javax.xml.transform.stream.StreamResult; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -45,6 +47,8 @@ import at.gv.egiz.bku.slexceptions.SLBindingException; import at.gv.egiz.bku.slexceptions.SLCommandException; import at.gv.egiz.bku.slexceptions.SLException; import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.bku.utils.DebugOutputStream; +import at.gv.egiz.bku.utils.DebugWriter; /** * This class serves as an abstract base class for the implementation of a @@ -85,7 +89,7 @@ public abstract class SLResultImpl implements SLResult { private Marshaller getMarshaller() { try { - JAXBContext context = SLCommandFactory.getJaxbContext(); + JAXBContext context = SLCommandFactory.getInstance().getJaxbContext(); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); return marshaller; @@ -128,6 +132,20 @@ public abstract class SLResultImpl implements SLResult { * @param templates */ protected void writeTo(JAXBElement<?> response, Result result, Templates templates) { + + DebugWriter dw = null; + DebugOutputStream ds = null; + if (log.isTraceEnabled() && result instanceof StreamResult) { + StreamResult streamResult = (StreamResult) result; + if (streamResult.getOutputStream() != null) { + ds = new DebugOutputStream(streamResult.getOutputStream()); + streamResult.setOutputStream(ds); + } + if (streamResult.getWriter() != null) { + dw = new DebugWriter(streamResult.getWriter()); + streamResult.setWriter(dw); + } + } TransformerHandler transformerHandler = null; if (templates != null) { @@ -151,10 +169,36 @@ public abstract class SLResultImpl implements SLResult { writeErrorTo(commandException, result, templates); } + if (ds != null) { + try { + log.trace("Marshalled result:\n" + new String(ds.getBufferedBytes(), "UTF-8")); + } catch (UnsupportedEncodingException e) { + log.trace(e.getMessage()); + } + } + + if (dw != null) { + log.trace("Marshalled result:\n" + dw.getBufferedString()); + } + } protected void writeTo(Node node, Result result, Templates templates) { + DebugWriter dw = null; + DebugOutputStream ds = null; + if (log.isTraceEnabled() && result instanceof StreamResult) { + StreamResult streamResult = (StreamResult) result; + if (streamResult.getOutputStream() != null) { + ds = new DebugOutputStream(streamResult.getOutputStream()); + streamResult.setOutputStream(ds); + } + if (streamResult.getWriter() != null) { + dw = new DebugWriter(streamResult.getWriter()); + streamResult.setWriter(dw); + } + } + if (templates == null) { try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); @@ -179,7 +223,19 @@ public abstract class SLResultImpl implements SLResult { writeErrorTo(new SLException(2008), result, templates); } } + + if (ds != null) { + try { + log.trace("Marshalled result:\n" + new String(ds.getBufferedBytes(), "UTF-8")); + } catch (UnsupportedEncodingException e) { + log.trace(e.getMessage()); + } + } + if (dw != null) { + log.trace("Marshalled result:\n" + dw.getBufferedString()); + } + } protected void writeErrorTo(SLException slException, Result result, Templates templates) { diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java new file mode 100644 index 00000000..0c7ce3f5 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/STALHelper.java @@ -0,0 +1,218 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import iaik.asn1.CodingException; +import iaik.asn1.DerCoder; + +import java.io.ByteArrayInputStream; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLExceptionMessages; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.idlink.ans1.IdentityLink; +import at.gv.egiz.stal.ErrorResponse; +import at.gv.egiz.stal.InfoboxReadResponse; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.STALResponse; + +/** + * A helper class for transmitting {@link STALRequest}s and obtaining their + * respective {@link STALResponse}s. + * + * @author mcentner + */ +public class STALHelper { + + /** + * Logging facility. + */ + private static Log log = LogFactory.getLog(STALHelper.class); + + /** + * The STAL implementation. + */ + private STAL stal; + + /** + * An iterator over the <code>STALResponse</code>s received in + * {@link SLCommandImpl#transmitSTALRequest(List)}. + */ + protected Iterator<STALResponse> stalResponses; + + /** + * Creates a new instance of this STALHelper with the given + * <code>stal</code>. + * + * @param stal the STAL to be used + */ + public STALHelper(STAL stal) { + if (stal == null) { + throw new NullPointerException("Argument 'stal' must not be null."); + } + this.stal = stal; + } + + /** + * Calls {@link STAL#handleRequest(List)} with the given + * <code>stalRequests</code>. + * + * @param stalRequests + * @throws SLCommandException + */ + public void transmitSTALRequest(List<? extends STALRequest> stalRequests) throws SLCommandException { + List<STALResponse> responses = stal.handleRequest(stalRequests); + if (responses == null) { + Log log = LogFactory.getLog(this.getClass()); + log.info("Received no responses from STAL."); + throw new SLCommandException(4000); + } else if (responses.size() != stalRequests.size()) { + Log log = LogFactory.getLog(this.getClass()); + log.info("Received invalid count of responses from STAL. Expected " + + stalRequests.size() + ", but got " + responses.size() + "."); + // throw new SLCommandException(4000); + } + stalResponses = responses.iterator(); + } + + /** + * @return <code>true</code> if there are more {@link STALResponse}s to be + * fetched with {@link #nextResponse(Class)}, or <code>false</code> + * otherwise. + */ + public boolean hasNextResponse() { + return (stalResponses != null) ? stalResponses.hasNext() : false; + } + + /** + * Returns the next response of type <code>responseClass</code> that has been + * received by {@link #transmitSTALRequest(List)}. + * + * @param responseClass + * the response must be an instance of + * @return the next response of type <code>responseClass</code> + * + * @throws NoSuchElementException + * if there is no more response + * @throws SLCommandException + * if the next response is of type {@link ErrorResponse} or not of + * type <code>responseClass</code> + */ + public STALResponse nextResponse( + Class<? extends STALResponse> responseClass) throws SLCommandException { + + if (stalResponses == null) { + throw new NoSuchElementException(); + } + + STALResponse response = stalResponses.next(); + + if (response instanceof ErrorResponse) { + throw new SLCommandException(((ErrorResponse) response).getErrorCode()); + } + + if (!(responseClass.isAssignableFrom(response.getClass()))) { + Log log = LogFactory.getLog(this.getClass()); + log.info("Received " + response.getClass() + " from STAL but expected " + + responseClass); + throw new SLCommandException(4000); + } + + return response; + + } + + /** + * Gets the list of certificates from the next STAL responses. + * + * @return the list of certificates + * + * @throws SLCommandException if getting the list of certificates fails + */ + public List<X509Certificate> getCertificatesFromResponses() throws SLCommandException { + + List<X509Certificate> certificates = new ArrayList<X509Certificate>(); + + CertificateFactory certFactory; + try { + certFactory = CertificateFactory.getInstance("X509"); + } catch (CertificateException e) { + // we should always be able to get an X509 certificate factory + log.error("CertificateFactory.getInstance(\"X509\") failed.", e); + throw new SLRuntimeException(e); + } + + InfoboxReadResponse response; + while(hasNextResponse()) { + response = (InfoboxReadResponse) nextResponse(InfoboxReadResponse.class); + byte[] cert = response.getInfoboxValue(); + try { + certificates.add((X509Certificate) certFactory.generateCertificate(new ByteArrayInputStream(cert))); + } catch (CertificateException e) { + log.info("Failed to decode certificate.", e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID, + new Object[] { "Certificates" }); + } + } + + return certificates; + + } + + /** + * Gets the IdentitiyLink form the next STAL response. + * + * @return the IdentityLink + * + * @throws SLCommandException if getting the IdentitiyLink fails + */ + public IdentityLink getIdentityLinkFromResponses() throws SLCommandException { + + // IdentityLink + InfoboxReadResponse response; + if (hasNextResponse()) { + response = (InfoboxReadResponse) nextResponse(InfoboxReadResponse.class); + byte[] idLink = response.getInfoboxValue(); + try { + return new IdentityLink(DerCoder.decode(idLink)); + } catch (CodingException e) { + log.info("Failed to decode infobox 'IdentityLink'.", e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID, + new Object[] { "IdentityLink" }); + } + } else { + log.info("No infobox 'IdentityLink' returned from STAL."); + throw new SLCommandException(4000); + } + + } + + +} diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImpl.java new file mode 100644 index 00000000..7e204632 --- /dev/null +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImpl.java @@ -0,0 +1,323 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl; + +import iaik.asn1.ASN; +import iaik.asn1.ASN1Object; +import iaik.asn1.CodingException; +import iaik.asn1.DerCoder; +import iaik.asn1.NumericString; +import iaik.asn1.OCTET_STRING; +import iaik.asn1.ObjectID; +import iaik.asn1.SEQUENCE; +import iaik.asn1.SET; +import iaik.asn1.UNKNOWN; +import iaik.asn1.structures.ChoiceOfTime; + +import java.io.IOException; +import java.math.BigInteger; +import java.nio.charset.Charset; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; + +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.buergerkarte.namespaces.cardchannel.AttributeList; +import at.buergerkarte.namespaces.cardchannel.AttributeType; +import at.buergerkarte.namespaces.cardchannel.ObjectFactory; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLExceptionMessages; +import at.gv.egiz.stal.InfoboxReadRequest; +import at.gv.egiz.stal.InfoboxReadResponse; +import at.gv.egiz.stal.STALRequest; + +/** + * An implementation of the {@link Infobox} <em>Certificates</em> as + * specified in Security Layer 1.2. + * + * @author mcentner + */ +public class SVPersonendatenInfoboxImpl extends AbstractAssocArrayInfobox { + + /** + * Logging facility. + */ + private static Log log = LogFactory.getLog(SVPersonendatenInfoboxImpl.class); + + public static final String EHIC = "EHIC"; + + public static final String GRUNDDATEN = "Grunddaten"; + + public static final String STATUS = "Status"; + + public static final String SV_PERSONENBINDUNG = "SV-Personenbindung"; + + /** + * The valid keys. + */ + public static final String[] KEYS = new String[] { + GRUNDDATEN, EHIC, STATUS, SV_PERSONENBINDUNG + }; + + @Override + public String getIdentifier() { + return "SV-Personendaten"; + } + + @Override + public String[] getKeys() { + return KEYS; + } + + @Override + public boolean isValuesAreXMLEntities() { + return true; + } + + @Override + public Map<String, Object> getValues(List<String> keys, SLCommandContext cmdCtx) throws SLCommandException { + + STALHelper stalHelper = new STALHelper(cmdCtx.getSTAL()); + + if (keys != null && !keys.isEmpty()) { + + List<STALRequest> stalRequests = new ArrayList<STALRequest>(); + + // get values + InfoboxReadRequest infoboxReadRequest; + for (int i = 0; i < keys.size(); i++) { + infoboxReadRequest = new InfoboxReadRequest(); + infoboxReadRequest.setInfoboxIdentifier(keys.get(i)); + stalRequests.add(infoboxReadRequest); + } + + stalHelper.transmitSTALRequest(stalRequests); + + Map<String, Object> values = new HashMap<String, Object>(); + + try { + for (int i = 0; i < keys.size(); i++) { + + String key = keys.get(i); + InfoboxReadResponse nextResponse = (InfoboxReadResponse) stalHelper.nextResponse(InfoboxReadResponse.class); + + + ObjectFactory objectFactory = new ObjectFactory(); + + if (EHIC.equals(key)) { + AttributeList attributeList = createAttributeList(nextResponse.getInfoboxValue()); + values.put(key, objectFactory.createEHIC(attributeList)); + } else if (GRUNDDATEN.equals(key)) { + AttributeList attributeList = createAttributeList(nextResponse.getInfoboxValue()); + values.put(key, objectFactory.createGrunddaten(attributeList)); + } else if (SV_PERSONENBINDUNG.equals(key)) { + values.put(key, objectFactory.createSVPersonenbindung(nextResponse.getInfoboxValue())); + } else if (STATUS.equals(key)) { + AttributeList attributeList = createAttributeListFromRecords(nextResponse.getInfoboxValue()); + values.put(key, objectFactory.createStatus(attributeList)); + } + + } + } catch (CodingException e) { + log.info("Failed to decode '" + getIdentifier() + "' infobox.", e); + throw new SLCommandException(4000, + SLExceptionMessages.EC4000_UNCLASSIFIED_INFOBOX_INVALID, + new Object[] { "IdentityLink" }); + + } + + return values; + + } else { + + return new HashMap<String, Object>(); + + } + + + } + + public static AttributeList createAttributeList(byte[] infoboxValue) throws CodingException { + + ObjectFactory objectFactory = new ObjectFactory(); + + ASN1Object asn1 = DerCoder.decode(infoboxValue); + + AttributeList attributeList = objectFactory.createAttributeList(); + List<AttributeType> attributes = attributeList.getAttribute(); + + if (asn1.isA(ASN.SEQUENCE)) { + for (int i = 0; i < ((SEQUENCE) asn1).countComponents(); i++) { + + AttributeType attributeType = objectFactory.createAttributeType(); + + if (asn1.getComponentAt(i).isA(ASN.SEQUENCE)) { + SEQUENCE attribute = (SEQUENCE) asn1.getComponentAt(i); + if (attribute.getComponentAt(0).isA(ASN.ObjectID)) { + ObjectID objectId = (ObjectID) attribute.getComponentAt(0); + attributeType.setOid("urn:oid:" + objectId.getID()); + } + if (attribute.getComponentAt(1).isA(ASN.SET)) { + SET values = (SET) attribute.getComponentAt(1); + for (int j = 0; j < values.countComponents(); j++) { + setAttributeValue(attributeType, values.getComponentAt(j)); + } + } + } + + attributes.add(attributeType); + + } + + } + + return attributeList; + + } + + public static AttributeList createAttributeListFromRecords(byte[] infoboxValue) throws CodingException { + + ObjectFactory objectFactory = new ObjectFactory(); + + AttributeList attributeList = objectFactory.createAttributeList(); + List<AttributeType> attributes = attributeList.getAttribute(); + + byte[] records = infoboxValue; + + while (records != null && records.length > 0) { + + int length; + + if (records[0] != 0x00) { + + ASN1Object asn1 = DerCoder.decode(records); + + AttributeType attributeType = objectFactory.createAttributeType(); + + if (asn1.isA(ASN.SEQUENCE)) { + SEQUENCE attribute = (SEQUENCE) asn1; + if (attribute.getComponentAt(0).isA(ASN.ObjectID)) { + ObjectID objectId = (ObjectID) attribute.getComponentAt(0); + attributeType.setOid("urn:oid:" + objectId.getID()); + } + if (attribute.getComponentAt(1).isA(ASN.SET)) { + SET values = (SET) attribute.getComponentAt(1); + for (int j = 0; j < values.countComponents(); j++) { + setAttributeValue(attributeType, values.getComponentAt(j)); + } + } + } + + attributes.add(attributeType); + + length = DerCoder.encode(asn1).length; + + } else { + length = 1; + } + + if (length < records.length) { + records = Arrays.copyOfRange(records, length + 1, records.length); + } else { + records = null; + } + + } + + return attributeList; + + } + + private static void setAttributeValue(AttributeType attributeType, ASN1Object value) { + + if (value.isA(ASN.OCTET_STRING)) { + + try { + byte[] octets = ((OCTET_STRING) value).getWholeValue(); + attributeType.setLatin1String(new String(octets, Charset.forName("ISO-8859-1"))); + } catch (IOException e) { + log.info("Failed to set Latin1String.", e); + } + + } else if (value.isA(ASN.NumericString)) { + + attributeType.setNumericString((String) ((NumericString) value).getValue()); + + } else if (value.isA(ASN.GeneralizedTime)) { + + try { + ChoiceOfTime choiceOfTime = new ChoiceOfTime(value); + + GregorianCalendar gregorianCalendar = new GregorianCalendar(); + gregorianCalendar.setTimeZone(TimeZone.getTimeZone("UTC")); + gregorianCalendar.setTime(choiceOfTime.getDate()); + + DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); + XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); + xmlGregorianCalendar.setTimezone(0); + + attributeType.setGeneralizedTime(xmlGregorianCalendar); + } catch (Exception e) { + log.info("Failed to set GeneralizedTime.", e); + } + + } else if (value.isA(ASN.INTEGER)) { + + attributeType.setInteger((BigInteger) value.getValue()); + + } else if (value.isA(ASN.UTF8String)) { + + attributeType.setUTF8String((String) value.getValue()); + + } else if (value.isA(ASN.PrintableString)) { + + attributeType.setPrintableString((String) value.getValue()); + + } else if (value.isA(ASN.UNKNOWN)) { + + byte[] bytes = (byte[]) ((UNKNOWN) value).getValue(); + + try { + BigInteger bigInteger = new BigInteger(bytes); + String string = bigInteger.toString(16); + + Date date = new SimpleDateFormat("yyyyMMdd").parse(string); + attributeType.setDate(new SimpleDateFormat("yyyy-MM-dd").format(date)); + } catch (Exception e) { + log.info("Failed to set Date.", e); + } + } + + } + + + + + +} diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java index 6a0792d5..58941401 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/HttpBindingProcessorTest.java @@ -27,7 +27,10 @@ import java.util.List; import java.util.Map;
import org.junit.Before;
+import org.junit.BeforeClass; import org.junit.Test;
+import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; import at.gv.egiz.bku.binding.MultiTestDataUrlConnection.DataSourceProvider;
import at.gv.egiz.bku.utils.StreamUtil;
@@ -80,7 +83,15 @@ public class HttpBindingProcessorTest { protected Map<String, String> serverHeaderMap;
protected Map<String, String> clientHeaderMap;
protected TestDataUrlConnection server;
-
+ + protected static ApplicationContext appCtx; + + @BeforeClass + public static void setUpClass() { + appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); + } + +
@Before
public void setUp() throws IOException {
server = new TestDataUrlConnection();
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java index 8a607b80..0a24b5c5 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/TestDataUrlConnection.java @@ -26,6 +26,9 @@ import java.util.Collections; import java.util.HashMap;
import java.util.Map;
import java.util.Properties; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSocketFactory; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -131,5 +134,17 @@ public class TestDataUrlConnection implements DataUrlConnectionSPI { public void setConfiguration(Properties config) { // TODO Auto-generated method stub + } + + @Override + public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { + // TODO Auto-generated method stub + + } + + @Override + public void setSSLSocketFactory(SSLSocketFactory socketFactory) { + // TODO Auto-generated method stub + }
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java index 7b35723d..cd931878 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/SLCommandFactoryTest.java @@ -25,21 +25,32 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; import at.gv.egiz.bku.slexceptions.SLCommandException; import at.gv.egiz.bku.slexceptions.SLRequestException; import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.stal.dummy.DummySTAL; public class SLCommandFactoryTest { + protected static ApplicationContext appCtx; SLCommandFactory factory; SLCommandContext context; + @BeforeClass + public static void setUpClass() { + appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); + } + @Before public void setUp() { factory = SLCommandFactory.getInstance(); context = new SLCommandContext(); + context.setSTAL(new DummySTAL()); } @Test diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java index c6dedf67..8fdec375 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/CreateXMLSignatureComandImplTest.java @@ -16,34 +16,34 @@ */ package at.gv.egiz.bku.slcommands.impl;
-import static org.junit.Assert.*;
-
-import iaik.xml.crypto.XSecProvider;
-
-import java.io.InputStream;
-import java.security.Security;
-
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore; -import org.junit.Test;
-
-import at.gv.egiz.bku.slcommands.CreateXMLSignatureCommand;
-import at.gv.egiz.bku.slcommands.InfoboxReadCommand;
-import at.gv.egiz.bku.slcommands.SLCommand;
-import at.gv.egiz.bku.slcommands.SLCommandContext;
-import at.gv.egiz.bku.slcommands.SLCommandFactory;
-import at.gv.egiz.bku.slcommands.SLResult;
-import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
-import at.gv.egiz.bku.slexceptions.SLCommandException;
-import at.gv.egiz.bku.slexceptions.SLRequestException;
-import at.gv.egiz.bku.slexceptions.SLRuntimeException;
-import at.gv.egiz.stal.STAL;
-import at.gv.egiz.stal.dummy.DummySTAL;
-@Ignore
+import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import iaik.xml.crypto.XSecProvider; + +import java.io.InputStream; +import java.security.Security; + +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import at.gv.egiz.bku.slcommands.CreateXMLSignatureCommand; +import at.gv.egiz.bku.slcommands.InfoboxReadCommand; +import at.gv.egiz.bku.slcommands.SLCommand; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slcommands.SLCommandFactory; +import at.gv.egiz.bku.slcommands.SLResult; +import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider; +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLRequestException; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.dummy.DummySTAL; +//@Ignore
public class CreateXMLSignatureComandImplTest {
private SLCommandFactory factory;
@@ -52,8 +52,9 @@ public class CreateXMLSignatureComandImplTest { @BeforeClass
public static void setUpClass() {
-
-
+ + new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); +
Security.addProvider(new STALProvider());
XSecProvider.addAsProvider(true);
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java index 7a7b90e3..b0d11d47 100644 --- a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadComandImplTest.java @@ -25,9 +25,12 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.junit.Before; -import org.junit.Ignore; +import org.junit.BeforeClass; import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import at.gv.egiz.bku.slcommands.ErrorResult; import at.gv.egiz.bku.slcommands.InfoboxReadCommand; import at.gv.egiz.bku.slcommands.SLCommand; import at.gv.egiz.bku.slcommands.SLCommandContext; @@ -39,13 +42,20 @@ import at.gv.egiz.bku.slexceptions.SLRuntimeException; import at.gv.egiz.stal.STAL; import at.gv.egiz.stal.dummy.DummySTAL; -@Ignore
+//@Ignore
public class InfoboxReadComandImplTest {
+ private static ApplicationContext appCtx; + private SLCommandFactory factory;
private STAL stal;
+ @BeforeClass + public static void setUpClass() { + appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); + } + @Before
public void setUp() {
factory = SLCommandFactory.getInstance();
@@ -71,19 +81,23 @@ public class InfoboxReadComandImplTest { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext();
+ SLCommandContext context = new SLCommandContext(); + context.setSTAL(stal);
SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
assertTrue(command instanceof InfoboxReadCommand);
}
- @Test(expected=SLCommandException.class)
public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
assertNotNull(inputStream);
- SLCommandContext context = new SLCommandContext();
+ SLCommandContext context = new SLCommandContext(); + context.setSTAL(stal);
SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
- assertTrue(command instanceof InfoboxReadCommand);
+ assertTrue(command instanceof InfoboxReadCommand); + + SLResult result = command.execute(); + assertTrue(result instanceof ErrorResult);
}
}
diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java new file mode 100644 index 00000000..f9c60b86 --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/slcommands/impl/SVPersonendatenInfoboxImplTest.java @@ -0,0 +1,147 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.slcommands.impl;
+
+import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import iaik.asn1.CodingException; + +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import at.buergerkarte.namespaces.cardchannel.AttributeList; +import at.buergerkarte.namespaces.cardchannel.ObjectFactory; +import at.gv.egiz.bku.slcommands.ErrorResult; +import at.gv.egiz.bku.slcommands.InfoboxReadCommand; +import at.gv.egiz.bku.slcommands.SLCommand; +import at.gv.egiz.bku.slcommands.SLCommandContext; +import at.gv.egiz.bku.slcommands.SLCommandFactory; +import at.gv.egiz.bku.slcommands.SLResult; +import at.gv.egiz.bku.slexceptions.SLCommandException; +import at.gv.egiz.bku.slexceptions.SLRequestException; +import at.gv.egiz.bku.slexceptions.SLRuntimeException; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.dummy.DummySTAL; + +//@Ignore
+public class SVPersonendatenInfoboxImplTest {
+ + private byte[] EHIC = new byte[] { + (byte) 0x30, (byte) 0x6b, (byte) 0x30, (byte) 0x12, (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28, + (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x14, (byte) 0x31, (byte) 0x06, + (byte) 0x04, (byte) 0x04, (byte) 0x42, (byte) 0x47, (byte) 0x4b, (byte) 0x4b, (byte) 0x30, (byte) 0x12, + (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28, (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04, + (byte) 0x01, (byte) 0x15, (byte) 0x31, (byte) 0x06, (byte) 0x12, (byte) 0x04, (byte) 0x31, (byte) 0x33, + (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x22, (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28, + (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x16, (byte) 0x31, (byte) 0x16, + (byte) 0x12, (byte) 0x14, (byte) 0x38, (byte) 0x30, (byte) 0x30, (byte) 0x34, (byte) 0x30, (byte) 0x30, + (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x32, (byte) 0x33, (byte) 0x30, (byte) 0x30, + (byte) 0x34, (byte) 0x37, (byte) 0x30, (byte) 0x37, (byte) 0x35, (byte) 0x39, (byte) 0x30, (byte) 0x1d, + (byte) 0x06, (byte) 0x08, (byte) 0x2a, (byte) 0x28, (byte) 0x00, (byte) 0x0a, (byte) 0x01, (byte) 0x04, + (byte) 0x01, (byte) 0x17, (byte) 0x31, (byte) 0x11, (byte) 0x18, (byte) 0x0f, (byte) 0x32, (byte) 0x30, + (byte) 0x30, (byte) 0x35, (byte) 0x30, (byte) 0x37, (byte) 0x30, (byte) 0x31, (byte) 0x31, (byte) 0x32, + (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x5a + }; +
+ private static ApplicationContext appCtx; + + private SLCommandFactory factory;
+
+ private STAL stal;
+
+// @BeforeClass + public static void setUpClass() { + appCtx = new ClassPathXmlApplicationContext("at/gv/egiz/bku/slcommands/testApplicationContext.xml"); + } + +// @Before
+ public void setUp() {
+ factory = SLCommandFactory.getInstance();
+ stal = new DummySTAL();
+ }
+ + @Test + public void testEHIC() throws SLCommandException, JAXBException, CodingException, IOException { + + AttributeList attributeList = SVPersonendatenInfoboxImpl.createAttributeList(EHIC); + + JAXBElement<AttributeList> ehic = new ObjectFactory().createEHIC(attributeList); + + JAXBContext jaxbContext = SLCommandFactory.getInstance().getJaxbContext(); + + Marshaller marshaller = jaxbContext.createMarshaller(); + + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + + marshaller.marshal(ehic, System.out); + + } + + @Ignore
+ @Test
+ public void testInfboxReadRequest() throws SLCommandException, SLRuntimeException, SLRequestException {
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.xml");
+ assertNotNull(inputStream);
+
+ SLCommandContext context = new SLCommandContext();
+ context.setSTAL(stal);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ assertTrue(command instanceof InfoboxReadCommand);
+
+ SLResult result = command.execute();
+ result.writeTo(new StreamResult(System.out));
+ }
+ + @Ignore
+ @Test(expected=SLCommandException.class)
+ public void testInfboxReadRequestInvalid1() throws SLCommandException, SLRuntimeException, SLRequestException {
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-1.xml");
+ assertNotNull(inputStream);
+
+ SLCommandContext context = new SLCommandContext(); + context.setSTAL(stal);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ assertTrue(command instanceof InfoboxReadCommand);
+ }
+ + @Ignore
+ public void testInfboxReadRequestInvalid2() throws SLCommandException, SLRuntimeException, SLRequestException {
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/slcommands/infoboxreadcommand/IdentityLink.Binary.Invalid-2.xml");
+ assertNotNull(inputStream);
+
+ SLCommandContext context = new SLCommandContext(); + context.setSTAL(stal);
+ SLCommand command = factory.createSLCommand(new StreamSource(inputStream), context);
+ assertTrue(command instanceof InfoboxReadCommand); + + SLResult result = command.execute(); + assertTrue(result instanceof ErrorResult);
+ }
+
+}
diff --git a/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java b/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java index 2ea0bae0..77dd7e4f 100644 --- a/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java +++ b/bkucommon/src/test/java/at/gv/egiz/stal/dummy/DummySTAL.java @@ -50,9 +50,10 @@ public class DummySTAL implements STAL { public DummySTAL() {
try {
- KeyStore ks = KeyStore.getInstance("pkcs12");
- ks.load(getClass().getClassLoader().getResourceAsStream(
- "at/gv/egiz/stal/dummy/keystore/Cert.p12"), "1622".toCharArray());
+ KeyStore ks = KeyStore.getInstance("pkcs12"); + InputStream ksStream = getClass().getClassLoader().getResourceAsStream( + "at/gv/egiz/bku/slcommands/impl/Cert.p12");
+ ks.load(ksStream, "1622".toCharArray());
for (Enumeration<String> aliases = ks.aliases(); aliases
.hasMoreElements();) {
String alias = aliases.nextElement();
@@ -71,7 +72,7 @@ public class DummySTAL implements STAL { }
@Override
- public List<STALResponse> handleRequest(List<STALRequest> requestList) {
+ public List<STALResponse> handleRequest(List<? extends STALRequest> requestList) {
List<STALResponse> responses = new ArrayList<STALResponse>();
for (STALRequest request : requestList) {
diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml b/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml new file mode 100644 index 00000000..a7b588aa --- /dev/null +++ b/bkucommon/src/test/resources/at/gv/egiz/bku/slcommands/testApplicationContext.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ Copyright 2008 Federal Chancellery Austria and Graz University of
+ Technology Licensed under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ --> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
+
+
+ <bean id="slCommandFactory" class="at.gv.egiz.bku.slcommands.SLCommandFactory"
+ factory-method="getInstance">
+ <property name="commandImpl">
+ <map>
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:NullOperationRequest"
+ value="at.gv.egiz.bku.slcommands.impl.NullOperationCommandImpl" />
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:InfoboxReadRequest"
+ value="at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl" />
+ <entry
+ key="http://www.buergerkarte.at/namespaces/securitylayer/1.2#:CreateXMLSignatureRequest"
+ value="at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl" />
+ </map>
+ </property>
+ </bean>
+
+ <bean id="infoboxFactory" class="at.gv.egiz.bku.slcommands.impl.InfoboxFactory"
+ factory-method="getInstance">
+ <property name="infoboxImpl">
+ <map>
+ <entry
+ key="Certificates"
+ value="at.gv.egiz.bku.slcommands.impl.CertificatesInfoboxImpl" />
+ <entry
+ key="IdentityLink"
+ value="at.gv.egiz.bku.slcommands.impl.IdentityLinkInfoboxImpl" />
+ <!--<entry
+ key="CardChannel"
+ value="at.gv.egiz.bku.slcommands.impl.CardChannel" />
+ --></map>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file @@ -19,6 +19,7 @@ <module>BKUCommonGUI</module> <module>BKUViewer</module> <module>BKULocalApp</module> + <module>STALExt</module> </modules> <developers> <developer> @@ -38,15 +39,15 @@ </developer> </developers> <scm> - <connection>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2</connection> - <developerConnection>scm:svn:svn+ssh://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2</developerConnection> + <connection>scm:svn:svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2</connection> + <developerConnection>scm:svn:svn+ssh://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2</developerConnection> <url>svn://svn.egovlabs.gv.at/svnroot/mocca/tags/mocca-1.0.2</url> </scm> <organization> <name>E-Government Innovation Center (EGIZ)</name> <url>http://www.egiz.gv.at</url> </organization> - <build> + <build> <pluginManagement> <plugins> <plugin> @@ -61,15 +62,15 @@ <target>1.6</target> <verbose>true</verbose> <showWarnings>true</showWarnings> - <encoding>UTF-8</encoding> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <configuration> + <encoding>UTF-8</encoding> </configuration> </plugin> - <plugin> - <artifactId>maven-resources-plugin</artifactId> - <configuration> - <encoding>UTF-8</encoding> - </configuration> - </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId> @@ -90,9 +91,9 @@ <version>1.10</version> </plugin> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-release-plugin</artifactId> - <version>2.0-beta-7</version> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-release-plugin</artifactId> + <version>2.0-beta-7</version> </plugin> </plugins> </pluginManagement> @@ -219,6 +220,16 @@ <version>3.1</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>2.5.5</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>2.5.5</version> + </dependency> </dependencies> </dependencyManagement> </project>
\ No newline at end of file diff --git a/smcc/pom.xml b/smcc/pom.xml index 2d56f24f..a973c809 100644 --- a/smcc/pom.xml +++ b/smcc/pom.xml @@ -30,7 +30,6 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.1</version> <scope>test</scope> </dependency> <!-- FIXME just for testing diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java index 2baff834..6d96599c 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java @@ -30,7 +30,6 @@ package at.gv.egiz.smcc; import java.nio.charset.Charset; -import javax.smartcardio.Card; import javax.smartcardio.CardChannel; import javax.smartcardio.CardException; import javax.smartcardio.CommandAPDU; @@ -110,41 +109,47 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { public byte[] getCertificate(KeyboxName keyboxName) throws SignatureCardException, InterruptedException { - byte[] aid; - byte[] efc; - int maxsize; - if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) { - aid = AID_SIG; - efc = EF_C_CH_DS; - maxsize = EF_C_CH_DS_MAX_SIZE; - } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) { - aid = AID_DEC; - efc = EF_C_CH_EKEY; - maxsize = EF_C_CH_EKEY_MAX_SIZE; - } else { - throw new IllegalArgumentException("Keybox " + keyboxName - + " not supported."); - } - - log.debug("Get certificate for keybox '" + keyboxName.getKeyboxName() + "'" + - " (AID=" + toString(aid) + " EF=" + toString(efc) + ")."); - try { - Card card = getCardChannel().getCard(); - try { - card.beginExclusive(); - return readTLVFile(aid, efc, maxsize + 15000); - } catch (FileNotFoundException e) { - // if certificate is not present, - // the citizen card application has not been activated - throw new NotActivatedException(); - } finally { - card.endExclusive(); + + if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) { + + try { + getCard().beginExclusive(); + byte[] certificate = readTLVFile(AID_SIG, EF_C_CH_DS, EF_C_CH_DS_MAX_SIZE); + if (certificate == null) { + throw new NotActivatedException(); + } + return certificate; + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } finally { + getCard().endExclusive(); + } + + } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) { + + try { + getCard().beginExclusive(); + byte[] certificate = readTLVFile(AID_DEC, EF_C_CH_EKEY, EF_C_CH_EKEY_MAX_SIZE); + if (certificate == null) { + throw new NotActivatedException(); + } + return certificate; + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } finally { + getCard().endExclusive(); + } + + } else { + throw new IllegalArgumentException("Keybox " + keyboxName + + " not supported."); } + } catch (CardException e) { - throw new SignatureCardException("Failed to get exclusive card access."); + log.warn(e); + throw new SignatureCardException("Failed to access card.", e); } - } @@ -155,30 +160,47 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { public byte[] getInfobox(String infobox, PINProvider provider, String domainId) throws SignatureCardException, InterruptedException { - if ("IdentityLink".equals(infobox)) { - - PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("inf.pin.name")); - - try { - Card card = getCardChannel().getCard(); - try { - card.beginExclusive(); - return readTLVFilePIN(AID_DEC, EF_INFOBOX, KID_PIN_INF, provider, - spec, EF_INFOBOX_MAX_SIZE); - } catch (FileNotFoundException e) { - // if certificate is not present, - // the citizen card application has not been activated - throw new NotActivatedException(); - } finally { - card.endExclusive(); - } - } catch (CardException e) { - throw new SignatureCardException("Failed to get exclusive card access."); + try { + if ("IdentityLink".equals(infobox)) { + + PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("inf.pin.name")); + + int retries = -1; + String pin = null; + boolean pinRequiered = false; + + do { + if (pinRequiered) { + pin = provider.providePIN(spec, retries); + if (pin == null) { + throw new CancelledException(); + } + } + try { + getCard().beginExclusive(); + return readTLVFile(AID_DEC, EF_INFOBOX, pin, KID_PIN_INF, EF_INFOBOX_MAX_SIZE); + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } catch (SecurityStatusNotSatisfiedException e) { + pinRequiered = true; + } catch (VerificationFailedException e) { + pinRequiered = true; + retries = e.getRetries(); + } finally { + getCard().endExclusive(); + } + } while (retries != 0); + + throw new LockedException(); + + } else { + throw new IllegalArgumentException("Infobox '" + infobox + + "' not supported."); } - - } else { - throw new IllegalArgumentException("Infobox '" + infobox - + "' not supported."); + + } catch (CardException e) { + log.warn(e); + throw new SignatureCardException("Failed to access card.", e); } } @@ -192,68 +214,103 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { } try { - Card card = getCardChannel().getCard(); - try { - card.beginExclusive(); - - if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) { - - // SELECT DF - selectFileFID(DF_SIG); - // VERIFY - verifyPIN(provider, new PINSpec(6, 10, "[0-9]", getResourceBundle() - .getString("sig.pin.name")), KID_PIN_SIG); - // MSE: SET DST - mseSetDST(0x81, 0xb6, DST_SIG); - // PSO: HASH - psoHash(hash); - // PSO: COMPUTE DIGITAL SIGNATURE - return psoComputDigitalSiganture(); - } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) { - - // SELECT DF - selectFileFID(DF_DEC); - // VERIFY - verifyPIN(provider, new PINSpec(4, 4, "[0-9]", getResourceBundle() - .getString("dec.pin.name")), KID_PIN_DEC); - // MSE: SET DST - mseSetDST(0x41, 0xa4, DST_DEC); - // INTERNAL AUTHENTICATE - return internalAuthenticate(hash); - - - // 00 88 10 00 23 30 21 30 09 06 05 2B 0E 03 02 1A 05 00 04 14 54 26 F0 EA AF EA F0 4E D4 A1 AD BF 66 D4 A5 9B 45 6F AF 79 00 - // 00 88 10 00 23 30 21 30 09 06 05 2B 0E 03 02 1A 05 00 04 14 DF 8C AB 8F E2 AD AC 7B 5A AF BE E9 44 5E 95 99 FA AF 2F 48 00 - - } else { - throw new IllegalArgumentException("KeyboxName '" + keyboxName - + "' not supported."); - } + if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) { + + PINSpec spec = new PINSpec(6, 10, "[0-9]", getResourceBundle().getString("sig.pin.name")); + + int retries = -1; + String pin = null; + + do { + pin = provider.providePIN(spec, retries); + if (pin == null) { + throw new CancelledException(); + } + try { + getCard().beginExclusive(); + + // SELECT DF + selectFileFID(DF_SIG); + // VERIFY + retries = verifyPIN(pin, KID_PIN_SIG); + if (retries != -1) { + throw new VerificationFailedException(retries); + } + // MSE: SET DST + mseSetDST(0x81, 0xb6, DST_SIG); + // PSO: HASH + psoHash(hash); + // PSO: COMPUTE DIGITAL SIGNATURE + return psoComputDigitalSiganture(); + + } catch (SecurityStatusNotSatisfiedException e) { + retries = verifyPIN(null, KID_PIN_SIG); + } catch (VerificationFailedException e) { + retries = e.getRetries(); + } finally { + getCard().endExclusive(); + } + } while (retries != 0); + + throw new LockedException(); + + + } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) { - } catch (FileNotFoundException e) { - // if certificate is not present, - // the citizen card application has not been activated - throw new NotActivatedException(); - } finally { - card.endExclusive(); + PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("dec.pin.name")); + + int retries = -1; + String pin = null; + boolean pinRequiered = false; + + do { + if (pinRequiered) { + pin = provider.providePIN(spec, retries); + if (pin == null) { + throw new CancelledException(); + } + } + try { + getCard().beginExclusive(); + + // SELECT DF + selectFileFID(DF_DEC); + // VERIFY + retries = verifyPIN(pin, KID_PIN_DEC); + if (retries != -1) { + throw new VerificationFailedException(retries); + } + // MSE: SET DST + mseSetDST(0x41, 0xa4, DST_DEC); + // INTERNAL AUTHENTICATE + return internalAuthenticate(hash); + + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } catch (SecurityStatusNotSatisfiedException e) { + pinRequiered = true; + retries = verifyPIN(null, KID_PIN_DEC); + } catch (VerificationFailedException e) { + pinRequiered = true; + retries = e.getRetries(); + } finally { + getCard().endExclusive(); + } + } while (retries != 0); + + throw new LockedException(); + + } else { + throw new IllegalArgumentException("KeyboxName '" + keyboxName + + "' not supported."); } + } catch (CardException e) { - throw new SignatureCardException("Failed to get exclusive card access."); - } - - } - - protected byte[] selectFileAID(byte[] fid) throws CardException, SignatureCardException { - CardChannel channel = getCardChannel(); - ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x04, - 0x00, fid, 256)); - if (resp.getSW() != 0x9000) { - throw new SignatureCardException("Failed to select file (AID=" - + toString(fid) + "): SW=" + Integer.toHexString(resp.getSW()) + "."); - } else { - return resp.getBytes(); - } + log.warn(e); + throw new SignatureCardException("Failed to access card.", e); + } + } protected ResponseAPDU selectFileFID(byte[] fid) throws CardException, SignatureCardException { @@ -262,6 +319,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { 0x00, fid, 256)); } + @Override protected int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); @@ -290,35 +348,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { } - /** - * - * @param pinProvider - * @param spec - * the PIN spec to be given to the pinProvider - * @param kid - * the KID (key identifier) of the PIN to be verified - * @throws CancelledException - * if the user canceld the operation - * @throws javax.smartcardio.CardException - * @throws at.gv.egiz.smcc.SignatureCardException - */ - @Override - protected void verifyPIN(PINProvider pinProvider, PINSpec spec, byte kid) - throws CardException, CancelledException, SignatureCardException, InterruptedException { - - int retries = -1; - do { - String pin = pinProvider.providePIN(spec, retries); - if (pin == null) { - // user canceled operation - throw new CancelledException("User canceled operation"); - } - retries = verifyPIN(pin, kid); - } while (retries > 0); - - } - - void mseSetDST(int p1, int p2, byte[] dst) throws CardException, SignatureCardException { + private void mseSetDST(int p1, int p2, byte[] dst) throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x22, p1, p2, dst)); @@ -328,7 +358,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { } } - void psoHash(byte[] hash) throws CardException, SignatureCardException { + private void psoHash(byte[] hash) throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x2A, 0x90, 0x81, hash)); @@ -338,7 +368,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { } } - byte[] psoComputDigitalSiganture() throws CardException, + private byte[] psoComputDigitalSiganture() throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x2A, 0x9E, @@ -352,7 +382,7 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { } } - byte[] internalAuthenticate(byte[] hash) throws CardException, SignatureCardException { + private byte[] internalAuthenticate(byte[] hash) throws CardException, SignatureCardException { byte[] digestInfo = new byte[] { (byte) 0x30, (byte) 0x21, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x05, (byte) 0x2B, (byte) 0x0E, (byte) 0x03, (byte) 0x02, (byte) 0x1A, (byte) 0x05, (byte) 0x00, (byte) 0x04 diff --git a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java index b828e8cd..633cc90d 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java @@ -28,6 +28,8 @@ // package at.gv.egiz.smcc; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.nio.ByteBuffer; import java.util.Locale; import java.util.ResourceBundle; @@ -36,6 +38,7 @@ import javax.smartcardio.ATR; import javax.smartcardio.Card; import javax.smartcardio.CardChannel; import javax.smartcardio.CardException; +import javax.smartcardio.CardTerminal; import javax.smartcardio.CommandAPDU; import javax.smartcardio.ResponseAPDU; @@ -53,7 +56,12 @@ public abstract class AbstractSignatureCard implements SignatureCard { int ifs_ = 254; - Card card_; + private Card card_; + + /** + * The card terminal that connects the {@link #card_}. + */ + private CardTerminal cardTerminal; protected AbstractSignatureCard(String resourceBundleName) { this.resourceBundleName = resourceBundleName; @@ -73,45 +81,56 @@ public abstract class AbstractSignatureCard implements SignatureCard { return sb.toString(); } - protected abstract byte[] selectFileAID(byte[] fid) throws CardException, - SignatureCardException; - - protected abstract ResponseAPDU selectFileFID(byte[] fid) throws CardException, - SignatureCardException; - /** - * VERIFY PIN + * Select an application using AID as DF name according to ISO/IEC 7816-4 + * section 8.2.2.2. * - * <p> - * Implementations of this method should call - * {@link PINProvider#providePIN(PINSpec, int)} to retrieve the PIN entered by - * the user and VERIFY PIN on the smart card until the PIN has been - * successfully verified. - * </p> + * @param dfName + * AID of the application to be selected * - * @param pinProvider - * the PINProvider - * @param spec - * the PINSpec - * @param kid - * the key ID (KID) of the PIN to verify + * @return the response data of the response APDU if SW=0x9000 * * @throws CardException - * if smart card communication fails - * - * @throws CancelledException - * if the PINProvider indicated that the user canceled the PIN entry - * @throws NotActivatedException - * if the card application has not been activated - * @throws LockedException - * if the card application is locked + * if card communication fails * * @throws SignatureCardException - * if VERIFY PIN fails + * if application selection fails (e.g. an application with the + * given AID is not present on the card) */ - protected abstract void verifyPIN(PINProvider pinProvider, PINSpec spec, - byte kid) throws CardException, SignatureCardException, InterruptedException; + protected byte[] selectFileAID(byte[] dfName) throws CardException, SignatureCardException { + CardChannel channel = getCardChannel(); + ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x04, + 0x00, dfName, 256)); + if (resp.getSW() != 0x9000) { + throw new SignatureCardException("Failed to select application AID=" + + toString(dfName) + ": SW=" + Integer.toHexString(resp.getSW()) + "."); + } else { + return resp.getBytes(); + } + } + protected abstract ResponseAPDU selectFileFID(byte[] fid) throws CardException, + SignatureCardException; + + protected abstract int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException; + + + protected byte[] readRecord(int recordNumber) throws SignatureCardException, CardException { + return readRecord(getCardChannel(), recordNumber); + } + + protected byte[] readRecord(CardChannel channel, int recordNumber) throws SignatureCardException, CardException { + + ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xB2, + recordNumber, 0x04, 256)); + if (resp.getSW() == 0x9000) { + return resp.getData(); + } else { + throw new SignatureCardException("Failed to read records. SW=" + Integer.toHexString(resp.getSW())); + } + + } + protected byte[] readBinary(CardChannel channel, int offset, int len) throws CardException, SignatureCardException { @@ -119,6 +138,8 @@ public abstract class AbstractSignatureCard implements SignatureCard { 0x7F & (offset >> 8), offset & 0xFF, len)); if (resp.getSW() == 0x9000) { return resp.getData(); + } else if (resp.getSW() == 0x6982) { + throw new SecurityStatusNotSatisfiedException(); } else { throw new SignatureCardException("Failed to read bytes (" + offset + "+" + len + "): SW=" + Integer.toHexString(resp.getSW())); @@ -182,43 +203,10 @@ public abstract class AbstractSignatureCard implements SignatureCard { } - /** - * Read the content of a TLV file. - * - * @param aid the application ID (AID) - * @param ef the elementary file (EF) - * @param maxLength the maximum length of the file - * - * @return the content of the file - * - * @throws SignatureCardException - */ - protected byte[] readTLVFile(byte[] aid, byte[] ef, int maxLength) - throws SignatureCardException, InterruptedException { - return readTLVFilePIN(aid, ef, (byte) 0, null, null, maxLength); - } - - - /** - * Read the content of a TLV file wich may require a PIN. - * - * @param aid the application ID (AID) - * @param ef the elementary file (EF) - * @param kid the key ID (KID) of the corresponding PIN - * @param provider the PINProvider - * @param spec the PINSpec - * @param maxLength the maximum length of the file - * - * @return the content of the file - * - * @throws SignatureCardException - */ - protected byte[] readTLVFilePIN(byte[] aid, byte[] ef, byte kid, - PINProvider provider, PINSpec spec, int maxLength) - throws SignatureCardException, InterruptedException { - + protected byte[] readRecords(byte[] aid, byte[] ef, int start, int end) throws SignatureCardException, InterruptedException { + try { - + // SELECT FILE (AID) byte[] rb = selectFileAID(aid); if (rb[rb.length - 2] != (byte) 0x90 || rb[rb.length - 1] != (byte) 0x00) { @@ -250,38 +238,90 @@ public abstract class AbstractSignatureCard implements SignatureCard { + Integer.toHexString(resp.getSW()) + ")."); } - - // try to READ BINARY - byte[] b = new byte[1]; - int sw = readBinary(0, 1, b); - if (provider != null && sw == 0x6982) { - - // VERIFY - verifyPIN(provider, spec, kid); - - } else if (sw == 0x9000) { - // not expected type - if (b[0] != 0x30) { - throw new NotActivatedException(); - } - } else { - throw new SignatureCardException("READ BINARY failed (SW=" - + Integer.toHexString(sw) + ")."); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + + for (int i = start; i <= end; i++) { + bytes.write(readRecord(i)); } - - // READ BINARY - byte[] data = readBinaryTLV(maxLength, (byte) 0x30); - - return data; - + + return bytes.toByteArray(); + } catch (CardException e) { throw new SignatureCardException("Failed to acces card.", e); + } catch (IOException e) { + throw new SignatureCardException("Failed to read records.", e); } - + + } + + /** + * Read the content of a TLV file. + * + * @param aid the application ID (AID) + * @param ef the elementary file (EF) + * @param maxLength the maximum length of the file + * + * @return the content of the file + * + * @throws SignatureCardException + * @throws CardException + */ + protected byte[] readTLVFile(byte[] aid, byte[] ef, int maxLength) + throws SignatureCardException, InterruptedException, CardException { + return readTLVFile(aid, ef, null, (byte) 0, maxLength); } /** + * Read the content of a TLV file wich may require a PIN. + * + * @param aid the application ID (AID) + * @param ef the elementary file (EF) + * @param kid the key ID (KID) of the corresponding PIN + * @param provider the PINProvider + * @param spec the PINSpec + * @param maxLength the maximum length of the file + * + * @return the content of the file + * + * @throws SignatureCardException + * @throws CardException + */ + protected byte[] readTLVFile(byte[] aid, byte[] ef, String pin, byte kid, int maxLength) + throws SignatureCardException, InterruptedException, CardException { + + + // SELECT FILE (AID) + selectFileAID(aid); + + // SELECT FILE (EF) + ResponseAPDU resp = selectFileFID(ef); + if (resp.getSW() == 0x6a82) { + // EF not found + throw new FileNotFoundException("EF " + toString(ef) + " not found."); + } else if (resp.getSW() != 0x9000) { + throw new SignatureCardException("SELECT FILE with " + + "FID=" + + toString(ef) + + " failed (" + + "SW=" + + Integer.toHexString(resp.getSW()) + ")."); + } + + // VERIFY + if (pin != null) { + int retries = verifyPIN(pin, kid); + if (retries != -1) { + throw new VerificationFailedException(retries); + } + } + + return readBinaryTLV(maxLength, (byte) 0x30); + + + } + + /** * Transmit the given command APDU using the given card channel. * * @param channel @@ -331,8 +371,9 @@ public abstract class AbstractSignatureCard implements SignatureCard { } - public void init(Card card) { + public void init(Card card, CardTerminal cardTerminal) { card_ = card; + this.cardTerminal = cardTerminal; ATR atr = card.getATR(); byte[] atrBytes = atr.getBytes(); if (atrBytes.length >= 6) { @@ -340,6 +381,11 @@ public abstract class AbstractSignatureCard implements SignatureCard { log.trace("Setting IFS (information field size) to " + ifs_); } } + + @Override + public Card getCard() { + return card_; + } protected CardChannel getCardChannel() { return card_.getBasicChannel(); @@ -372,4 +418,18 @@ public abstract class AbstractSignatureCard implements SignatureCard { } } + @Override + public void reset() throws SignatureCardException { + try { + log.debug("Disconnect and reset smart card."); + card_.disconnect(true); + log.debug("Reconnect smart card."); + if (cardTerminal != null) { + card_ = cardTerminal.connect("*"); + } + } catch (CardException e) { + throw new SignatureCardException("Failed to reset card.", e); + } + } + } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java index d6d02475..2a6e90bf 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java @@ -31,7 +31,6 @@ package at.gv.egiz.smcc; import java.math.BigInteger; import java.util.Arrays; -import javax.smartcardio.Card; import javax.smartcardio.CardChannel; import javax.smartcardio.CardException; import javax.smartcardio.CommandAPDU; @@ -49,6 +48,42 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard public static final byte[] MF = new byte[] { (byte) 0x3F, (byte) 0x00 }; + /** + * Application ID <em>SV-Personendaten</em>. + */ + public static final byte[] AID_SV_PERSONENDATEN = new byte[] { + (byte) 0xD0, (byte) 0x40, (byte) 0x00, (byte) 0x00, + (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01 + }; + + /** + * File ID <em>Grunddaten</em> ({@link #AID_SV_PERSONENDATEN}). + */ + public static final byte[] FID_GRUNDDATEN = new byte[] { + (byte) 0xEF, (byte) 0x01 + }; + + /** + * File ID <em>EHIC</em> ({@link #AID_SV_PERSONENDATEN}). + */ + public static final byte[] FID_EHIC = new byte[] { + (byte) 0xEF, (byte) 0x02 + }; + + /** + * File ID <em>Status</em> ({@link #AID_SV_PERSONENDATEN}). + */ + public static final byte[] FID_SV_PERSONENBINDUNG = new byte[] { + (byte) 0xEF, (byte) 0x03 + }; + + /** + * File ID <em>Status</em> ({@link #AID_SV_PERSONENDATEN}). + */ + public static final byte[] FID_STATUS = new byte[] { + (byte) 0xEF, (byte) 0x04 + }; + public static final byte[] AID_INFOBOX = new byte[] { (byte) 0xd0, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x17, (byte) 0x00, (byte) 0x18, (byte) 0x01 }; @@ -126,85 +161,134 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard super("at/gv/egiz/smcc/STARCOSCard"); } - /* (non-Javadoc) - * @see at.gv.egiz.smcc.SignatureCard#getCertificate(at.gv.egiz.smcc.SignatureCard.KeyboxName) - */ @Override public byte[] getCertificate(KeyboxName keyboxName) throws SignatureCardException, InterruptedException { - byte[] aid; - byte[] efc; - if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) { - aid = AID_DF_SS; - efc = EF_C_X509_CH_DS; - } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) { - aid = AID_DF_GS; - efc = EF_C_X509_CH_AUT; - } else { - throw new IllegalArgumentException("Keybox " + keyboxName - + " not supported."); - } + try { + + if (keyboxName == KeyboxName.SECURE_SIGNATURE_KEYPAIR) { + + try { + getCard().beginExclusive(); + return readTLVFile(AID_DF_SS, EF_C_X509_CH_DS, 2000); + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } finally { + getCard().endExclusive(); + } + + } else if (keyboxName == KeyboxName.CERITIFIED_KEYPAIR) { - log.debug("Get certificate for keybox '" + keyboxName.getKeyboxName() + "'" + - " (AID=" + toString(aid) + " EF=" + toString(efc) + ")."); + try { + getCard().beginExclusive(); + return readTLVFile(AID_DF_GS, EF_C_X509_CH_AUT, 2000); + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } finally { + getCard().endExclusive(); + } - try { - Card card = getCardChannel().getCard(); - try { - card.beginExclusive(); - return readTLVFile(aid, efc, 2000); - } catch (FileNotFoundException e) { - // if certificate is not present, - // the citizen card application has not been activated - throw new NotActivatedException(); - } finally { - card.endExclusive(); + } else { + throw new IllegalArgumentException("Keybox " + keyboxName + + " not supported."); } + } catch (CardException e) { - throw new SignatureCardException("Failed to get exclusive card access."); + log.warn(e); + throw new SignatureCardException("Failed to access card.", e); } - - } - /* (non-Javadoc) - * @see at.gv.egiz.smcc.SignatureCard#getInfobox(java.lang.String, at.gv.egiz.smcc.PINProvider, java.lang.String) - */ + } + @Override public byte[] getInfobox(String infobox, PINProvider provider, String domainId) throws SignatureCardException, InterruptedException { - if ("IdentityLink".equals(infobox)) { - - PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name")); - - try { - Card card = getCardChannel().getCard(); + try { + if ("IdentityLink".equals(infobox)) { + + PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name")); + + int retries = -1; + String pin = null; + boolean pinRequiered = false; + + do { + if (pinRequiered) { + pin = provider.providePIN(spec, retries); + if (pin == null) { + throw new CancelledException(); + } + } + try { + getCard().beginExclusive(); + return readTLVFile(AID_INFOBOX, EF_INFOBOX, pin, KID_PIN_CARD, 2000); + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } catch (SecurityStatusNotSatisfiedException e) { + pinRequiered = true; + retries = verifyPIN(null, KID_PIN_CARD); + } catch (VerificationFailedException e) { + pinRequiered = true; + retries = e.getRetries(); + } finally { + getCard().endExclusive(); + } + } while (retries != 0); + + throw new LockedException(); + + + } else if ("EHIC".equals(infobox)) { + try { - card.beginExclusive(); - return readTLVFilePIN(AID_INFOBOX, EF_INFOBOX, KID_PIN_CARD, - provider, spec, 2000); - } catch (FileNotFoundException e) { - // if certificate is not present, - // the citizen card application has not been activated - throw new NotActivatedException(); + getCard().beginExclusive(); + return readTLVFile(AID_SV_PERSONENDATEN, FID_EHIC, 126); } finally { - card.endExclusive(); + getCard().endExclusive(); } - } catch (CardException e) { - throw new SignatureCardException("Failed to get exclusive card access."); + + } else if ("Grunddaten".equals(infobox)) { + + try { + getCard().beginExclusive(); + return readTLVFile(AID_SV_PERSONENDATEN, FID_GRUNDDATEN, 550); + } finally { + getCard().endExclusive(); + } + + } else if ("SV-Personenbindung".equals(infobox)) { + + try { + getCard().beginExclusive(); + return readTLVFile(AID_SV_PERSONENDATEN, FID_SV_PERSONENBINDUNG, 500); + } finally { + getCard().endExclusive(); + } + + } else if ("Status".equals(infobox)) { + + try { + getCard().beginExclusive(); + return readRecords(AID_SV_PERSONENDATEN, FID_STATUS, 1, 5); + } finally { + getCard().endExclusive(); + } + + } else { + throw new IllegalArgumentException("Infobox '" + infobox + + "' not supported."); } - } else { - throw new IllegalArgumentException("Infobox '" + infobox - + "' not supported."); + } catch (CardException e) { + log.warn(e); + throw new SignatureCardException("Failed to access card.", e); } } - /* (non-Javadoc) - * @see at.gv.egiz.smcc.SignatureCard#createSignature(byte[], at.gv.egiz.smcc.SignatureCard.KeyboxName, at.gv.egiz.smcc.PINProvider) - */ + @Override public byte[] createSignature(byte[] hash, KeyboxName keyboxName, PINProvider provider) throws SignatureCardException, InterruptedException { @@ -212,72 +296,115 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard throw new IllegalArgumentException("Hash value must be of length 20."); } - byte[] aid; - byte kid; - byte[] dst; - PINSpec spec; - if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) { - aid = AID_DF_SS; - kid = KID_PIN_SS; - dst = DST_SS; - spec = new PINSpec(6, 10, "[0-9]", getResourceBundle().getString("sig.pin.name")); - - } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) { - aid = AID_DF_GS; - kid = KID_PIN_CARD; - dst = DST_GS; - spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name")); - - } else { - throw new IllegalArgumentException("KeyboxName '" + keyboxName - + "' not supported."); - } - try { - Card card = getCardChannel().getCard(); - try { - card.beginExclusive(); - - // SELECT MF - selectMF(); - // SELECT DF - selectFileAID(aid); - // VERIFY - verifyPIN(provider, spec, kid); - // MSE: SET DST - mseSetDST(dst); - // PSO: HASH - psoHash(hash); - // PSO: COMPUTE DIGITAL SIGNATURE - return psoComputDigitalSiganture(); - - - } catch (FileNotFoundException e) { - // if certificate is not present, - // the citizen card application has not been activated - throw new NotActivatedException(); - } finally { - card.endExclusive(); + + if (KeyboxName.SECURE_SIGNATURE_KEYPAIR.equals(keyboxName)) { + + PINSpec spec = new PINSpec(6, 10, "[0-9]", getResourceBundle().getString("sig.pin.name")); + + int retries = -1; + String pin = null; + + do { + try { + getCard().beginExclusive(); + selectFileAID(AID_DF_SS); + retries = verifyPIN(null, KID_PIN_SS); + } finally { + getCard().endExclusive(); + } + pin = provider.providePIN(spec, retries); + if (pin == null) { + throw new CancelledException(); + } + try { + getCard().beginExclusive(); + return createSignature(hash, AID_DF_SS, pin, KID_PIN_SS, DST_SS); + } catch (VerificationFailedException e) { + retries = e.getRetries(); + } finally { + getCard().endExclusive(); + } + } while (retries != 0); + + throw new LockedException(); + + + } else if (KeyboxName.CERITIFIED_KEYPAIR.equals(keyboxName)) { + + PINSpec spec = new PINSpec(4, 4, "[0-9]", getResourceBundle().getString("card.pin.name")); + + int retries = -1; + String pin = null; + boolean pinRequiered = false; + + do { + if (pinRequiered) { + pin = provider.providePIN(spec, retries); + if (pin == null) { + throw new CancelledException(); + } + } + try { + getCard().beginExclusive(); + return createSignature(hash, AID_DF_GS, pin, KID_PIN_CARD, DST_GS); + } catch (FileNotFoundException e) { + throw new NotActivatedException(); + } catch (SecurityStatusNotSatisfiedException e) { + pinRequiered = true; + retries = verifyPIN(null, KID_PIN_CARD); + } catch (VerificationFailedException e) { + pinRequiered = true; + retries = e.getRetries(); + } finally { + getCard().endExclusive(); + } + } while (retries != 0); + + throw new LockedException(); + + } else { + throw new IllegalArgumentException("KeyboxName '" + keyboxName + + "' not supported."); } + } catch (CardException e) { - throw new SignatureCardException("Failed to get exclusive card access."); + log.warn(e); + throw new SignatureCardException("Failed to access card.", e); } } - protected byte[] selectFileAID(byte[] fid) throws CardException, SignatureCardException { + protected ResponseAPDU selectFileFID(byte[] fid) throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); - ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x04, + return transmit(channel, new CommandAPDU(0x00, 0xA4, 0x02, 0x04, fid, 256)); - if (resp.getSW() != 0x9000) { - throw new SignatureCardException("Failed to select file (AID=" - + toString(fid) + "): SW=" + Integer.toHexString(resp.getSW()) + "."); - } else { - return resp.getBytes(); + } + + private byte[] createSignature(byte[] hash, byte[] aid, String pin, byte kid, + byte[] dst) throws CardException, SignatureCardException { + + // SELECT MF + selectMF(); + // SELECT DF + selectFileAID(aid); + // VERIFY + int retries = verifyPIN(pin, kid); + if (retries != -1) { + throw new VerificationFailedException(retries); } + // MSE: SET DST + mseSetDST(dst); + // PSO: HASH + psoHash(hash); + // PSO: COMPUTE DIGITAL SIGNATURE + return psoComputDigitalSiganture(); + + } - void selectMF() throws CardException, SignatureCardException { + + private void selectMF() throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0xA4, 0x00, 0x0C)); @@ -287,13 +414,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard } } - protected ResponseAPDU selectFileFID(byte[] fid) throws CardException, SignatureCardException { - CardChannel channel = getCardChannel(); - return transmit(channel, new CommandAPDU(0x00, 0xA4, 0x02, - 0x04, fid, 256)); - } - - void mseSetDST(byte[] dst) throws CardException, SignatureCardException { + private void mseSetDST(byte[] dst) throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x22, 0x41, 0xB6, dst)); @@ -303,7 +424,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard } } - void psoHash(byte[] hash) throws CardException, SignatureCardException { + private void psoHash(byte[] hash) throws CardException, SignatureCardException { byte[] data = new byte[hash.length + 2]; data[0] = (byte) 0x90; // tag data[1] = (byte) (hash.length); // length @@ -318,7 +439,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard } } - byte[] psoComputDigitalSiganture() throws CardException, + private byte[] psoComputDigitalSiganture() throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); ResponseAPDU resp = transmit(channel, new CommandAPDU(0x00, 0x2A, 0x9E, @@ -353,7 +474,8 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard * @throws SignatureCardException * if VERIFY PIN fails */ - private int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException { + @Override + protected int verifyPIN(String pin, byte kid) throws CardException, SignatureCardException { CardChannel channel = getCardChannel(); @@ -385,6 +507,8 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard } else if (resp.getSW1() == 0x63 && resp.getSW2() >> 4 == 0xc) { // return number of possible retries return resp.getSW2() & 0x0f; + } else if (resp.getSW() == 0x6983) { + throw new LockedException(); } else if (resp.getSW() == 0x6984) { // PIN LCS = "Initialized" (-> not activated) throw new NotActivatedException("PIN not set."); @@ -397,26 +521,8 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard } - /* (non-Javadoc) - * @see at.gv.egiz.smcc.AbstractSignatureCard#verifyPIN(at.gv.egiz.smcc.PINProvider, at.gv.egiz.smcc.PINSpec, byte, int) - */ - protected void verifyPIN(PINProvider pinProvider, PINSpec spec, byte kid) - throws CardException, SignatureCardException, InterruptedException { - - int retries = verifyPIN(null, kid); - do { - String pin = pinProvider.providePIN(spec, retries); - if (pin == null) { - // user canceled operation - throw new CancelledException("User canceld operation."); - } - retries = verifyPIN(pin, kid); - } while (retries > 0); - - } - public String toString() { - return "eCard"; + return "e-card"; } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java index 42943541..439be034 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java @@ -40,6 +40,7 @@ import java.util.Enumeration; import java.util.Locale; import javax.smartcardio.Card; +import javax.smartcardio.CardTerminal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -102,7 +103,12 @@ public class SWCard implements SignatureCard { SWCard.swCardDir = swCardDir; } - public void init(Card card) { + public void init(Card card, CardTerminal cardTerminal) { + } + + @Override + public Card getCard() { + return null; } private String getFileName(String fileName) { @@ -379,4 +385,8 @@ public class SWCard implements SignatureCard { public void disconnect(boolean reset) { } + @Override + public void reset() throws SignatureCardException { + } + } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SecurityStatusNotSatisfiedException.java b/smcc/src/main/java/at/gv/egiz/smcc/SecurityStatusNotSatisfiedException.java new file mode 100644 index 00000000..bf0af76c --- /dev/null +++ b/smcc/src/main/java/at/gv/egiz/smcc/SecurityStatusNotSatisfiedException.java @@ -0,0 +1,38 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.smcc; + +public class SecurityStatusNotSatisfiedException extends SignatureCardException { + + private static final long serialVersionUID = 1L; + + public SecurityStatusNotSatisfiedException() { + } + + public SecurityStatusNotSatisfiedException(String message, Throwable cause) { + super(message, cause); + } + + public SecurityStatusNotSatisfiedException(String message) { + super(message); + } + + public SecurityStatusNotSatisfiedException(Throwable cause) { + super(cause); + } + +} diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java index b6a453df..d7e76dd8 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java @@ -31,6 +31,7 @@ package at.gv.egiz.smcc; import java.util.Locale; import javax.smartcardio.Card; +import javax.smartcardio.CardTerminal; public interface SignatureCard { @@ -75,12 +76,21 @@ public interface SignatureCard { } - public void init(Card card); + public void init(Card card, CardTerminal cardTerminal); + + public Card getCard(); public byte[] getCertificate(KeyboxName keyboxName) throws SignatureCardException, InterruptedException; public void disconnect(boolean reset); + + /** + * Performs a reset of the card. + * + * @throws SignatureCardException if reset fails. + */ + public void reset() throws SignatureCardException; /** * diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java index 777299d9..ab66e9a1 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCardFactory.java @@ -34,6 +34,7 @@ import java.util.List; import javax.smartcardio.ATR; import javax.smartcardio.Card; +import javax.smartcardio.CardTerminal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -204,6 +205,7 @@ public class SignatureCardFactory { * @param card * the smart card, or <code>null</code> if a software card should be * created + * @param cardTerminal TODO * * @return a SignatureCard instance * @@ -211,12 +213,12 @@ public class SignatureCardFactory { * if no implementation of the given <code>card</code> could be * found */ - public SignatureCard createSignatureCard(Card card) + public SignatureCard createSignatureCard(Card card, CardTerminal cardTerminal) throws CardNotSupportedException { if(card == null) { SignatureCard sCard = new SWCard(); - sCard.init(card); + sCard.init(card, cardTerminal); return sCard; } @@ -231,7 +233,7 @@ public class SignatureCardFactory { try { Class<?> scClass = cl.loadClass(supportedCard.getImplementationClassName()); sc = (SignatureCard) scClass.newInstance(); - sc.init(card); + sc.init(card, cardTerminal); return sc; } catch (ClassNotFoundException e) { diff --git a/smcc/src/main/java/at/gv/egiz/smcc/VerificationFailedException.java b/smcc/src/main/java/at/gv/egiz/smcc/VerificationFailedException.java new file mode 100644 index 00000000..fa066ff9 --- /dev/null +++ b/smcc/src/main/java/at/gv/egiz/smcc/VerificationFailedException.java @@ -0,0 +1,65 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.smcc; + +public class VerificationFailedException extends SignatureCardException { + + private static final long serialVersionUID = 1L; + + public static final int UNKNOWN = -1; + + private int retries = UNKNOWN; + + public VerificationFailedException() { + } + + public VerificationFailedException(String message, Throwable cause) { + super(message, cause); + } + + public VerificationFailedException(String message) { + super(message); + } + + public VerificationFailedException(Throwable cause) { + super(cause); + } + + public VerificationFailedException(int retries) { + this.retries = retries; + } + + public VerificationFailedException(int retries, String message, Throwable cause) { + super(message, cause); + this.retries = retries; + } + + public VerificationFailedException(int retries, String message) { + super(message); + this.retries = retries; + } + + public VerificationFailedException(int retries, Throwable cause) { + super(cause); + this.retries = retries; + } + + public int getRetries() { + return retries; + } + +} diff --git a/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java b/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java index 4dae7975..f7d3bab7 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/util/SMCCHelper.java @@ -57,7 +57,7 @@ public class SMCCHelper { SignatureCardFactory factory = SignatureCardFactory.getInstance();
if (useSWCard) {
try {
- signatureCard = factory.createSignatureCard(null);
+ signatureCard = factory.createSignatureCard(null, null);
resultCode = CARD_FOUND;
} catch (CardNotSupportedException e) {
resultCode = CARD_NOT_SUPPORTED;
@@ -83,7 +83,7 @@ public class SMCCHelper { if (c == null) {
throw new CardNotSupportedException();
}
- signatureCard = factory.createSignatureCard(c);
+ signatureCard = factory.createSignatureCard(c, cardTerminal);
ATR atr = newCards.get(cardTerminal).getATR();
log.trace("Found supported card (" + signatureCard.toString() + ") "
+ "in terminal '" + cardTerminal.getName() + "', ATR = "
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java b/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java index b70b44a7..b1866894 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/util/SmartCardIO.java @@ -16,6 +16,7 @@ */ package at.gv.egiz.smcc.util;
+import java.security.NoSuchAlgorithmException; import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -54,7 +55,13 @@ public class SmartCardIO { CardTerminals cardTerminals_;
private void updateTerminalFactory() {
- TerminalFactory terminalFactory = TerminalFactory.getDefault();
+ TerminalFactory terminalFactory; + try { + terminalFactory = TerminalFactory.getInstance("PC/SC", null); + } catch (NoSuchAlgorithmException e) { + log.info("Failed to get TerminalFactory of type 'PC/SC'.", e); + terminalFactory = TerminalFactory.getDefault(); + }
log.debug("TerminalFactory : " + terminalFactory);
if ("PC/SC".equals(terminalFactory.getType())) {
terminalFactory_ = terminalFactory;
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/SMCCApplication.java b/smcc/src/test/java/at/gv/egiz/smcc/SMCCApplication.java deleted file mode 100644 index 5f4bb67e..00000000 --- a/smcc/src/test/java/at/gv/egiz/smcc/SMCCApplication.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright 2008 Federal Chancellery Austria and -* Graz University of Technology -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package at.gv.egiz.smcc;
-
-import java.util.Locale;
-
-import at.gv.egiz.smcc.util.SMCCHelper;
-
-public class SMCCApplication {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- SignatureCard sc = null;
- SMCCHelper smccHelper = new SMCCHelper();
- while (smccHelper.getResultCode() != SMCCHelper.CARD_FOUND) {
- System.out.println("Did not get a signature card ... "+smccHelper.getResultCode());
- smccHelper.update();
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- sc = smccHelper.getSignatureCard(Locale.getDefault());
- System.out.println("Found supported siganture card: "+sc);
- }
-
-}
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java deleted file mode 100644 index 13210540..00000000 --- a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* -* Copyright 2008 Federal Chancellery Austria and -* Graz University of Technology -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package at.gv.egiz.smcc; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Locale; - -import javax.smartcardio.CardException; -import javax.smartcardio.CommandAPDU; -import javax.smartcardio.ResponseAPDU; - -import at.gv.egiz.smcc.SignatureCard.KeyboxName; -import at.gv.egiz.smcc.util.SMCCHelper; - -public class STARCOSCardTest { - - /** - * @param args - * @throws CardException - * @throws NoSuchAlgorithmException - */ - public static void main(String[] args) throws CardException, NoSuchAlgorithmException, InterruptedException { - - SMCCHelper helper = new SMCCHelper(); - while (helper.getResultCode() != SMCCHelper.CARD_FOUND) { - System.out.println("Did not get a signature card ... " + helper.getResultCode()); - helper.update(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - SignatureCard signatureCard = helper.getSignatureCard(Locale.getDefault()); - - System.out.println("Found '" + signatureCard + "'."); - - try { -// signatureCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR); -// signatureCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR); -// signatureCard.getInfobox("IdentityLink", new CommandLinePINProvider(), null); - MessageDigest messageDigest = MessageDigest.getInstance("SHA-1"); - byte[] digest = messageDigest.digest("test".getBytes()); - signatureCard.createSignature(digest, KeyboxName.CERITIFIED_KEYPAIR, new CommandLinePINProvider()); - } catch (SignatureCardException e) { - e.printStackTrace(); - } - - } - - private static class CommandLinePINProvider implements PINProvider { - - @Override - public String providePIN(PINSpec spec, int retries) { - - InputStreamReader inputStreamReader = new InputStreamReader(System.in); - BufferedReader in = new BufferedReader(inputStreamReader); - - System.out.print("Enter " + spec.getLocalizedName() + " [" - + spec.getMinLength() + "-" + spec.getMaxLength() + "] (" + retries - + " retries):"); - - try { - return in.readLine(); - } catch (IOException e) { - return null; - } - - } - - } - -} diff --git a/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java deleted file mode 100644 index 38126a67..00000000 --- a/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -* Copyright 2008 Federal Chancellery Austria and -* Graz University of Technology -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package at.gv.egiz.smcc; - -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import at.gv.egiz.smcc.SignatureCard.KeyboxName; - -public class SWCardTest implements PINProvider { - - SWCard swCard = new SWCard(); - - public static void main(String[] args) throws Exception { - - SWCardTest swCardTest = new SWCardTest(); - swCardTest.test(); - - } - - public void test() throws SignatureCardException, NoSuchAlgorithmException, InterruptedException { - - swCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR); - swCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR); - - BigInteger t = BigInteger.valueOf(System.currentTimeMillis()); - - MessageDigest messageDigest = MessageDigest.getInstance("SHA-1"); - byte[] hash = messageDigest.digest(t.toByteArray()); - - byte[] signature; - signature = swCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR, this); - System.out.println(SignatureCardFactory.toString(signature)); - - signature = swCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR, this); - System.out.println(SignatureCardFactory.toString(signature)); - - byte[] infobox = swCard.getInfobox("IdentityLink", this, null); - System.out.println(SignatureCardFactory.toString(infobox)); - - } - - @Override - public String providePIN(PINSpec spec, int retries) { - return "buerger"; - } - -} diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java index 04d8d0dd..6f08a135 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java @@ -24,8 +24,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,7 +34,6 @@ import at.gv.egiz.stal.InfoboxReadRequest; import at.gv.egiz.stal.STAL; import at.gv.egiz.stal.STALRequest; import at.gv.egiz.stal.STALResponse; -import java.util.Collections; public abstract class AbstractSMCCSTAL implements STAL { private static Log log = LogFactory.getLog(AbstractSMCCSTAL.class); @@ -106,7 +103,7 @@ public abstract class AbstractSMCCSTAL implements STAL { log.info("Interrupt in handleRequest, do not retry"); throw e; } catch (Exception e) { - log.info("Error while handling STAL request:" + e); + log.info("Error while handling STAL request:", e); if (++retryCounter < maxRetries) { signatureCard.disconnect(true); signatureCard = null; @@ -124,7 +121,7 @@ public abstract class AbstractSMCCSTAL implements STAL { } @Override - public List<STALResponse> handleRequest(List<STALRequest> requestList) { + public List<STALResponse> handleRequest(List<? extends STALRequest> requestList) { log.debug("Got request list containing " + requestList.size() + " STAL requests"); List<STALResponse> responseList = new ArrayList<STALResponse>(requestList @@ -143,8 +140,7 @@ public abstract class AbstractSMCCSTAL implements STAL { } } catch (InterruptedException ex) { log.error("got interrupted, return ErrorResponse 6001"); - responseList = Collections.singletonList((STALResponse) new ErrorResponse(6001)); - break; + throw new RuntimeException(ex); } } diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java index 04f179e7..5a54e97f 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java @@ -103,6 +103,9 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements stalResp.setInfoboxValue(resp); return stalResp; } + } catch (IllegalArgumentException e) { + log.info("Infobox " + infoBox.getInfoboxIdentifier() + " not supported."); + return new ErrorResponse(4002); } catch (NotActivatedException e) { log.info("Citizen card not activated.", e); gui.showErrorDialog(BKUGUIFacade.ERR_CARD_NOTACTIVATED, null, this, null); diff --git a/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java b/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java index 59ea141c..77997217 100644 --- a/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java +++ b/smccSTAL/src/test/java/at/gv/egiz/smcc/AbstractSMCCSTALTest.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Locale;
import javax.smartcardio.Card;
+import javax.smartcardio.CardTerminal;
import org.junit.Assert;
import org.junit.Before;
@@ -61,7 +62,7 @@ public class AbstractSMCCSTALTest extends AbstractSMCCSTAL implements }
@Override
- public void init(Card card) {
+ public void init(Card card, CardTerminal cardTerminal) {
// TODO Auto-generated method stub
}
@@ -71,6 +72,18 @@ public class AbstractSMCCSTALTest extends AbstractSMCCSTAL implements // TODO Auto-generated method stub
}
+
+ @Override
+ public Card getCard() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void reset() throws SignatureCardException {
+ // TODO Auto-generated method stub
+
+ }
};
return false;
diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ATRType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ATRType.java new file mode 100644 index 00000000..9620e66b --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ATRType.java @@ -0,0 +1,100 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.HexBinaryAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + * Contains the ATR received as reponse to a Reset + * command + * + * <p>Java class for ATRType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="ATRType"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>hexBinary"> + * <attribute name="rc" type="{http://www.w3.org/2001/XMLSchema}integer" default="0" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ATRType", propOrder = { + "value" +}) +public class ATRType { + + @XmlValue + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] value; + @XmlAttribute + protected BigInteger rc; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(byte[] value) { + this.value = ((byte[]) value); + } + + /** + * Gets the value of the rc property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getRc() { + if (rc == null) { + return new BigInteger("0"); + } else { + return rc; + } + } + + /** + * Sets the value of the rc property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setRc(BigInteger value) { + this.rc = value; + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/AttributeList.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/AttributeList.java new file mode 100644 index 00000000..70ad7b91 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/AttributeList.java @@ -0,0 +1,71 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * Contains a list of attributes + * + * <p>Java class for AttributeList complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="AttributeList"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="Attribute" type="{}AttributeType" maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "AttributeList", propOrder = { + "attribute" +}) +public class AttributeList { + + @XmlElement(name = "Attribute") + protected List<AttributeType> attribute; + + /** + * Gets the value of the attribute property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the attribute property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getAttribute().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link AttributeType } + * + * + */ + public List<AttributeType> getAttribute() { + if (attribute == null) { + attribute = new ArrayList<AttributeType>(); + } + return this.attribute; + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/AttributeType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/AttributeType.java new file mode 100644 index 00000000..60d467e0 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/AttributeType.java @@ -0,0 +1,264 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.datatype.XMLGregorianCalendar; + + +/** + * Contains an attribute converted from ASN.1 + * + * <p>Java class for AttributeType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="AttributeType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="Integer" type="{http://www.w3.org/2001/XMLSchema}integer" minOccurs="0"/> + * <element name="Latin1String" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="UTF8String" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="NumericString" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="PrintableString" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="GeneralizedTime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/> + * <element name="Date" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * <attribute name="oid" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "AttributeType", propOrder = { + "integer", + "latin1String", + "utf8String", + "numericString", + "printableString", + "generalizedTime", + "date" +}) +public class AttributeType { + + @XmlElement(name = "Integer") + protected BigInteger integer; + @XmlElement(name = "Latin1String") + protected String latin1String; + @XmlElement(name = "UTF8String") + protected String utf8String; + @XmlElement(name = "NumericString") + protected String numericString; + @XmlElement(name = "PrintableString") + protected String printableString; + @XmlElement(name = "GeneralizedTime") + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar generalizedTime; + @XmlElement(name = "Date") + protected String date; + @XmlAttribute(required = true) + protected String oid; + + /** + * Gets the value of the integer property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getInteger() { + return integer; + } + + /** + * Sets the value of the integer property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setInteger(BigInteger value) { + this.integer = value; + } + + /** + * Gets the value of the latin1String property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLatin1String() { + return latin1String; + } + + /** + * Sets the value of the latin1String property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLatin1String(String value) { + this.latin1String = value; + } + + /** + * Gets the value of the utf8String property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUTF8String() { + return utf8String; + } + + /** + * Sets the value of the utf8String property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUTF8String(String value) { + this.utf8String = value; + } + + /** + * Gets the value of the numericString property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNumericString() { + return numericString; + } + + /** + * Sets the value of the numericString property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNumericString(String value) { + this.numericString = value; + } + + /** + * Gets the value of the printableString property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPrintableString() { + return printableString; + } + + /** + * Sets the value of the printableString property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPrintableString(String value) { + this.printableString = value; + } + + /** + * Gets the value of the generalizedTime property. + * + * @return + * possible object is + * {@link XMLGregorianCalendar } + * + */ + public XMLGregorianCalendar getGeneralizedTime() { + return generalizedTime; + } + + /** + * Sets the value of the generalizedTime property. + * + * @param value + * allowed object is + * {@link XMLGregorianCalendar } + * + */ + public void setGeneralizedTime(XMLGregorianCalendar value) { + this.generalizedTime = value; + } + + /** + * Gets the value of the date property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDate() { + return date; + } + + /** + * Sets the value of the date property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDate(String value) { + this.date = value; + } + + /** + * Gets the value of the oid property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getOid() { + return oid; + } + + /** + * Sets the value of the oid property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setOid(String value) { + this.oid = value; + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/CommandAPDUType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/CommandAPDUType.java new file mode 100644 index 00000000..b47359b6 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/CommandAPDUType.java @@ -0,0 +1,154 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.HexBinaryAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + * Contains a sequence of bytes send as command APDU to the + * icc + * + * <p>Java class for CommandAPDUType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="CommandAPDUType"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>hexBinary"> + * <attribute name="sequence" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" /> + * <attribute name="of" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" /> + * <attribute name="expectedSW" type="{http://www.w3.org/2001/XMLSchema}hexBinary" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CommandAPDUType", propOrder = { + "value" +}) +public class CommandAPDUType { + + @XmlValue + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] value; + @XmlAttribute(required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequence; + @XmlAttribute(required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger of; + @XmlAttribute + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] expectedSW; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(byte[] value) { + this.value = ((byte[]) value); + } + + /** + * Gets the value of the sequence property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getSequence() { + return sequence; + } + + /** + * Sets the value of the sequence property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setSequence(BigInteger value) { + this.sequence = value; + } + + /** + * Gets the value of the of property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getOf() { + return of; + } + + /** + * Sets the value of the of property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setOf(BigInteger value) { + this.of = value; + } + + /** + * Gets the value of the expectedSW property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getExpectedSW() { + return expectedSW; + } + + /** + * Sets the value of the expectedSW property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setExpectedSW(byte[] value) { + this.expectedSW = ((byte[]) value); + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ObjectFactory.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ObjectFactory.java new file mode 100644 index 00000000..cb0a163c --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ObjectFactory.java @@ -0,0 +1,170 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.bind.annotation.adapters.HexBinaryAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the at.buergerkarte.namespaces.cardchannel package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _Grunddaten_QNAME = new QName("", "Grunddaten"); + private final static QName _Script_QNAME = new QName("", "Script"); + private final static QName _Response_QNAME = new QName("", "Response"); + private final static QName _SVPersonenbindung_QNAME = new QName("", "SV-Personenbindung"); + private final static QName _Status_QNAME = new QName("", "Status"); + private final static QName _EHIC_QNAME = new QName("", "EHIC"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: at.buergerkarte.namespaces.cardchannel + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link AttributeList } + * + */ + public AttributeList createAttributeList() { + return new AttributeList(); + } + + /** + * Create an instance of {@link AttributeType } + * + */ + public AttributeType createAttributeType() { + return new AttributeType(); + } + + /** + * Create an instance of {@link ScriptType } + * + */ + public ScriptType createScriptType() { + return new ScriptType(); + } + + /** + * Create an instance of {@link ATRType } + * + */ + public ATRType createATRType() { + return new ATRType(); + } + + /** + * Create an instance of {@link CommandAPDUType } + * + */ + public CommandAPDUType createCommandAPDUType() { + return new CommandAPDUType(); + } + + /** + * Create an instance of {@link ResetType } + * + */ + public ResetType createResetType() { + return new ResetType(); + } + + /** + * Create an instance of {@link VerifyAPDUType } + * + */ + public VerifyAPDUType createVerifyAPDUType() { + return new VerifyAPDUType(); + } + + /** + * Create an instance of {@link ResponseAPDUType } + * + */ + public ResponseAPDUType createResponseAPDUType() { + return new ResponseAPDUType(); + } + + /** + * Create an instance of {@link ResponseType } + * + */ + public ResponseType createResponseType() { + return new ResponseType(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link AttributeList }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "Grunddaten") + public JAXBElement<AttributeList> createGrunddaten(AttributeList value) { + return new JAXBElement<AttributeList>(_Grunddaten_QNAME, AttributeList.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link ScriptType }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "Script") + public JAXBElement<ScriptType> createScript(ScriptType value) { + return new JAXBElement<ScriptType>(_Script_QNAME, ScriptType.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link ResponseType }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "Response") + public JAXBElement<ResponseType> createResponse(ResponseType value) { + return new JAXBElement<ResponseType>(_Response_QNAME, ResponseType.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "SV-Personenbindung") + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + public JAXBElement<byte[]> createSVPersonenbindung(byte[] value) { + return new JAXBElement<byte[]>(_SVPersonenbindung_QNAME, byte[].class, null, ((byte[]) value)); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link AttributeList }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "Status") + public JAXBElement<AttributeList> createStatus(AttributeList value) { + return new JAXBElement<AttributeList>(_Status_QNAME, AttributeList.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link AttributeList }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "EHIC") + public JAXBElement<AttributeList> createEHIC(AttributeList value) { + return new JAXBElement<AttributeList>(_EHIC_QNAME, AttributeList.class, null, value); + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResetType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResetType.java new file mode 100644 index 00000000..815a3f76 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResetType.java @@ -0,0 +1,64 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + * Reset the icc and sequence counter + * + * <p>Java class for ResetType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="ResetType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <attribute name="cold" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ResetType") +public class ResetType { + + @XmlAttribute + protected Boolean cold; + + /** + * Gets the value of the cold property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public boolean isCold() { + if (cold == null) { + return true; + } else { + return cold; + } + } + + /** + * Sets the value of the cold property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setCold(Boolean value) { + this.cold = value; + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResponseAPDUType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResponseAPDUType.java new file mode 100644 index 00000000..70f2948e --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResponseAPDUType.java @@ -0,0 +1,161 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.HexBinaryAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + * Contains a sequence of bytes received from the card as response + * APDU + * + * <p>Java class for ResponseAPDUType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="ResponseAPDUType"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>hexBinary"> + * <attribute name="sequence" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" /> + * <attribute name="rc" type="{http://www.w3.org/2001/XMLSchema}integer" default="0" /> + * <attribute name="sw" type="{http://www.w3.org/2001/XMLSchema}hexBinary" default="9000" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ResponseAPDUType", propOrder = { + "value" +}) +public class ResponseAPDUType { + + @XmlValue + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] value; + @XmlAttribute(required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequence; + @XmlAttribute + protected BigInteger rc; + @XmlAttribute(name = "SW") + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] sw; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(byte[] value) { + this.value = ((byte[]) value); + } + + /** + * Gets the value of the sequence property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getSequence() { + return sequence; + } + + /** + * Sets the value of the sequence property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setSequence(BigInteger value) { + this.sequence = value; + } + + /** + * Gets the value of the rc property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getRc() { + if (rc == null) { + return new BigInteger("0"); + } else { + return rc; + } + } + + /** + * Sets the value of the rc property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setRc(BigInteger value) { + this.rc = value; + } + + /** + * Gets the value of the sw property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getSw() { + if (sw == null) { + return new HexBinaryAdapter().unmarshal("9000"); + } else { + return sw; + } + } + + /** + * Sets the value of the sw property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSw(byte[] value) { + this.sw = ((byte[]) value); + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResponseType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResponseType.java new file mode 100644 index 00000000..b92015e3 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ResponseType.java @@ -0,0 +1,78 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlType; + + +/** + * Contains the result of the script executed by the + * BKU + * + * <p>Java class for ResponseType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="ResponseType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <choice maxOccurs="unbounded"> + * <element name="ATR" type="{}ATRType"/> + * <element name="ResponseAPDU" type="{}ResponseAPDUType"/> + * </choice> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ResponseType", propOrder = { + "atrOrResponseAPDU" +}) +public class ResponseType { + + @XmlElements({ + @XmlElement(name = "ATR", type = ATRType.class), + @XmlElement(name = "ResponseAPDU", type = ResponseAPDUType.class) + }) + protected List<Object> atrOrResponseAPDU; + + /** + * Gets the value of the atrOrResponseAPDU property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the atrOrResponseAPDU property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getATROrResponseAPDU().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link ATRType } + * {@link ResponseAPDUType } + * + * + */ + public List<Object> getATROrResponseAPDU() { + if (atrOrResponseAPDU == null) { + atrOrResponseAPDU = new ArrayList<Object>(); + } + return this.atrOrResponseAPDU; + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ScriptType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ScriptType.java new file mode 100644 index 00000000..bff76f06 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/ScriptType.java @@ -0,0 +1,80 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlType; + + +/** + * Contains the script to be executed by the BKU + * + * <p>Java class for ScriptType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="ScriptType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <choice maxOccurs="unbounded"> + * <element name="Reset" type="{}ResetType"/> + * <element name="CommandAPDU" type="{}CommandAPDUType"/> + * <element name="VerifyAPDU" type="{}VerifyAPDUType"/> + * </choice> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ScriptType", propOrder = { + "resetOrCommandAPDUOrVerifyAPDU" +}) +public class ScriptType { + + @XmlElements({ + @XmlElement(name = "Reset", type = ResetType.class), + @XmlElement(name = "VerifyAPDU", type = VerifyAPDUType.class), + @XmlElement(name = "CommandAPDU", type = CommandAPDUType.class) + }) + protected List<Object> resetOrCommandAPDUOrVerifyAPDU; + + /** + * Gets the value of the resetOrCommandAPDUOrVerifyAPDU property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the resetOrCommandAPDUOrVerifyAPDU property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getResetOrCommandAPDUOrVerifyAPDU().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link ResetType } + * {@link VerifyAPDUType } + * {@link CommandAPDUType } + * + * + */ + public List<Object> getResetOrCommandAPDUOrVerifyAPDU() { + if (resetOrCommandAPDUOrVerifyAPDU == null) { + resetOrCommandAPDUOrVerifyAPDU = new ArrayList<Object>(); + } + return this.resetOrCommandAPDUOrVerifyAPDU; + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/VerifyAPDUType.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/VerifyAPDUType.java new file mode 100644 index 00000000..20d7f3e8 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/VerifyAPDUType.java @@ -0,0 +1,266 @@ + +package at.buergerkarte.namespaces.cardchannel; + +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.HexBinaryAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + * Contains a sequence of bytes send as command APDU to the icc after a + * PIN entered by the user has been incorporated into the APDU + * + * <p>Java class for VerifyAPDUType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="VerifyAPDUType"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>hexBinary"> + * <attribute name="sequence" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" /> + * <attribute name="of" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" /> + * <attribute name="expectedSW" type="{http://www.w3.org/2001/XMLSchema}hexBinary" /> + * <attribute name="message" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="format" use="required" type="{http://www.w3.org/2001/XMLSchema}hexBinary" /> + * <attribute name="offset" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" /> + * <attribute name="timeout" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "VerifyAPDUType", propOrder = { + "value" +}) +public class VerifyAPDUType { + + @XmlValue + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] value; + @XmlAttribute(required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger sequence; + @XmlAttribute(required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger of; + @XmlAttribute + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] expectedSW; + @XmlAttribute(required = true) + protected String message; + @XmlAttribute(required = true) + @XmlJavaTypeAdapter(HexBinaryAdapter.class) + @XmlSchemaType(name = "hexBinary") + protected byte[] format; + @XmlAttribute(required = true) + @XmlSchemaType(name = "nonNegativeInteger") + protected BigInteger offset; + @XmlAttribute(required = true) + @XmlSchemaType(name = "nonNegativeInteger") + protected BigInteger timeout; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(byte[] value) { + this.value = ((byte[]) value); + } + + /** + * Gets the value of the sequence property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getSequence() { + return sequence; + } + + /** + * Sets the value of the sequence property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setSequence(BigInteger value) { + this.sequence = value; + } + + /** + * Gets the value of the of property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getOf() { + return of; + } + + /** + * Sets the value of the of property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setOf(BigInteger value) { + this.of = value; + } + + /** + * Gets the value of the expectedSW property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getExpectedSW() { + return expectedSW; + } + + /** + * Sets the value of the expectedSW property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setExpectedSW(byte[] value) { + this.expectedSW = ((byte[]) value); + } + + /** + * Gets the value of the message property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessage() { + return message; + } + + /** + * Sets the value of the message property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessage(String value) { + this.message = value; + } + + /** + * Gets the value of the format property. + * + * @return + * possible object is + * {@link String } + * + */ + public byte[] getFormat() { + return format; + } + + /** + * Sets the value of the format property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFormat(byte[] value) { + this.format = ((byte[]) value); + } + + /** + * Gets the value of the offset property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getOffset() { + return offset; + } + + /** + * Sets the value of the offset property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setOffset(BigInteger value) { + this.offset = value; + } + + /** + * Gets the value of the timeout property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getTimeout() { + return timeout; + } + + /** + * Sets the value of the timeout property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setTimeout(BigInteger value) { + this.timeout = value; + } + +} diff --git a/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/package-info.java b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/package-info.java new file mode 100644 index 00000000..13f79000 --- /dev/null +++ b/utils/src/main/java/at/buergerkarte/namespaces/cardchannel/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.buergerkarte.at/cardchannel", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package at.buergerkarte.namespaces.cardchannel; diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/DebugOutputStream.java b/utils/src/main/java/at/gv/egiz/bku/utils/DebugOutputStream.java new file mode 100644 index 00000000..8516b76c --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/bku/utils/DebugOutputStream.java @@ -0,0 +1,48 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.utils; + +import java.io.ByteArrayOutputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +public class DebugOutputStream extends FilterOutputStream { + + private ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + + public DebugOutputStream(OutputStream out) { + super(out); + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + buffer.write(b, off, len); + super.write(b, off, len); + } + + @Override + public void write(int b) throws IOException { + buffer.write(b); + super.write(b); + } + + public byte[] getBufferedBytes() { + return buffer.toByteArray(); + } + +} diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/DebugReader.java b/utils/src/main/java/at/gv/egiz/bku/utils/DebugReader.java new file mode 100644 index 00000000..cafe4a72 --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/bku/utils/DebugReader.java @@ -0,0 +1,58 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.utils; + +import java.io.FilterReader; +import java.io.IOException; +import java.io.Reader; +import java.io.StringWriter; + +public class DebugReader extends FilterReader { + + private StringWriter buffer = new StringWriter(); + + public DebugReader(Reader in) { + super(in); + } + + public DebugReader(Reader in, String start) { + super(in); + buffer.write(start); + } + + @Override + public int read() throws IOException { + int c = super.read(); + if (c != -1) + buffer.write(c); + return c; + } + + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + int l = super.read(cbuf, off, len); + if (l != -1 ) { + buffer.write(cbuf, off, l); + } + return l; + } + + public String getCachedString() { + return buffer.toString(); + } + +} diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/DebugWriter.java b/utils/src/main/java/at/gv/egiz/bku/utils/DebugWriter.java new file mode 100644 index 00000000..5566f927 --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/bku/utils/DebugWriter.java @@ -0,0 +1,55 @@ +/* +* Copyright 2008 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package at.gv.egiz.bku.utils; + +import java.io.FilterWriter; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +public class DebugWriter extends FilterWriter { + + private Writer buffer = new StringWriter(); + + public DebugWriter(Writer out) { + super(out); + } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + buffer.write(cbuf, off, len); + super.write(cbuf, off, len); + } + + @Override + public void write(String str, int off, int len) throws IOException { + buffer.write(str, off, len); + super.write(str, off, len); + } + + @Override + public void write(int c) throws IOException { + buffer.write(c); + super.write(c); + } + + public String getBufferedString() { + return buffer.toString(); + } + + +} diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/NullOutputStream.java b/utils/src/main/java/at/gv/egiz/bku/utils/NullOutputStream.java new file mode 100644 index 00000000..edbd9c01 --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/bku/utils/NullOutputStream.java @@ -0,0 +1,10 @@ +package at.gv.egiz.bku.utils;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class NullOutputStream extends OutputStream {
+ @Override
+ public void write(int b) throws IOException {
+ }
+}
diff --git a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java index a5ceeafc..fb7943dc 100644 --- a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java +++ b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package at.gv.egiz.idlink;
-
+package at.gv.egiz.idlink; + import iaik.xml.crypto.XmldsigMore; import java.io.InputStreamReader; @@ -81,6 +81,7 @@ import org.apache.commons.logging.LogFactory; import org.w3c.dom.Element; import org.w3c.dom.Node; +import at.gv.e_government.reference.namespace.persondata._20020228_.AbstractPersonType; import at.gv.e_government.reference.namespace.persondata._20020228_.IdentificationType; import at.gv.e_government.reference.namespace.persondata._20020228_.PersonNameType; import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPersonType; @@ -88,63 +89,64 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.Identificati import at.gv.e_government.reference.namespace.persondata._20020228_.PersonNameType.FamilyName; import at.gv.egiz.xmldsig.KeyTypeNotSupportedException; import at.gv.egiz.xmldsig.KeyValueFactory; -
+import oasis.names.tc.saml._1_0.assertion.AnyType; + public class IdentityLinkFactory { - private static Log log = LogFactory.getLog(IdentityLinkFactory.class);
-
- /**
- * The instance returned by {@link #getInstance()}.
- */
- private static IdentityLinkFactory instance;
-
- /**
- * The <code>JAXBContext</code>.
- */
- private static JAXBContext jaxbContext;
-
- /**
- * The <code>KeyValueFactory</code>.
- */
- private static KeyValueFactory keyValueFactory;
-
- /**
- * Get an instance of this <code>CompressedIdentityLinkFactory</code>.
- *
- * @return an instance of this <code>CompressedIdentityLinkFactory</code>
- */
- public synchronized static IdentityLinkFactory getInstance() {
- if (instance == null) {
- instance = new IdentityLinkFactory();
- }
- return instance;
- }
-
- /**
- * Private constructor.
- */
- private IdentityLinkFactory() {
-
- keyValueFactory = new KeyValueFactory();
-
- StringBuffer packageNames = new StringBuffer();
- packageNames.append(at.gv.e_government.reference.namespace.persondata._20020228_.ObjectFactory.class.getPackage().getName());
- packageNames.append(":");
- packageNames.append(org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName());
- packageNames.append(":");
- packageNames.append(org.w3._2001._04.xmldsig_more_.ObjectFactory.class.getPackage().getName());
- packageNames.append(":");
- packageNames.append(at.buergerkarte.namespaces.personenbindung._20020506_.ObjectFactory.class.getPackage().getName());
+ private static Log log = LogFactory.getLog(IdentityLinkFactory.class); + + /** + * The instance returned by {@link #getInstance()}. + */ + private static IdentityLinkFactory instance; + + /** + * The <code>JAXBContext</code>. + */ + private static JAXBContext jaxbContext; + + /** + * The <code>KeyValueFactory</code>. + */ + private static KeyValueFactory keyValueFactory; + + /** + * Get an instance of this <code>CompressedIdentityLinkFactory</code>. + * + * @return an instance of this <code>CompressedIdentityLinkFactory</code> + */ + public synchronized static IdentityLinkFactory getInstance() { + if (instance == null) { + instance = new IdentityLinkFactory(); + } + return instance; + } + + /** + * Private constructor. + */ + private IdentityLinkFactory() { + + keyValueFactory = new KeyValueFactory(); + + StringBuffer packageNames = new StringBuffer(); + packageNames.append(at.gv.e_government.reference.namespace.persondata._20020228_.ObjectFactory.class.getPackage().getName()); + packageNames.append(":"); + packageNames.append(org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName()); + packageNames.append(":"); + packageNames.append(org.w3._2001._04.xmldsig_more_.ObjectFactory.class.getPackage().getName()); + packageNames.append(":"); + packageNames.append(at.buergerkarte.namespaces.personenbindung._20020506_.ObjectFactory.class.getPackage().getName()); packageNames.append(":"); packageNames.append(oasis.names.tc.saml._1_0.assertion.ObjectFactory.class.getPackage().getName()); -
- try {
- jaxbContext = JAXBContext.newInstance(packageNames.toString());
- } catch (JAXBException e) {
- // we should not get an JAXBException initializing the JAXBContext
- throw new RuntimeException(e);
- }
-
+ + try { + jaxbContext = JAXBContext.newInstance(packageNames.toString()); + } catch (JAXBException e) { + // we should not get an JAXBException initializing the JAXBContext + throw new RuntimeException(e); + } + } public JAXBElement<AssertionType> createAssertion(String assertionId, @@ -175,11 +177,11 @@ public class IdentityLinkFactory { return asFactory.createAssertion(assertionType); - }
-
+ } + public AttributeStatementType createAttributeStatement(String idValue, String idType, String givenName, String familyName, String dateOfBirth, - PublicKey[] publicKeys) throws KeyTypeNotSupportedException {
+ PublicKey[] publicKeys) throws KeyTypeNotSupportedException { oasis.names.tc.saml._1_0.assertion.ObjectFactory asFactory = new oasis.names.tc.saml._1_0.assertion.ObjectFactory(); @@ -215,8 +217,11 @@ public class IdentityLinkFactory { physicalPersonType.getIdentification().add(identificationType); physicalPersonType.setName(personNameType); physicalPersonType.setDateOfBirth(dateOfBirth); - - subjectConfirmationType.setSubjectConfirmationData(physicalPersonType); + JAXBElement<AbstractPersonType> physicalPerson = prFactory.createPerson(physicalPersonType); + + AnyType personType = asFactory.createAnyType(); + personType.getContent().add(physicalPerson); + subjectConfirmationType.setSubjectConfirmationData(personType); JAXBElement<SubjectConfirmationType> subjectConfirmation = asFactory.createSubjectConfirmation(subjectConfirmationType); @@ -232,52 +237,54 @@ public class IdentityLinkFactory { AttributeType attributeType = asFactory.createAttributeType(); attributeType.setAttributeName("CitizenPublicKey"); attributeType.setAttributeNamespace("urn:publicid:gv.at:namespaces:identitylink:1.2"); - attributeType.getAttributeValue().add(createKeyValue.getValue()); + AnyType attributeValueType = asFactory.createAnyType(); + attributeValueType.getContent().add(createKeyValue); + attributeType.getAttributeValue().add(attributeValueType); attributeStatementType.getAttribute().add(attributeType); } return attributeStatementType; - }
-
- /**
- * Marshall the given <code>compressedIdentityLink</code> into a DOM document
- * with the given Nodes as <code>parent</code> and <code>nextSibling</code>
- * nodes.
- *
- * @param identityLink
- * the <code>CompressedIdentityLink</code> element
- * @param parent
- * the parent node
- * @param nextSibling
- * the next sibling node (may be <code>null</code>)
- * @param applyWorkarounds
- * apply workarounds as spefiyed by
- * {@link #applyWorkarounds(Element, int)}
- *
- * @throws JAXBException
- * if an unexpected error occurs while marshalling
- * @throws NullPointerException
- * if <code>compressdIdentityLink</code> or <code>parent</code> is
- * <code>null</code>
- */
- public void marshallIdentityLink(
- JAXBElement<AssertionType> identityLink,
- Node parent, Node nextSibling) throws JAXBException {
-
- DOMResult result = new DOMResult(parent, nextSibling);
-
- try {
- Marshaller marshaller = jaxbContext.createMarshaller();
-
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-
- marshaller.marshal(identityLink, result);
- } catch (PropertyException e) {
- throw new RuntimeException(e);
- }
-
+ } + + /** + * Marshall the given <code>compressedIdentityLink</code> into a DOM document + * with the given Nodes as <code>parent</code> and <code>nextSibling</code> + * nodes. + * + * @param identityLink + * the <code>CompressedIdentityLink</code> element + * @param parent + * the parent node + * @param nextSibling + * the next sibling node (may be <code>null</code>) + * @param applyWorkarounds + * apply workarounds as spefiyed by + * {@link #applyWorkarounds(Element, int)} + * + * @throws JAXBException + * if an unexpected error occurs while marshalling + * @throws NullPointerException + * if <code>compressdIdentityLink</code> or <code>parent</code> is + * <code>null</code> + */ + public void marshallIdentityLink( + JAXBElement<AssertionType> identityLink, + Node parent, Node nextSibling) throws JAXBException { + + DOMResult result = new DOMResult(parent, nextSibling); + + try { + Marshaller marshaller = jaxbContext.createMarshaller(); + + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + + marshaller.marshal(identityLink, result); + } catch (PropertyException e) { + throw new RuntimeException(e); + } + } public void signIdentityLink(Element assertion, X509Certificate certificate, @@ -416,6 +423,6 @@ public class IdentityLinkFactory { log.trace(sb.toString()); } - }
-
-}
+ } + +} diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ActionType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ActionType.java index 144b4e17..d2b96381 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ActionType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ActionType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AdviceType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AdviceType.java index e5342409..d2630fac 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AdviceType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AdviceType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // @@ -32,7 +32,7 @@ import org.w3c.dom.Element; * <choice maxOccurs="unbounded" minOccurs="0"> * <element ref="{urn:oasis:names:tc:SAML:1.0:assertion}AssertionIDReference"/> * <element ref="{urn:oasis:names:tc:SAML:1.0:assertion}Assertion"/> - * <any/> + * <any processContents='lax' namespace='##other'/> * </choice> * </restriction> * </complexContent> @@ -72,10 +72,10 @@ public class AdviceType { * * <p> * Objects of the following type(s) are allowed in the list - * {@link Object } - * {@link JAXBElement }{@code <}{@link String }{@code >} - * {@link JAXBElement }{@code <}{@link AssertionType }{@code >} * {@link Element } + * {@link JAXBElement }{@code <}{@link AssertionType }{@code >} + * {@link JAXBElement }{@code <}{@link String }{@code >} + * {@link Object } * * */ diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AnyType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AnyType.java new file mode 100644 index 00000000..a9f7dd8d --- /dev/null +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AnyType.java @@ -0,0 +1,87 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2008.12.23 at 03:26:53 PM GMT +// + + +package oasis.names.tc.saml._1_0.assertion; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlType; + + +/** + * This type is introduced to avoid the DOM Element binding of + * AttributeValue and SubjectConfirmationData, specified as + * <pre> + * <element name="AttributeValue" type="anyType"/> + * <element name="SubjectConfirmationData" type="anyType"/> + * </pre> + * in the original SAML 1.0 Assertion schema. + * + * <p>Java class for AnyType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="AnyType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence maxOccurs="unbounded" minOccurs="0"> + * <any/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "AnyType", propOrder = { + "content" +}) +public class AnyType { + + @XmlMixed + @XmlAnyElement(lax = true) + protected List<Object> content; + + /** + * Gets the value of the content property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the content property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getContent().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link String } + * + * + */ + public List<Object> getContent() { + if (content == null) { + content = new ArrayList<Object>(); + } + return this.content; + } + +} diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AssertionType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AssertionType.java index 2157dd67..2a108984 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AssertionType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AssertionType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // @@ -70,10 +70,10 @@ public class AssertionType { protected AdviceType advice; @XmlElements({ @XmlElement(name = "Statement"), - @XmlElement(name = "AuthorizationDecisionStatement", type = AuthorizationDecisionStatementType.class), - @XmlElement(name = "AuthenticationStatement", type = AuthenticationStatementType.class), + @XmlElement(name = "AttributeStatement", type = AttributeStatementType.class), @XmlElement(name = "SubjectStatement", type = SubjectStatementAbstractType.class), - @XmlElement(name = "AttributeStatement", type = AttributeStatementType.class) + @XmlElement(name = "AuthorizationDecisionStatement", type = AuthorizationDecisionStatementType.class), + @XmlElement(name = "AuthenticationStatement", type = AuthenticationStatementType.class) }) protected List<StatementAbstractType> statementOrSubjectStatementOrAuthenticationStatement; @XmlElement(name = "Signature", namespace = "http://www.w3.org/2000/09/xmldsig#") @@ -157,10 +157,10 @@ public class AssertionType { * <p> * Objects of the following type(s) are allowed in the list * {@link StatementAbstractType } + * {@link AttributeStatementType } + * {@link SubjectStatementAbstractType } * {@link AuthorizationDecisionStatementType } * {@link AuthenticationStatementType } - * {@link SubjectStatementAbstractType } - * {@link AttributeStatementType } * * */ diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeDesignatorType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeDesignatorType.java index f96815d8..12bd8738 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeDesignatorType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeDesignatorType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeStatementType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeStatementType.java index 71faeffb..f710b74b 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeStatementType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeStatementType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeType.java index 68e41ab4..31d258a9 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AttributeType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // @@ -44,7 +44,7 @@ public class AttributeType { @XmlElement(name = "AttributeValue", required = true) - protected List<Object> attributeValue; + protected List<AnyType> attributeValue; /** * Gets the value of the attributeValue property. @@ -64,13 +64,13 @@ public class AttributeType * * <p> * Objects of the following type(s) are allowed in the list - * {@link Object } + * {@link AnyType } * * */ - public List<Object> getAttributeValue() { + public List<AnyType> getAttributeValue() { if (attributeValue == null) { - attributeValue = new ArrayList<Object>(); + attributeValue = new ArrayList<AnyType>(); } return this.attributeValue; } diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AudienceRestrictionConditionType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AudienceRestrictionConditionType.java index aa95892a..61091b73 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AudienceRestrictionConditionType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AudienceRestrictionConditionType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthenticationStatementType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthenticationStatementType.java index 5f22ea2d..93c24117 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthenticationStatementType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthenticationStatementType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorityBindingType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorityBindingType.java index 32ccb3f6..8663f35a 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorityBindingType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorityBindingType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorizationDecisionStatementType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorizationDecisionStatementType.java index 5678a373..b6b37c90 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorizationDecisionStatementType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/AuthorizationDecisionStatementType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionAbstractType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionAbstractType.java index 6952e51f..965bb4bd 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionAbstractType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionAbstractType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionsType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionsType.java index 8160779f..42c1e1af 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionsType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ConditionsType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/DecisionType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/DecisionType.java index 4fa36320..e5efbf0a 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/DecisionType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/DecisionType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/EvidenceType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/EvidenceType.java index a2fc049c..74f74440 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/EvidenceType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/EvidenceType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/NameIdentifierType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/NameIdentifierType.java index 1970e6f8..34fed5d2 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/NameIdentifierType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/NameIdentifierType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ObjectFactory.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ObjectFactory.java index fe0982ef..d5165b71 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ObjectFactory.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/ObjectFactory.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // @@ -64,43 +64,43 @@ public class ObjectFactory { } /** - * Create an instance of {@link AuthorityBindingType } + * Create an instance of {@link AnyType } * */ - public AuthorityBindingType createAuthorityBindingType() { - return new AuthorityBindingType(); + public AnyType createAnyType() { + return new AnyType(); } /** - * Create an instance of {@link AttributeDesignatorType } + * Create an instance of {@link ActionType } * */ - public AttributeDesignatorType createAttributeDesignatorType() { - return new AttributeDesignatorType(); + public ActionType createActionType() { + return new ActionType(); } /** - * Create an instance of {@link AuthenticationStatementType } + * Create an instance of {@link AttributeDesignatorType } * */ - public AuthenticationStatementType createAuthenticationStatementType() { - return new AuthenticationStatementType(); + public AttributeDesignatorType createAttributeDesignatorType() { + return new AttributeDesignatorType(); } /** - * Create an instance of {@link EvidenceType } + * Create an instance of {@link SubjectConfirmationType } * */ - public EvidenceType createEvidenceType() { - return new EvidenceType(); + public SubjectConfirmationType createSubjectConfirmationType() { + return new SubjectConfirmationType(); } /** - * Create an instance of {@link SubjectConfirmationType } + * Create an instance of {@link SubjectLocalityType } * */ - public SubjectConfirmationType createSubjectConfirmationType() { - return new SubjectConfirmationType(); + public SubjectLocalityType createSubjectLocalityType() { + return new SubjectLocalityType(); } /** @@ -112,11 +112,11 @@ public class ObjectFactory { } /** - * Create an instance of {@link SubjectLocalityType } + * Create an instance of {@link AuthenticationStatementType } * */ - public SubjectLocalityType createSubjectLocalityType() { - return new SubjectLocalityType(); + public AuthenticationStatementType createAuthenticationStatementType() { + return new AuthenticationStatementType(); } /** @@ -128,67 +128,75 @@ public class ObjectFactory { } /** - * Create an instance of {@link ActionType } + * Create an instance of {@link AuthorityBindingType } * */ - public ActionType createActionType() { - return new ActionType(); + public AuthorityBindingType createAuthorityBindingType() { + return new AuthorityBindingType(); } /** - * Create an instance of {@link AttributeStatementType } + * Create an instance of {@link AttributeType } * */ - public AttributeStatementType createAttributeStatementType() { - return new AttributeStatementType(); + public AttributeType createAttributeType() { + return new AttributeType(); } /** - * Create an instance of {@link NameIdentifierType } + * Create an instance of {@link AdviceType } * */ - public NameIdentifierType createNameIdentifierType() { - return new NameIdentifierType(); + public AdviceType createAdviceType() { + return new AdviceType(); } /** - * Create an instance of {@link AuthorizationDecisionStatementType } + * Create an instance of {@link EvidenceType } * */ - public AuthorizationDecisionStatementType createAuthorizationDecisionStatementType() { - return new AuthorizationDecisionStatementType(); + public EvidenceType createEvidenceType() { + return new EvidenceType(); } /** - * Create an instance of {@link AttributeType } + * Create an instance of {@link ConditionsType } * */ - public AttributeType createAttributeType() { - return new AttributeType(); + public ConditionsType createConditionsType() { + return new ConditionsType(); } /** - * Create an instance of {@link SubjectType } + * Create an instance of {@link AttributeStatementType } * */ - public SubjectType createSubjectType() { - return new SubjectType(); + public AttributeStatementType createAttributeStatementType() { + return new AttributeStatementType(); } /** - * Create an instance of {@link AdviceType } + * Create an instance of {@link NameIdentifierType } * */ - public AdviceType createAdviceType() { - return new AdviceType(); + public NameIdentifierType createNameIdentifierType() { + return new NameIdentifierType(); } /** - * Create an instance of {@link ConditionsType } + * Create an instance of {@link AuthorizationDecisionStatementType } * */ - public ConditionsType createConditionsType() { - return new ConditionsType(); + public AuthorizationDecisionStatementType createAuthorizationDecisionStatementType() { + return new AuthorizationDecisionStatementType(); + } + + /** + * Create an instance of {@link SubjectType } + * + */ + public SubjectType createSubjectType() { + return new SubjectType(); } /** @@ -363,12 +371,12 @@ public class ObjectFactory { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link AnyType }{@code >}} * */ @XmlElementDecl(namespace = "urn:oasis:names:tc:SAML:1.0:assertion", name = "SubjectConfirmationData") - public JAXBElement<Object> createSubjectConfirmationData(Object value) { - return new JAXBElement<Object>(_SubjectConfirmationData_QNAME, Object.class, null, value); + public JAXBElement<AnyType> createSubjectConfirmationData(AnyType value) { + return new JAXBElement<AnyType>(_SubjectConfirmationData_QNAME, AnyType.class, null, value); } /** @@ -399,12 +407,12 @@ public class ObjectFactory { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link AnyType }{@code >}} * */ @XmlElementDecl(namespace = "urn:oasis:names:tc:SAML:1.0:assertion", name = "AttributeValue") - public JAXBElement<Object> createAttributeValue(Object value) { - return new JAXBElement<Object>(_AttributeValue_QNAME, Object.class, null, value); + public JAXBElement<AnyType> createAttributeValue(AnyType value) { + return new JAXBElement<AnyType>(_AttributeValue_QNAME, AnyType.class, null, value); } } diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/StatementAbstractType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/StatementAbstractType.java index efe8faae..eabd815f 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/StatementAbstractType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/StatementAbstractType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectConfirmationType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectConfirmationType.java index 094e8840..d7bd8856 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectConfirmationType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectConfirmationType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // @@ -51,7 +51,7 @@ public class SubjectConfirmationType { @XmlSchemaType(name = "anyURI") protected List<String> confirmationMethod; @XmlElement(name = "SubjectConfirmationData") - protected Object subjectConfirmationData; + protected AnyType subjectConfirmationData; @XmlElement(name = "KeyInfo", namespace = "http://www.w3.org/2000/09/xmldsig#") protected KeyInfoType keyInfo; @@ -89,10 +89,10 @@ public class SubjectConfirmationType { * * @return * possible object is - * {@link Object } + * {@link AnyType } * */ - public Object getSubjectConfirmationData() { + public AnyType getSubjectConfirmationData() { return subjectConfirmationData; } @@ -101,10 +101,10 @@ public class SubjectConfirmationType { * * @param value * allowed object is - * {@link Object } + * {@link AnyType } * */ - public void setSubjectConfirmationData(Object value) { + public void setSubjectConfirmationData(AnyType value) { this.subjectConfirmationData = value; } diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectLocalityType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectLocalityType.java index 8c59d4ae..1515d535 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectLocalityType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectLocalityType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectStatementAbstractType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectStatementAbstractType.java index 38e9bcbd..07916c14 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectStatementAbstractType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectStatementAbstractType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectType.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectType.java index 453713a1..646339c8 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectType.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/SubjectType.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // diff --git a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/package-info.java b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/package-info.java index 9de42741..4eb7ece2 100644 --- a/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/package-info.java +++ b/utils/src/main/java/oasis/names/tc/saml/_1_0/assertion/package-info.java @@ -1,8 +1,8 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-661 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2008.10.29 at 09:14:07 AM GMT +// Generated on: 2008.12.23 at 03:26:53 PM GMT // @javax.xml.bind.annotation.XmlSchema(namespace = "urn:oasis:names:tc:SAML:1.0:assertion", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) diff --git a/utils/src/test/java/saml/KeyValueAttributeTypeTest.java b/utils/src/test/java/saml/KeyValueAttributeTypeTest.java new file mode 100644 index 00000000..2df04ce6 --- /dev/null +++ b/utils/src/test/java/saml/KeyValueAttributeTypeTest.java @@ -0,0 +1,129 @@ +/* + * Copyright 2008 Federal Chancellery Austria and + * Graz University of Technology + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package saml; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.List; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.namespace.QName; +import oasis.names.tc.saml._1_0.assertion.AnyType; +import oasis.names.tc.saml._1_0.assertion.AssertionType; +import oasis.names.tc.saml._1_0.assertion.AttributeStatementType; +import oasis.names.tc.saml._1_0.assertion.AttributeType; +import oasis.names.tc.saml._1_0.assertion.NameIdentifierType; +import oasis.names.tc.saml._1_0.assertion.ObjectFactory; +import oasis.names.tc.saml._1_0.assertion.StatementAbstractType; +import oasis.names.tc.saml._1_0.assertion.SubjectType; +import org.junit.Ignore; +import org.junit.Test; +import org.w3._2000._09.xmldsig_.KeyValueType; +import org.w3._2000._09.xmldsig_.RSAKeyValueType; +import org.w3c.dom.Element; + +/** + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> + */ +@Ignore +public class KeyValueAttributeTypeTest { + + @Test + public void testAttrStatement() throws FileNotFoundException, JAXBException { + JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class, org.w3._2000._09.xmldsig_.ObjectFactory.class); + Unmarshaller um = ctx.createUnmarshaller(); + + JAXBElement<AssertionType> assertion = (JAXBElement<AssertionType>) um.unmarshal(new File("/home/clemens/workspace/schema-base/src/main/schema/test/saml10.xml")); + List<StatementAbstractType> statements = assertion.getValue().getStatementOrSubjectStatementOrAuthenticationStatement(); + for (StatementAbstractType stmt : statements) { + if (stmt instanceof AttributeStatementType) { + System.out.println("AttributeStatement"); + List<AttributeType> attrs = ((AttributeStatementType) stmt).getAttribute(); + for (AttributeType attr : attrs) { + List<AnyType> attrValue = attr.getAttributeValue(); + System.out.println(attrValue.size() + " AttributeValue(s)"); + for (AnyType attrValueT : attrValue) { + List<Object> attrValueContent = attrValueT.getContent(); + System.out.println(" AttributeValue: " + attrValueContent.size() + " child nodes"); + for (Object node : attrValueContent) { + if (node instanceof String) { + System.out.println(" - CDATA: " + node); + } else if (node instanceof Element) { + System.out.println(" - DOM Element: " + ((Element)node).getTagName()); + } else { + System.out.println(" - " + node.getClass()); + } + } + } + + } + } + } + } + + @Test + public void testAttributeStatement() throws JAXBException { + + org.w3._2000._09.xmldsig_.ObjectFactory dsOF = new org.w3._2000._09.xmldsig_.ObjectFactory(); + RSAKeyValueType rsaKeyValueType = dsOF.createRSAKeyValueType(); + rsaKeyValueType.setExponent("1234".getBytes()); + rsaKeyValueType.setModulus("5678".getBytes()); + + JAXBElement<RSAKeyValueType> rsaKeyValue = dsOF.createRSAKeyValue(rsaKeyValueType); + + +// KeyValueType kvT = dsOF.createKeyValueType(); +// kvT.getContent().add(rsaKeyValue); +// JAXBElement<KeyValueType> kv = dsOF.createKeyValue(kvT); + + ObjectFactory saml10OF = new ObjectFactory(); + AssertionType assertionT = saml10OF.createAssertionType(); + + AttributeStatementType attrStatementT = saml10OF.createAttributeStatementType(); + NameIdentifierType nameIdT = saml10OF.createNameIdentifierType(); + nameIdT.setFormat("format"); + nameIdT.setNameQualifier("qualifier"); + nameIdT.setValue("value"); + JAXBElement<NameIdentifierType> subjNameId = saml10OF.createNameIdentifier(nameIdT); + SubjectType subjT = saml10OF.createSubjectType(); + subjT.getContent().add(subjNameId); + attrStatementT.setSubject(subjT); + + + AttributeType attrT = saml10OF.createAttributeType(); +// QName keyVal = new QName("testNS", "keyVal"); + attrT.setAttributeName("RSAkeyvalue"); + attrT.setAttributeNamespace("lskdfjlk"); + AnyType attrValueT = saml10OF.createAnyType(); + attrValueT.getContent().add(rsaKeyValue); + attrT.getAttributeValue().add(attrValueT); //kv); //keyValue); //new JAXBElement(keyVal, declaredType, attrT)) + attrStatementT.getAttribute().add(attrT); + assertionT.getStatementOrSubjectStatementOrAuthenticationStatement().add(attrStatementT); + JAXBElement<AssertionType> assertion = saml10OF.createAssertion(assertionT); + + JAXBContext ctx = JAXBContext.newInstance(saml10OF.getClass()); + Marshaller m = ctx.createMarshaller(); + m.marshal(assertion, System.out); + } +} |