Search in sources :

Example 1 with UserCredentials

use of org.apache.zeppelin.user.UserCredentials in project zeppelin by apache.

the class JDBCInterpreterTest method getUserAuth.

private AuthenticationInfo getUserAuth(String user, String entityName, String dbUser, String dbPassword) {
    UserCredentials userCredentials = new UserCredentials();
    if (entityName != null && dbUser != null && dbPassword != null) {
        UsernamePassword up = new UsernamePassword(dbUser, dbPassword);
        userCredentials.putUsernamePassword(entityName, up);
    }
    AuthenticationInfo authInfo = new AuthenticationInfo();
    authInfo.setUserCredentials(userCredentials);
    authInfo.setUser(user);
    return authInfo;
}
Also used : UserCredentials(org.apache.zeppelin.user.UserCredentials) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) UsernamePassword(org.apache.zeppelin.user.UsernamePassword)

Example 2 with UserCredentials

use of org.apache.zeppelin.user.UserCredentials in project zeppelin by apache.

the class CredentialRestApi method getCredentials.

/**
   * Get User Credentials list REST API
   * @param
   * @return JSON with status.OK
   * @throws IOException, IllegalArgumentException
   */
@GET
public Response getCredentials(String message) throws IOException, IllegalArgumentException {
    String user = SecurityUtils.getPrincipal();
    logger.info("getCredentials credentials for user {} ", user);
    UserCredentials uc = credentials.getUserCredentials(user);
    return new JsonResponse(Status.OK, uc).build();
}
Also used : UserCredentials(org.apache.zeppelin.user.UserCredentials) JsonResponse(org.apache.zeppelin.server.JsonResponse)

Example 3 with UserCredentials

use of org.apache.zeppelin.user.UserCredentials in project zeppelin by apache.

the class Paragraph method getInterpreterContextWithoutRunner.

private InterpreterContext getInterpreterContextWithoutRunner(InterpreterOutput output) {
    AngularObjectRegistry registry = null;
    ResourcePool resourcePool = null;
    if (!interpreterSettingManager.getInterpreterSettings(note.getId()).isEmpty()) {
        InterpreterSetting intpGroup = interpreterSettingManager.getInterpreterSettings(note.getId()).get(0);
        registry = intpGroup.getInterpreterGroup(getUser(), note.getId()).getAngularObjectRegistry();
        resourcePool = intpGroup.getInterpreterGroup(getUser(), note.getId()).getResourcePool();
    }
    List<InterpreterContextRunner> runners = new LinkedList<>();
    final Paragraph self = this;
    Credentials credentials = note.getCredentials();
    if (authenticationInfo != null) {
        UserCredentials userCredentials = credentials.getUserCredentials(authenticationInfo.getUser());
        authenticationInfo.setUserCredentials(userCredentials);
    }
    InterpreterContext interpreterContext = new InterpreterContext(note.getId(), getId(), getRequiredReplName(), this.getTitle(), this.getText(), this.getAuthenticationInfo(), this.getConfig(), this.settings, registry, resourcePool, runners, output);
    return interpreterContext;
}
Also used : ResourcePool(org.apache.zeppelin.resource.ResourcePool) UserCredentials(org.apache.zeppelin.user.UserCredentials) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) UserCredentials(org.apache.zeppelin.user.UserCredentials) Credentials(org.apache.zeppelin.user.Credentials)

Example 4 with UserCredentials

use of org.apache.zeppelin.user.UserCredentials in project zeppelin by apache.

the class Paragraph method getInterpreterContext.

private InterpreterContext getInterpreterContext(InterpreterOutput output) {
    AngularObjectRegistry registry = null;
    ResourcePool resourcePool = null;
    if (!interpreterSettingManager.getInterpreterSettings(note.getId()).isEmpty()) {
        InterpreterSetting intpGroup = interpreterSettingManager.getInterpreterSettings(note.getId()).get(0);
        registry = intpGroup.getInterpreterGroup(getUser(), note.getId()).getAngularObjectRegistry();
        resourcePool = intpGroup.getInterpreterGroup(getUser(), note.getId()).getResourcePool();
    }
    List<InterpreterContextRunner> runners = new LinkedList<>();
    for (Paragraph p : note.getParagraphs()) {
        runners.add(new ParagraphRunner(note, note.getId(), p.getId()));
    }
    final Paragraph self = this;
    Credentials credentials = note.getCredentials();
    if (authenticationInfo != null) {
        UserCredentials userCredentials = credentials.getUserCredentials(authenticationInfo.getUser());
        authenticationInfo.setUserCredentials(userCredentials);
    }
    InterpreterContext interpreterContext = new InterpreterContext(note.getId(), getId(), getRequiredReplName(), this.getTitle(), this.getText(), this.getAuthenticationInfo(), this.getConfig(), this.settings, registry, resourcePool, runners, output);
    return interpreterContext;
}
Also used : ResourcePool(org.apache.zeppelin.resource.ResourcePool) UserCredentials(org.apache.zeppelin.user.UserCredentials) AngularObjectRegistry(org.apache.zeppelin.display.AngularObjectRegistry) UserCredentials(org.apache.zeppelin.user.UserCredentials) Credentials(org.apache.zeppelin.user.Credentials)

Example 5 with UserCredentials

use of org.apache.zeppelin.user.UserCredentials in project zeppelin by apache.

the class CredentialRestApi method removeCredentials.

/**
  * Remove User Credentials REST API
  * @param
  * @return JSON with status.OK
  * @throws IOException, IllegalArgumentException
  */
@DELETE
public Response removeCredentials(String message) throws IOException, IllegalArgumentException {
    String user = SecurityUtils.getPrincipal();
    logger.info("removeCredentials credentials for user {} ", user);
    UserCredentials uc = credentials.removeUserCredentials(user);
    if (uc == null) {
        return new JsonResponse(Status.NOT_FOUND).build();
    }
    return new JsonResponse(Status.OK).build();
}
Also used : UserCredentials(org.apache.zeppelin.user.UserCredentials) JsonResponse(org.apache.zeppelin.server.JsonResponse)

Aggregations

UserCredentials (org.apache.zeppelin.user.UserCredentials)7 JsonResponse (org.apache.zeppelin.server.JsonResponse)3 TypeToken (com.google.gson.reflect.TypeToken)2 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)2 ResourcePool (org.apache.zeppelin.resource.ResourcePool)2 Credentials (org.apache.zeppelin.user.Credentials)2 UsernamePassword (org.apache.zeppelin.user.UsernamePassword)2 Map (java.util.Map)1 GetMethod (org.apache.commons.httpclient.methods.GetMethod)1 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)1