Examples of AuthenticationToken


Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

  }
 
  @Override
  public ByteBuffer login(String principal, Map<String,String> loginProperties) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
    try {
      AuthenticationToken token = getToken(principal, loginProperties);
      TCredentials credential = CredentialHelper.create(principal, token, instance.getInstanceID());
      ByteBuffer login = ByteBuffer.wrap(CredentialHelper.asByteArray(credential));
      getConnector(login); // check to make sure user exists
      return login;
    } catch (AccumuloSecurityException e) {
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

  }
 
  private AuthenticationToken getToken(String principal, Map<String,String> properties) throws AccumuloSecurityException, AccumuloException {
    AuthenticationToken.Properties props = new AuthenticationToken.Properties();
    props.putAllStrings(properties);
    AuthenticationToken token;
    try {
      token = tokenClass.newInstance();
    } catch (InstantiationException e) {
      throw new AccumuloException(e);
    } catch (IllegalAccessException e) {
      throw new AccumuloException(e);
    }
    token.init(props);
    return token;
  }
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

    }
    Instance instance = opts.getInstance();
     
    try {
      String principal;
      AuthenticationToken token;
      if (opts.getToken() == null) {
        principal = SecurityConstants.getSystemPrincipal();
        token = SecurityConstants.getSystemToken();
      } else {
        principal = opts.principal;
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

    return connector;
  }
 
  public TCredentials getCredentials() {
    String username = getUserName();
    AuthenticationToken password = getToken();
    return CredentialHelper.createSquelchError(username, password, getInstance().getInstanceID());
  }
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

    AccumuloConfiguration conf = serverConfiguration.getConfiguration();
    table = conf.get(Property.TRACE_TABLE);
    while (true) {
      try {
        String principal = conf.get(Property.TRACE_USER);
        AuthenticationToken at;
        Map<String,String> loginMap = conf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX);
        if (loginMap.isEmpty()) {
          Property p = Property.TRACE_PASSWORD;
          at = new PasswordToken(conf.get(p).getBytes());
        } else {
          Properties props = new Properties();
          AuthenticationToken token = AccumuloClassLoader.getClassLoader().loadClass(conf.get(Property.TRACE_TOKEN_TYPE)).asSubclass(AuthenticationToken.class)
              .newInstance();

          int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length() + 1;
          for (Entry<String,String> entry : loginMap.entrySet()) {
            props.put(entry.getKey().substring(prefixLength), entry.getValue());
          }

          token.init(props);
         
          at = token;
        }
       
        connector = serverConfiguration.getInstance().getConnector(principal, at);
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

    else if (credentials.getPrincipal().equals(SecurityConstants.SYSTEM_PRINCIPAL)) {
      throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.BAD_CREDENTIALS);
    }
   
    try {
      AuthenticationToken token = reassembleToken(credentials);
      if (!authenticator.authenticateUser(credentials.getPrincipal(), token)) {
        throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.BAD_CREDENTIALS);
      }
    } catch (AccumuloSecurityException e) {
      log.debug(e);
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

    canAskAboutUser(credentials, toAuth.getPrincipal());
    // User is already authenticated from canAskAboutUser, this gets around issues with !SYSTEM user
    if (credentials.equals(toAuth))
      return true;
    try {
      AuthenticationToken token = reassembleToken(toAuth);
      return authenticator.authenticateUser(toAuth.getPrincipal(), token);
    } catch (AccumuloSecurityException e) {
      throw e.asThriftException();
    }
  }
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

 
  public void changePassword(TCredentials credentials, TCredentials toChange) throws ThriftSecurityException {
    if (!canChangePassword(credentials, toChange.getPrincipal()))
      throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
      AuthenticationToken token = reassembleToken(toChange);
      authenticator.changePassword(toChange.getPrincipal(), token);
      log.info("Changed password for user " + toChange.getPrincipal() + " at the request of user " + credentials.getPrincipal());
    } catch (AccumuloSecurityException e) {
      throw e.asThriftException();
    }
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

 
  public void createUser(TCredentials credentials, TCredentials newUser, Authorizations authorizations) throws ThriftSecurityException {
    if (!canCreateUser(credentials, newUser.getPrincipal()))
      throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
      AuthenticationToken token = reassembleToken(newUser);
      authenticator.createUser(newUser.getPrincipal(), token);
      authorizor.initUser(newUser.getPrincipal());
      permHandle.initUser(newUser.getPrincipal());
      log.info("Created user " + newUser.getPrincipal() + " at the request of user " + credentials.getPrincipal());
      if (canChangeAuthorizations(credentials, newUser.getPrincipal()))
View Full Code Here

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

 
  public static AuthenticationToken extractToken(String tokenClass, byte[] token) throws AccumuloSecurityException {
    try {
      Object obj = Class.forName(tokenClass).newInstance();
      if (obj instanceof AuthenticationToken) {
        AuthenticationToken toRet = (AuthenticationToken) obj;
        toRet.readFields(new DataInputStream(new ByteArrayInputStream(token)));
        return toRet;
      }
    } catch (ClassNotFoundException cnfe) {
      log.error(cnfe, cnfe);
    } catch (InstantiationException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.