+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.aaa.api;
-@SuppressWarnings("serial")
+/*
+ * @author - Sharon Aicler (saichler@cisco.com)
+ */
public class IDMStoreException extends Exception{
+
+ private static final long serialVersionUID = -7534127680943957878L;
+
+ public IDMStoreException(Exception e){
+ super(e);
+ }
public IDMStoreException(String msg){
super(msg);
}
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.aaa.api;
+import javax.naming.OperationNotSupportedException;
+/*
+ * This class is a utility to construct the different elements keys for the different data stores.
+ * For not making mistakes around the code constructing an element key, this class standardize the
+ * way the key is constructed to be used by the different data stores.
+ *
+ * @author - Sharon Aicler (saichler@cisco.com)
+ */
+
public class IDMStoreUtil {
+ private IDMStoreUtil() throws OperationNotSupportedException{
+ throw new OperationNotSupportedException();
+ }
public static String createDomainid(String domainName){
return domainName;
}
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.aaa.api;
import org.opendaylight.aaa.api.model.Domain;
import org.opendaylight.aaa.api.model.Roles;
import org.opendaylight.aaa.api.model.User;
import org.opendaylight.aaa.api.model.Users;
-
+/**
+ * @author - Sharon Aicler (saichler@cisco.com)
+ **/
public interface IIDMStore {
- public static final String DEFAULT_DOMAIN = "sdn";
- public static final int MAX_FIELD_LEN = 256;
+ public String DEFAULT_DOMAIN = "sdn";
//Domain methods
public Domain writeDomain(Domain domain) throws IDMStoreException;
public Domain readDomain(String domainid) throws IDMStoreException;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.security.spec.KeySpec;
-
+/**
+ * @author - Sharon Aicler (saichler@cisco.com)
+ **/
public class DataEncrypter {
final protected SecretKey k;
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @author Sharon Aicler - saichler@cisco.com
+ *
+ */
public abstract class IDMObject2MDSAL {
private static final Logger LOGGER = LoggerFactory.getLogger(IDMObject2MDSAL.class);
//this is a Map mapping between the class type of the IDM Model object to a structure containing the corresponding setters and getter methods
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.aaa.authn.mdsal.store;
import java.util.List;
import org.opendaylight.aaa.api.model.Roles;
import org.opendaylight.aaa.api.model.User;
import org.opendaylight.aaa.api.model.Users;
-
+/**
+ * @author Sharon Aicler - saichler@cisco.com
+ *
+ */
public class IDMStore implements IIDMStore{
private final IDMMDSALStore mdsalStore;
*/
public class IdmLightApplication extends Application {
private static Logger logger = LoggerFactory.getLogger(IdmLightApplication.class);
-
+ public static final int MAX_FIELD_LEN = 256;
public IdmLightApplication() {
try {
StoreBuilder.init();
import org.opendaylight.aaa.api.model.IDMError;
import org.opendaylight.aaa.api.model.Role;
import org.opendaylight.aaa.api.model.Roles;
+import org.opendaylight.aaa.idm.IdmLightApplication;
import org.opendaylight.aaa.idm.IdmLightProxy;
import org.opendaylight.aaa.idm.ServiceLocator;
import org.slf4j.Logger;
if (role.getName()==null) {
return new IDMError(404,"name must be defined on role create","").response();
}
- else if (role.getName().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"role name max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (role.getName().length()> IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"role name max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// domain
if (role.getDomainid()==null) {
return new IDMError(404,"The role's domain must be defined on role when creating a role.","").response();
}
- else if (role.getDomainid().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"role domain max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (role.getDomainid().length()>IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"role domain max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// description
if (role.getDescription()==null) {
role.setDescription("");
}
- else if (role.getDescription().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"role description max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (role.getDescription().length()>IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"role description max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
role = ServiceLocator.INSTANCE.getStore().writeRole(role);
// name
// TODO: names should be unique
- if ((role.getName()!=null) && (role.getName().length()>IIDMStore.MAX_FIELD_LEN)) {
- return new IDMError(400,"role name max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ if ((role.getName()!=null) && (role.getName().length()>IdmLightApplication.MAX_FIELD_LEN)) {
+ return new IDMError(400,"role name max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// description
- if ((role.getDescription()!=null) && (role.getDescription().length()>IIDMStore.MAX_FIELD_LEN)) {
- return new IDMError(400,"role description max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ if ((role.getDescription()!=null) && (role.getDescription().length()>IdmLightApplication.MAX_FIELD_LEN)) {
+ return new IDMError(400,"role description max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
role = ServiceLocator.INSTANCE.getStore().updateRole(role);
import org.opendaylight.aaa.api.model.IDMError;
import org.opendaylight.aaa.api.model.User;
import org.opendaylight.aaa.api.model.Users;
+import org.opendaylight.aaa.idm.IdmLightApplication;
import org.opendaylight.aaa.idm.IdmLightProxy;
import org.opendaylight.aaa.idm.ServiceLocator;
import org.slf4j.Logger;
if (user.getName()==null) {
return new IDMError(400,"user name is required","").response();
}
- else if (user.getName().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"user name max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (user.getName().length()> IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"user name max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// domain id/name is required
if (user.getDomainid()==null) {
return new IDMError(400,"user domain is required","").response();
}
- else if (user.getDomainid().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"user domain max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (user.getDomainid().length()>IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"user domain max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// user description is optional
if (user.getDescription()==null) {
user.setDescription("");
}
- else if (user.getDescription().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"user description max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (user.getDescription().length()>IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"user description max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// user email is optional
if (user.getEmail()==null) {
user.setEmail("");
}
- else if (user.getEmail().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"user email max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (user.getEmail().length()>IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"user email max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// user password optional and will default if not provided
if (user.getPassword()==null) {
user.setPassword(DEFAULT_PWD);
}
- else if (user.getPassword().length()>IIDMStore.MAX_FIELD_LEN) {
- return new IDMError(400,"user password max length is :" + IIDMStore.MAX_FIELD_LEN,"").response();
+ else if (user.getPassword().length()>IdmLightApplication.MAX_FIELD_LEN) {
+ return new IDMError(400,"user password max length is :" + IdmLightApplication.MAX_FIELD_LEN,"").response();
}
// create user