Java Code Examples for java.security.PrivilegedActionException#getLocalizedMessage()

The following examples show how to use java.security.PrivilegedActionException#getLocalizedMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: URLSecurity.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param protocol
 * @param host
 * @param file
 * @return
 * @throws MalformedURLException
 * @throws DataException
 */
public static URL getURL( final String protocol, final String host,
		final String file ) throws MalformedURLException, DataException
{
	try
	{
		return AccessController.doPrivileged( new PrivilegedExceptionAction<URL>( ) {

			public URL run( ) throws MalformedURLException
			{
				return new URL( protocol, host, file );
			}
		} );
	}
	catch ( PrivilegedActionException e )
	{
		Exception typedException = e.getException( );
		if ( typedException instanceof MalformedURLException )
		{
			throw (MalformedURLException) typedException;
		}
		throw new DataException( e.getLocalizedMessage( ) );
	}

}
 
Example 2
Source File: URLSecurity.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param spec
 * @return
 * @throws MalformedURLException
 * @throws DataException
 */
public static URL getURL( final String spec ) throws MalformedURLException, DataException
{
	try
	{
		return AccessController.doPrivileged( new PrivilegedExceptionAction<URL>( ) {

			public URL run( ) throws MalformedURLException
			{
				return new URL( spec );
			}
		} );
	}
	catch ( PrivilegedActionException e )
	{
		Exception typedException = e.getException( );
		if ( typedException instanceof MalformedURLException )
		{
			throw (MalformedURLException) typedException;
		}
		throw new DataException( e.getLocalizedMessage( ) );
	}

}
 
Example 3
Source File: FileSecurity.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param path
 * @param type
 * @return
 * @throws FileNotFoundException
 * @throws DataException
 */
public static RandomAccessFile createRandomAccessFile( final String path,
		final String type ) throws FileNotFoundException, DataException
{
	try
	{
		return AccessController.doPrivileged( new PrivilegedExceptionAction<RandomAccessFile>( ) {

			public RandomAccessFile run( ) throws FileNotFoundException
			{
				return new RandomAccessFile( path, type );
			}
		} );
	}
	catch ( PrivilegedActionException e )
	{
		Exception typedException = e.getException( );
		if ( typedException instanceof FileNotFoundException )
		{
			throw (FileNotFoundException) typedException;
		}
		throw new DataException( e.getLocalizedMessage( ) );
	}
}
 
Example 4
Source File: FileSecurity.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 * @param file
 * @return
 * @throws FileNotFoundException
 * @throws DataException
 */
public static FileReader createFileReader( final File file )
		throws FileNotFoundException, DataException
{
	try
	{
		return AccessController.doPrivileged( new PrivilegedExceptionAction<FileReader>( ) {

			public FileReader run( ) throws FileNotFoundException
			{
				return new FileReader( file );
			}
		} );
	}
	catch ( PrivilegedActionException e )
	{
		Exception typedException = e.getException( );
		if ( typedException instanceof FileNotFoundException )
		{
			throw (FileNotFoundException) typedException;
		}
		throw new DataException( e.getLocalizedMessage( ) );
	}
}