congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CredentialService
Code IndexAdd Tabnine to your IDE (free)

How to use
CredentialService
in
org.eclipse.kapua.service.authentication.credential

Best Java code snippets using org.eclipse.kapua.service.authentication.credential.CredentialService (Showing top 18 results out of 315)

origin: eclipse/kapua

/**
 * Creates a new Credential based on the information provided in CredentialCreator
 * parameter.
 *
 * @param scopeId
 *            The {@link ScopeId} in which to create the {@link Credential}
 * @param credentialCreator
 *            Provides the information for the new Credential to be created.
 * @return The newly created Credential object.
 * @throws Exception
 *             Whenever something bad happens. See specific {@link KapuaService} exceptions.
 * @since 1.0.0
 */
@ApiOperation(nickname = "credentialCreate", value = "Create a Credential", notes = "Creates a new Credential based on the information provided in CredentialCreator parameter.", response = Credential.class)
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Credential create(
    @ApiParam(value = "The ScopeId in which to create the Credential", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
    @ApiParam(value = "Provides the information for the new Credential to be created", required = true) CredentialCreator credentialCreator) throws Exception {
  credentialCreator.setScopeId(scopeId);
  return credentialService.create(credentialCreator);
}
origin: eclipse/kapua

/**
 * Updates the Credential based on the information provided in the Credential parameter.
 *
 * @param credential
 *            The modified Credential whose attributed need to be updated.
 * @return The updated credential.
 * @throws Exception
 *             Whenever something bad happens. See specific {@link KapuaService} exceptions.
 * @since 1.0.0
 */
@ApiOperation(nickname = "credentialUpdate", value = "Update an Credential", notes = "Updates a new Credential based on the information provided in the Credential parameter.", response = Credential.class)
@PUT
@Path("{credentialId}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Credential update(
    @ApiParam(value = "The ScopeId of the requested Credential.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
    @ApiParam(value = "The id of the requested Credential", required = true) @PathParam("credentialId") EntityId credentialId,
    @ApiParam(value = "The modified Credential whose attributed need to be updated", required = true) Credential credential) throws Exception {
  credential.setScopeId(scopeId);
  credential.setId(credentialId);
  return credentialService.update(credential);
}
origin: eclipse/kapua

/**
 * Counts the results with the given {@link CredentialQuery} parameter.
 *
 * @param scopeId
 *            The {@link ScopeId} in which to search results.
 * @param query
 *            The {@link CredentialQuery} to use to filter results.
 * @return The count of all the result matching the given {@link CredentialQuery} parameter.
 * @throws Exception
 *             Whenever something bad happens. See specific {@link KapuaService} exceptions.
 * @since 1.0.0
 */
@ApiOperation(nickname = "credentialCount", value = "Counts the Credentials", notes = "Counts the Credentials with the given CredentialQuery parameter returning the number of matching Credentials", response = CountResult.class)
@POST
@Path("_count")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CountResult count(
    @ApiParam(value = "The ScopeId in which to count results", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
    @ApiParam(value = "The CredentialQuery to use to filter count results", required = true) CredentialQuery query) throws Exception {
  query.setScopeId(scopeId);
  return new CountResult(credentialService.count(query));
}
origin: org.eclipse.kapua/kapua-security-shiro

  credential = KapuaSecurityUtils.doPrivileged(() -> credentialService.findByApiKey(tokenApiKey));
} catch (AuthenticationException ae) {
  throw ae;
  credentialServiceConfig = KapuaSecurityUtils.doPrivileged(() -> credentialService.getConfigValues(account.getId()));
  boolean lockoutPolicyEnabled = (boolean) credentialServiceConfig.get("lockoutPolicy.enabled");
  if (lockoutPolicyEnabled) {
origin: org.eclipse.kapua/kapua-security-shiro

try {
  credential = KapuaSecurityUtils.doPrivileged(() -> {
    CredentialListResult credentialList = credentialService.findByUserId(user.getScopeId(), user.getId());
  credentialServiceConfig = KapuaSecurityUtils.doPrivileged(() -> credentialService.getConfigValues(account.getId()));
  boolean lockoutPolicyEnabled = (boolean) credentialServiceConfig.get("lockoutPolicy.enabled");
  if (lockoutPolicyEnabled) {
origin: eclipse/kapua

/**
 * Deletes the Credential specified by the "credentialId" path parameter.
 *
 * @param credentialId
 *            The id of the Credential to be deleted.
 * @return HTTP 200 if operation has completed successfully.
 * @throws Exception
 *             Whenever something bad happens. See specific {@link KapuaService} exceptions.
 * @since 1.0.0
 */
@ApiOperation(nickname = "credentialDelete", value = "Delete a Credential", notes = "Deletes the Credential specified by the \"credentialId\" path parameter.")
@DELETE
@Path("{credentialId}")
public Response deleteCredential(
    @ApiParam(value = "The ScopeId of the Credential to delete.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
    @ApiParam(value = "The id of the Credential to be deleted", required = true) @PathParam("credentialId") EntityId credentialId) throws Exception {
  credentialService.delete(scopeId, credentialId);
  return returnOk();
}
origin: eclipse/kapua

/**
 * Queries the results with the given {@link CredentialQuery} parameter.
 *
 * @param scopeId
 *            The {@link ScopeId} in which to search results.
 * @param query
 *            The {@link CredentialQuery} to use to filter results.
 * @return The {@link CredentialListResult} of all the result matching the given {@link CredentialQuery} parameter.
 * @throws Exception
 *             Whenever something bad happens. See specific {@link KapuaService} exceptions.
 * @since 1.0.0
 */
@ApiOperation(nickname = "credentialQuery", value = "Queries the Credentials", notes = "Queries the Credentials with the given CredentialQuery parameter returning all matching Credentials", response = CredentialListResult.class)
@POST
@Path("_query")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CredentialListResult query(
    @ApiParam(value = "The ScopeId in which to search results.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
    @ApiParam(value = "The CredentialQuery to use to filter results.", required = true) CredentialQuery query) throws Exception {
  query.setScopeId(scopeId);
  return credentialService.query(query);
}
origin: eclipse/kapua

/**
 * Returns the Credential specified by the "credentialId" path parameter.
 *
 * @param scopeId
 *            The {@link ScopeId} of the requested {@link Credential}.
 * @param credentialId
 *            The id of the requested Credential.
 * @return The requested Credential object.
 * @throws Exception
 *             Whenever something bad happens. See specific {@link KapuaService} exceptions.
 * @since 1.0.0
 */
@ApiOperation(nickname = "credentialFind", value = "Get a Credential", notes = "Returns the Credential specified by the \"credentialId\" path parameter.", response = Credential.class)
@GET
@Path("{credentialId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Credential find(
    @ApiParam(value = "The ScopeId of the requested Credential.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
    @ApiParam(value = "The id of the requested Credential", required = true) @PathParam("credentialId") EntityId credentialId) throws Exception {
  Credential credential = credentialService.find(scopeId, credentialId);
  if (credential == null) {
    throw new KapuaEntityNotFoundException(Credential.TYPE, credentialId);
  }
  return credential;
}
origin: eclipse/kapua

  credential = KapuaSecurityUtils.doPrivileged(() -> credentialService.findByApiKey(tokenApiKey));
} catch (AuthenticationException ae) {
  throw ae;
  credentialServiceConfig = KapuaSecurityUtils.doPrivileged(() -> credentialService.getConfigValues(account.getId()));
  boolean lockoutPolicyEnabled = (boolean) credentialServiceConfig.get("lockoutPolicy.enabled");
  if (lockoutPolicyEnabled) {
origin: eclipse/kapua

try {
  credential = KapuaSecurityUtils.doPrivileged(() -> {
    CredentialListResult credentialList = credentialService.findByUserId(user.getScopeId(), user.getId());
  credentialServiceConfig = KapuaSecurityUtils.doPrivileged(() -> credentialService.getConfigValues(account.getId()));
  boolean lockoutPolicyEnabled = (boolean) credentialServiceConfig.get("lockoutPolicy.enabled");
  if (lockoutPolicyEnabled) {
origin: eclipse/kapua

public void attachUserCredentials(Account account, User user) throws KapuaException {
  KapuaSecurityUtils.doPrivileged(() -> {
    CredentialCreator credentialCreator;
    credentialCreator = new CredentialFactoryImpl().newCreator(account.getId(), user.getId(), CredentialType.PASSWORD, "KeepCalm123.", CredentialStatus.ENABLED, null);
    try {
      credentialService.create(credentialCreator);
    } catch (KapuaException ke) {
      // skip
    }
    return null;
  });
}
origin: eclipse/kapua

      credentialService.update(failedCredential);
    });
  } catch (KapuaException kex) {
credential.setLoginFailures(0);
try {
  KapuaSecurityUtils.doPrivileged(() -> credentialService.update(credential));
} catch (KapuaException kex) {
  throw new ShiroException("Error while updating lockout policy", kex);
origin: eclipse/kapua

public void attachUserCredentials(Account account, User user, String password) throws KapuaException {
  KapuaSecurityUtils.doPrivileged(() -> {
    CredentialCreator credentialCreator;
    credentialCreator = new CredentialFactoryImpl().newCreator(account.getId(), user.getId(), CredentialType.PASSWORD, password, CredentialStatus.ENABLED, null);
    try {
      credentialService.create(credentialCreator);
    } catch (KapuaException ke) {
      // skip
    }
    return null;
  });
}
origin: org.eclipse.kapua/kapua-security-shiro

      credentialService.update(failedCredential);
    });
  } catch (KapuaException kex) {
credential.setLoginFailures(0);
try {
  KapuaSecurityUtils.doPrivileged(() -> credentialService.update(credential));
} catch (KapuaException kex) {
  throw new ShiroException("Error while updating lockout policy", kex);
origin: eclipse/kapua

/**
 * Create credentials for specific user, set users password.
 * It finds user by name and sets its password.
 *
 * @param testCredentials username and open password
 * @return created credential
 */
private Credential createCredentials(TestCredentials testCredentials) throws Exception {
  List<Credential> credentialList = new ArrayList<>();
  KapuaSecurityUtils.doPrivileged(() -> {
    primeException();
    try {
      User user = userService.findByName(testCredentials.getName());
      Credential credential = credentialService.create(credentialCreatorCreator(user.getScopeId(),
          user.getId(), testCredentials.getPassword(),
          testCredentials.getStatus(), testCredentials.getExpirationDate()));
      credentialList.add(credential);
    } catch (KapuaException ke) {
      verifyException(ke);
    }
    return null;
  });
  return credentialList.size() == 1 ? credentialList.get(0) : null;
}
origin: org.eclipse.kapua/kapua-security-shiro

      credentialService.update(failedCredential);
    });
  } catch (KapuaException kex) {
credential.setLoginFailures(0);
try {
  KapuaSecurityUtils.doPrivileged(() -> credentialService.update(credential));
} catch (KapuaException kex) {
  throw new ShiroException("Error while updating lockout policy", kex);
origin: eclipse/kapua

private User createBrokerUser(String baseName, Account account) throws KapuaException {
  // define
  UserCreator userCreator = userFactory.newCreator(account.getId(), baseName + "-broker");
  userCreator.setUserType(UserType.INTERNAL); // FIXME: need to find out why this isn't DEVICE but INTERNAL
  userCreator.setDisplayName("Gateway User");
  // create
  User user = userService.create(userCreator);
  // assign permissions
  AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(user.getScopeId());
  accessInfoCreator.setUserId(user.getId());
  Set<Permission> permissions = new HashSet<>();
  permissions.add(permissionFactory.newPermission(BrokerDomains.BROKER_DOMAIN, Actions.connect, user.getScopeId()));
  accessInfoCreator.setPermissions(permissions);
  accessInfoService.create(accessInfoCreator);
  // Create default password
  CredentialCreator credential = credentialFactory.newCreator(account.getId(), user.getId(), CredentialType.PASSWORD, baseName + "-password", CredentialStatus.ENABLED, null);
  credentialService.create(credential);
  return user;
}
origin: eclipse/kapua

      credentialService.update(failedCredential);
    });
  } catch (KapuaException kex) {
credential.setLoginFailures(0);
try {
  KapuaSecurityUtils.doPrivileged(() -> credentialService.update(credential));
} catch (KapuaException kex) {
  throw new ShiroException("Error while updating lockout policy", kex);
org.eclipse.kapua.service.authentication.credentialCredentialService

Javadoc

Credential service definition.

Most used methods

  • create
  • update
  • count
  • delete
  • find
  • findByApiKey
    Returns the Credential of type CredentialType#API_KEY matching the given parameters
  • findByUserId
    Return the credential list result looking by user identifier (and also scope identifier)
  • getConfigValues
  • query
  • setConfigValues
  • unlock
    Unlocks a Credential
  • unlock

Popular in Java

  • Reactive rest calls using spring rest template
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Menu (java.awt)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • JOptionPane (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now