All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nimbusds.oauth2.sdk.id.Issuer Maven / Gradle / Ivy

Go to download

OAuth 2.0 SDK with OpenID Connection extensions for developing client and server applications.

There is a newer version: 11.19.1
Show newest version
package com.nimbusds.oauth2.sdk.id;


import java.net.URI;
import java.net.URISyntaxException;

import net.jcip.annotations.Immutable;


/**
 * Issuer identifier.
 *
 * 

Valid issuer identifiers are URIs with "https" schema and no query or * fragment component. */ @Immutable public final class Issuer extends Identifier { /** * Checks if the specified string represents a valid issuer identifier. * This method is {@code null}-safe. * * @param value The issuer string. * * @return {@code true} if the string represents a valid issuer * identifier, else {@code false}. */ public static boolean isValid(final String value) { if (value == null) return false; try { return isValid(new URI(value)); } catch (URISyntaxException e) { return false; } } /** * Checks if the specified issuer is a valid identifier. This method is * {@code null}-safe. * * @param value The issuer. * * @return {@code true} if the value is a valid identifier, else * {@code false}. */ public static boolean isValid(final Issuer value) { if (value == null) return false; try { return isValid(new URI(value.getValue())); } catch (URISyntaxException e) { return false; } } /** * Checks if the specified URI represents a valid issuer identifier. * This method is {@code null}-safe. * * @param value The URI. * * @return {@code true} if the values represents a valid issuer * identifier, else {@code false}. */ public static boolean isValid(final URI value) { if (value == null) return false; if (value.getScheme() == null || ! value.getScheme().equalsIgnoreCase("https")) return false; if (value.getQuery() != null) return false; if (value.getRawFragment() != null) return false; return true; } /** * Creates a new issuer identifier with the specified value. * * @param value The issuer identifier value. Must not be {@code null} * or empty string. */ public Issuer(final String value) { super(value); } /** * Checks if this issuer is a valid identifier. This method is * {@code null}-safe. * * @return {@code true} if the value is a valid identifier, else * {@code false}. */ public boolean isValid() { return Issuer.isValid(this); } @Override public boolean equals(final Object object) { return object instanceof Issuer && this.toString().equals(object.toString()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy