提交 5fb7e144 编写于 作者: J juh

8016916: UnstructuredName should support DirectoryString

Reviewed-by: mullan
上级 ffac7c43
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -310,7 +310,8 @@ public class PKCS9Attribute implements DerEncoder { ...@@ -310,7 +310,8 @@ public class PKCS9Attribute implements DerEncoder {
private static final Byte[][] PKCS9_VALUE_TAGS = { private static final Byte[][] PKCS9_VALUE_TAGS = {
null, null,
{new Byte(DerValue.tag_IA5String)}, // EMailAddress {new Byte(DerValue.tag_IA5String)}, // EMailAddress
{new Byte(DerValue.tag_IA5String)}, // UnstructuredName {new Byte(DerValue.tag_IA5String), // UnstructuredName
new Byte(DerValue.tag_PrintableString)},
{new Byte(DerValue.tag_ObjectId)}, // ContentType {new Byte(DerValue.tag_ObjectId)}, // ContentType
{new Byte(DerValue.tag_OctetString)}, // MessageDigest {new Byte(DerValue.tag_OctetString)}, // MessageDigest
{new Byte(DerValue.tag_UtcTime)}, // SigningTime {new Byte(DerValue.tag_UtcTime)}, // SigningTime
......
/* /*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -2198,8 +2198,15 @@ public final class Main { ...@@ -2198,8 +2198,15 @@ public final class Main {
printExtensions(rb.getString("Extension.Request."), exts, out); printExtensions(rb.getString("Extension.Request."), exts, out);
} }
} else { } else {
out.println(attr.getAttributeId()); out.println("Attribute: " + attr.getAttributeId());
out.println(attr.getAttributeValue()); PKCS9Attribute pkcs9Attr =
new PKCS9Attribute(attr.getAttributeId(),
attr.getAttributeValue());
out.print(pkcs9Attr.getName() + ": ");
Object attrVal = attr.getAttributeValue();
out.println(attrVal instanceof String[] ?
Arrays.toString((String[]) attrVal) :
attrVal);
} }
} }
if (debug) { if (debug) {
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8016916
* @summary UnstructuredName should support DirectoryString
*/
import java.util.Base64;
import sun.security.pkcs10.PKCS10;
public class UnstructuredName {
// Certificate request with an Unstructured Name attribute
static String csrStr =
"MIIBtjCCAR8CAQAwEzERMA8GA1UEAxMIdGVzdE5hbWUwgZ8wDQYJKoZIhvcNAQEB\n" +
"BQADgY0AMIGJAoGBAMTEIVCsM8IIhvsbzn6AwQFX5C8RGAWIrL6P5XEr1z+bvHx3\n" +
"XhPD4tWLCR6CTKq0lTlo+QKKct7MUY7pdKShajpyYD+1YLgEve0nNd4r5kVUeoHe\n" +
"CyIZoImONgAlmVD7M8IJjz2Vg84WVVjkHK67H5qt7Agi1hUnFGmRbJ8rbL7jAgMB\n" +
"AAGgYzAXBgkqhkiG9w0BCQcxChMIcGFzc3dvcmQwHAYJKoZIhvcNAQkCMQ8TDW9w\n" +
"dGlvbmFsIG5hbWUwKgYJKoZIhvcNAQkOMR0wGzAMBgNVHRMBAf8EAjAAMAsGA1Ud\n" +
"DwQEAwIGQDANBgkqhkiG9w0BAQUFAAOBgQBc7ldGSmyCjMU+ssjglCimqknCVdig\n" +
"N8FsI/aNRgLqf+eXKWZOxl1v3GB9HCXWDtqOnHd6AJKFpGtK0bqRu7bIncYIiQ1a\n" +
"P1NW4Kup8d1fTPhw6xgYtxeHvUxRa2y4IXskPUYqp05HavfNZxmcJ5mZOLtgiDIC\n" +
"I3J80saqEUQKqQ==";
public static void main(String[] args) throws Exception {
PKCS10 req = new PKCS10(Base64.getMimeDecoder().decode(csrStr));
// If PKCS9Attribute did not accept the PrintableString ASN.1 tag,
// this would fail with an IOException
Object attr = req.getAttributes().getAttribute("1.2.840.113549.1.9.2");
// Check that the attribute exists
if (attr == null) {
throw new Exception("Attribute should not be null.");
}
System.out.println("Test passed.");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册