當前位置: 首頁>>代碼示例>>Java>>正文


Java Oid.equals方法代碼示例

本文整理匯總了Java中org.ietf.jgss.Oid.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Oid.equals方法的具體用法?Java Oid.equals怎麽用?Java Oid.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.ietf.jgss.Oid的用法示例。


在下文中一共展示了Oid.equals方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LoginConfigImpl

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
/**
 * A new instance of LoginConfigImpl must be created for each login request
 * since it's only used by a single (caller, mech) pair
 * @param caller defined in GSSUtil as CALLER_XXX final fields
 * @param oid defined in GSSUtil as XXX_MECH_OID final fields
 */
public LoginConfigImpl(GSSCaller caller, Oid mech) {

    this.caller = caller;

    if (mech.equals(GSSUtil.GSS_KRB5_MECH_OID)) {
        mechName = "krb5";
    } else {
        throw new IllegalArgumentException(mech.toString() + " not supported");
    }
    config = java.security.AccessController.doPrivileged
            (new java.security.PrivilegedAction <Configuration> () {
        public Configuration run() {
            return Configuration.getConfiguration();
        }
    });
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:LoginConfigImpl.java

示例2: LoginConfigImpl

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
/**
 * A new instance of LoginConfigImpl must be created for each login request
 * since it's only used by a single (caller, mech) pair
 * @param caller defined in GSSUtil as CALLER_XXX final fields
 * @param mech defined in GSSUtil as XXX_MECH_OID final fields
 */
public LoginConfigImpl(GSSCaller caller, Oid mech) {

    this.caller = caller;

    if (mech.equals(GSSUtil.GSS_KRB5_MECH_OID)) {
        mechName = "krb5";
    } else {
        throw new IllegalArgumentException(mech.toString() + " not supported");
    }
    config = java.security.AccessController.doPrivileged
            (new java.security.PrivilegedAction <Configuration> () {
        public Configuration run() {
            return Configuration.getConfiguration();
        }
    });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:LoginConfigImpl.java

示例3: KerberosName

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
public KerberosName(String name, Oid nameType) throws GSSException {
	if (null == name) {
		throw new GSSException(KerberosUtils.DEFAULT_GSSEXCEPTION_MAJOR_CODE,
				KerberosUtils.DEFAULT_GSSEXCEPTION_MINOR_CODE,
				"Cannot import null GSSName");
	}

	if (null == nameType) {
		nameType = KerberosUtils.KRB5_PRINCIPAL_NAMETYPE;
	}
	
	if(nameType.equals(GSSName.NT_HOSTBASED_SERVICE)){
		name = name.replaceAll("@", "/");
	}
	
	if (!(nameType.equals(GSSName.NT_HOSTBASED_SERVICE)
			|| nameType.equals(GSSName.NT_USER_NAME) || nameType
			.equals(KerberosUtils.KRB5_PRINCIPAL_NAMETYPE))) {
		throw new GSSException(
				KerberosUtils.DEFAULT_GSSEXCEPTION_MAJOR_CODE,
				KerberosUtils.DEFAULT_GSSEXCEPTION_MINOR_CODE,
				"Unsupported OID");
	}
	this.name = name;
	this.nameType = nameType;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:27,代碼來源:KerberosName.java

示例4: getMechsForName

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
@Override
public Oid[] getMechsForName(Oid nameType) {
	ArrayList<Oid> mechs = new ArrayList<Oid>();
	Oid[] oids = getMechs();
	for (Oid oid : oids) {
		GSSMechSpi api = spis.get(oid);
		Oid[] mechNames = api.getNameMechs();
		boolean support = false;
		for (Oid mechName : mechNames) {
			if (mechName.equals(nameType)) {
				support = true;
				break;
			}
		}
		if (support) {
			mechs.add(oid);
		}
	}
	return mechs.toArray(new Oid[mechs.size()]);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:GSSManagerImpl.java

示例5: testGetNamesForMech

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
public void testGetNamesForMech() throws Exception {
	Oid kerberosMech = new Oid("1.2.840.113554.1.2.2");
	Oid[] nameTypes = gssManager.getNamesForMech(kerberosMech);
	Oid[] expectedNameTypes = new Oid[] { GSSName.NT_USER_NAME,
			GSSName.NT_HOSTBASED_SERVICE, GSSName.NT_EXPORT_NAME,
			KerberosUtils.KRB5_PRINCIPAL_NAMETYPE };
	assertEquals(expectedNameTypes.length, nameTypes.length);
	for (Oid expectedNameType : expectedNameTypes) {
		boolean got = false;
		for (Oid nameType : nameTypes) {
			if (nameType.equals(expectedNameType)) {
				got = true;
				break;
			}
		}
		if (!got) {
			fail("Missing expected NameType " + expectedNameType);
		}
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:GSSManagerImplTest.java

示例6: equals

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
public boolean equals(GSSName another) throws GSSException {		
	if (isAnonymous() && another.isAnonymous()) {
		return true;
	}

	if (!(another instanceof KerberosName)) {		
		
		return false;
	}

	KerberosName anotherNameImpl = (KerberosName) another;
	String thisName = getName();
	String anotherName = anotherNameImpl.getName();

	if (!thisName.equals(anotherName)) {
		return false;
	}

	Oid thisOid = getStringNameType();
	Oid anotherOid = anotherNameImpl.getStringNameType();

	if (thisOid.equals(KerberosUtils.KRB5_PRINCIPAL_NAMETYPE)
			|| anotherOid.equals(KerberosUtils.KRB5_PRINCIPAL_NAMETYPE)) {
		return true;
	}
	return thisOid.equals(anotherOid);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:28,代碼來源:KerberosName.java

示例7: createName

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
@Override
public GSSName createName(String nameStr, Oid nameType) throws GSSException {
	if(nameType != null && nameType.equals(GSSName.NT_EXPORT_NAME)){
		return GSSNameImpl.importFromString(GSSUtils.getBytes(nameStr), this);
	}		
	return DEFAULT_API.createName(nameStr, nameType);	
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:8,代碼來源:GSSManagerImpl.java

示例8: encodeGSSAPIAuthenticationPacket

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
/**
 * Encodes the authentication packet for supported authentication methods.
 * 
 * @param request the socks proxy request data
 * @return the encoded buffer
 * @throws GSSException when something fails while using GSSAPI
 */
private IoBuffer encodeGSSAPIAuthenticationPacket(final SocksProxyRequest request) throws GSSException {
    GSSContext ctx = (GSSContext) getSession().getAttribute(GSS_CONTEXT);
    if (ctx == null) {
        // first step in the authentication process
        GSSManager manager = GSSManager.getInstance();
        GSSName serverName = manager.createName(request.getServiceKerberosName(), null);
        Oid krb5OID = new Oid(SocksProxyConstants.KERBEROS_V5_OID);

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Available mechs:");
            for (Oid o : manager.getMechs()) {
                if (o.equals(krb5OID)) {
                    LOGGER.debug("Found Kerberos V OID available");
                }
                LOGGER.debug("{} with oid = {}", manager.getNamesForMech(o), o);
            }
        }

        ctx = manager.createContext(serverName, krb5OID, null, GSSContext.DEFAULT_LIFETIME);

        ctx.requestMutualAuth(true); // Mutual authentication
        ctx.requestConf(false);
        ctx.requestInteg(false);

        getSession().setAttribute(GSS_CONTEXT, ctx);
    }

    byte[] token = (byte[]) getSession().getAttribute(GSS_TOKEN);
    if (token != null) {
        LOGGER.debug("  Received Token[{}] = {}", token.length, ByteUtilities.asHex(token));
    }
    IoBuffer buf = null;

    if (!ctx.isEstablished()) {
        // token is ignored on the first call
        if (token == null) {
            token = new byte[32];
        }

        token = ctx.initSecContext(token, 0, token.length);

        // Send a token to the server if one was generated by
        // initSecContext
        if (token != null) {
            LOGGER.debug("  Sending Token[{}] = {}", token.length, ByteUtilities.asHex(token));

            getSession().setAttribute(GSS_TOKEN, token);
            buf = IoBuffer.allocate(4 + token.length);
            buf.put(new byte[] { SocksProxyConstants.GSSAPI_AUTH_SUBNEGOTIATION_VERSION,
                    SocksProxyConstants.GSSAPI_MSG_TYPE });

            buf.put(ByteUtilities.intToNetworkByteOrder(token.length, 2));
            buf.put(token);
        }
    }

    return buf;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:66,代碼來源:Socks5LogicHandler.java

示例9: main

import org.ietf.jgss.Oid; //導入方法依賴的package包/類
public static void main(String[] args)
        throws Exception {

    Oid oldOid = new Oid("1.3.6.1.5.6.2");
    new OneKDC(null).writeJAASConf();

    System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
    GSSManager m = GSSManager.getInstance();
    boolean found = false;

    // Test 1: the getMechsForName() method accepts it.
    for (Oid tmp: m.getMechsForName(oldOid)) {
        if (tmp.equals(GSSUtil.GSS_KRB5_MECH_OID)) {
            found = true;
            break;
        }
    }
    if (!found) {
        throw new Exception("Cannot found krb5 mech for old name type");
    }

    // Test 2: the createName() method accepts it.
    GSSName name = m.createName("[email protected]", oldOid);

    // Test 3: its getStringNameType() output is correct
    if (!name.getStringNameType().equals(GSSName.NT_HOSTBASED_SERVICE)) {
        throw new Exception("GSSName not correct name type");
    }

    // Test 4: everything still works.
    GSSContext c1 = m.createContext(
            name,
            GSSUtil.GSS_KRB5_MECH_OID,
            null,
            GSSContext.DEFAULT_LIFETIME);
    byte[] token = c1.initSecContext(new byte[0], 0, 0);

    Context s;
    s = Context.fromJAAS("server");
    s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
    s.x().acceptSecContext(token, 0, token.length);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:43,代碼來源:Test5653.java


注:本文中的org.ietf.jgss.Oid.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。