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;
}
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());
}
}
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());
}
}
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"));
}
}
}
Aggregations