OAuthToken extends AbstractAuthzEntity implements Principal { @Override @Transient @JsonIgnore public String getName() { Client c = getClient(); UserIdentity i = getIdentity(); if (c != null && c.getType().equals(ClientType.ClientCredentials)) { return c.getName(); } else if (i != null) { return i.getRemoteId(); } return null; }  String getIssuer(); void setIssuer(final String issuer); HttpSession getHttpSession(); void setHttpSession(final HttpSession httpSession); UserIdentity getIdentity(); void setIdentity(final UserIdentity identity); Client getClient(); void setClient(final Client client); OAuthToken getAuthToken(); void setAuthToken(final OAuthToken authToken); OAuthTokenType getTokenType(); void setTokenType(final OAuthTokenType tokenType); Long getExpiresIn(); void setExpiresIn(final int expiresIn); @JsonSetter void setExpiresIn(final long expiresIn); void setExpiresIn(final Number expiresIn); @JsonIgnore SortedMap<String, ApplicationScope> getScopes(); @JsonIgnore void setScopes(final SortedMap<String, ApplicationScope> scopes); @Transient @JsonIgnore boolean isExpired(); URI getRedirect(); void setRedirect(final URI redirect); @Override @Transient @JsonIgnore String getName(); @Override @Transient @JsonIgnore User getOwner();  }
@Test public void testGetNullClient() throws Exception { OAuthToken token = new OAuthToken(); assertNull(token.getName()); }