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


Java AuthenticatedUser类代码示例

本文整理汇总了Java中org.apache.cassandra.auth.AuthenticatedUser的典型用法代码示例。如果您正苦于以下问题:Java AuthenticatedUser类的具体用法?Java AuthenticatedUser怎么用?Java AuthenticatedUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkAccess

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public void checkAccess(ClientState state) throws UnauthorizedException
{
    AuthenticatedUser user = state.getUser();

    boolean isSuper = user.isSuper();

    if (superuser != null && user.getName().equals(username))
        throw new UnauthorizedException("You aren't allowed to alter your own superuser status");

    if (superuser != null && !isSuper)
        throw new UnauthorizedException("Only superusers are allowed to alter superuser status");

    if (!user.isSuper() && !user.getName().equals(username))
        throw new UnauthorizedException("You aren't allowed to alter this user");

    if (!isSuper)
    {
        for (IAuthenticator.Option option : opts.getOptions().keySet())
        {
            if (!DatabaseDescriptor.getAuthenticator().alterableOptions().contains(option))
                throw new UnauthorizedException(String.format("You aren't allowed to alter %s option", option));
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:AlterUserStatement.java

示例2: execute

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
@Override
public Response execute(QueryState queryState)
{
    try
    {
        SaslAuthenticator authenticator = ((ServerConnection) connection).getAuthenticator();
        byte[] challenge = authenticator.evaluateResponse(token == null ? new byte[0] : token);
        if (authenticator.isComplete())
        {
            AuthenticatedUser user = authenticator.getAuthenticatedUser();
            queryState.getClientState().login(user);
            // authentication is complete, send a ready message to the client
            return new AuthSuccess(challenge);
        }
        else
        {
            return new AuthChallenge(challenge);
        }
    }
    catch (AuthenticationException e)
    {
        return ErrorMessage.fromException(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:AuthResponse.java

示例3: execute

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
@Override
public Response execute(QueryState queryState)
{
    try
    {
        IAuthenticator.SaslNegotiator negotiator = ((ServerConnection) connection).getSaslNegotiator(queryState);
        byte[] challenge = negotiator.evaluateResponse(token);
        if (negotiator.isComplete())
        {
            AuthenticatedUser user = negotiator.getAuthenticatedUser();
            queryState.getClientState().login(user);
            // authentication is complete, send a ready message to the client
            return new AuthSuccess(challenge);
        }
        else
        {
            return new AuthChallenge(challenge);
        }
    }
    catch (AuthenticationException e)
    {
        return ErrorMessage.fromException(e);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:AuthResponse.java

示例4: authenticate

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
/**
 * Performs the authentication
 *
 * @param credentials A Map containing the Cassandra managed username and password to authorize against.
 * @return a valid AuthenticatedUser injected with the cf_username if authentication was successful.
 * @throws AuthenticationException if the cf_username and cf_password could not be validated against credentials.
 */
public AuthenticatedUser authenticate(Map<? extends CharSequence, ? extends CharSequence> credentials) throws AuthenticationException {
    CharSequence username = credentials.get(USERNAME_KEY);
    if (username == null || username.equals(""))
        throw new AuthenticationException("Authentication request was missing the required key '" + USERNAME_KEY + "'");

    CharSequence password = credentials.get(PASSWORD_KEY);
    if (password == null || password.equals(""))
        throw new AuthenticationException("Authentication request was missing the required key '" + PASSWORD_KEY + "'");

    boolean authenticated = username.equals(cf_username) && password.equals(cf_password);

    if (!authenticated) throw new AuthenticationException(
            String.format("User could not be validated : %s", username));

    return new AuthenticatedUser(username.toString());
}
 
开发者ID:CloudCredo,项目名称:cassandra_chastity,代码行数:24,代码来源:CloudFoundryAuthenticator.java

示例5: authorize

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public Set<Permission> authorize(AuthenticatedUser user, IResource resource) {
 	String uname, rname;
 	access.log(Level.DEBUG,"Authorizing",uname=user.getName(),"for",rname=resource.getName());

 	Set<Permission> permissions;

 	if(user instanceof AAFAuthenticatedUser) {
      AAFAuthenticatedUser aafUser = (AAFAuthenticatedUser) user;
aafUser.setAnonymous(false);

if(aafUser.isLocal()) {
	permissions = checkPermissions(aafUser, new LocalPermission(
		rname.replaceFirst("data", cluster_name)
	));
} else {
  		permissions = checkPermissions(
  				aafUser,
  				perm_type,
  				':'+rname.replaceFirst("data", cluster_name).replace('/', ':'));
}
 	} else {
 		permissions = Permission.NONE;
 	}
 	
 	access.log(Level.INFO,"Permissions on",rname,"for",uname,':', permissions);

     return permissions;
 }
 
开发者ID:att,项目名称:AAF,代码行数:29,代码来源:AAFAuthorizer.java

示例6: validate

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
    // validate login here before checkAccess to avoid leaking user existence to anonymous users.
    state.ensureNotAnonymous();

    if (!ifExists && !Auth.isExistingUser(username))
        throw new InvalidRequestException(String.format("User %s doesn't exist", username));

    AuthenticatedUser user = state.getUser();
    if (user != null && user.getName().equals(username))
        throw new InvalidRequestException("Users aren't allowed to DROP themselves");
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:DropUserStatement.java

示例7: execute

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().authenticate(credentials);
        state.getClientState().login(user);
        return new ReadyMessage();
    }
    catch (AuthenticationException e)
    {
        return ErrorMessage.fromException(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:CredentialsMessage.java

示例8: login

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public void login(AuthenticationRequest auth_request) throws AuthenticationException, AuthorizationException, TException
{
    try
    {
        AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().authenticate(auth_request.getCredentials());
        state().login(user);
    }
    catch (org.apache.cassandra.exceptions.AuthenticationException e)
    {
        throw ThriftConversion.toThrift(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:CassandraServer.java

示例9: validate

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
    // validate login here before checkAccess to avoid leaking user existence to anonymous users.
    state.ensureNotAnonymous();

    if (!Auth.isExistingUser(username))
        throw new InvalidRequestException(String.format("User %s doesn't exist", username));

    AuthenticatedUser user = state.getUser();
    if (user != null && user.getName().equals(username))
        throw new InvalidRequestException("Users aren't allowed to DROP themselves");
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:13,代码来源:DropUserStatement.java

示例10: execute

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public ResultMessage execute(QueryState state, QueryOptions options) throws RequestValidationException
{
    // If an IF [NOT] EXISTS clause was used, this may not result in an actual schema change.  To avoid doing
    // extra work in the drivers to handle schema changes, we return an empty message in this case. (CASSANDRA-7600)
    Event.SchemaChange ce = announceMigration(false);
    if (ce == null)
        return new ResultMessage.Void();

    // when a schema alteration results in a new db object being created, we grant permissions on the new
    // object to the user performing the request if:
    // * the user is not anonymous
    // * the configured IAuthorizer supports granting of permissions (not all do, AllowAllAuthorizer doesn't and
    //   custom external implementations may not)
    AuthenticatedUser user = state.getClientState().getUser();
    if (user != null && !user.isAnonymous() && ce.change == Event.SchemaChange.Change.CREATED)
    {
        try
        {
            grantPermissionsToCreator(state);
        }
        catch (UnsupportedOperationException e)
        {
            // not a problem, grant is an optional method on IAuthorizer
        }
    }

    return new ResultMessage.SchemaChange(ce);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:SchemaAlteringStatement.java

示例11: execute

import org.apache.cassandra.auth.AuthenticatedUser; //导入依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().legacyAuthenticate(credentials);
        state.getClientState().login(user);
    }
    catch (AuthenticationException e)
    {
        return ErrorMessage.fromException(e);
    }

    return new ReadyMessage();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:CredentialsMessage.java


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