use of org.forgerock.oauth2.core.exceptions.NotFoundException in project OpenAM by OpenRock.
the class PendingRequestEmailTemplate method getLocale.
private Locale getLocale(String username, String realm) {
try {
String localeAttributeName = settingsFactory.get(realm).getUserProfilePreferredLocaleAttribute();
if (localeAttributeName != null) {
AMIdentity identity = IdUtils.getIdentity(username, realm);
@SuppressWarnings("unchecked") Set<String> localeAttribute = identity.getAttribute(localeAttributeName);
if (localeAttribute != null && !localeAttribute.isEmpty()) {
return Locale.forLanguageTag(CollectionUtils.getFirstItem(localeAttribute, ""));
}
}
String defaultLocale = authServiceSettings.getStringSetting(realm, "iplanet-am-auth-locale");
if (defaultLocale != null) {
return Locale.forLanguageTag(defaultLocale);
}
} catch (SSOException | IdRepoException | ServerException | SMSException | NotFoundException e) {
debug.warning("Failed to get locale for user, " + username + ", in realm, " + realm, e);
}
return Locale.ROOT;
}
use of org.forgerock.oauth2.core.exceptions.NotFoundException in project OpenAM by OpenRock.
the class UmaTokenStore method deleteRPT.
public void deleteRPT(String id) throws NotFoundException, ServerException {
try {
// check token is RPT
readRPT(id);
cts.delete(id);
} catch (CoreTokenException e) {
throw new ServerException("Could not delete token: " + id);
}
}
use of org.forgerock.oauth2.core.exceptions.NotFoundException in project OpenAM by OpenRock.
the class UmaTokenStore method readToken.
public UmaToken readToken(String ticketId, JavaBeanAdapter<? extends UmaToken> adapter) throws NotFoundException {
try {
Token token = cts.read(ticketId);
if (token == null) {
throw new NotFoundException("No valid ticket exists with ticketId");
}
UmaToken ticket = adapter.fromToken(token);
if (!realm.equals(ticket.getRealm())) {
throw new NotFoundException("No valid ticket exists with ticketId in the realm, " + realm);
}
return ticket;
} catch (CoreTokenException e) {
throw new NotFoundException("No valid ticket exists with ticketId");
}
}
use of org.forgerock.oauth2.core.exceptions.NotFoundException in project OpenAM by OpenRock.
the class UmaUrisFactory method get.
/**
* <p>Gets the instance of the UmaProviderSettings.</p>
*
* <p>Cache each provider settings on the realm it was created for.</p>
*
* @param context The context instance from which the base URL can be deduced.
* @param realmInfo The realm.
* @return The OAuth2ProviderSettings instance.
*/
public UmaUris get(Context context, RealmInfo realmInfo) throws NotFoundException, ServerException {
String absoluteRealm = realmInfo.getAbsoluteRealm();
HttpContext httpContext = context.asContext(HttpContext.class);
String baseUrl;
try {
baseUrl = baseURLProviderFactory.get(absoluteRealm).getRealmURL(httpContext, "/uma", absoluteRealm);
} catch (InvalidBaseUrlException e) {
throw new ServerException("Configuration error");
}
UmaUris uris = urisMap.get(baseUrl);
if (uris == null) {
OAuth2Uris oAuth2Uris = oAuth2UriFactory.get(context, realmInfo);
uris = get(absoluteRealm, oAuth2Uris, baseUrl);
}
return uris;
}
use of org.forgerock.oauth2.core.exceptions.NotFoundException in project OpenAM by OpenRock.
the class UmaTokenStore method createRPT.
RequestingPartyToken createRPT(PermissionTicket permissionTicket) throws ServerException, NotFoundException {
UmaProviderSettings settings = settingsFactory.get(realm);
Permission permission = new Permission(permissionTicket.getResourceSetId(), permissionTicket.getScopes());
RequestingPartyToken rpt = new RequestingPartyToken(null, permissionTicket.getResourceServerClientId(), asSet(permission), System.currentTimeMillis() + (settings.getRPTLifetime() * 1000), permissionTicket.getId(), permissionTicket.getClientClientId());
rpt.setRealm(realm);
try {
cts.create(rptAdapter.toToken(rpt));
} catch (CoreTokenException e) {
throw new ServerException(e);
}
return rpt;
}
Aggregations