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

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

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

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) {
  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) {
  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) {
  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

@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: 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 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: 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/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

validationResult.getCallerPrincipal(),
validationResult.getCallerDn(),
validationResult.getCallerUniqueId(),
origin: org.glassfish.soteria/javax.security.enterprise

validationResult.getCallerPrincipal(),
validationResult.getCallerDn(),
validationResult.getCallerUniqueId(),
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: 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

    result.getCallerPrincipal(), result.getCallerGroups());
} else {
origin: javaee/security-soteria

    result.getCallerPrincipal(), result.getCallerGroups());
} else {
javax.security.enterprise.identitystoreCredentialValidationResultgetCallerPrincipal

Javadoc

Return the CallerPrincipal for the validated credential.

Popular methods of CredentialValidationResult

  • <init>
    Private constructor.
  • getCallerGroups
    Determines the set of groups that the specified Caller is in, based on the associated identity store
  • 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

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • getSupportFragmentManager (FragmentActivity)
  • onRequestPermissionsResult (Fragment)
  • Menu (java.awt)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top PhpStorm plugins
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