Example usage for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException

List of usage examples for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException

Introduction

In this page you can find the example usage for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException.

Prototype

public UndeclaredThrowableException(Throwable undeclaredThrowable) 

Source Link

Document

Constructs an UndeclaredThrowableException with the specified Throwable .

Usage

From source file:Main.java

public static final boolean isWellFormedXml(final InputSource isource) {
    try {/*  w  w  w  . ja v a 2 s. c o m*/
        newXMLReader().parse(isource);
        return true;
    } catch (SAXException e) {
        System.out.println(e);
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        throw new UndeclaredThrowableException(e);
    } catch (ParserConfigurationException e) {
        throw new UndeclaredThrowableException(e);
    }
}

From source file:com.hack23.cia.service.data.impl.util.LoadHelper.java

/**
 * Handle reflection exception./*w  w  w  . ja  v a 2 s.  c o m*/
 *
 * @param ex
 *            the ex
 */
private static void handleReflectionException(final Exception ex) {
    if (ex instanceof NoSuchMethodException) {
        throw new IllegalStateException("Method not found: " + ex.getMessage());
    }
    if (ex instanceof IllegalAccessException) {
        throw new IllegalStateException("Could not access method: " + ex.getMessage());
    }
    if (ex instanceof RuntimeException) {
        throw (RuntimeException) ex;
    }
    throw new UndeclaredThrowableException(ex);
}

From source file:org.jahia.security.TOTP.java

/**
 * This method uses the JCE to provide the crypto algorithm. HMAC computes a
 * Hashed Message Authentication Code with the crypto hash algorithm as a
 * parameter.//from  w  ww.j av  a 2  s .  co  m
 * 
 * @param crypto
 *            : the crypto algorithm (HmacSHA1, HmacSHA256, HmacSHA512)
 * @param keyBytes
 *            : the bytes to use for the HMAC key
 * @param text
 *            : the message or text to be authenticated
 */
private static byte[] hmac_sha(String crypto, byte[] keyBytes, byte[] text) {
    try {
        Mac hmac;
        hmac = Mac.getInstance(crypto);
        SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
        hmac.init(macKey);
        return hmac.doFinal(text);
    } catch (GeneralSecurityException gse) {
        throw new UndeclaredThrowableException(gse);
    }
}

From source file:com.chumbok.aauth.otp.TOTP.java

/**
 * This method uses the JCE to provide the crypto algorithm. HMAC computes a
 * Hashed Message Authentication Code with the crypto hash algorithm as a
 * parameter.// w  w w  .j  a va 2  s. c o m
 *
 * @param crypto
 *            : the crypto algorithm (HmacSHA1, HmacSHA256, HmacSHA512)
 * @param keyBytes
 *            : the bytes to use for the HMAC key
 * @param text
 *            : the message or text to be authenticated
 */

private static byte[] hmac_sha(String crypto, byte[] keyBytes, byte[] text) {
    try {
        Mac hmac;
        hmac = Mac.getInstance(crypto);
        SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
        hmac.init(macKey);
        return hmac.doFinal(text);
    } catch (GeneralSecurityException gse) {
        throw new UndeclaredThrowableException(gse);
    }
}

From source file:org.jeelee.utils.AppLogging.java

public static void handleException(final Throwable e) {
    if (debug) {/*from   w w w.j a v  a  2 s  . com*/
        e.printStackTrace();
    }
    try {
        FileWriter fw = new FileWriter(new File("app.log"), true);
        fw.write(Calendar.getInstance().toString() + "\n");
        PrintWriter pw = new PrintWriter(fw, true);
        e.printStackTrace(pw);

        JeeleePlatformUI.getDisplay().asyncExec(new Runnable() {
            @Override
            public void run() {
                ErrorDialog.openError(JeeleePlatformUI.getDisplay().getActiveShell(), "error", e.getMessage(),
                        Status.OK_STATUS);
            }
        });
    } catch (IOException e1) {
        throw new UndeclaredThrowableException(e1);
    }
}

From source file:org.openrdf.repository.sparql.query.BackgroundTupleResult.java

public List<String> getBindingNames() {
    try {/* w w  w .ja v a 2  s . c  om*/
        bindingNamesReady.await();
        queue.checkException();
        return bindingNames;
    } catch (InterruptedException e) {
        throw new UndeclaredThrowableException(e);
    } catch (QueryEvaluationException e) {
        throw new UndeclaredThrowableException(e);
    }
}

From source file:fr.ortolang.diffusion.security.authentication.TOTPHelper.java

private static byte[] hmacSha(byte[] keyBytes, byte[] text) {
    try {/* w  w  w  .  j  av  a2 s . com*/
        Mac hmac;
        hmac = Mac.getInstance("HmacSHA1");
        SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
        hmac.init(macKey);
        return hmac.doFinal(text);
    } catch (GeneralSecurityException gse) {
        throw new UndeclaredThrowableException(gse);
    }
}

From source file:org.apache.nifi.dbcp.hive.HiveConnectionPoolTest.java

@Before
public void setup() throws Exception {
    userGroupInformation = mock(UserGroupInformation.class);
    basicDataSource = mock(BasicDataSource.class);
    componentLog = mock(ComponentLog.class);

    when(userGroupInformation.doAs(isA(PrivilegedExceptionAction.class))).thenAnswer(invocation -> {
        try {//  w w  w .  j av a 2  s .co m
            return ((PrivilegedExceptionAction) invocation.getArguments()[0]).run();
        } catch (IOException | Error | RuntimeException | InterruptedException e) {
            throw e;
        } catch (Throwable e) {
            throw new UndeclaredThrowableException(e);
        }
    });
    initPool();
}

From source file:org.jitsi.videobridge.rest.JSONDeserializer.java

public static <T extends CandidatePacketExtension> T deserializeCandidate(JSONObject candidate,
        Class<T> candidateIQClass, IceUdpTransportPacketExtension transportIQ) {
    T candidateIQ;//from w  w  w .  j  a va  2  s  . c  o  m

    if (candidate == null) {
        candidateIQ = null;
    } else {
        try {
            candidateIQ = candidateIQClass.newInstance();
        } catch (IllegalAccessException iae) {
            throw new UndeclaredThrowableException(iae);
        } catch (InstantiationException ie) {
            throw new UndeclaredThrowableException(ie);
        }
        // attributes
        deserializeAbstractPacketExtensionAttributes(candidate, candidateIQ);

        transportIQ.addChildExtension(candidateIQ);
    }
    return candidateIQ;
}

From source file:org.apache.nifi.dbcp.hive.Hive_1_1ConnectionPoolTest.java

@Before
public void setup() throws Exception {
    // have to initialize this system property before anything else
    System.setProperty("java.security.krb5.conf", krb5conf.getAbsolutePath());
    System.setProperty("java.security.krb5.realm", "nifi.com");
    System.setProperty("java.security.krb5.kdc", "nifi.kdc");

    userGroupInformation = mock(UserGroupInformation.class);
    basicDataSource = mock(BasicDataSource.class);
    componentLog = mock(ComponentLog.class);

    when(userGroupInformation.doAs(isA(PrivilegedExceptionAction.class))).thenAnswer(invocation -> {
        try {/*from   www  .  ja va  2  s. com*/
            return ((PrivilegedExceptionAction) invocation.getArguments()[0]).run();
        } catch (IOException | Error | RuntimeException | InterruptedException e) {
            throw e;
        } catch (Throwable e) {
            throw new UndeclaredThrowableException(e);
        }
    });

    initPool();
}