当前位置: 首页>>代码示例>>Java>>正文


Java Realm.AUTODEDUCEREALM属性代码示例

本文整理汇总了Java中sun.security.krb5.Realm.AUTODEDUCEREALM属性的典型用法代码示例。如果您正苦于以下问题:Java Realm.AUTODEDUCEREALM属性的具体用法?Java Realm.AUTODEDUCEREALM怎么用?Java Realm.AUTODEDUCEREALM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sun.security.krb5.Realm的用法示例。


在下文中一共展示了Realm.AUTODEDUCEREALM属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GSSNameElement

GSSNameElement(byte[] nameBytes, Oid nameType, GSSLibStub stub)
    throws GSSException {
    assert(stub != null);
    if (nameBytes == null) {
        throw new GSSException(GSSException.BAD_NAME);
    }
    cStub = stub;
    byte[] name = nameBytes;

    if (nameType != null) {
        // Special handling the specified name type if
        // necessary
        nameType = getNativeNameType(nameType, stub);

        if (GSSName.NT_EXPORT_NAME.equals(nameType)) {
            // Need to add back the mech Oid portion (stripped
            // off by GSSNameImpl class prior to calling this
            // method) for "NT_EXPORT_NAME"
            byte[] mechBytes = null;
            DerOutputStream dout = new DerOutputStream();
            Oid mech = cStub.getMech();
            try {
                dout.putOID(new ObjectIdentifier(mech.toString()));
            } catch (IOException e) {
                throw new GSSExceptionImpl(GSSException.FAILURE, e);
            }
            mechBytes = dout.toByteArray();
            name = new byte[2 + 2 + mechBytes.length + 4 + nameBytes.length];
            int pos = 0;
            name[pos++] = 0x04;
            name[pos++] = 0x01;
            name[pos++] = (byte) (mechBytes.length>>>8);
            name[pos++] = (byte) mechBytes.length;
            System.arraycopy(mechBytes, 0, name, pos, mechBytes.length);
            pos += mechBytes.length;
            name[pos++] = (byte) (nameBytes.length>>>24);
            name[pos++] = (byte) (nameBytes.length>>>16);
            name[pos++] = (byte) (nameBytes.length>>>8);
            name[pos++] = (byte) nameBytes.length;
            System.arraycopy(nameBytes, 0, name, pos, nameBytes.length);
        }
    }
    pName = cStub.importName(name, nameType);
    setPrintables();

    SecurityManager sm = System.getSecurityManager();
    if (sm != null && !Realm.AUTODEDUCEREALM) {
        String krbName = getKrbName();
        int atPos = krbName.lastIndexOf('@');
        if (atPos != -1) {
            String atRealm = krbName.substring(atPos);
            // getNativeNameType() can modify NT_GSS_KRB5_PRINCIPAL to null
            if ((nameType == null
                        || nameType.equals(GSSUtil.NT_GSS_KRB5_PRINCIPAL))
                    && new String(nameBytes).endsWith(atRealm)) {
                // Created from Kerberos name with realm, no need to check
            } else {
                try {
                    sm.checkPermission(new ServicePermission(atRealm, "-"));
                } catch (SecurityException se) {
                    // Do not chain the actual exception to hide info
                    throw new GSSException(GSSException.FAILURE);
                }
            }
        }
    }

    SunNativeProvider.debug("Imported " + printableName + " w/ type " +
                            printableType);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:70,代码来源:GSSNameElement.java


注:本文中的sun.security.krb5.Realm.AUTODEDUCEREALM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。