Package javax.security.auth.x500

Examples of javax.security.auth.x500.X500PrincipalTest


    /**
     * getIssuerDN() method testing.
     */
    public void testGetIssuerDN() {
        assertEquals("Incorrect issuer",
                new X500Principal(issuerName).getName(),
                certificate.getIssuerDN().getName());
    }
View Full Code Here


    /**
     * getIssuerX500Principal() method testing.
     */
    public void testGetIssuerX500Principal() {
        assertEquals("Incorrect issuer",
                new X500Principal(issuerName),
                certificate.getIssuerX500Principal());
    }
View Full Code Here

    /**
     * getSubjectDN() method testing.
     */
    public void testGetSubjectDN() {
        assertEquals("Incorrect subject",
                new X500Principal(subjectName).getName(),
                certificate.getSubjectDN().getName());
    }
View Full Code Here

    /**
     * getSubjectX500Principal() method testing.
     */
    public void testGetSubjectX500Principal() {
        assertEquals("Incorrect subject",
                new X500Principal(subjectName),
                certificate.getSubjectX500Principal());
    }
View Full Code Here

    /**
     * getIssuerDN() method testing.
     */
    public void testGetIssuerDN() {
        assertEquals("Incorrect issuer value",
                new X500Principal(issuerName), crl.getIssuerDN());
    }
View Full Code Here

    /**
     * getIssuerX500Principal() method testing.
     */
    public void testGetIssuerX500Principal() {
        assertEquals("Incorrect issuer value",
                new X500Principal(issuerName), crl.getIssuerDN());
    }
View Full Code Here

            // byte[] x500name_data = uncapsulateByteArray(name_data);

            try {

                Subject subject = new Subject();
                subject.getPrincipals().add(new X500Principal(x500name_data));
                SecurityContext.setAuthenticatedSubject(subject);

            }
            catch (IllegalArgumentException ex) {
View Full Code Here

    }
   
    public static String getUsername() {
       
        String ret = null;
        X500PrivateCredential cred = getPrivateCredentials();
        if (cred == null) {
            Subject sub = Subject.getSubject(AccessController.getContext());
            if(sub != null) {
                Set p = sub.getPrincipals(JGDIPrincipal.class);
                if (p != null && !p.isEmpty()) {
                    ret = ((JGDIPrincipal)p.iterator().next()).getUsername();
                }
            }
            if (ret == null) {
                ret = System.getProperty("user.name");
            }
           
           
        } else {
            return cred.getAlias();
        }
        logger.log(Level.FINE, "user.name: {0}", ret);       
        return ret;
    }
View Full Code Here

        return ret;
    }
   
   
    public static String getPrivateKey() {
        X500PrivateCredential cred = getPrivateCredentials();
        if (cred == null) {
            return null;
        }
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
       
       
        pw.println("-----BEGIN PRIVATE KEY-----");
        String str = Base64.encode(cred.getPrivateKey().getEncoded());
        int lines = str.length() / 64;
        boolean lastline = (str.length() % 64) != 0;
        int i;
        for (i = 0; i < lines; i++) {
            pw.println(str.substring(i * 64, (i * 64) + 64));
View Full Code Here

        pw.close();
        return sw.getBuffer().toString();
    }
   
    public static String getCertificate() throws CertificateEncodingException {
        X500PrivateCredential cred = getPrivateCredentials();
        if (cred == null) {
            return null;
        }
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        pw.println("-----BEGIN CERTIFICATE-----");
        String str = Base64.encode(cred.getCertificate().getEncoded());
        int lines = str.length() / 64;
        boolean lastline = (str.length() % 64) != 0;
        int i;
        for (i = 0; i < lines; i++) {
            pw.println(str.substring(i * 64, (i * 64) + 64));
View Full Code Here

TOP

Related Classes of javax.security.auth.x500.X500PrincipalTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.