public static NamiCredentials getCredentialsFromClassname(String className,
            String username) throws CredentialsInitiationException {
        String fullClassname = "nami.connector.credentials." + className;
        try {
            Class<? extends NamiCredentials> credClass;
            credClass = Class.forName(fullClassname).asSubclass(
                    NamiCredentials.class);
            Constructor<? extends NamiCredentials> constr;

            // find suitable constructor

            if (username != null) {
                // Konstruktor mit einem String-Parameter
                constr = credClass.getConstructor(String.class);
                return constr.newInstance(username);
            } else {
                // Konstruktor ohne Parameter
                constr = credClass.getConstructor();
                return constr.newInstance();
            }

        } catch (ClassNotFoundException e) {
            throw new CredentialsInitiationException(
                    "Could not find requested credentials class: "
                            + fullClassname, e);
        } catch (NoSuchMethodException e) {
            throw new CredentialsInitiationException(
                    "Credentials class doesn't have supported constructor", e);
        } catch (InvocationTargetException e) {
            throw new CredentialsInitiationException(
                    "Exception in constructor", e);
        } catch (InstantiationException e) {
            throw new CredentialsInitiationException(e);
        } catch (IllegalAccessException e) {
            throw new CredentialsInitiationException(e);
        }

    }