类java.lang.SecurityException源码实例Demo

下面列出了怎么用java.lang.SecurityException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gemfirexd-oss   文件: RawStore.java
private synchronized String privGetCanonicalPath(final StorageFile file)
{
    actionCode = STORAGE_FILE_GET_CANONICALPATH_ACTION;
    actionStorageFile = file;

    try
    {
        return (String) AccessController.doPrivileged( this);
    }
    catch( PrivilegedActionException pae) { 
        return null;
    } // does not throw an exception
    catch(SecurityException se) {
        // there are no permission to get canonical path 
        // just return null.
        return null;
    }
    finally
    {
        actionStorageFile = null;
    }
}
 
源代码2 项目: gemfirexd-oss   文件: RawStore.java
private synchronized String privGetCanonicalPath(final File file)
{
    actionCode = REGULAR_FILE_GET_CANONICALPATH_ACTION;
    actionRegularFile = file;

    try
    {
        return (String) AccessController.doPrivileged( this);
    }
    catch( PrivilegedActionException pae) { 
        return null;
    } // does not throw an exception
    catch(SecurityException se) { 
        // there are no permission to get canonical path 
        // just return null.
        return null;
    }
    finally
    {
        actionRegularFile = null;
    }
}
 
源代码3 项目: gemfirexd-oss   文件: RawStore.java
private synchronized String privGetCanonicalPath(final StorageFile file)
{
    actionCode = STORAGE_FILE_GET_CANONICALPATH_ACTION;
    actionStorageFile = file;

    try
    {
        return (String) AccessController.doPrivileged( this);
    }
    catch( PrivilegedActionException pae) { 
        return null;
    } // does not throw an exception
    catch(SecurityException se) {
        // there are no permission to get canonical path 
        // just return null.
        return null;
    }
    finally
    {
        actionStorageFile = null;
    }
}
 
源代码4 项目: gemfirexd-oss   文件: RawStore.java
private synchronized String privGetCanonicalPath(final File file)
{
    actionCode = REGULAR_FILE_GET_CANONICALPATH_ACTION;
    actionRegularFile = file;

    try
    {
        return (String) AccessController.doPrivileged( this);
    }
    catch( PrivilegedActionException pae) { 
        return null;
    } // does not throw an exception
    catch(SecurityException se) { 
        // there are no permission to get canonical path 
        // just return null.
        return null;
    }
    finally
    {
        actionRegularFile = null;
    }
}
 
源代码5 项目: pluotsorbet   文件: constructor.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    SecurityException object1 = new SecurityException();
    harness.check(object1 != null);
    harness.check(object1.toString(), "java.lang.SecurityException");

    SecurityException object2 = new SecurityException("nothing happens");
    harness.check(object2 != null);
    harness.check(object2.toString(), "java.lang.SecurityException: nothing happens");

    SecurityException object3 = new SecurityException((String)null);
    harness.check(object3 != null);
    harness.check(object3.toString(), "java.lang.SecurityException");


}
 
源代码6 项目: gemfirexd-oss   文件: derbyrunjartest.java
public static void main(String[] args) throws Exception
{
    // get location of run class.
    CodeSource cs = null;
    try {
        cs = com.pivotal.gemfirexd.internal.iapi.tools.run.class.getProtectionDomain().getCodeSource();
    } catch (SecurityException se) {
        System.out.println("Security exception: " + se.getMessage());
    }
 
    URL result = cs.getLocation();
    jvm jvm = null;
    String derbyrunloc = null;

    if (result.toString().endsWith(".jar")) {
        derbyrunloc = result.toString().substring(5);
        if (System.getProperty("os.name").startsWith("Windows"))
          derbyrunloc = derbyrunloc.substring(1);
        jvm = jvm.getJvm("currentjvm"); // ensure compatibility
    }

    String[][] testCommands = new String[][] {
        {"ij", "--help"},
        {"sysinfo", "-cp", "help"},
        {"dblook"},
        {"server"},
    };

    for (int i = 0; i < testCommands.length; i++) {
        runtool(jvm, derbyrunloc, testCommands[i]);
    }
}
 
源代码7 项目: Java2PlantUML   文件: SaveFileHelper.java
private static String getPathName(String route) throws IOException {
   if (route == null) {
      route = TARGET_DIRECTORY;
   }
   File file = new File(route);
   if (file.exists() && !file.isDirectory()) {
      throw new IOException("File " + route + " exists but it is not a directory");
   }
   else if (!file.exists()) { // path does not yet exist
      try {
         if (!file.mkdir()) {
            throw new IOException("Error creating directory " + route);
         }
      }
      catch (SecurityException se) {
         throw new IOException("Security Exception creating " + route);
      }
   }
   StringBuilder path = new StringBuilder().append(route).append(File.separator).append(J2PUML);

   SimpleDateFormat instant = new SimpleDateFormat("ddMMyyyy_HM_mm", Locale.getDefault());
   Date now = new Date();
   StringBuilder fileName = new StringBuilder(instant.format(now));

   path.append(fileName).append("." + FILE_EXTENSION);
   return path.toString();
}
 
源代码8 项目: gemfirexd-oss   文件: derbyrunjartest.java
public static void main(String[] args) throws Exception
{
    // get location of run class.
    CodeSource cs = null;
    try {
        cs = com.pivotal.gemfirexd.internal.iapi.tools.run.class.getProtectionDomain().getCodeSource();
    } catch (SecurityException se) {
        System.out.println("Security exception: " + se.getMessage());
    }
 
    URL result = cs.getLocation();
    jvm jvm = null;
    String derbyrunloc = null;

    if (result.toString().endsWith(".jar")) {
        derbyrunloc = result.toString().substring(5);
        if (System.getProperty("os.name").startsWith("Windows"))
          derbyrunloc = derbyrunloc.substring(1);
        jvm = jvm.getJvm("currentjvm"); // ensure compatibility
    }

    String[][] testCommands = new String[][] {
        {"ij", "--help"},
        {"sysinfo", "-cp", "help"},
        {"dblook"},
        {"server"},
    };

    for (int i = 0; i < testCommands.length; i++) {
        runtool(jvm, derbyrunloc, testCommands[i]);
    }
}
 
private void writeSimpleFiles(String path, String ext, int numOfFiles) {
  // Create folder
  File folder = new File(path);
  if (!folder.exists()) {
    try {
      folder.mkdir();
    } catch (SecurityException se) {
      fail("Failed creating directory:" + path + se);
    }
  }

  // Write files
  for (int i = 1; i <= numOfFiles; i++) {
    String fn = null;
    if (ext != null) {
      fn = Integer.toString(i) + "." + ext;
    } else {
      fn = Integer.toString(i);
    }

    try {
      FileWriter fwr = new FileWriter(new File(path, fn));
      fwr.write(Integer.toString(i));
      fwr.close();
    } catch (IOException ioe) {
      fail("Fail writing to input file: " + fn + " in directory: " + path + ioe.getMessage());
    }
  }
}
 
源代码10 项目: pluotsorbet   文件: TryCatch.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    // flag that is set when exception is caught
    boolean caught = false;
    try {
        throw new SecurityException("SecurityException");
    }
    catch (SecurityException e) {
        // correct exception was caught
        caught = true;
    }
    harness.check(caught);
}
 
源代码11 项目: samoa   文件: LocalFileStreamSourceTest.java
private void writeSimpleFiles(String path, String ext, int numOfFiles) {
	// Create folder
	File folder = new File(path);
	if (!folder.exists()) {
		try{
	        folder.mkdir();
	    } catch(SecurityException se){
	    	fail("Failed creating directory:"+path+se);
	    }
	}
	
	// Write files
	for (int i=1; i<=numOfFiles; i++) {
		String fn = null;
		if (ext != null) {
			fn = Integer.toString(i) + "."+ ext;
		} else {
			fn = Integer.toString(i);
		}
		
		try {
			FileWriter fwr = new FileWriter(new File(path,fn));
			fwr.write(Integer.toString(i));
			fwr.close();
		} catch (IOException ioe) {
			fail("Fail writing to input file: "+ fn + " in directory: " + path + ioe.getMessage());
		}
	}
}
 
源代码12 项目: lams   文件: SecurityDomain.java
/** Get the keystore associated with the security domain */
public KeyStore getKeyStore() throws SecurityException;
 
源代码13 项目: lams   文件: SecurityDomain.java
/** Get the KeyManagerFactory associated with the security domain */
public KeyManagerFactory getKeyManagerFactory() throws SecurityException;
 
源代码14 项目: lams   文件: SecurityDomain.java
/** Get the TrustManagerFactory associated with the security domain */
public TrustManagerFactory getTrustManagerFactory() throws SecurityException;
 
源代码15 项目: gemfirexd-oss   文件: ClassSizeCrawler.java
private void crawl( File curDir, StringBuilder className)
{
    if( verbose)
        System.out.println( "Searching directory " + curDir.getPath());

    try
    {
        if( ! curDir.isDirectory())
        {
            System.err.println( "*** " + curDir.getPath() + " is not a directory.");
            System.exit(1);
        }
    }
    catch( SecurityException se)
    {
        System.err.println( "Cannot access " + curDir.getPath());
        System.exit(1);
    }
    String[] filenames = curDir.list( );
    if( className.length() != 0)
        className.append( ".");

    int classNameLength = className.length();
    for( int fileIdx = 0; fileIdx < filenames.length; fileIdx++)
    {
        if( filenames[fileIdx].endsWith( ".class"))
        {
            // Strip off the ".class" suffix
            String s = filenames[fileIdx].substring( 0, filenames[fileIdx].length() - 6);
            className.append( s);
            Class targetClass = null;
            String targetClassName = className.toString();
            try
            {
                targetClass = Class.forName( targetClassName);
                if( !targetClass.isInterface())
                {
                    for( int interfaceIdx = 0; interfaceIdx < interfaceCount; interfaceIdx++)
                    {
                        if( interfaceList[interfaceIdx].isAssignableFrom( targetClass))
                            addClass( targetClass);
                    }
                }
            }
            catch( ClassNotFoundException cnfe)
            {
                System.err.println( "Could not find class " + targetClassName);
                System.exit(1);
            }
            catch( Throwable t){}
            className.setLength( classNameLength);
        }
        else
        {
            File nextDir = new File( curDir, filenames[fileIdx]);
            if( nextDir.isDirectory())
            {
                className.append( filenames[fileIdx]);
                crawl( nextDir, className);
                className.setLength( classNameLength);
            }
        }
    }
}
 
源代码16 项目: gemfirexd-oss   文件: ClassSizeCrawler.java
private void crawl( File curDir, StringBuilder className)
{
    if( verbose)
        System.out.println( "Searching directory " + curDir.getPath());

    try
    {
        if( ! curDir.isDirectory())
        {
            System.err.println( "*** " + curDir.getPath() + " is not a directory.");
            System.exit(1);
        }
    }
    catch( SecurityException se)
    {
        System.err.println( "Cannot access " + curDir.getPath());
        System.exit(1);
    }
    String[] filenames = curDir.list( );
    if( className.length() != 0)
        className.append( ".");

    int classNameLength = className.length();
    for( int fileIdx = 0; fileIdx < filenames.length; fileIdx++)
    {
        if( filenames[fileIdx].endsWith( ".class"))
        {
            // Strip off the ".class" suffix
            String s = filenames[fileIdx].substring( 0, filenames[fileIdx].length() - 6);
            className.append( s);
            Class targetClass = null;
            String targetClassName = className.toString();
            try
            {
                targetClass = Class.forName( targetClassName);
                if( !targetClass.isInterface())
                {
                    for( int interfaceIdx = 0; interfaceIdx < interfaceCount; interfaceIdx++)
                    {
                        if( interfaceList[interfaceIdx].isAssignableFrom( targetClass))
                            addClass( targetClass);
                    }
                }
            }
            catch( ClassNotFoundException cnfe)
            {
                System.err.println( "Could not find class " + targetClassName);
                System.exit(1);
            }
            catch( Throwable t){}
            className.setLength( classNameLength);
        }
        else
        {
            File nextDir = new File( curDir, filenames[fileIdx]);
            if( nextDir.isDirectory())
            {
                className.append( filenames[fileIdx]);
                crawl( nextDir, className);
                className.setLength( classNameLength);
            }
        }
    }
}
 
public List getEntities(EntityReference ref, Search search){
 Vector results = new Vector();
 

 String siteId = null;
 Restriction[] restrictions = search.getRestrictions();

    String userId = null;	  
 
 for(int r=0;r<restrictions.length;r++){
  if(restrictions[r].property.equalsIgnoreCase("siteId")){
	  siteId = (String) restrictions[r].value;
  }
  if(restrictions[r].property.equalsIgnoreCase("userId")){
	  userId = (String) restrictions[r].value;
  }
  if(restrictions[r].property.equalsIgnoreCase("context")){
	  siteId = (String) restrictions[r].value;
  }		  
 }

 if(userId==null){
  userId = developerHelperService.getCurrentUserId();
 }
    if (userId == null) {
        throw new SecurityException("No user is currently logged in so no data can be retrieved");
    }
 
 if(userId==null)return results;
 if(siteId==null) return results;
  String orderBy = "title";
  List assessments = null;
  boolean canPublish = false;
  Date currentDate = new Date();

   // Check what the user can do
   if (securityService.unlock(CAN_PUBLISH, "/site/"+siteId)) {
     publishedAssessmentFacadeQueries.
       getBasicInfoOfAllActivePublishedAssessments(orderBy, siteId, true);
     assessments = publishedAssessmentFacadeQueries
       .getBasicInfoOfAllInActivePublishedAssessments(orderBy, siteId, true);
     assessments.addAll(publishedAssessmentFacadeQueries
       .getBasicInfoOfAllActivePublishedAssessments(orderBy, siteId, true));
     canPublish = true;
   }
   else if (securityService.unlock(CAN_TAKE, "/site/"+siteId)) {
     assessments = publishedAssessmentFacadeQueries
       .getBasicInfoOfAllActivePublishedAssessments(orderBy, siteId, true);
   }

if (assessments != null) {
	Iterator assessmentIterator = assessments.iterator();
	while(assessmentIterator.hasNext()){
		PublishedAssessmentFacade pub = (PublishedAssessmentFacade) assessmentIterator.next();
		results.add(pub);

	}
}
 return results;
}
 
public List getEntities(EntityReference ref, Search search){
 Vector results = new Vector();
 

 String siteId = null;
 Restriction[] restrictions = search.getRestrictions();

    String userId = null;	  
 
 for(int r=0;r<restrictions.length;r++){
  if(restrictions[r].property.equalsIgnoreCase("siteId")){
	  siteId = (String) restrictions[r].value;
  }
  if(restrictions[r].property.equalsIgnoreCase("userId")){
	  userId = (String) restrictions[r].value;
  }
  if(restrictions[r].property.equalsIgnoreCase("context")){
	  siteId = (String) restrictions[r].value;
  }		  
 }

 if(userId==null){
  userId = developerHelperService.getCurrentUserId();
 }
    if (userId == null) {
        throw new SecurityException("No user is currently logged in so no data can be retrieved");
    }
 
 if(userId==null)return results;
 if(siteId==null) return results;
  String orderBy = "title";
  List assessments = null;
  boolean canPublish = false;
  Date currentDate = new Date();

   // Check what the user can do
   if (securityService.unlock(CAN_PUBLISH, "/site/"+siteId)) {
     publishedAssessmentFacadeQueries.
       getBasicInfoOfAllActivePublishedAssessments(orderBy, siteId, true);
     assessments = publishedAssessmentFacadeQueries
       .getBasicInfoOfAllInActivePublishedAssessments(orderBy, siteId, true);
     assessments.addAll(publishedAssessmentFacadeQueries
       .getBasicInfoOfAllActivePublishedAssessments(orderBy, siteId, true));
     canPublish = true;
   }
   else if (securityService.unlock(CAN_TAKE, "/site/"+siteId)) {
     assessments = publishedAssessmentFacadeQueries
       .getBasicInfoOfAllActivePublishedAssessments(orderBy, siteId, true);
   }

if (assessments != null) {
	Iterator assessmentIterator = assessments.iterator();
	while(assessmentIterator.hasNext()){
		PublishedAssessmentFacade pub = (PublishedAssessmentFacade) assessmentIterator.next();
		results.add(pub);

	}
}
 return results;
}
 
源代码19 项目: lams   文件: JSSESecurityDomain.java
/** 
 * Get the keystore associated with the security domain
 * 
 * @return the keystore
 */
public KeyStore getKeyStore() throws SecurityException;
 
源代码20 项目: lams   文件: JSSESecurityDomain.java
/**
 * Get the KeyManagers created by the configured KeyManagerFactory
 * 
 * @return the initialized KeyManagers
 */
public KeyManager[] getKeyManagers() throws SecurityException;
 
源代码21 项目: lams   文件: JSSESecurityDomain.java
/**
 * Get the truststore associated with the security domain. This may be the same as the keystore
 * 
 * @return the truststore
 */
public KeyStore getTrustStore() throws SecurityException;
 
源代码22 项目: lams   文件: JSSESecurityDomain.java
/**
 * Get the TrustManagers created by the configured TrustManagerFactory
 * 
 * @return the initialized TrustManagers
 */
public TrustManager[] getTrustManagers() throws SecurityException;
 
源代码23 项目: lams   文件: SecurityDomain.java
/** Get the truststore associated with the security domain. This may be
 the same as the keystore. */
public KeyStore getTrustStore() throws SecurityException;
 
源代码24 项目: tomee   文件: AutoConnectionTrackerTest.java
@Override
public void close() throws SecurityException {

}
 
 类所在包
 同包方法