List of usage examples for javax.xml.registry RegistryException RegistryException
public RegistryException(String reason, Throwable cause)
JAXRException
object with the given String
as the reason for the exception being thrown and the given Throwable
object as an embedded Throwable. From source file:it.cnr.icar.eric.server.security.authentication.AuthenticationServiceImpl.java
public KeyStore getTrustAnchorsKeyStore() throws RegistryException { try {/*ww w . j a va 2 s. c o m*/ if (trustAnchorsKeyStore == null) { synchronized (AuthenticationServiceImpl.class) { if (trustAnchorsKeyStore == null) { String keyStoreFile = propsReader.getProperty("eric.security.trustAnchors.keystoreFile"); String keystorePassword = propsReader .getProperty("eric.security.trustAnchors.keystorePassword"); String keystoreType = propsReader.getProperty("eric.security.trustAnchors.keystoreType"); trustAnchorsKeyStore = KeyStore.getInstance(keystoreType); trustAnchorsKeyStore.load(new java.io.FileInputStream(keyStoreFile), keystorePassword.toCharArray()); } } } return trustAnchorsKeyStore; } catch (NoSuchAlgorithmException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (KeyStoreException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (java.security.cert.CertificateException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (java.io.FileNotFoundException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (IOException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } }
From source file:it.cnr.icar.eric.server.query.federation.FederatedQueryWorker.java
/** * @param registry//w ww . ja v a 2s . c o m * @param user * @param queryRequest * @param timeout * @return */ @SuppressWarnings("static-access") private AdhocQueryResponse sendRequestToDestination(RegistryType registry, UserType user, AdhocQueryRequest queryRequest, long timeout) throws RegistryException { AdhocQueryResponse resp = null; try { /* AdhocQueryType ahq = queryRequest.getAdhocQuery(); QueryExpressionType queryExp = ahq.getQueryExpression(); String queryLang = queryExp.getQueryLanguage(); String queryStr = (String)queryExp.getContent().get(0); Query query = null; if (queryLang.equals(BindingUtility.CANONICAL_QUERY_LANG_ID_SQL_92)) { query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryStr); } else { //TODO: filter query throw new JAXRException("No support for Query Language: " + queryLang + " in persistent queries."); } */ //If registry is local (connection == null) then use local call. //Otherwise use JAXR connection / SOAP if (connection == null) { try { it.cnr.icar.eric.common.spi.QueryManager qm = it.cnr.icar.eric.common.spi.QueryManagerFactory .getInstance().getQueryManager(); ServerRequestContext context = new ServerRequestContext( "FederatedQueryWorker:sendRequestToDestination", queryRequest); context.setUser(user); resp = qm.submitAdhocQuery(context); repositoryItemsMap = new HashMap<String, Object>(); } catch (JAXRException e) { String msg = ServerResourceBundle.getInstance().getString("message.error.localQuery", new Object[] { registry.getId(), bu.getInternationalStringAsString(registry.getName()) }); throw new RegistryException(msg, e); } } else { //Using impl specific convenient constructor try { HashMap<String, String> queryParams = new HashMap<String, String>(); String returnType = ReturnType.LEAF_CLASS_WITH_REPOSITORY_ITEM.toString(); queryParams.put(dqm.CANONICAL_SLOT_RESPONSEOPTION_RETURN_TYPE, returnType); ClientRequestContext context = new ClientRequestContext( "it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl:executeQuery", queryRequest); BulkResponseImpl br = (BulkResponseImpl) dqm.executeQuery(context, queryParams, new IterativeQueryParams()); log.trace("Registry id: " + registry.getId() + " name: " + bu.getInternationalStringAsString(registry.getName()) + " returned the following objects: " + br.getCollection()); resp = (AdhocQueryResponse) br.getRegistryResponse(); bu.convertRepositoryItemMapForServer(context.getRepositoryItemsMap()); this.repositoryItemsMap = context.getRepositoryItemsMap(); } catch (Exception e) { String msg = ServerResourceBundle.getInstance().getString("message.error.remoteQuery", new Object[] { registry.getId(), bu.getInternationalStringAsString(registry.getName()) }); throw new RegistryException(msg, e); } } } catch (JAXRException e) { //This exception is thrown potentially (unlikely) by bu.getInternationalStringAsString throw new RegistryException(e); } return resp; }
From source file:it.cnr.icar.eric.server.security.authentication.CertificateAuthority.java
/** * Signed specified cert using the private key of RegistryOperator. * Warning this uses Sun's JDK impl specific classes and will not work * with other JDK impls.//from w w w . ja v a2s . c om * */ @SuppressWarnings("static-access") X509Certificate signCertificate(X509Certificate inCert) throws RegistryException { X509CertImpl signedCert = null; try { X509CertImpl caCert = (X509CertImpl) getCACertificate(); X509CertInfo caCertInfo = new X509CertInfo(caCert.getTBSCertificate()); X509CertInfo inCertInfo = new X509CertInfo(inCert.getTBSCertificate()); // Use catch (certs subject name as signed cert's issuer name CertificateSubjectName caCertSubjectName = (CertificateSubjectName) caCertInfo .get(X509CertInfo.SUBJECT); CertificateIssuerName signedCertIssuerName = new CertificateIssuerName( (X500Name) caCertSubjectName.get(CertificateSubjectName.DN_NAME)); inCertInfo.set(X509CertInfo.ISSUER, signedCertIssuerName); signedCert = new X509CertImpl(inCertInfo); //TODO: Need to remove hardcoding below and instead somehow use info.algId => algName // signedCert.sign(ac.getPrivateKey(ac.ALIAS_REGISTRY_OPERATOR, ac.ALIAS_REGISTRY_OPERATOR), "MD5WithRSA"); // JDK6 // signedCert.sign(ac.getPrivateKey(ac.ALIAS_REGISTRY_OPERATOR, ac.ALIAS_REGISTRY_OPERATOR), "SHA256withRSA"); // JDK7 // removed hardcoding signedCert.sign(ac.getPrivateKey(ac.ALIAS_REGISTRY_OPERATOR, ac.ALIAS_REGISTRY_OPERATOR), inCert.getSigAlgName()); } catch (java.security.GeneralSecurityException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.ErrorSigningRegIssuedCert"), e); } catch (java.io.IOException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.ErrorSigningRegIssuedCert"), e); } return signedCert; }
From source file:it.cnr.icar.eric.server.security.authentication.AuthenticationServiceImpl.java
public java.security.PrivateKey getPrivateKey(String alias, String password) throws RegistryException { java.security.PrivateKey privateKey = null; try {// w ww . ja va 2 s . c om privateKey = (java.security.PrivateKey) getKeyStore().getKey(alias, password.toCharArray()); } catch (KeyStoreException e) { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.privateKey"), e); } catch (NoSuchAlgorithmException e) { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.privateKey"), e); } catch (java.security.UnrecoverableKeyException e) { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.privateKey"), e); } return privateKey; }
From source file:it.cnr.icar.eric.server.security.authentication.AuthenticationServiceImpl.java
public java.security.cert.Certificate[] getCertificateChain(String alias) throws RegistryException { try {/*from ww w .jav a 2 s .c o m*/ return getKeyStore().getCertificateChain(alias); } catch (KeyStoreException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.gettingCertificateChain"), e); } }
From source file:it.cnr.icar.eric.server.security.authentication.CertificateAuthority.java
/** * Generate a registry issued certificate signed by private key of RegistryOperator. *//*from w w w.ja va 2 s.c o m*/ public X509Certificate generateRegistryIssuedCertificate(String dname) throws RegistryException { X509Certificate cert = null; File ksFile = null; try { String keystoreFileName = System.getProperty("java.io.tmpdir") + "/eric-temp-ks.jks"; String keystoreType = "JKS"; String alias = "ebxmlrr"; String storePassStr = "ebxmlrr"; String keyPassStr = "ebxmlrr"; String keyAlg = "RSA"; //XWSS does not support DSA which is default is KeyTool. Hmm. Weird. String[] args = { "-genkey", "-keyAlg", keyAlg, "-alias", alias, "-keypass", keyPassStr, "-keystore", keystoreFileName, "-storepass", storePassStr, "-storetype", keystoreType, "-dname", dname }; KeyTool keytool = new KeyTool(); keytool.run(args, System.out); ksFile = new File(keystoreFileName); //Now load the KeyStore and get the cert FileInputStream fis = new java.io.FileInputStream(ksFile); KeyStore keyStore = KeyStore.getInstance(keystoreType); keyStore.load(fis, storePassStr.toCharArray()); cert = (X509Certificate) keyStore.getCertificate(alias); cert = signCertificate(cert); } catch (Exception e) { throw new RegistryException(ServerResourceBundle.getInstance().getString("message.CertGenError"), e); } finally { if (ksFile != null) { try { ksFile.delete(); } catch (Exception e) { ksFile = null; } } } return cert; }
From source file:it.cnr.icar.eric.server.persistence.rdb.SQLPersistenceManagerImpl.java
/** * Get a database connection. The connection is of autocommit off and with * transaction isolation level "transaction read committed" *//* w w w. ja va 2 s . c o m*/ public Connection getConnection(ServerRequestContext context) throws RegistryException { Connection connection = null; if (log.isTraceEnabled()) { log.debug("SQLPersistenceManagerImpl.getConnection"); numConnectionsOpen++; } try { if (useConnectionPool) { if (ds != null) { connection = ds.getConnection(); if (connection == null) { log.info(ServerResourceBundle.getInstance().getString( "message.ErrorUnableToOpenDbConnctionForDataSource=", new Object[] { ds })); } } if (connection == null) { // Default to registry server ConnectionPool connection = connectionPool.getConnection(context.getId()); } connection.setTransactionIsolation(transactionIsolation); connection.setAutoCommit(false); } else { // create connection directly if ((user != null) && (user.length() > 0)) { connection = java.sql.DriverManager.getConnection(databaseURL, user, password); } else { connection = java.sql.DriverManager.getConnection(databaseURL); } // Set Transaction Isolation and AutoComit // WARNING: till present Oracle dirvers (9.2.0.5) do not accept // setTransactionIsolation being called after // setAutoCommit(false) connection.setTransactionIsolation(transactionIsolation); connection.setAutoCommit(false); } } catch (SQLException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.connectToDatabaseFailed"), e); } return connection; }
From source file:org.freebxml.omar.server.persistence.rdb.SQLPersistenceManagerImpl.java
/** * Get a database connection. The connection is of autocommit off and with * transaction isolation level "transaction read committed" *///ww w. ja v a 2 s . co m public Connection getConnection(ServerRequestContext context) throws RegistryException { Connection connection = null; if (log.isTraceEnabled()) { log.debug("SQLPersistenceManagerImpl.getConnection"); numConnectionsOpen++; } try { if (useConnectionPool) { if (ds != null) { connection = ds.getConnection(); if (connection == null) { log.info(ServerResourceBundle.getInstance().getString( "message.ErrorUnableToOpenDbConnctionForDataSource=", new Object[] { ds })); } } if (connection == null) { //Default to registry server ConnectionPool connection = connectionPool.getConnection(context.getId()); } connection.setTransactionIsolation(transactionIsolation); connection.setAutoCommit(false); } else { // create connection directly if ((user != null) && (user.length() > 0)) { connection = java.sql.DriverManager.getConnection(databaseURL, user, password); } else { connection = java.sql.DriverManager.getConnection(databaseURL); } // Set Transaction Isolation and AutoComit // WARNING: till present Oracle dirvers (9.2.0.5) do not accept // setTransactionIsolation being called after setAutoCommit(false) connection.setTransactionIsolation(transactionIsolation); connection.setAutoCommit(false); } } catch (SQLException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.connectToDatabaseFailed"), e); } return connection; }
From source file:org.freebxml.omar.server.security.authentication.AuthenticationServiceImpl.java
public KeyStore getTrustAnchorsKeyStore() throws RegistryException { try {//www. ja v a2 s .c o m if (trustAnchorsKeyStore == null) { synchronized (AuthenticationServiceImpl.class) { if (trustAnchorsKeyStore == null) { String keyStoreFile = propsReader.getProperty("omar.security.trustAnchors.keystoreFile"); String keystorePassword = propsReader .getProperty("omar.security.trustAnchors.keystorePassword"); String keystoreType = propsReader.getProperty("omar.security.trustAnchors.keystoreType"); trustAnchorsKeyStore = KeyStore.getInstance(keystoreType); trustAnchorsKeyStore.load(new java.io.FileInputStream(keyStoreFile), keystorePassword.toCharArray()); } } } return trustAnchorsKeyStore; } catch (NoSuchAlgorithmException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (KeyStoreException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (java.security.cert.CertificateException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (java.io.FileNotFoundException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } catch (IOException e) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.trustAnchorsKeystore"), e); } }