Package org.openmhealth.reference.exception

Examples of org.openmhealth.reference.exception.OmhException


  public static String validatePassword(
    final String password)
    throws OmhException {
   
    if(password == null) {
      throw new OmhException("The password is null.");
    }
    if(password.length() == 0) {
      throw new OmhException("The password is empty.");
    }
   
    return password;
  }
View Full Code Here


  public static InternetAddress validateEmail(
    final String email)
    throws OmhException {

    if(email == null) {
      throw new OmhException("The email address is null");
    }
    String trimmedEmail = email.trim();
    if(trimmedEmail.length() == 0) {
      throw new OmhException("The email address is empty.");
    }
   
    // Create the InternetAddress object.
    InternetAddress result;
    try {
      result = new InternetAddress(email);
    }
    catch(AddressException e) {
      throw
        new OmhException(
          "The email address is not a valid email address.",
          e);
    }
   
    // Validate the address.
    try {
      result.validate();
    }
    catch(AddressException e) {
      throw
      new OmhException(
        "The email address is not a valid email address.",
        e);
    }
   
    return result;
View Full Code Here

    final String state)
    throws OmhException {
   
    // Validate the parameters.
    if(thirdParty == null) {
      throw new OmhException("The third-party is null.");
    }
    else if(scopes == null) {
      throw new OmhException("The scopes is null.");
    }
    else if(scopes.size() == 0) {
      throw
        new OmhException(
          "An authorization token cannot be created without any " +
            "scope.");
    }
   
    // Store the relevant information.
View Full Code Here

    @JsonProperty(JSON_KEY_STATE) final String state)
    throws OmhException {

    // Validate the third-party.
    if(thirdParty == null) {
      throw new OmhException("The third-party is null.");
    }
    else {
      this.thirdParty = thirdParty;
    }
   
    // Validate the code.
    if(code == null) {
      throw new OmhException("The code is null.");
    }
    else {
      this.code = code;
    }
   
    // Validate the creation time.
    DateTime creationTimeDateTime = new DateTime(creationTime);
    if(creationTimeDateTime.isAfterNow()) {
      throw
        new OmhException(
          "The token's creation time cannot be in the future.");
    }
    else {
      this.creationTime = creationTime;
    }
   
    // Validate the expiration time.
    if(creationTimeDateTime.isAfter(expirationTime)) {
      throw
        new OmhException(
          "The token's expiration time cannot be before its " +
            "creation time.");
    }
    else {
      this.expirationTime = expirationTime;
    }
   
    // Validate the scopes.
    if(scopes == null) {
      throw new OmhException("The scopes set is null.");
    }
    else if(scopes.size() == 0) {
      throw
        new OmhException(
          "An authorization token cannot be created without any " +
            "scope.");
    }
    else {
      this.scopes.addAll(scopes);
View Full Code Here

    final AuthorizationCodeResponse response)
    throws OmhException {
   
    // Validate the parameters.
    if(response == null) {
      throw new OmhException("The response is null.");
    }
    else if(! response.getGranted()) {
      throw new OmhException(
        "An authorization token cannot be created for an " +
          "authorization code that was denied.");
    }
   
    // Store the relevant information.
View Full Code Here

    final AuthorizationToken oldToken)
    throws OmhException {
   
    // Validate the token.
    if(oldToken == null) {
      throw new OmhException("The token is null.");
    }

    // Store the relevant information.
    this.authorizationCode = oldToken.authorizationCode;
    this.accessToken = UUID.randomUUID().toString();
View Full Code Here

    @JsonProperty(JSON_KEY_EXPIRATION_TIME) final long expirationTime)
    throws OmhException {
   
    // Validate the authorization code.
    if(authorizationCode == null) {
      throw new OmhException("The authorization code is null.");
    }
    else {
      this.authorizationCode = authorizationCode;
    }
   
    // Validate the access token.
    if(accessToken == null) {
      throw new OmhException("The access token is null.");
    }
    else {
      this.accessToken = accessToken;
    }
   
    // Validate the refresh token.
    if(refreshToken == null) {
      throw new OmhException("The refresh token is null.");
    }
    else {
      this.refreshToken = refreshToken;
    }
   
    // Validate the creation time.
    DateTime creationTimeDateTime = new DateTime(creationTime);
    if(creationTimeDateTime.isAfterNow()) {
      throw
        new OmhException(
          "The token's creation time cannot be in the future.");
    }
    else {
      this.creationTime = creationTime;
    }
   
    // Validate the expiration time.
    if(creationTimeDateTime.isAfter(expirationTime)) {
      throw
        new OmhException(
          "The token's expiration time cannot be before its " +
            "creation time.");
    }
    else {
      this.expirationTime = expirationTime;
View Full Code Here

    final URI redirectUri)
    throws OmhException {
   
    // Validate the owner.
    if(owner == null) {
      throw new OmhException("The owner is null.");
    }
    else {
      this.owner = owner.getUsername();
    }
   
    // Validate the name.
    if(name == null) {
      throw new OmhException("The name is null.");
    }
    else {
      // Trim the name.
      String trimmedName = name.trim();
     
      // Verify that the name isn't empty.
      if(trimmedName.length() == 0) {
        throw new OmhException("The name is empty.");
      }
      else {
        this.name = name;
      }
    }
   
    // Validate the description.
    if(description == null) {
      throw new OmhException("The description is null.");
    }
    else {
      // Trim the description.
      String trimmedDescription = description.trim();
     
      // Verify that the description isn't empty.
      if(trimmedDescription.length() == 0) {
        throw new OmhException("The description is empty.");
      }
      else {
        this.description = description;
      }
    }
   
    // Validate the redirect URI.
    if(redirectUri == null) {
      throw new OmhException("The redirect URI is invalid.");
    }
    else {
      this.redirectUri = redirectUri;
    }
   
View Full Code Here

    @JsonProperty(JSON_KEY_REDIRECT_URI) final URI redirectUri)
    throws OmhException {

    // Validate the owner.
    if(owner == null) {
      throw new OmhException("The owner is null.");
    }
    else {
      this.owner = owner;
    }
   
    // Validate the redirect URI.
    if(redirectUri == null) {
      throw new OmhException("The redirect URI is null.");
    }
    else {
      this.redirectUri = redirectUri;
    }
   
    // Validate the ID.
    if(id == null) {
      throw new OmhException("The ID is null.");
    }
    else {
      String idTrimmed = id.trim();
     
      if(idTrimmed.length() == 0) {
        throw new OmhException("The ID is empty.");
      }
      else {
        this.id = idTrimmed;
      }
    }
   
    // Validate the shared secret.
    if(sharedSecret == null) {
      throw new OmhException("The shared secret is null.");
    }
    else {
      String sharedSecretTrimmed = sharedSecret.trim();
     
      if(sharedSecretTrimmed.length() == 0) {
        throw new OmhException("The shared secret is empty.");
      }
      else {
        this.sharedSecret = sharedSecretTrimmed;
      }
    }
   
    // Validate the name.
    if(name == null) {
      throw new OmhException("The name is null.");
    }
    else {
      String nameTrimmed = name.trim();
     
      if(nameTrimmed.length() == 0) {
        throw new OmhException("The name is empty.");
      }
      else {
        this.name = nameTrimmed;
      }
    }
   
    // Validate the description.
    if(description == null) {
      throw new OmhException("The description is null.");
    }
    else {
      String descriptionTrimmed = description.trim();
     
      if(descriptionTrimmed.length() == 0) {
        throw new OmhException("The description is empty.");
      }
      else {
        this.description = descriptionTrimmed;
      }
    }
View Full Code Here

   
    super(authorizationCode, owner, granted);
   
    // Store the MongoDB ID.
    if(dbId == null) {
      throw new OmhException("The MongoDB ID is missing.");
    }
    else {
      this.dbId = dbId;
    }
  }
View Full Code Here

TOP

Related Classes of org.openmhealth.reference.exception.OmhException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.