public DefaultIdSiteCallbackHandler(
      InternalDataStore dataStore, Application application, Object httpRequest) {
    Assert.notNull(dataStore, "datastore cannot be null or empty.");
    Assert.notNull(application, "application cannot be null.");
    Assert.notNull(httpRequest, "httpRequest cannot be null.");

    this.dataStore = dataStore;
    this.application = application;
    this.jwtResponse = getJwtResponse(httpRequest);
    this.nonceStore = new DefaultNonceStore(dataStore.getCacheResolver());
  }
  @Override
  public void init() throws Exception {
    super.init();

    if (this.accountModelFactory == null) {
      this.accountModelFactory = new DefaultAccountModelFactory();
    }
    if (this.accountStoreModelFactory == null) {
      this.accountStoreModelFactory = new ExternalAccountStoreModelFactory();
    }
    if (this.errorModelFactory == null) {
      this.errorModelFactory = new RegisterErrorModelFactory(this.messageSource);
    }

    Assert.notNull(this.client, "client cannot be null.");
    Assert.notNull(this.authenticationResultSaver, "authenticationResultSaver cannot be null.");
    Assert.hasText(this.loginUri, "loginUri cannot be null or empty.");
    Assert.hasText(this.verifyViewName, "verifyViewName cannot be null or empty.");
    Assert.notNull(this.preRegisterHandler, "preRegisterHandler cannot be null.");
    Assert.notNull(this.postRegisterHandler, "postRegisterHandler cannot be null.");
    Assert.notNull(this.accountModelFactory, "accountModelFactory cannot be null.");
    Assert.notNull(this.accountStoreModelFactory, "accountStoreModelFactory cannot be null.");
    Assert.notNull(this.errorModelFactory, "errorModelFactory cannot be null.");
    Assert.notNull(this.accountStoreResolver, "accountStoreResolver cannot be null.");
  }
 @Override
 public CreatePhoneRequestBuilder withResponseOptions(PhoneOptions options)
     throws IllegalArgumentException {
   Assert.notNull(options, "options can't be null.");
   this.options = options;
   return this;
 }
 /**
  * Creates a new instance.
  *
  * @param nonceCache a cache to place used CSRF tokens. This is required to ensure the consumed
  *     token is never used again, which is mandatory for CSRF protection. This cache <em>MUST</em>
  *     have a TTL value equal to or greater than {@code ttlMillis}. Cache key: a unique token ID,
  *     Cache value: the used token
  * @param signingKey a base64-encoded (and hopefully secure-random) cryptographic signing key used
  *     to digitally sign the CSRF token to ensure it cannot be tampered with by HTTP clients.
  * @param ttlMillis the length of time in milliseconds for which a generated CSRF token is valid.
  *     When a token is created, it cannot be used after this duration, even if it has not been
  *     consumed yet.
  */
 public CacheCsrfTokenRepository(Cache nonceCache, String signingKey, long ttlMillis) {
   Assert.notNull(nonceCache, "nonce cache cannot be null.");
   this.nonceCache = nonceCache;
   Assert.hasText(signingKey, "signingKey cannot be null or empty.");
   this.signingKey = signingKey;
   Assert.isTrue(ttlMillis > 0, "ttlMillis must be greater than zero.");
   this.ttlMillis = ttlMillis;
 }
 public void init() {
   super.init();
   Assert.notNull(serverUriResolver, "serverUriResolver must be configured.");
   IdSiteController controller = new LogoutIdSiteController();
   controller.setServerUriResolver(serverUriResolver);
   controller.setCallbackUri(idSiteResultUri);
   controller.init();
   this.idSiteController = controller;
 }
 public SpringSpaController(
     Controller delegate, String jsonView, List<MediaType> producesMediaTypes) {
   Assert.notNull(delegate, "Delegate controller cannot be null.");
   Assert.notEmpty(producesMediaTypes, "produced media types cannot be null or empty.");
   Assert.hasText(jsonView, "jsonView cannot be null or empty.");
   this.delegate = delegate;
   this.jsonView = jsonView;
   this.producesMediaTypes = producesMediaTypes;
 }
 protected DefaultCriteria(O options) {
   Assert.notNull(options, "options argument cannot be null.");
   Assert.isInstanceOf(
       Expandable.class,
       options,
       "options argument is expected to implement the "
           + Expandable.class.getName()
           + " interface.");
   this.options = options;
   this.criterionEntries = new ArrayList<Criterion>();
   this.orderEntries = new ArrayList<Order>();
 }
 /**
  * Ensures the message used for the exception (i.e. exception.getMessage()) reports the {@code
  * developerMessage} returned by the Stormpath API Server. The regular Stormpath response body
  * {@code message} field is targeted at applicadtion end-users that could very likely be
  * non-technical. Since an exception should be helpful to developers, it is better to show a more
  * technical message.
  *
  * <p>Added as a fix for <a href="https://github.com/stormpath/stormpath-sdk-java/issues/28">Issue
  * #28</a>.
  *
  * @param error the response Error. Cannot be null.
  * @return {@code error.getDeveloperMessage()}
  * @since 0.9.2
  */
 private static String buildExceptionMessage(Error error) {
   Assert.notNull(error, "Error argument cannot be null.");
   StringBuilder sb = new StringBuilder();
   sb.append("HTTP ")
       .append(error.getStatus())
       .append(", Stormpath ")
       .append(error.getCode())
       .append(" (")
       .append(error.getMoreInfo())
       .append("): ")
       .append(error.getDeveloperMessage());
   return sb.toString();
 }
 @Override
 public IdSiteCallbackHandler setNonceStore(NonceStore nonceStore) {
   Assert.notNull(nonceStore);
   this.nonceStore = nonceStore;
   return this;
 }
 /* @since 1.0.RC5 */
 private boolean isError(Map jsonMap) {
   Assert.notNull(jsonMap, "jsonMap cannot be null.");
   Object error = getOptionalValue(jsonMap, ERROR);
   return error != null;
 }
Exemplo n.º 11
0
 /**
  * Sorts the given list of {@code MimeType} objects by specificity.
  *
  * <p>Given two mime types:
  *
  * <ol>
  *   <li>if either mime type has a {@linkplain MimeType#isWildcardType() wildcard type}, then the
  *       mime type without the wildcard is ordered before the other.
  *   <li>if the two mime types have different {@linkplain MimeType#getType() types}, then they are
  *       considered equal and remain their current order.
  *   <li>if either mime type has a {@linkplain MimeType#isWildcardSubtype() wildcard subtype} ,
  *       then the mime type without the wildcard is sorted before the other.
  *   <li>if the two mime types have different {@linkplain MimeType#getSubtype() subtypes}, then
  *       they are considered equal and remain their current order.
  *   <li>if the two mime types have a different amount of {@linkplain
  *       MimeType#getParameter(String) parameters}, then the mime type with the most parameters is
  *       ordered before the other.
  * </ol>
  *
  * <p>For example:
  *
  * <blockquote>
  *
  * audio/basic &lt; audio/* &lt; *&#047;*
  *
  * </blockquote>
  *
  * <blockquote>
  *
  * audio/basic;level=1 &lt; audio/basic
  *
  * </blockquote>
  *
  * <blockquote>
  *
  * audio/basic == text/html
  *
  * </blockquote>
  *
  * <blockquote>
  *
  * audio/basic == audio/wave
  *
  * </blockquote>
  *
  * @param mimeTypes the list of mime types to be sorted
  * @see <a href="http://tools.ietf.org/html/rfc7231#section-5.3.2">HTTP 1.1: Semantics and
  *     Content, section 5.3.2</a>
  */
 public static void sortBySpecificity(List<MimeType> mimeTypes) {
   Assert.notNull(mimeTypes, "'mimeTypes' must not be null");
   if (mimeTypes.size() > 1) {
     Collections.sort(mimeTypes, SPECIFICITY_COMPARATOR);
   }
 }
 public T add(Order order) {
   Assert.notNull(order, "order cannot be null.");
   this.orderEntries.add(order);
   this.currentOrderIndex = this.orderEntries.size() - 1;
   return (T) this;
 }
 public T add(Criterion criterion) {
   Assert.notNull(criterion, "criterion cannot be null.");
   this.criterionEntries.add(criterion);
   return (T) this;
 }
 @Override
 public Map<String, Object> convert(AbstractResource resource) {
   Assert.notNull(resource, "resource cannot be null.");
   return toMap(resource, true);
 }
 public DefaultResourceConverter(ReferenceFactory referenceFactory) {
   Assert.notNull(referenceFactory, "referenceFactory cannot be null.");
   this.referenceFactory = referenceFactory;
 }
 public DefaultCreatePhoneRequestBuilder(Phone phone) {
   Assert.notNull(phone, "Phone can't be null.");
   this.phone = phone;
 }