public void getCredentials() throws IOException, GeneralSecurityException {
        if (this.state != State.LOGGEDON) {
            logon();
        }
        KeyPairGenerator localKeyPairGenerator = KeyPairGenerator
                .getInstance("RSA");
        localKeyPairGenerator.initialize(1024);
        this.keypair = localKeyPairGenerator.genKeyPair();
        PKCS10CertificationRequest localPKCS10CertificationRequest = new PKCS10CertificationRequest(
                "SHA1withRSA", new X500Principal("CN=ignore"),
                this.keypair.getPublic(), null, this.keypair.getPrivate(),
                "SunRsaSign");
        this.socketOut.write(localPKCS10CertificationRequest.getEncoded());
        this.socketOut.flush();
        int i = this.socketIn.read();
        if (i == -1) {
            System.err.println("connection aborted");
            System.exit(1);
        } else if ((i == 0) || (i < 0)) {
            System.err.print("bad number of certificates sent by server: ");
            System.err.println(Integer.toString(i));
            System.exit(1);
        }
        CertificateFactory localCertificateFactory = CertificateFactory
                .getInstance("X.509");
        this.certificateChain = localCertificateFactory
                .generateCertificates(this.socketIn);
        this.state = State.DONE;
    }