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


Java GSSContext.getSrcName方法代码示例

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


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

示例1: authenticate

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Principal authenticate(GSSContext gssContext, boolean storeCreds) {
    if (gssContext.isEstablished()) {
        String username = null;
        GSSName name = null;
        try {
            name = gssContext.getSrcName();
        } catch (GSSException e) {
            log.warn(sm.getString("realmBase.gssNameFail"), e);
            return null;
        }
        
        username = name.toString();
        
        Principal authenticatedUser = super.authenticate(gssContext, storeCreds);
            
        return filterLockedAccounts(username, authenticatedUser);
    }
    
    // Fail in all other cases
    return null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:LockOutRealm.java

示例2: authenticate

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Principal authenticate(GSSContext gssContext, boolean storeCreds) {
	if (gssContext.isEstablished()) {
		String username = null;
		GSSName name = null;
		try {
			name = gssContext.getSrcName();
		} catch (GSSException e) {
			log.warn(sm.getString("realmBase.gssNameFail"), e);
			return null;
		}

		username = name.toString();

		Principal authenticatedUser = super.authenticate(gssContext, storeCreds);

		return filterLockedAccounts(username, authenticatedUser);
	}

	// Fail in all other cases
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:LockOutRealm.java

示例3: getUsernameFromGSSContext

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
private static String getUsernameFromGSSContext(final GSSContext gssContext, final boolean strip, final ESLogger logger) {
    if (gssContext.isEstablished()) {
        GSSName gssName = null;
        try {
            gssName = gssContext.getSrcName();
        } catch (final GSSException e) {
            logger.error("Unable to get src name from gss context", e);
        }

        if (gssName != null) {
            String name = gssName.toString();

            return stripRealmName(name, strip);

        }
    }

    return null;
}
 
开发者ID:codecentric,项目名称:elasticsearch-shield-kerberos-realm,代码行数:20,代码来源:KerberosRealm.java

示例4: authorize

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
 * Performs host authentication. The hostname of the peer is
 * compared with the hostname specified in the peer's (topmost) 
 * certificate in the certificate chain. The hostnames must
 * match exactly (in case-insensitive way)
 *
 * @param context the security context
 * @param host host address of the peer.
 * @exception AuthorizationException if the hostnames
 *            do not match.
 */
public void authorize(GSSContext context, String host)
    throws AuthorizationException {
    logger.debug("Authorization: HOST");

    try {
        GSSName expected = getExpectedName(null, host);
    
        GSSName target = null;
        if (context.isInitiator()) {
            target = context.getTargName();
        } else {
            target = context.getSrcName();
        }
    
        if (!expected.equals(target)) {
            generateAuthorizationException(expected, target);
        }
    } catch (GSSException e) {
        throw new AuthorizationException("Authorization failure", e);
    }
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:33,代码来源:HostAuthorization.java

示例5: authorize

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
    * Performs self authorization.
    */
   public void authorize(GSSContext context, String host)
throws AuthorizationException {
logger.debug("Authorization: SELF");

try {
    if (!context.getSrcName().equals(context.getTargName())) {
	GSSName expected = null;
	GSSName target = null;
	if (context.isInitiator()) {
	    expected = context.getSrcName();
	    target = context.getTargName();
	} else {
	    expected = context.getTargName();
	    target = context.getSrcName();
	}
	generateAuthorizationException(expected, target);
    }
} catch (GSSException e) {
    throw new AuthorizationException("Authorization failure", e);
}
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:25,代码来源:SelfAuthorization.java

示例6: authorize

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
 * Performs identity authorization. The given identity is compared
 * with the peer's identity.
 *
 * @param context the security context
 * @param host host address of the peer.
 * @exception AuthorizationException if the peer's
 *            identity does not match the expected identity.
 */
public void authorize(GSSContext context, String host)
    throws AuthorizationException {
    logger.debug("Authorization: IDENTITY");

    try {
        GSSName expected = getExpectedName(null, host);
    
        GSSName target = null;
        if (context.isInitiator()) {
            target = context.getTargName();
        } else {
            target = context.getSrcName();
        }
        
        if (!expected.equals(target)) {
            generateAuthorizationException(expected, target);
        }
    } catch (GSSException e) {
        throw new AuthorizationException("Authorization failure", e);
    }
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:31,代码来源:IdentityAuthorization.java

示例7: GSSAuthentication

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
public GSSAuthentication(byte[] token) throws GSSException {
	GSSManager gssManager = GSSManager.getInstance();
	GSSCredential gssCreds = gssManager.createCredential(
			(GSSName) null, GSSCredential.INDEFINITE_LIFETIME,
			(Oid) null, GSSCredential.ACCEPT_ONLY);
	GSSContext gssContext = gssManager.createContext(gssCreds);

	responseToken = gssContext
			.acceptSecContext(token, 0, token.length);

	if (gssContext.isEstablished()) {
		GSSName name = gssContext.getSrcName();
		username = name.toString();
	}
}
 
开发者ID:cbsit,项目名称:JaasLounge,代码行数:16,代码来源:GSSAuthentication.java

示例8: getUsernameFromGSSContext

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
private String getUsernameFromGSSContext(final GSSContext gssContext, final boolean strip) {
    if (gssContext.isEstablished()) {
        GSSName gssName = null;
        try {
            gssName = gssContext.getSrcName();
        } catch (final GSSException e) {
            log.warn("realmBase.gssNameFail", e);
        }

        if (gssName != null) {
            String name = gssName.toString();

            if (strip && name != null) {
                final int i = name.indexOf('@');
                if (i > 0) {
                    // Zero so we don;t leave a zero length name
                    name = name.substring(0, i);
                }
            }

            return name;

        }
    }

    return null;
}
 
开发者ID:petalmd,项目名称:armor,代码行数:28,代码来源:HTTPSpnegoAuthenticator.java

示例9: authenticate

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Principal authenticate(GSSContext gssContext, boolean storeCreds) {
    if (gssContext.isEstablished()) {
        String username = null;
        GSSName name = null;
        try {
            name = gssContext.getSrcName();
        } catch (GSSException e) {
            log.warn(sm.getString("realmBase.gssNameFail"), e);
            return null;
        }
        
        username = name.toString();
        
        if (isLocked(username)) {
            // Trying to authenticate a locked user is an automatic failure
            registerAuthFailure(username);
            
            log.warn(sm.getString("lockOutRealm.authLockedUser", username));
            return null;
        }

        Principal authenticatedUser =
                super.authenticate(gssContext, storeCreds);
        
        if (authenticatedUser == null) {
            registerAuthFailure(username);
        } else {
            registerAuthSuccess(username);
        }
        return authenticatedUser;
    }
    
    // Fail in all other cases
    return null;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:40,代码来源:LockOutRealm.java

示例10: getKerberosUser

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
private String getKerberosUser()
{
    log.debug("Obtaining userID from kerberos");
    String service = conSettings.getSaslProtocol() + "@" + conSettings.getSaslServerName();
    GSSManager manager = GSSManager.getInstance();

    try
    {
        GSSName acceptorName = manager.createName(service,
            GSSName.NT_HOSTBASED_SERVICE, KRB5_OID);

        GSSContext secCtx = manager.createContext(acceptorName,
                                                  KRB5_OID,
                                                  null,
                                                  GSSContext.INDEFINITE_LIFETIME);

        secCtx.initSecContext(new byte[0], 0, 1);

        if (secCtx.getSrcName() != null)
        {
            return secCtx.getSrcName().toString();
        }

    }
    catch (GSSException e)
    {
        log.warn("Unable to retrieve userID from Kerberos due to error",e);
    }

    return null;
}
 
开发者ID:wso2,项目名称:andes,代码行数:32,代码来源:ClientDelegate.java

示例11: authenticate

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Principal authenticate(GSSContext gssContext, boolean storeCreds) {
    if (gssContext.isEstablished()) {
        Principal authenticatedUser = null;
        String username = null;
        
        GSSName name = null;
        try {
            name = gssContext.getSrcName();
        } catch (GSSException e) {
            log.warn(sm.getString("realmBase.gssNameFail"), e);
            return null;
        }
        
        username = name.toString();

        for (Realm realm : realms) {
            if (log.isDebugEnabled()) {
                log.debug(sm.getString("combinedRealm.authStart",
                        username, realm.getInfo()));
            }

            authenticatedUser = realm.authenticate(gssContext, storeCreds);

            if (authenticatedUser == null) {
                if (log.isDebugEnabled()) {
                    log.debug(sm.getString("combinedRealm.authFail",
                            username, realm.getInfo()));
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug(sm.getString("combinedRealm.authSuccess",
                            username, realm.getInfo()));
                }
                break;
            }
        }
        return authenticatedUser;
    }
    
    // Fail in all other cases
    return null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:47,代码来源:CombinedRealm.java

示例12: authenticate

import org.ietf.jgss.GSSContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Principal authenticate(GSSContext gssContext, boolean storeCreds) {
	if (gssContext.isEstablished()) {
		Principal authenticatedUser = null;
		String username = null;

		GSSName name = null;
		try {
			name = gssContext.getSrcName();
		} catch (GSSException e) {
			log.warn(sm.getString("realmBase.gssNameFail"), e);
			return null;
		}

		username = name.toString();

		for (Realm realm : realms) {
			if (log.isDebugEnabled()) {
				log.debug(sm.getString("combinedRealm.authStart", username, realm.getInfo()));
			}

			authenticatedUser = realm.authenticate(gssContext, storeCreds);

			if (authenticatedUser == null) {
				if (log.isDebugEnabled()) {
					log.debug(sm.getString("combinedRealm.authFail", username, realm.getInfo()));
				}
			} else {
				if (log.isDebugEnabled()) {
					log.debug(sm.getString("combinedRealm.authSuccess", username, realm.getInfo()));
				}
				break;
			}
		}
		return authenticatedUser;
	}

	// Fail in all other cases
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:44,代码来源:CombinedRealm.java


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