RestSecurity.java revision b1d33c0a07fc2bb7ed7d4712f62492aee8dcc650
/*
* DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013-2014 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions copyright [year] [name of copyright owner]"
*/
public class RestSecurity {
private static ServiceConfigManager mgr;
private final static String SELF_REG_CONFIRMATION_URL = "forgerockRESTSecuritySelfRegConfirmationUrl";
private final static String FORGOT_PASSWORD_TOKEN_LIFE_TIME= "forgerockRESTSecurityForgotPassTokenTTL";
private final static String FORGOT_PASSWORD_CONFIRMATION_URL = "forgerockRESTSecurityForgotPassConfirmationUrl";
private final static String PROTECTED_USER_ATTRIBUTES = "forgerockRESTSecurityProtectedUserAttributes";
private final static String SUCCESSFUL_USER_REGISTRATION_DESTINATION = "forgerockRESTSecuritySuccessfulUserRegistrationDestination";
private class RestSecurityChangeListener implements ServiceListener {
+ serviceName + ". This is unexpected.");
}
public void globalConfigChanged(String serviceName, String version, String groupName, String serviceComponent, int type) {
+ serviceName);
//if the global config changes, all organizationalConfig change listeners are invoked as well.
}
public void organizationConfigChanged(String serviceName, String version, String orgName, String groupName,
if (debug.messageEnabled()) {
}
} else {
if (debug.messageEnabled()) {
}
}
}
private boolean currentRealmTargetedByOrganizaionRemoved(String serviceName, String version, String orgName, int type){
}
private boolean currentRealmTargetedByOrganizationUpdate(String serviceName, String version, String orgName, int type) {
}
}
private static class RestSecurityConfiguration {
final Long selfRegTokenLifeTime;
final Long forgotPasswordTokenLifeTime;
final Boolean selfRegistration;
final Boolean forgotPassword;
private RestSecurityConfiguration(Long selfRegTokenLifeTime, String selfRegistrationConfirmationUrl, Long forgotPasswordLifeTime, String forgotPasswordConfirmationUrl,
Boolean selfRegistration, Boolean forgotPassword, Set<String> protectedUserAttributes, String successfulUserRegistrationDestination) {
this.selfRegistration = selfRegistration;
this.forgotPassword = forgotPassword;
}
}
try {
Boolean selfRegistration = ServiceConfigUtils.getBooleanAttribute(serviceConfig, SELF_REGISTRATION);
String selfRegistrationConfirmationUrl = ServiceConfigUtils.getStringAttribute(serviceConfig, SELF_REG_CONFIRMATION_URL);
String forgotPasswordConfirmationUrl = ServiceConfigUtils.getStringAttribute(serviceConfig, FORGOT_PASSWORD_CONFIRMATION_URL);
Long selfRegTokLifeTime = ServiceConfigUtils.getLongAttribute(serviceConfig, SELF_REG_TOKEN_LIFE_TIME);
Long forgotPassTokLifeTime = ServiceConfigUtils.getLongAttribute(serviceConfig, FORGOT_PASSWORD_TOKEN_LIFE_TIME);
Set<String> protectedUserAttributes = ServiceConfigUtils.getSetAttribute(serviceConfig, PROTECTED_USER_ATTRIBUTES);
String successfulUserRegistrationDestination = ServiceConfigUtils.getStringAttribute(serviceConfig, SUCCESSFUL_USER_REGISTRATION_DESTINATION);
if (debug.messageEnabled()) {
debug.message("Successfully updated rest security service settings for realm " + realm + " with settings " +
}
} catch (Exception e) {
String message = "Not able to initialize Rest Security service settings for realm " + realm + " Exception: " + e;
}
}
}
/**
* Default Constructor
* @param realm in which Rest Security service shall be created
*/
try {
} catch (Exception e) {
}
"changes will not be dynamically updated for realm " + realm);
}
}
public boolean isSelfRegistration() throws ServiceNotFoundException {
} else {
throw new ServiceNotFoundException(message);
}
}
public String getSelfRegistrationConfirmationUrl() {
}
public boolean isForgotPassword() throws ServiceNotFoundException {
} else {
throw new ServiceNotFoundException(message);
}
}
public String getForgotPasswordConfirmationUrl() {
}
/**
* Retrieves the Self-Registration CTS Token Life Time
* @return Long representing the time that the Token shall be valid
* @throws ServiceNotFoundException
*/
if ((restSecurityConfiguration != null) && (restSecurityConfiguration.selfRegTokenLifeTime != null)) {
} else {
throw new ServiceNotFoundException(message);
}
}
}
public String getSuccessfulUserRegistrationDestination() {
}
/**
* Retrieves the Forgotten Password CTS Token Life Time
* @return Long representing the time that the Token shall be valid
* @throws ServiceNotFoundException
*/
if ((restSecurityConfiguration != null) && (restSecurityConfiguration.forgotPasswordTokenLifeTime != null)) {
} else {
String message = "RestSecurity::Unable to get provider setting for : "+ FORGOT_PASSWORD_TOKEN_LIFE_TIME;
throw new ServiceNotFoundException(message);
}
}
}