Search in sources :

Example 6 with AccessException

use of java.rmi.AccessException in project adempiere by adempiere.

the class ALogin method tryConnection.

//	defaultsOK
/**************************************************************************
	 *	Try to connect.
	 *  - Get Connection
	 *  - Compare User info
	 *  @return true if connected
	 */
private boolean tryConnection() {
    m_user = userTextField.getText();
    m_pwd = new String(passwordField.getPassword());
    //	Establish connection
    if (!DB.isConnected(false))
        validateConnection();
    if (!DB.isConnected(false)) {
        statusBar.setStatusLine(txt_NoDatabase, true);
        hostField.setBackground(AdempierePLAF.getFieldBackground_Error());
        return false;
    }
    //	Reference check
    Ini.setProperty(Ini.P_ADEMPIERESYS, "Reference".equalsIgnoreCase(CConnection.get().getDbUid()));
    //	Reference check
    Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, "Reference".equalsIgnoreCase(CConnection.get().getDbUid()));
    //  Get Roles
    m_login = new Login(m_ctx);
    KeyNamePair[] roles = null;
    try {
        roles = m_login.getRoles(m_user, m_pwd);
        if (roles == null || roles.length == 0) {
            statusBar.setStatusLine(txt_UserPwdError, true);
            userTextField.setBackground(AdempierePLAF.getFieldBackground_Error());
            passwordField.setBackground(AdempierePLAF.getFieldBackground_Error());
            return false;
        }
    } catch (Throwable e) {
        if (e.getCause() instanceof AccessException) {
            statusBar.setStatusLine(txt_UserPwdError, true);
            userTextField.setBackground(AdempierePLAF.getFieldBackground_Error());
            passwordField.setBackground(AdempierePLAF.getFieldBackground_Error());
            return false;
        } else {
            log.severe(CLogger.getRootCause(e).getLocalizedMessage());
            statusBar.setStatusLine(CLogger.getRootCause(e).getLocalizedMessage(), true);
            return false;
        }
    }
    //	Delete existing role items
    m_comboActive = true;
    if (roleCombo.getItemCount() > 0)
        roleCombo.removeAllItems();
    //  Initial role
    KeyNamePair iniValue = null;
    String iniDefault = Ini.getProperty(Ini.P_ROLE);
    //  fill roles
    for (int i = 0; i < roles.length; i++) {
        roleCombo.addItem(roles[i]);
        if (roles[i].getName().equals(iniDefault))
            iniValue = roles[i];
    }
    if (iniValue != null)
        roleCombo.setSelectedItem(iniValue);
    // If we have only one role, we can hide the combobox - metas-2009_0021_AP1_G94
    if (roleCombo.getItemCount() == 1 && !MSysConfig.getBooleanValue("ALogin_ShowOneRole", true)) {
        roleCombo.setSelectedIndex(0);
        roleLabel.setVisible(false);
        roleCombo.setVisible(false);
    } else {
        roleLabel.setVisible(true);
        roleCombo.setVisible(true);
    }
    userTextField.setBackground(AdempierePLAF.getFieldBackground_Normal());
    passwordField.setBackground(AdempierePLAF.getFieldBackground_Normal());
    //
    this.setTitle(hostField.getDisplay());
    statusBar.setStatusLine(txt_LoggedIn);
    m_comboActive = false;
    roleComboChanged();
    return true;
}
Also used : AccessException(java.rmi.AccessException) Login(org.compiere.util.Login) KeyNamePair(org.compiere.util.KeyNamePair)

Example 7 with AccessException

use of java.rmi.AccessException in project guice by google.

the class CheckedProviderTest method testProviderMethodWithManyExceptions.

public void testProviderMethodWithManyExceptions() {
    try {
        Guice.createInjector(new AbstractModule() {

            @Override
            protected void configure() {
                install(ThrowingProviderBinder.forModule(this));
            }

            @SuppressWarnings("unused")
            @CheckedProvides(RemoteProvider.class)
            String foo() throws InterruptedException, RuntimeException, RemoteException, AccessException, TooManyListenersException, BindException, SubBindException {
                return null;
            }
        });
        fail();
    } catch (CreationException ce) {
        // The only two that should fail are Interrupted & TooManyListeners.. the rest are OK.
        List<Message> errors = ImmutableList.copyOf(ce.getErrorMessages());
        assertEquals(InterruptedException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + ", " + BindException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(0).getMessage());
        assertEquals(TooManyListenersException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + ", " + BindException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(1).getMessage());
        assertEquals(2, errors.size());
    }
}
Also used : BindException(java.net.BindException) CreationException(com.google.inject.CreationException) AbstractModule(com.google.inject.AbstractModule) TooManyListenersException(java.util.TooManyListenersException) AccessException(java.rmi.AccessException) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) RemoteException(java.rmi.RemoteException)

Example 8 with AccessException

use of java.rmi.AccessException in project roboguice by roboguice.

the class CheckedProviderTest method testProviderMethodWithManyExceptions.

public void testProviderMethodWithManyExceptions() {
    try {
        Guice.createInjector(new AbstractModule() {

            @Override
            protected void configure() {
                install(ThrowingProviderBinder.forModule(this));
            }

            @SuppressWarnings("unused")
            @CheckedProvides(RemoteProvider.class)
            String foo() throws InterruptedException, RuntimeException, RemoteException, AccessException, TooManyListenersException, BindException, SubBindException {
                return null;
            }
        });
        fail();
    } catch (CreationException ce) {
        // The only two that should fail are Interrupted & TooManyListeners.. the rest are OK.
        List<Message> errors = ImmutableList.copyOf(ce.getErrorMessages());
        assertEquals(InterruptedException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + ", " + BindException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(0).getMessage());
        assertEquals(TooManyListenersException.class.getName() + " is not compatible with the exceptions ([" + RemoteException.class + ", " + BindException.class + "]) declared in the CheckedProvider interface (" + RemoteProvider.class.getName() + ")", errors.get(1).getMessage());
        assertEquals(2, errors.size());
    }
}
Also used : BindException(java.net.BindException) CreationException(com.google.inject.CreationException) AbstractModule(com.google.inject.AbstractModule) TooManyListenersException(java.util.TooManyListenersException) AccessException(java.rmi.AccessException) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) RemoteException(java.rmi.RemoteException)

Example 9 with AccessException

use of java.rmi.AccessException in project Payara by payara.

the class SafeProperties method authorizeRemoteMethod.

/**
 * Check if caller is authorized to invoke the method.
 * Only called for EJBObject and EJBHome methods,
 * from EJBHome|ObjectImpl classes.
 * @param method an integer identifying the method to be checked,
 *		        must be one of the EJB{Home|Object}_* constants.
 */
protected void authorizeRemoteMethod(int method) throws RemoteException {
    EjbInvocation inv = invFactory.create();
    inv.isLocal = false;
    inv.isHome = EJB_INTF_METHODS_INFO[method];
    inv.method = ejbIntfMethods[method];
    inv.invocationInfo = ejbIntfMethodInfo[method];
    if (!authorize(inv)) {
        final Throwable t = mapRemoteException(inv);
        if (t instanceof RuntimeException) {
            throw (RuntimeException) t;
        } else if (t instanceof RemoteException) {
            throw (RemoteException) t;
        } else {
            throw new AccessException(// 
            localStrings.getLocalString(// 
            "ejb.client_not_authorized", "Client not authorized for this invocation"));
        }
    }
}
Also used : EjbInvocation(com.sun.ejb.EjbInvocation) AccessException(java.rmi.AccessException) RemoteException(java.rmi.RemoteException)

Aggregations

AccessException (java.rmi.AccessException)9 RemoteException (java.rmi.RemoteException)7 ImmutableList (com.google.common.collect.ImmutableList)4 AbstractModule (com.google.inject.AbstractModule)4 CreationException (com.google.inject.CreationException)4 List (java.util.List)4 TooManyListenersException (java.util.TooManyListenersException)4 BindException (java.net.BindException)2 ArrayList (java.util.ArrayList)2 AccessLocalException (javax.ejb.AccessLocalException)2 EJBAccessException (javax.ejb.EJBAccessException)2 ApplicationException (org.apache.openejb.ApplicationException)2 InvalidateReferenceException (org.apache.openejb.InvalidateReferenceException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)2 SystemException (org.apache.openejb.SystemException)2 KeyNamePair (org.compiere.util.KeyNamePair)2 Login (org.compiere.util.Login)2 EjbInvocation (com.sun.ejb.EjbInvocation)1 ObjectStreamException (java.io.ObjectStreamException)1