CPD Results

The following document contains the results of PMD's CPD 3.7.

Duplications

FileLine
org/apache/geronimo/security/jaas/UPCredentialLoginModule.java60
org/apache/geronimo/security/jaas/NamedUPCredentialLoginModule.java63
            pvtCreds.add(nupCredential);
        }

        return true;
    }

    public boolean login() throws LoginException {

        Callback[] callbacks = new Callback[2];

        callbacks[0] = new NameCallback("User name");
        callbacks[1] = new PasswordCallback("Password", false);
        try {
            callbackHandler.handle(callbacks);
        } catch (IOException ioe) {
            throw (LoginException) new LoginException().initCause(ioe);
        } catch (UnsupportedCallbackException uce) {
            throw (LoginException) new LoginException().initCause(uce);
        }

        String username = ((NameCallback) callbacks[0]).getName();
        char[] password = ((PasswordCallback) callbacks[1]).getPassword();

        if (username == null || password == null) return true;

FileLine
org/apache/geronimo/security/keystore/FileKeystoreManager.java248
org/apache/geronimo/security/keystore/FileKeystoreManager.java301
        }
        KeystoreInstance trustInstance = trustStore == null ? null : getKeystore(trustStore);
        if(trustInstance != null && trustInstance.isKeystoreLocked()) {
            throw new KeystoreIsLocked("Keystore '"+trustStore+"' is locked; please use the keystore page in the admin console to unlock it");
        }

        // OMG this hurts, but it causes ClassCastExceptions elsewhere unless done this way!
        try {
            Class cls = loader.loadClass("javax.net.ssl.SSLContext");
            Object ctx = cls.getMethod("getInstance", new Class[] {String.class}).invoke(null, new Object[]{protocol});
            Class kmc = loader.loadClass("[Ljavax.net.ssl.KeyManager;");
            Class tmc = loader.loadClass("[Ljavax.net.ssl.TrustManager;");
            Class src = loader.loadClass("java.security.SecureRandom");
            cls.getMethod("init", new Class[]{kmc, tmc, src}).invoke(ctx, new Object[]{keyInstance.getKeyManager(algorithm, keyAlias, null),

FileLine
org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java93
org/apache/geronimo/security/realm/providers/CertificatePropertiesFileLoginModule.java102
            Properties temp = new Properties();
            stream = groupFile.toURL().openStream();
            temp.load(stream);
            stream.close();

            Enumeration e = temp.keys();
            while (e.hasMoreElements()) {
                String groupName = (String) e.nextElement();
                String[] userList = ((String) temp.get(groupName)).split(",");

                Set userset = (Set) groups.get(groupName);
                if (userset == null) {
                    userset = new HashSet();
                    groups.put(groupName, userset);
                }

                for (int i = 0; i < userList.length; i++) {

FileLine
org/apache/geronimo/security/jaas/server/JaasSessionId.java60
org/apache/geronimo/security/SubjectId.java60
            buffer.append(subjectId);
            buffer.append(":0x");
            for (int i = 0; i < hash.length; i++) {
                buffer.append(HEXCHAR[(hash[i]>>>4)&0x0F]);
                buffer.append(HEXCHAR[(hash[i]    )&0x0F]);
            }
            buffer.append(']');
            name = buffer.toString();
        }
        return name;
    }

    /**
     * Returns a hashcode for this LoginModuleId.
     *
     * @return a hashcode for this LoginModuleId.
     */
    public int hashCode() {
        if (hashCode == 0) {
            for (int i = 0; i < hash.length; i++) {
                hashCode ^= hash[i];
            }
            hashCode ^= subjectId.hashCode();