congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
AssertionUtil.asString
Code IndexAdd Tabnine to your IDE (free)

How to use
asString
method
in
org.picketlink.identity.federation.core.saml.v2.util.AssertionUtil

Best Java code snippets using org.picketlink.identity.federation.core.saml.v2.util.AssertionUtil.asString (Showing top 7 results out of 315)

origin: org.picketlink.distribution/picketlink-wildfly8

  @POST
  public Response generateAssertion(@Context HttpServletRequest httpServletRequest,
      @Context HttpServletResponse httpServletResponse) throws Exception {
    Principal principal = httpServletRequest.getUserPrincipal();
    if (principal == null) {
      // Send Error Response
      return Response.status(403).build();
    }
    SAMLProtocolContext samlProtocolContext = getSAMLProtocolContext(principal.getName());
    AssertionType assertionType = issueSAMLAssertion(samlProtocolContext);
    // TODO: sign/encrypt
    String base64EncodedAssertion = PostBindingUtil.base64Encode(AssertionUtil.asString(assertionType));

    return Response.status(200).entity(base64EncodedAssertion).build();
  }
}
origin: org.picketlink/picketlink-wildfly-common

  @POST
  public Response generateAssertion(@Context HttpServletRequest httpServletRequest,
      @Context HttpServletResponse httpServletResponse) throws Exception {
    Principal principal = httpServletRequest.getUserPrincipal();
    if (principal == null) {
      // Send Error Response
      return Response.status(403).build();
    }
    SAMLProtocolContext samlProtocolContext = getSAMLProtocolContext(principal.getName());
    AssertionType assertionType = issueSAMLAssertion(samlProtocolContext);
    // TODO: sign/encrypt
    String base64EncodedAssertion = PostBindingUtil.base64Encode(AssertionUtil.asString(assertionType));

    return Response.status(200).entity(base64EncodedAssertion).build();
  }
}
origin: org.overlord/overlord-commons-auth

/**
 * Creates a SAML Assertion that can be used as a bearer token when invoking REST
 * services.  The REST service must be configured to accept SAML Assertion bearer
 * tokens.
 *
 * In JBoss this means protecting the REST services with {@link org.overlord.commons.auth.jboss7.SAMLBearerTokenLoginModule}.
 * In Tomcat7 this means protecting the REST services with {@link org.overlord.commons.auth.tomcat7.SAMLBearerTokenAuthenticator}.
 *
 * @param principal
 * @param roles
 * @param issuerName
 * @param forService
 * @param timeValidInMillis
 */
public static String createSAMLAssertion(Principal principal, Set<String> roles, String issuerName,
    String forService, int timeValidInMillis) {
  try {
    NameIDType issuer = SAMLAssertionFactory.createNameID(null, null, issuerName);
    SubjectType subject = AssertionUtil.createAssertionSubject(principal.getName());
    AssertionType assertion = AssertionUtil.createAssertion(UUID.randomUUID().toString(), issuer);
    assertion.setSubject(subject);
    AssertionUtil.createTimedConditions(assertion, timeValidInMillis);
    ConditionAbstractType restriction = SAMLAssertionFactory.createAudienceRestriction(forService);
    assertion.getConditions().addCondition(restriction);
    addRoleStatements(roles, assertion, principal);
    return AssertionUtil.asString(assertion);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: org.picketlink.distribution/picketlink-jbas5

@Override
protected Group[] getRoleSets() throws LoginException {
  if (this.assertion == null) {
    try {
      this.assertion = SAMLUtil.fromElement(this.credential.getAssertionAsElement());
    } catch (Exception e) {
      throw logger.authFailedToParseSAMLAssertion(e);
    }
  }
  if (logger.isTraceEnabled()) {
    try {
      logger.trace("Assertion from where roles will be sought = " + AssertionUtil.asString(assertion));
    } catch (ProcessingException ignore) {
    }
  }
  List<String> roleKeys = new ArrayList<String>();
  if (StringUtil.isNotNull(roleKey)) {
    roleKeys.addAll(StringUtil.tokenize(roleKey));
  }
  String groupName = SecurityConstants.ROLES_IDENTIFIER;
  Group rolesGroup = new PicketLinkGroup(groupName);
  List<String> roles = AssertionUtil.getRoles(assertion, roleKeys);
  for (String role : roles) {
    rolesGroup.addMember(new SimplePrincipal(role));
  }
  return new Group[]{rolesGroup};
}
origin: org.picketlink.distribution/picketlink-jbas7

@Override
protected Group[] getRoleSets() throws LoginException {
  if (this.assertion == null) {
    try {
      this.assertion = SAMLUtil.fromElement(this.credential.getAssertionAsElement());
    } catch (Exception e) {
      throw logger.authFailedToParseSAMLAssertion(e);
    }
  }
  if (logger.isTraceEnabled()) {
    try {
      logger.trace("Assertion from where roles will be sought = " + AssertionUtil.asString(assertion));
    } catch (ProcessingException ignore) {
    }
  }
  List<String> roleKeys = new ArrayList<String>();
  if (StringUtil.isNotNull(roleKey)) {
    roleKeys.addAll(StringUtil.tokenize(roleKey));
  }
  String groupName = SecurityConstants.ROLES_IDENTIFIER;
  Group rolesGroup = new PicketLinkGroup(groupName);
  List<String> roles = AssertionUtil.getRoles(assertion, roleKeys);
  for (String role : roles) {
    rolesGroup.addMember(new SimplePrincipal(role));
  }
  return new Group[]{rolesGroup};
}
origin: org.picketlink.distribution/picketlink-jbas7

@Override
protected Group[] getRoleSets() throws LoginException {
  if (this.assertion == null) {
    try {
      this.assertion = SAMLUtil.fromElement(this.credential.getAssertionAsElement());
    } catch (Exception e) {
      throw logger.authFailedToParseSAMLAssertion(e);
    }
  }
  if (logger.isTraceEnabled()) {
    try {
      logger.trace("Assertion from where roles will be sought = " + AssertionUtil.asString(assertion));
    } catch (ProcessingException ignore) {
    }
  }
  List<String> roleKeys = new ArrayList<String>();
  if (StringUtil.isNotNull(roleKey)) {
    roleKeys.addAll(StringUtil.tokenize(roleKey));
  }
  String groupName = SecurityConstants.ROLES_IDENTIFIER;
  Group rolesGroup = new PicketLinkGroup(groupName);
  List<String> roles = AssertionUtil.getRoles(assertion, roleKeys);
  for (String role : roles) {
    rolesGroup.addMember(new SimplePrincipal(role));
  }
  return new Group[]{rolesGroup};
}
origin: org.picketlink.distribution/picketlink-jbas5

@Override
protected Group[] getRoleSets() throws LoginException {
  if (this.assertion == null) {
    try {
      this.assertion = SAMLUtil.fromElement(this.credential.getAssertionAsElement());
    } catch (Exception e) {
      throw logger.authFailedToParseSAMLAssertion(e);
    }
  }
  if (logger.isTraceEnabled()) {
    try {
      logger.trace("Assertion from where roles will be sought = " + AssertionUtil.asString(assertion));
    } catch (ProcessingException ignore) {
    }
  }
  List<String> roleKeys = new ArrayList<String>();
  if (StringUtil.isNotNull(roleKey)) {
    roleKeys.addAll(StringUtil.tokenize(roleKey));
  }
  String groupName = SecurityConstants.ROLES_IDENTIFIER;
  Group rolesGroup = new PicketLinkGroup(groupName);
  List<String> roles = AssertionUtil.getRoles(assertion, roleKeys);
  for (String role : roles) {
    rolesGroup.addMember(new SimplePrincipal(role));
  }
  return new Group[]{rolesGroup};
}
org.picketlink.identity.federation.core.saml.v2.utilAssertionUtilasString

Javadoc

Given AssertionType, convert it into a String

Popular methods of AssertionUtil

  • hasExpired
    Verify whether the assertion has expired. You can add in a clock skew to adapt to conditions where i
  • getRoles
    Given an assertion, return the list of roles it may have
  • getExpiration
    Extract the expiration time from an AssertionType
  • createTimedConditions
    Add validity conditions to the SAML2 Assertion
  • createAssertion
    Create an assertion
  • createSAML11TimedConditions
    Add validity conditions to the SAML2 Assertion
  • isSignatureValid
    Given an assertion element, validate the signature
  • asDocument
    Given AssertionType, convert it into a DOM Document.
  • createAssertionSubject
    Given a user name, create a SubjectType that can then be inserted into an assertion
  • isAudience
    Checks whether the given assertion is intended for the given org.picketlink.config.federation.SPType

Popular in Java

  • Creating JSON documents from java classes using gson
  • requestLocationUpdates (LocationManager)
  • setContentView (Activity)
  • getContentResolver (Context)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JComboBox (javax.swing)
  • JPanel (javax.swing)
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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