Java 8 AccessControlException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AccessControlException class.

This code example shows how to use the following methods:
		} 
 
		IHostedThread robotProxy = threadManager.getLoadedOrLoadingRobotProxy(c);
 
		if (robotProxy == null) {
			throw new AccessControlException("Preventing " + c.getName() + " from access to " + g.getName());			
		} 
 
		if (cg.activeCount() > 5) {
			String message = "Robots are only allowed to create up to 5 threads!";
 
			robotProxy.punishSecurityViolation(message);
			throw new AccessControlException(message);
		} 
	} 
 
	private boolean isSafeThread(Thread c) {
		return threadManager.isSafeThread(c);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:
        return; 
      } 
    } else if (dirPerms.getOtherAction().implies(action)) {
      return; 
    } 
    throw new AccessControlException("action " + action + " not permitted on path "
        + stat.getPath() + " for user " + user);
  } 
 
  private static String getSuperGroupName(Configuration configuration) {
    return configuration.get("dfs.permissions.supergroup", ""); 
  } 
 
  private static boolean userBelongsToSuperGroup(String superGroupName, List<String> groups) {
    return groups.contains(superGroupName);
  } 
} 
5
CodeRank
This code example shows how to use the following methods:printStackTrace
            if( !isSecure ) {
                System.err.println("Expected exception for insecure property <"+propKey+">");
                System.err.println("Message: "+se0.getMessage());
            } else { 
                System.err.println("Unexpected exception for secure property <"+propKey+">");
                se0.printStackTrace();
            } 
        } 
        if( isSecure ) {
            Assert.assertNull("AccessControlException thrown on secure property <"+propKey+">", se0);
        } else { 
            Assert.assertNotNull("AccessControlException not thrown on insecure property <"+propKey+">", se0);
        } 
    } 
 
    @Test
    public void testProp00_Temp() { 
        testPropImpl01(os_name_propkey, true);
    } 
 
5
CodeRank
This code example shows how to use the following methods:
        } 
        if (packageNames == null || packageNames.length == 0) {
            throw new AccessControlException("package names must be specified");
        } 
        if (aid == null || aid.length == 0) {
            throw new AccessControlException("AID must be specified");
        } 
        if (aid.length < 5 || aid.length > 16) {
            throw new AccessControlException("AID has an invalid length");
        } 
         
        // create ara controller db if not available  
        // otherwise re-use access controller DB for caching 
        if( mAccessControlDB == null ) { 
        	mAccessControlDB = new AraControlDB();
        }  
        // set new applet handler since a new channel is used. 
    	mAccessControlDB.setApplet(new AccessRuleApplet(channel));
         
        if(checkForNfcAccess) // NFC Access Control
3
CodeRank
This code example shows how to use the following methods:
                // make sure they're not trying to 
                // update private information. 
                return; 
            } 
        } 
        throw new AccessControlException("You do not have the required permissions.");
    } 
 
    private void performClientChecks(OAuth2Authentication oAuth2Authentication, ScopePathType requiredScope, OrcidMessage orcidMessage, String orcid) {
        AuthorizationRequest authorizationRequest = oAuth2Authentication.getAuthorizationRequest();
        // If we have an ORCID in the request, we assume that this is intended 
        // as an update 
        if (orcidMessage != null && orcidMessage.getOrcidProfile() != null && StringUtils.isNotBlank(orcid)) {
 
            OrcidIdentifier orcidOb = orcidMessage.getOrcidProfile().getOrcidIdentifier();
            String messageOrcid = orcidOb != null ? orcidOb.getPath() : orcid;
            if (StringUtils.isNotBlank(messageOrcid) && !orcid.equals(messageOrcid)) {
                throw new IllegalArgumentException("The ORCID in the body and the URI do NOT match. Body ORCID: " + messageOrcid + " URI ORCID: " + orcid
                        + " do NOT match."); 
            } 
4
CodeRank
This code example shows how to use the following methods:
				tempTlv = Response_DO_Factory.createDO(response.getData());
				if( tempTlv instanceof Response_RefreshTag_DO ) {
					refreshDo = (Response_RefreshTag_DO)tempTlv;
					return refreshDo.getRefreshTagArray();
				} else { 
					throw new AccessControlException("GET REFRESH TAG returned invalid Tlv.");
				} 
			} catch (ParserException e) {
				throw new AccessControlException("GET REFRESH TAG not successfull. Tlv encoding wrong.");
			} 
        }  
        throw new AccessControlException("GET REFRESH TAG not successfull.");			
    } 
 
    private ResponseApdu send(CommandApdu cmdApdu) throws org.simalliance.openmobileapi.service.CardException {
 
        byte[] response = mChannel.transmit(cmdApdu.toBytes());
 
        ResponseApdu resApdu = new ResponseApdu(response);
        return resApdu;
3
CodeRank
This code example shows how to use the following methods:
  public static Subject getSubject()
  { 
    AccessControlContext context = AccessController.getContext();
    Subject subject = Subject.getSubject(context);
    if (subject == null)
      throw new AccessControlException("Denied");
    return subject;
  } 
 
  public static Set<Principal> getPrincipals()
  { 
    return getSubject().getPrincipals();
  } 
 
  public static Set<Principal> getPrincipals(Class<Principal> c)
  { 
    Subject subject = getSubject();
    return subject.getPrincipals(c);
  } 
 
4
CodeRank
This code example shows how to use the following methods:
        if (annotation != null) {
            String[] roles = annotation.value();
            String role = AccessControl.getCurrentRole();
            if (!Arrays.asList(roles).contains(role)) {
            	System.out.println("该角色木有权限哇~");
                throw new AccessControlException("The user is not allowed to invoke this method.");
            } 
        } 
        return method.invoke(accessObj, args);
         
//        java.util.Observable 
    }  
     
}  
4
CodeRank
This code example shows how to use the following methods:
        if (annotation != null) {
            String[] roles = annotation.value();
            //String role = AccessControl.getCurrentRole(); 
            String role = "admin";
            if (!Arrays.asList(roles).contains(role)) {
                throw new AccessControlException("该用户每权限访问该方法.");
            } 
        } 
        return method.invoke(accessObj, args);
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
    } 
 
    public void testAuthorisationFailure() 
    { 
        when(_broker.getSubjectCreator(any(SocketAddress.class), anyBoolean())).thenReturn(_usernamePasswordOkaySubjectCreator);
        doThrow(new AccessControlException(USER_NOT_AUTHORISED_FOR_MANAGEMENT)).when(_securityManager).accessManagement();
 
        try 
        { 
            _rmipa.authenticate(_credentials);
            fail("Exception not thrown");
        } 
        catch (SecurityException se)
        { 
            assertEquals("Unexpected exception message",
                    USER_NOT_AUTHORISED_FOR_MANAGEMENT, se.getMessage());
        } 
    } 
 
    public void testSubjectCreatorInternalFailure() 
4
CodeRank
This code example shows how to use the following methods:
    public void checkPermission(Permission perm)
    { 
        switch ( perm.getName() )
        { 
            case "setSecurityManager": 
                throw new AccessControlException( "Restricted Action", perm );
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getPermission
        THROWABLE_COMPARATOR.assertDeserialized(oref, otest);
 
        // class specific checks 
        AccessControlException ref = (AccessControlException) oref;
        AccessControlException test = (AccessControlException) otest;
        Permission p = ref.getPermission();
        if (p == null) {
            assertNull(test.getPermission());
        } else { 
            assertEquals(p, test.getPermission());
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
    { 
        if(desiredState == State.DELETED) 
        { 
            if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), AccessControlProvider.class, Operation.DELETE))
            { 
                throw new AccessControlException("Deletion of AccessControlProvider is denied");
            } 
        } 
    } 
 
    @Override 
    protected void authoriseSetAttributes(ConfiguredObject<?> modified, Set<String> attributes) throws AccessControlException
    { 
        if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), AccessControlProvider.class, Operation.UPDATE))
        { 
            throw new AccessControlException("Setting of AccessControlProvider attributes is denied");
        } 
    } 
     
    public AccessControl getAccessControl() 
4
CodeRank
This code example shows how to use the following methods:
    @Override 
    protected void authoriseSetAttributes(ConfiguredObject<?> modified, Set<String> attributes) throws AccessControlException
    { 
        if (!_broker.getSecurityManager().authoriseConfiguringBroker(getName(), Plugin.class, Operation.UPDATE))
        { 
            throw new AccessControlException("Setting of plugin attributes is denied");
        } 
    } 
 
    protected Broker<?> getBroker() 
    { 
        return _broker;
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
		} 
 
		IHostedThread robotProxy = threadManager.getLoadedOrLoadingRobotProxy(c);
 
		if (robotProxy == null) {
			throw new AccessControlException("Preventing " + c.getName() + " from access to " + g.getName());			
		} 
 
		if (cg.activeCount() > 5) {
			String message = "Robots are only allowed to create up to 5 threads!";
 
			robotProxy.punishSecurityViolation(message);
			throw new AccessControlException(message);
		} 
	} 
 
	private boolean isSafeThread(Thread c) {
		return threadManager.isSafeThread(c);
	} 
} 
4
CodeRank
This code example shows how to use the following methods:
            throw new HiveException("Unable to make local directory: " 
                + targetPath);
          } 
        } 
      } else { 
        throw new AccessControlException(
            "Unable to delete the existing destination directory: " 
            + targetPath);
      } 
    } 
  } 
 
  @Override 
  public int execute(DriverContext driverContext) {
 
    try { 
      // Do any hive related operations like moving tables and files 
      // to appropriate locations 
      LoadFileDesc lfd = work.getLoadFileWork();
      if (lfd != null) {
3
CodeRank
This code example shows how to use the following methods:
    	 
    	// TODO: check difference between DeviceCertHash and Certificate Chain (EndEntityCertHash, IntermediateCertHash (1..n), RootCertHash) 
    	// The DeviceCertificate is equal to the EndEntityCertificate. 
    	// The android systems seems always to deliver only the EndEntityCertificate, but this seems not to be sure. 
    	// thats why we implement the whole chain. 
    	 
    	AID_REF_DO aid_ref_do = null;
    	Hash_REF_DO hash_ref_do = null;
    	AR_DO ar_do = null;
        REF_DO ref_do = null;
 
        // build-up hash map key as specific as possible. 
        REF_DO ref_do_key = null;
		try { 
	        ref_do_key = this.buildHashMapKey(aid, AccessController.getAppCertHash(appCerts[0]));
		} catch (CertificateEncodingException e1) {
			throw new AccessControlException("Problem with App Certificate.");
		} 
         
    	// Search Rule A ( Certificate(s); AID ) 
3
CodeRank
This code example shows how to use the following methods:
	public UserIdentity find(String login) throws AccessControlException {
		try { 
			open(); 
			ObjectId v = datasource.resolve("HEAD:users.properties");
			if (v == null) {
				throw new AccessControlException(String.format("User '%s' not found in authentication database.", login));
			} 
			if (!v.equals(lastVersion)) {
				data.clear();
				data.load(new StringReader(gitUtils.show(datasource, "HEAD:users.properties")));
			} 
			 
			String email = data.getProperty(String.format("user.%s.email", login));
			String name = data.getProperty(String.format("user.%s.name", login));
			if (email != null && name != null) {
				return new UserIdentity(email, name);
			} 
		} catch (IOException e) {
			e.printStackTrace();
		} finally { 
4
CodeRank
This code example shows how to use the following methods:
	    if( getTerminal().getAccessController() != null ) { // re-use existing controller object for caching 
	    	// check command if it complies to the access rules. 
	    	// if not an exception is thrown 
	    	getTerminal().getAccessController().checkCommand(this, command);
	    } else { 
	    	throw new AccessControlException( "FATAL: Access Controller not set for Terminal: " + getTerminal().getName());
	    } 
    } 
 
 
    /** 
     * @return 
     */ 
    public boolean hasSelectedAid() { 
        return mHasSelectedAid;
    } 
 
    /** 
     * @return 
     */ 
3
CodeRank
This code example shows how to use the following methods:
  @Override 
  public GetAllDAGsResponseProto getAllDAGs(RpcController controller,
      GetAllDAGsRequestProto request) throws ServiceException {
    UserGroupInformation user = getRPCUser();
    if (!real.getACLManager().checkAMViewAccess(user)) {
      throw new AccessControlException("User " + user + " cannot perform AM view operation");
    } 
    try{ 
      List<String> dagIds = real.getAllDAGs();
      return GetAllDAGsResponseProto.newBuilder().addAllDagId(dagIds).build();
    } catch(TezException e) {
      throw wrapException(e);
    } 
  } 
 
  @Override 
  public GetDAGStatusResponseProto getDAGStatus(RpcController controller,
      GetDAGStatusRequestProto request) throws ServiceException {
    UserGroupInformation user = getRPCUser();
    try { 
3
CodeRank
This code example shows how to use the following methods:
            throw new HiveException("Unable to make local directory: " 
                + targetPath); 
          } 
        } 
      } else { 
        throw new AccessControlException(
            "Unable to delete the existing destination directory: " 
            + targetPath); 
      } 
    } 
  } 
 
  @Override 
  public int execute(DriverContext driverContext) {
 
    try { 
      // Do any hive related operations like moving tables and files 
      // to appropriate locations 
      LoadFileDesc lfd = work.getLoadFileWork();
      if (lfd != null) {
3
CodeRank
This code example shows how to use the following methods:
    } 
    if (!f.isFile()) {
      throw new FileNotFoundException(filepath + " is not a file");
    } 
    if (!f.canRead()) {
      throw new AccessControlException(filepath + " could not be read");
    } 
  } 
 
  /** 
   * util classes are not instantiable. 
   * */ 
  private FSUtils() { 
  } 
} 
3
CodeRank
This code example shows how to use the following methods:
 
		if (cg.activeCount() > 5) {
			String message = "Robots are only allowed to create up to 5 threads!";
 
			robotProxy.punishSecurityViolation(message);
			throw new AccessControlException(message);
		} 
	} 
 
	private boolean isSafeThread(Thread c) {
		return threadManager.isSafeThread(c);
	} 
} 
4
CodeRank
This code example shows how to use the following methods:
    } 
 
    public void checkLengthAndStatus(int length, int sw1sw2, String message)
            throws AccessControlException { 
        if (getSW1SW2() != sw1sw2 || mData.length != length) {
            throw new AccessControlException("ResponseApdu is wrong at " + message);
        } 
    } 
 
    public void checkLengthAndStatus(int length, int[] sw1sw2List, String message)
            throws AccessControlException { 
        if (mData.length != length) {
            throw new AccessControlException("ResponseApdu is wrong at " + message);
        } 
        for (int sw1sw2 : sw1sw2List) {
            if (getSW1SW2() == sw1sw2) {
                return; // sw1sw2 matches => return 
            } 
        } 
        throw new AccessControlException("ResponseApdu is wrong at " + message);
4
CodeRank
This code example shows how to use the following methods:getMessage
                AccessController.checkPermission(permission);
        } catch (AccessControlException e) {
            // Need to throw a simplified version as AccessControlException 
            // will have a reference to Derby's SystemPermission which most likely 
            // will not be available on the client. 
            throw new SecurityException(e.getMessage());
        }   
    } 
 
    // Some of the code is disabled (commented out) due to security concerns, 
    // see DERBY-1387 for details. 
     
    // 
    // ------------------------- MBEAN ATTRIBUTES  ---------------------------- 
    // 
     
    public String getDrdaHost() {
        // Since this is sensitive information require control permission. 
        checkControl(); 
 
4
CodeRank
See Code Examples for Java 8 AccessControlException Methods: