Tabnine Logo
CredentialValidationResult
Code IndexAdd Tabnine to your IDE (free)

How to use
CredentialValidationResult
in
javax.security.enterprise.identitystore

Best Java code snippets using javax.security.enterprise.identitystore.CredentialValidationResult (Showing top 20 results out of 315)

origin: org.glassfish.soteria/javax.security.enterprise

  if (validationResult.getStatus() == VALID) {
    identityStore = authenticationIdentityStore;
    break;
  else if (validationResult.getStatus() == INVALID) {
    isGotAnInvalidResult = true;
if (validationResult == null || validationResult.getStatus() != VALID) {
  groups.addAll(validationResult.getCallerGroups());
return new CredentialValidationResult(
    validationResult.getIdentityStoreId(),
    validationResult.getCallerPrincipal(),
    validationResult.getCallerDn(),
    validationResult.getCallerUniqueId(),
    groups);
origin: org.glassfish.soteria/javax.security.enterprise

@Override
public AuthenticationStatus notifyContainerAboutLogin(CredentialValidationResult result) {
  if (result.getStatus() == VALID) {
    return notifyContainerAboutLogin(
        result.getCallerPrincipal(),
        result.getCallerGroups());
  } 
    
  return SEND_FAILURE;
}
origin: javaee-samples/javaee8-samples

/**
 * Create the JWT using CredentialValidationResult received from
 * IdentityStoreHandler
 *
 * @param result the result from validation of UsernamePasswordCredential
 * @param context
 * @return the AuthenticationStatus to notify the container
 */
private AuthenticationStatus createToken(CredentialValidationResult result, HttpMessageContext context) {
  if (!isRememberMe(context)) {
    String jwt = tokenProvider.createToken(result.getCallerPrincipal().getName(), result.getCallerGroups(), false);
    context.getResponse().setHeader(AUTHORIZATION_HEADER, BEARER + jwt);
  }
  return context.notifyContainerAboutLogin(result.getCallerPrincipal(), result.getCallerGroups());
}
origin: fish.payara.api/payara-api

/**
 * Returns a valid {@link CredentialValidationResult}.
 * <p>
 * If further validation is required this method should be overridden in a sub-class
 * or alternative {@link IdentityStore}. Calling {@link RememberMeCredential#getToken()}
 * on the credential passed in will get the authorisation token which can be used to get
 * more information about the user from the OAuth provider by sending a GET request to
 * an endpoint i.e. https://oauthprovider/user&token=exampletoken.
 * @param credential
 * @return 
 */
public CredentialValidationResult validate(RememberMeCredential credential){
  return new CredentialValidationResult(credential.toString());
}

origin: javaee-samples/javaee8-samples

@Override
public Set<String> getCallerGroups(CredentialValidationResult validationResult) {
  Set<String> result = groupsPerCaller.get(validationResult.getCallerPrincipal().getName());
  if (result == null) {
    result = emptySet();
  }
  return result;
}
origin: org.glassfish.soteria/javax.security.enterprise

@Override
public Set<String> getCallerGroups(CredentialValidationResult validationResult) {
  // Make sure caller has permission to invoke this method
  SecurityManager securityManager = System.getSecurityManager();
  if (securityManager != null) {
    securityManager.checkPermission(new IdentityStorePermission("getGroups"));
  }
  LdapContext searchContext = createSearchLdapContext();
  try {
    String callerDn = validationResult.getCallerDn();
    if (callerDn == null || callerDn.isEmpty()) {
      callerDn = getCallerDn(searchContext, validationResult.getCallerPrincipal().getName());
    }
    return retrieveGroupsForCallerDn(searchContext, callerDn);
  }
  finally {
    closeContext(searchContext);
  }
}
origin: javaee-samples/javaee8-samples

if (result.getStatus() == CredentialValidationResult.Status.VALID) {
origin: javaee-samples/javaee8-samples

@Override
public String generateLoginToken(CallerPrincipal callerPrincipal, Set<String> groups) {
  String token = UUID.randomUUID().toString();
  loginTokens.put(token, new CredentialValidationResult(callerPrincipal, groups));
  return token;
}
origin: javaee/security-soteria

@Override
public AuthenticationStatus notifyContainerAboutLogin(CredentialValidationResult result) {
  if (result.getStatus() == VALID) {
    return notifyContainerAboutLogin(
        result.getCallerPrincipal(),
        result.getCallerGroups());
  } 
    
  return SEND_FAILURE;
}
origin: org.glassfish.soteria/javax.security.enterprise

@Override
public Set<String> getCallerGroups(CredentialValidationResult validationResult) {
  SecurityManager securityManager = System.getSecurityManager();
  if (securityManager != null) {
    securityManager.checkPermission(new IdentityStorePermission("getGroups"));
  }
  Credentials credentials = callerToCredentials.get(validationResult.getCallerPrincipal().getName());
  return credentials != null ? new HashSet<>(asList(credentials.groups())) : emptySet();
}
origin: javaee/security-soteria

@Override
public Set<String> getCallerGroups(CredentialValidationResult validationResult) {
  // Make sure caller has permission to invoke this method
  SecurityManager securityManager = System.getSecurityManager();
  if (securityManager != null) {
    securityManager.checkPermission(new IdentityStorePermission("getGroups"));
  }
  LdapContext searchContext = createSearchLdapContext();
  try {
    String callerDn = validationResult.getCallerDn();
    if (callerDn == null || callerDn.isEmpty()) {
      callerDn = getCallerDn(searchContext, validationResult.getCallerPrincipal().getName());
    }
    return retrieveGroupsForCallerDn(searchContext, callerDn);
  }
  finally {
    closeContext(searchContext);
  }
}
origin: javaee/security-soteria

  if (validationResult.getStatus() == VALID) {
    identityStore = authenticationIdentityStore;
    break;
  else if (validationResult.getStatus() == INVALID) {
    isGotAnInvalidResult = true;
if (validationResult == null || validationResult.getStatus() != VALID) {
  groups.addAll(validationResult.getCallerGroups());
return new CredentialValidationResult(
    validationResult.getIdentityStoreId(),
    validationResult.getCallerPrincipal(),
    validationResult.getCallerDn(),
    validationResult.getCallerUniqueId(),
    groups);
origin: javaee-samples/javaee8-samples

public CredentialValidationResult validate(UsernamePasswordCredential credential) {
  if (!(credential.getCaller().equals("test") && credential.getPassword().compareTo("pass"))) {
    return INVALID_RESULT;
  }
  
  return new CredentialValidationResult("test", new HashSet<>(asList("architect", "admin")));
}
origin: javaee/security-soteria

@Override
public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMsgContext) throws AuthenticationException {
  String[] credentials = getCredentials(request);
  if (!isEmpty(credentials)) {
    IdentityStoreHandler identityStoreHandler = CDI.current().select(IdentityStoreHandler.class).get();
    CredentialValidationResult result = identityStoreHandler.validate(
        new UsernamePasswordCredential(credentials[0], new Password(credentials[1])));
    if (result.getStatus() == VALID) {
      return httpMsgContext.notifyContainerAboutLogin(
        result.getCallerPrincipal(), result.getCallerGroups());
    }
  }
  if (httpMsgContext.isProtected()) {
    response.setHeader("WWW-Authenticate", format("Basic realm=\"%s\"", basicAuthenticationMechanismDefinition.realmName()));
    return httpMsgContext.responseUnauthorized();
  }
  return httpMsgContext.doNothing();
}
origin: javaee/security-soteria

@Override
public Set<String> getCallerGroups(CredentialValidationResult validationResult) {
  SecurityManager securityManager = System.getSecurityManager();
  if (securityManager != null) {
    securityManager.checkPermission(new IdentityStorePermission("getGroups"));
  }
  Credentials credentials = callerToCredentials.get(validationResult.getCallerPrincipal().getName());
  return credentials != null ? new HashSet<>(asList(credentials.groups())) : emptySet();
}
origin: javaee-samples/javaee8-samples

@Override
public CredentialValidationResult validate(Credential credential) {
  CredentialValidationResult result;
  if (credential instanceof UsernamePasswordCredential) {
    UsernamePasswordCredential usernamePassword = (UsernamePasswordCredential) credential;
    String expectedPW = callerToPassword.get(usernamePassword.getCaller());
    if (expectedPW != null && expectedPW.equals(usernamePassword.getPasswordAsString())) {
      result = new CredentialValidationResult(usernamePassword.getCaller());
    } else {
      result = INVALID_RESULT;
    }
  } else {
    result = NOT_VALIDATED_RESULT;
  }
  return result;
}
origin: org.glassfish.soteria/javax.security.enterprise

@Override
public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMsgContext) throws AuthenticationException {
  String[] credentials = getCredentials(request);
  if (!isEmpty(credentials)) {
    IdentityStoreHandler identityStoreHandler = CDI.current().select(IdentityStoreHandler.class).get();
    CredentialValidationResult result = identityStoreHandler.validate(
        new UsernamePasswordCredential(credentials[0], new Password(credentials[1])));
    if (result.getStatus() == VALID) {
      return httpMsgContext.notifyContainerAboutLogin(
        result.getCallerPrincipal(), result.getCallerGroups());
    }
  }
  if (httpMsgContext.isProtected()) {
    response.setHeader("WWW-Authenticate", format("Basic realm=\"%s\"", basicAuthenticationMechanismDefinition.realmName()));
    return httpMsgContext.responseUnauthorized();
  }
  return httpMsgContext.doNothing();
}
origin: org.glassfish.soteria/javax.security.enterprise

@Override
public Set<String> getCallerGroups(CredentialValidationResult validationResult) {
  SecurityManager securityManager = System.getSecurityManager();
  if (securityManager != null) {
    securityManager.checkPermission(new IdentityStorePermission("getGroups"));
  }
  DataSource dataSource = getDataSource();
  return new HashSet<>(executeQuery(
    dataSource,
    dataBaseIdentityStoreDefinition.groupsQuery(),
    validationResult.getCallerPrincipal().getName())
  );
}
origin: org.glassfish.soteria/javax.security.enterprise

public CredentialValidationResult validate(UsernamePasswordCredential usernamePasswordCredential) {
  Credentials credentials = callerToCredentials.get(usernamePasswordCredential.getCaller());
  if (credentials != null && usernamePasswordCredential.getPassword().compareTo(credentials.password())) {
    return new CredentialValidationResult(
      new CallerPrincipal(credentials.callerName()), 
      new HashSet<>(asList(credentials.groups()))
    );
  }
  return INVALID_RESULT;
}

origin: org.glassfish.soteria/javax.security.enterprise

);
if (result.getStatus() == VALID) {
    result.getCallerPrincipal(), result.getCallerGroups());
} else {
javax.security.enterprise.identitystoreCredentialValidationResult

Javadoc

CredentialValidationResult is the result from an attempt to validate an instance of Credential.

Most used methods

  • <init>
    Private constructor.
  • getCallerGroups
    Determines the set of groups that the specified Caller is in, based on the associated identity store
  • getCallerPrincipal
    Return the CallerPrincipal for the validated credential.
  • getStatus
    Determines the validation status.
  • getCallerDn
    Return the CallerPrincipal for the validated credential.
  • getCallerUniqueId
    Return a string that uniquely identifies this caller within the identity store (since the Principal
  • getIdentityStoreId
    Return the unique ID of the identity store used to validate the credentials.

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • CodeWhisperer alternatives
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