001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.oauth2.sdk.id; 019 020 021import net.jcip.annotations.Immutable; 022 023 024/** 025 * Subject (user) identifier. 026 */ 027@Immutable 028public final class Subject extends Identifier { 029 030 031 private static final long serialVersionUID = 4305952346483638353L; 032 033 034 /** 035 * Creates a new subject identifier with the specified value. 036 * 037 * @param value The subject identifier value. Must not be {@code null} 038 * or empty string. 039 */ 040 public Subject(final String value) { 041 042 super(value); 043 } 044 045 046 /** 047 * Creates a new subject identifier with a randomly generated value of 048 * the specified byte length, Base64URL-encoded. 049 * 050 * @param byteLength The byte length of the value to generate. Must be 051 * greater than one. 052 */ 053 public Subject(final int byteLength) { 054 055 super(byteLength); 056 } 057 058 059 /** 060 * Creates a new subject identifier with a randomly generated 256-bit 061 * (32-byte) value, Base64URL-encoded. 062 */ 063 public Subject() { 064 065 super(); 066 } 067 068 069 @Override 070 public boolean equals(final Object object) { 071 072 return object instanceof Subject && 073 this.toString().equals(object.toString()); 074 } 075}