You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2015/03/19 16:02:28 UTC
[02/62] [abbrv] airavata git commit: Reorganizing credential store to
create a light weight stubs artifact - AIRAVATA-1621
http://git-wip-us.apache.org/repos/asf/airavata/blob/58c58cf2/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java
new file mode 100644
index 0000000..9fc373a
--- /dev/null
+++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java
@@ -0,0 +1,998 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.airavata.credential.store.datamodel;
+
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all") public class SSHCredential implements org.apache.thrift.TBase<SSHCredential, SSHCredential._Fields>, java.io.Serializable, Cloneable, Comparable<SSHCredential> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SSHCredential");
+
+ private static final org.apache.thrift.protocol.TField GATEWAY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("gatewayId", org.apache.thrift.protocol.TType.STRING, (short)1);
+ private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2);
+ private static final org.apache.thrift.protocol.TField PASSPHRASE_FIELD_DESC = new org.apache.thrift.protocol.TField("passphrase", org.apache.thrift.protocol.TType.STRING, (short)3);
+ private static final org.apache.thrift.protocol.TField PUBLIC_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("publicKey", org.apache.thrift.protocol.TType.STRING, (short)4);
+ private static final org.apache.thrift.protocol.TField PRIVATE_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("privateKey", org.apache.thrift.protocol.TType.STRING, (short)5);
+ private static final org.apache.thrift.protocol.TField PERSISTED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("persistedTime", org.apache.thrift.protocol.TType.I64, (short)6);
+ private static final org.apache.thrift.protocol.TField TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("token", org.apache.thrift.protocol.TType.STRING, (short)7);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new SSHCredentialStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new SSHCredentialTupleSchemeFactory());
+ }
+
+ public String gatewayId; // required
+ public String username; // required
+ public String passphrase; // required
+ public String publicKey; // optional
+ public String privateKey; // optional
+ public long persistedTime; // optional
+ public String token; // optional
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ GATEWAY_ID((short)1, "gatewayId"),
+ USERNAME((short)2, "username"),
+ PASSPHRASE((short)3, "passphrase"),
+ PUBLIC_KEY((short)4, "publicKey"),
+ PRIVATE_KEY((short)5, "privateKey"),
+ PERSISTED_TIME((short)6, "persistedTime"),
+ TOKEN((short)7, "token");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // GATEWAY_ID
+ return GATEWAY_ID;
+ case 2: // USERNAME
+ return USERNAME;
+ case 3: // PASSPHRASE
+ return PASSPHRASE;
+ case 4: // PUBLIC_KEY
+ return PUBLIC_KEY;
+ case 5: // PRIVATE_KEY
+ return PRIVATE_KEY;
+ case 6: // PERSISTED_TIME
+ return PERSISTED_TIME;
+ case 7: // TOKEN
+ return TOKEN;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ private static final int __PERSISTEDTIME_ISSET_ID = 0;
+ private byte __isset_bitfield = 0;
+ private _Fields optionals[] = {_Fields.PUBLIC_KEY,_Fields.PRIVATE_KEY,_Fields.PERSISTED_TIME,_Fields.TOKEN};
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.GATEWAY_ID, new org.apache.thrift.meta_data.FieldMetaData("gatewayId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.USERNAME, new org.apache.thrift.meta_data.FieldMetaData("username", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.PASSPHRASE, new org.apache.thrift.meta_data.FieldMetaData("passphrase", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.PUBLIC_KEY, new org.apache.thrift.meta_data.FieldMetaData("publicKey", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.PRIVATE_KEY, new org.apache.thrift.meta_data.FieldMetaData("privateKey", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ tmpMap.put(_Fields.PERSISTED_TIME, new org.apache.thrift.meta_data.FieldMetaData("persistedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+ tmpMap.put(_Fields.TOKEN, new org.apache.thrift.meta_data.FieldMetaData("token", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SSHCredential.class, metaDataMap);
+ }
+
+ public SSHCredential() {
+ }
+
+ public SSHCredential(
+ String gatewayId,
+ String username,
+ String passphrase)
+ {
+ this();
+ this.gatewayId = gatewayId;
+ this.username = username;
+ this.passphrase = passphrase;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public SSHCredential(SSHCredential other) {
+ __isset_bitfield = other.__isset_bitfield;
+ if (other.isSetGatewayId()) {
+ this.gatewayId = other.gatewayId;
+ }
+ if (other.isSetUsername()) {
+ this.username = other.username;
+ }
+ if (other.isSetPassphrase()) {
+ this.passphrase = other.passphrase;
+ }
+ if (other.isSetPublicKey()) {
+ this.publicKey = other.publicKey;
+ }
+ if (other.isSetPrivateKey()) {
+ this.privateKey = other.privateKey;
+ }
+ this.persistedTime = other.persistedTime;
+ if (other.isSetToken()) {
+ this.token = other.token;
+ }
+ }
+
+ public SSHCredential deepCopy() {
+ return new SSHCredential(this);
+ }
+
+ @Override
+ public void clear() {
+ this.gatewayId = null;
+ this.username = null;
+ this.passphrase = null;
+ this.publicKey = null;
+ this.privateKey = null;
+ setPersistedTimeIsSet(false);
+ this.persistedTime = 0;
+ this.token = null;
+ }
+
+ public String getGatewayId() {
+ return this.gatewayId;
+ }
+
+ public SSHCredential setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ return this;
+ }
+
+ public void unsetGatewayId() {
+ this.gatewayId = null;
+ }
+
+ /** Returns true if field gatewayId is set (has been assigned a value) and false otherwise */
+ public boolean isSetGatewayId() {
+ return this.gatewayId != null;
+ }
+
+ public void setGatewayIdIsSet(boolean value) {
+ if (!value) {
+ this.gatewayId = null;
+ }
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public SSHCredential setUsername(String username) {
+ this.username = username;
+ return this;
+ }
+
+ public void unsetUsername() {
+ this.username = null;
+ }
+
+ /** Returns true if field username is set (has been assigned a value) and false otherwise */
+ public boolean isSetUsername() {
+ return this.username != null;
+ }
+
+ public void setUsernameIsSet(boolean value) {
+ if (!value) {
+ this.username = null;
+ }
+ }
+
+ public String getPassphrase() {
+ return this.passphrase;
+ }
+
+ public SSHCredential setPassphrase(String passphrase) {
+ this.passphrase = passphrase;
+ return this;
+ }
+
+ public void unsetPassphrase() {
+ this.passphrase = null;
+ }
+
+ /** Returns true if field passphrase is set (has been assigned a value) and false otherwise */
+ public boolean isSetPassphrase() {
+ return this.passphrase != null;
+ }
+
+ public void setPassphraseIsSet(boolean value) {
+ if (!value) {
+ this.passphrase = null;
+ }
+ }
+
+ public String getPublicKey() {
+ return this.publicKey;
+ }
+
+ public SSHCredential setPublicKey(String publicKey) {
+ this.publicKey = publicKey;
+ return this;
+ }
+
+ public void unsetPublicKey() {
+ this.publicKey = null;
+ }
+
+ /** Returns true if field publicKey is set (has been assigned a value) and false otherwise */
+ public boolean isSetPublicKey() {
+ return this.publicKey != null;
+ }
+
+ public void setPublicKeyIsSet(boolean value) {
+ if (!value) {
+ this.publicKey = null;
+ }
+ }
+
+ public String getPrivateKey() {
+ return this.privateKey;
+ }
+
+ public SSHCredential setPrivateKey(String privateKey) {
+ this.privateKey = privateKey;
+ return this;
+ }
+
+ public void unsetPrivateKey() {
+ this.privateKey = null;
+ }
+
+ /** Returns true if field privateKey is set (has been assigned a value) and false otherwise */
+ public boolean isSetPrivateKey() {
+ return this.privateKey != null;
+ }
+
+ public void setPrivateKeyIsSet(boolean value) {
+ if (!value) {
+ this.privateKey = null;
+ }
+ }
+
+ public long getPersistedTime() {
+ return this.persistedTime;
+ }
+
+ public SSHCredential setPersistedTime(long persistedTime) {
+ this.persistedTime = persistedTime;
+ setPersistedTimeIsSet(true);
+ return this;
+ }
+
+ public void unsetPersistedTime() {
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PERSISTEDTIME_ISSET_ID);
+ }
+
+ /** Returns true if field persistedTime is set (has been assigned a value) and false otherwise */
+ public boolean isSetPersistedTime() {
+ return EncodingUtils.testBit(__isset_bitfield, __PERSISTEDTIME_ISSET_ID);
+ }
+
+ public void setPersistedTimeIsSet(boolean value) {
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PERSISTEDTIME_ISSET_ID, value);
+ }
+
+ public String getToken() {
+ return this.token;
+ }
+
+ public SSHCredential setToken(String token) {
+ this.token = token;
+ return this;
+ }
+
+ public void unsetToken() {
+ this.token = null;
+ }
+
+ /** Returns true if field token is set (has been assigned a value) and false otherwise */
+ public boolean isSetToken() {
+ return this.token != null;
+ }
+
+ public void setTokenIsSet(boolean value) {
+ if (!value) {
+ this.token = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case GATEWAY_ID:
+ if (value == null) {
+ unsetGatewayId();
+ } else {
+ setGatewayId((String)value);
+ }
+ break;
+
+ case USERNAME:
+ if (value == null) {
+ unsetUsername();
+ } else {
+ setUsername((String)value);
+ }
+ break;
+
+ case PASSPHRASE:
+ if (value == null) {
+ unsetPassphrase();
+ } else {
+ setPassphrase((String)value);
+ }
+ break;
+
+ case PUBLIC_KEY:
+ if (value == null) {
+ unsetPublicKey();
+ } else {
+ setPublicKey((String)value);
+ }
+ break;
+
+ case PRIVATE_KEY:
+ if (value == null) {
+ unsetPrivateKey();
+ } else {
+ setPrivateKey((String)value);
+ }
+ break;
+
+ case PERSISTED_TIME:
+ if (value == null) {
+ unsetPersistedTime();
+ } else {
+ setPersistedTime((Long)value);
+ }
+ break;
+
+ case TOKEN:
+ if (value == null) {
+ unsetToken();
+ } else {
+ setToken((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case GATEWAY_ID:
+ return getGatewayId();
+
+ case USERNAME:
+ return getUsername();
+
+ case PASSPHRASE:
+ return getPassphrase();
+
+ case PUBLIC_KEY:
+ return getPublicKey();
+
+ case PRIVATE_KEY:
+ return getPrivateKey();
+
+ case PERSISTED_TIME:
+ return Long.valueOf(getPersistedTime());
+
+ case TOKEN:
+ return getToken();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case GATEWAY_ID:
+ return isSetGatewayId();
+ case USERNAME:
+ return isSetUsername();
+ case PASSPHRASE:
+ return isSetPassphrase();
+ case PUBLIC_KEY:
+ return isSetPublicKey();
+ case PRIVATE_KEY:
+ return isSetPrivateKey();
+ case PERSISTED_TIME:
+ return isSetPersistedTime();
+ case TOKEN:
+ return isSetToken();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof SSHCredential)
+ return this.equals((SSHCredential)that);
+ return false;
+ }
+
+ public boolean equals(SSHCredential that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_gatewayId = true && this.isSetGatewayId();
+ boolean that_present_gatewayId = true && that.isSetGatewayId();
+ if (this_present_gatewayId || that_present_gatewayId) {
+ if (!(this_present_gatewayId && that_present_gatewayId))
+ return false;
+ if (!this.gatewayId.equals(that.gatewayId))
+ return false;
+ }
+
+ boolean this_present_username = true && this.isSetUsername();
+ boolean that_present_username = true && that.isSetUsername();
+ if (this_present_username || that_present_username) {
+ if (!(this_present_username && that_present_username))
+ return false;
+ if (!this.username.equals(that.username))
+ return false;
+ }
+
+ boolean this_present_passphrase = true && this.isSetPassphrase();
+ boolean that_present_passphrase = true && that.isSetPassphrase();
+ if (this_present_passphrase || that_present_passphrase) {
+ if (!(this_present_passphrase && that_present_passphrase))
+ return false;
+ if (!this.passphrase.equals(that.passphrase))
+ return false;
+ }
+
+ boolean this_present_publicKey = true && this.isSetPublicKey();
+ boolean that_present_publicKey = true && that.isSetPublicKey();
+ if (this_present_publicKey || that_present_publicKey) {
+ if (!(this_present_publicKey && that_present_publicKey))
+ return false;
+ if (!this.publicKey.equals(that.publicKey))
+ return false;
+ }
+
+ boolean this_present_privateKey = true && this.isSetPrivateKey();
+ boolean that_present_privateKey = true && that.isSetPrivateKey();
+ if (this_present_privateKey || that_present_privateKey) {
+ if (!(this_present_privateKey && that_present_privateKey))
+ return false;
+ if (!this.privateKey.equals(that.privateKey))
+ return false;
+ }
+
+ boolean this_present_persistedTime = true && this.isSetPersistedTime();
+ boolean that_present_persistedTime = true && that.isSetPersistedTime();
+ if (this_present_persistedTime || that_present_persistedTime) {
+ if (!(this_present_persistedTime && that_present_persistedTime))
+ return false;
+ if (this.persistedTime != that.persistedTime)
+ return false;
+ }
+
+ boolean this_present_token = true && this.isSetToken();
+ boolean that_present_token = true && that.isSetToken();
+ if (this_present_token || that_present_token) {
+ if (!(this_present_token && that_present_token))
+ return false;
+ if (!this.token.equals(that.token))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(SSHCredential other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetGatewayId()).compareTo(other.isSetGatewayId());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetGatewayId()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.gatewayId, other.gatewayId);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetUsername()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.username, other.username);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetPassphrase()).compareTo(other.isSetPassphrase());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetPassphrase()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.passphrase, other.passphrase);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetPublicKey()).compareTo(other.isSetPublicKey());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetPublicKey()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.publicKey, other.publicKey);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetPrivateKey()).compareTo(other.isSetPrivateKey());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetPrivateKey()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.privateKey, other.privateKey);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetPersistedTime()).compareTo(other.isSetPersistedTime());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetPersistedTime()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.persistedTime, other.persistedTime);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetToken()).compareTo(other.isSetToken());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetToken()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.token, other.token);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("SSHCredential(");
+ boolean first = true;
+
+ sb.append("gatewayId:");
+ if (this.gatewayId == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.gatewayId);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("username:");
+ if (this.username == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.username);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("passphrase:");
+ if (this.passphrase == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.passphrase);
+ }
+ first = false;
+ if (isSetPublicKey()) {
+ if (!first) sb.append(", ");
+ sb.append("publicKey:");
+ if (this.publicKey == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.publicKey);
+ }
+ first = false;
+ }
+ if (isSetPrivateKey()) {
+ if (!first) sb.append(", ");
+ sb.append("privateKey:");
+ if (this.privateKey == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.privateKey);
+ }
+ first = false;
+ }
+ if (isSetPersistedTime()) {
+ if (!first) sb.append(", ");
+ sb.append("persistedTime:");
+ sb.append(this.persistedTime);
+ first = false;
+ }
+ if (isSetToken()) {
+ if (!first) sb.append(", ");
+ sb.append("token:");
+ if (this.token == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.token);
+ }
+ first = false;
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ if (gatewayId == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' was not present! Struct: " + toString());
+ }
+ if (username == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' was not present! Struct: " + toString());
+ }
+ if (passphrase == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'passphrase' was not present! Struct: " + toString());
+ }
+ // check for sub-struct validity
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+ __isset_bitfield = 0;
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class SSHCredentialStandardSchemeFactory implements SchemeFactory {
+ public SSHCredentialStandardScheme getScheme() {
+ return new SSHCredentialStandardScheme();
+ }
+ }
+
+ private static class SSHCredentialStandardScheme extends StandardScheme<SSHCredential> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, SSHCredential struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // GATEWAY_ID
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.gatewayId = iprot.readString();
+ struct.setGatewayIdIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 2: // USERNAME
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.username = iprot.readString();
+ struct.setUsernameIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 3: // PASSPHRASE
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.passphrase = iprot.readString();
+ struct.setPassphraseIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 4: // PUBLIC_KEY
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.publicKey = iprot.readString();
+ struct.setPublicKeyIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 5: // PRIVATE_KEY
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.privateKey = iprot.readString();
+ struct.setPrivateKeyIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 6: // PERSISTED_TIME
+ if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+ struct.persistedTime = iprot.readI64();
+ struct.setPersistedTimeIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 7: // TOKEN
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.token = iprot.readString();
+ struct.setTokenIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, SSHCredential struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.gatewayId != null) {
+ oprot.writeFieldBegin(GATEWAY_ID_FIELD_DESC);
+ oprot.writeString(struct.gatewayId);
+ oprot.writeFieldEnd();
+ }
+ if (struct.username != null) {
+ oprot.writeFieldBegin(USERNAME_FIELD_DESC);
+ oprot.writeString(struct.username);
+ oprot.writeFieldEnd();
+ }
+ if (struct.passphrase != null) {
+ oprot.writeFieldBegin(PASSPHRASE_FIELD_DESC);
+ oprot.writeString(struct.passphrase);
+ oprot.writeFieldEnd();
+ }
+ if (struct.publicKey != null) {
+ if (struct.isSetPublicKey()) {
+ oprot.writeFieldBegin(PUBLIC_KEY_FIELD_DESC);
+ oprot.writeString(struct.publicKey);
+ oprot.writeFieldEnd();
+ }
+ }
+ if (struct.privateKey != null) {
+ if (struct.isSetPrivateKey()) {
+ oprot.writeFieldBegin(PRIVATE_KEY_FIELD_DESC);
+ oprot.writeString(struct.privateKey);
+ oprot.writeFieldEnd();
+ }
+ }
+ if (struct.isSetPersistedTime()) {
+ oprot.writeFieldBegin(PERSISTED_TIME_FIELD_DESC);
+ oprot.writeI64(struct.persistedTime);
+ oprot.writeFieldEnd();
+ }
+ if (struct.token != null) {
+ if (struct.isSetToken()) {
+ oprot.writeFieldBegin(TOKEN_FIELD_DESC);
+ oprot.writeString(struct.token);
+ oprot.writeFieldEnd();
+ }
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class SSHCredentialTupleSchemeFactory implements SchemeFactory {
+ public SSHCredentialTupleScheme getScheme() {
+ return new SSHCredentialTupleScheme();
+ }
+ }
+
+ private static class SSHCredentialTupleScheme extends TupleScheme<SSHCredential> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, SSHCredential struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ oprot.writeString(struct.gatewayId);
+ oprot.writeString(struct.username);
+ oprot.writeString(struct.passphrase);
+ BitSet optionals = new BitSet();
+ if (struct.isSetPublicKey()) {
+ optionals.set(0);
+ }
+ if (struct.isSetPrivateKey()) {
+ optionals.set(1);
+ }
+ if (struct.isSetPersistedTime()) {
+ optionals.set(2);
+ }
+ if (struct.isSetToken()) {
+ optionals.set(3);
+ }
+ oprot.writeBitSet(optionals, 4);
+ if (struct.isSetPublicKey()) {
+ oprot.writeString(struct.publicKey);
+ }
+ if (struct.isSetPrivateKey()) {
+ oprot.writeString(struct.privateKey);
+ }
+ if (struct.isSetPersistedTime()) {
+ oprot.writeI64(struct.persistedTime);
+ }
+ if (struct.isSetToken()) {
+ oprot.writeString(struct.token);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, SSHCredential struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ struct.gatewayId = iprot.readString();
+ struct.setGatewayIdIsSet(true);
+ struct.username = iprot.readString();
+ struct.setUsernameIsSet(true);
+ struct.passphrase = iprot.readString();
+ struct.setPassphraseIsSet(true);
+ BitSet incoming = iprot.readBitSet(4);
+ if (incoming.get(0)) {
+ struct.publicKey = iprot.readString();
+ struct.setPublicKeyIsSet(true);
+ }
+ if (incoming.get(1)) {
+ struct.privateKey = iprot.readString();
+ struct.setPrivateKeyIsSet(true);
+ }
+ if (incoming.get(2)) {
+ struct.persistedTime = iprot.readI64();
+ struct.setPersistedTimeIsSet(true);
+ }
+ if (incoming.get(3)) {
+ struct.token = iprot.readString();
+ struct.setTokenIsSet(true);
+ }
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/58c58cf2/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/credentialStoreDataModelConstants.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/credentialStoreDataModelConstants.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/credentialStoreDataModelConstants.java
new file mode 100644
index 0000000..975210d
--- /dev/null
+++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/credentialStoreDataModelConstants.java
@@ -0,0 +1,55 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.airavata.credential.store.datamodel;
+
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all") public class credentialStoreDataModelConstants {
+
+ public static final String DEFAULT_ID = "DO_NOT_SET_AT_CLIENTS";
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/58c58cf2/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java
new file mode 100644
index 0000000..7be01da
--- /dev/null
+++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java
@@ -0,0 +1,397 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Autogenerated by Thrift Compiler (0.9.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.airavata.credential.store.exception;
+
+import org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("all") public class CredentialStoreException extends TException implements org.apache.thrift.TBase<CredentialStoreException, CredentialStoreException._Fields>, java.io.Serializable, Cloneable, Comparable<CredentialStoreException> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CredentialStoreException");
+
+ private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new CredentialStoreExceptionStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new CredentialStoreExceptionTupleSchemeFactory());
+ }
+
+ public String message; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ MESSAGE((short)1, "message");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // MESSAGE
+ return MESSAGE;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CredentialStoreException.class, metaDataMap);
+ }
+
+ public CredentialStoreException() {
+ }
+
+ public CredentialStoreException(
+ String message)
+ {
+ this();
+ this.message = message;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public CredentialStoreException(CredentialStoreException other) {
+ if (other.isSetMessage()) {
+ this.message = other.message;
+ }
+ }
+
+ public CredentialStoreException deepCopy() {
+ return new CredentialStoreException(this);
+ }
+
+ @Override
+ public void clear() {
+ this.message = null;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public CredentialStoreException setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public void unsetMessage() {
+ this.message = null;
+ }
+
+ /** Returns true if field message is set (has been assigned a value) and false otherwise */
+ public boolean isSetMessage() {
+ return this.message != null;
+ }
+
+ public void setMessageIsSet(boolean value) {
+ if (!value) {
+ this.message = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case MESSAGE:
+ if (value == null) {
+ unsetMessage();
+ } else {
+ setMessage((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case MESSAGE:
+ return getMessage();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case MESSAGE:
+ return isSetMessage();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof CredentialStoreException)
+ return this.equals((CredentialStoreException)that);
+ return false;
+ }
+
+ public boolean equals(CredentialStoreException that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_message = true && this.isSetMessage();
+ boolean that_present_message = true && that.isSetMessage();
+ if (this_present_message || that_present_message) {
+ if (!(this_present_message && that_present_message))
+ return false;
+ if (!this.message.equals(that.message))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(CredentialStoreException other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetMessage()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("CredentialStoreException(");
+ boolean first = true;
+
+ sb.append("message:");
+ if (this.message == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.message);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ if (message == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' was not present! Struct: " + toString());
+ }
+ // check for sub-struct validity
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class CredentialStoreExceptionStandardSchemeFactory implements SchemeFactory {
+ public CredentialStoreExceptionStandardScheme getScheme() {
+ return new CredentialStoreExceptionStandardScheme();
+ }
+ }
+
+ private static class CredentialStoreExceptionStandardScheme extends StandardScheme<CredentialStoreException> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, CredentialStoreException struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // MESSAGE
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.message = iprot.readString();
+ struct.setMessageIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, CredentialStoreException struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.message != null) {
+ oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+ oprot.writeString(struct.message);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class CredentialStoreExceptionTupleSchemeFactory implements SchemeFactory {
+ public CredentialStoreExceptionTupleScheme getScheme() {
+ return new CredentialStoreExceptionTupleScheme();
+ }
+ }
+
+ private static class CredentialStoreExceptionTupleScheme extends TupleScheme<CredentialStoreException> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, CredentialStoreException struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ oprot.writeString(struct.message);
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, CredentialStoreException struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ struct.message = iprot.readString();
+ struct.setMessageIsSet(true);
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/58c58cf2/modules/credential-store/credential-store-webapp/pom.xml
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-webapp/pom.xml b/modules/credential-store/credential-store-webapp/pom.xml
new file mode 100644
index 0000000..e326fe8
--- /dev/null
+++ b/modules/credential-store/credential-store-webapp/pom.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor
+ license agreements. See the NOTICE file distributed with this work for additional
+ information regarding copyright ownership. The ASF licenses this file to
+ you under the Apache License, Version 2.0 (theà "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of
+ the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY ~ KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>credential-store</artifactId>
+ <version>0.15-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>airavata-credential-store-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>airavata-credential-store-webapp</name>
+ <build>
+ <finalName>credential-store</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>${cargo.version}</version>
+ <configuration>
+ <wait>true</wait>
+ <configuration>
+ <properties>
+ <cargo.servlet.port>8443</cargo.servlet.port>
+ <cargo.protocol>https</cargo.protocol>
+ <cargo.tomcat.connector.clientAuth>false</cargo.tomcat.connector.clientAuth>
+ <cargo.tomcat.connector.sslProtocol>TLS</cargo.tomcat.connector.sslProtocol>
+ <cargo.tomcat.connector.keystoreFile>/Users/chathuri/dev/airavata/credential-store/oa4mp/airavata_sym.jks</cargo.tomcat.connector.keystoreFile>
+ <cargo.tomcat.connector.keystorePass>airavata</cargo.tomcat.connector.keystorePass>
+ <cargo.tomcat.ajp.port>9009</cargo.tomcat.ajp.port>
+ <cargo.rmi.port>9099</cargo.rmi.port>
+ <cargo.jvmargs>
+ <![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend} -noverify ${javaagent}]]>
+ </cargo.jvmargs>
+ <cargo.tomcat.context.reloadable>true</cargo.tomcat.context.reloadable>
+ </properties>
+ <home>${project.build.directory}/tomcat6x</home>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-credential-store-webapp</artifactId>
+ <type>war</type>
+ <properties>
+ <context>/acs</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ <container>
+ <containerId>tomcat6x</containerId>
+ <timeout>180000</timeout>
+ <zipUrlInstaller>
+ <url>
+ http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.tar.gz
+ </url>
+ </zipUrlInstaller>
+ <systemProperties>
+
+ </systemProperties>
+ </container>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbyclient</artifactId>
+ <version>${derby.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-credential-store</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.oauth.core</groupId>
+ <artifactId>oauth-httpclient4</artifactId>
+ <version>20090617</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-security</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-common-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.6</version>
+ </dependency>
+ <!-- <dependency>
+ <groupId>edu.uiuc.ncsa.myproxy</groupId>
+ <artifactId>oa4mp-client-oauth1</artifactId>
+ <version>${oa4mp.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency> -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${org.slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${org.slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${org.slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${org.slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ebaysf.web</groupId>
+ <artifactId>cors-filter</artifactId>
+ <version>${ebay.cors.filter}</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <cargo.version>1.2.1</cargo.version>
+ <cargo.debug.address>8000</cargo.debug.address>
+ <cargo.debug.suspend>y</cargo.debug.suspend>
+ <javaagent />
+ </properties>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/58c58cf2/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/basic/BasicAccessAuthenticator.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/basic/BasicAccessAuthenticator.java b/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/basic/BasicAccessAuthenticator.java
new file mode 100644
index 0000000..c34cb1b
--- /dev/null
+++ b/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/basic/BasicAccessAuthenticator.java
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.credentialstore.basic;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.Constants;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.credentialstore.session.ServletRequestHelper;
+import org.apache.airavata.security.AbstractAuthenticator;
+import org.apache.airavata.security.AuthenticationException;
+import org.apache.airavata.security.UserStoreException;
+import org.w3c.dom.Node;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * This authenticator handles basic access authentication requests. In basic access authentication
+ * we get user name and password as HTTP headers. The password is encoded with base64.
+ * More information @link{http://en.wikipedia.org/wiki/Basic_access_authentication}
+ */
+public class BasicAccessAuthenticator extends AbstractAuthenticator {
+
+
+ private static final String AUTHENTICATOR_NAME = "BasicAccessAuthenticator";
+
+ private ServletRequestHelper servletRequestHelper = new ServletRequestHelper();
+
+ public BasicAccessAuthenticator() {
+ super(AUTHENTICATOR_NAME);
+ }
+
+
+ /**
+ * Returns user name and password as an array. The first element is user name and second is password.
+ *
+ * @param httpServletRequest The servlet request.
+ * @return User name password pair as an array.
+ * @throws AuthenticationException If an error occurred while extracting user name and password.
+ */
+ private String[] getUserNamePassword(HttpServletRequest httpServletRequest) throws AuthenticationException {
+
+ String basicHeader = httpServletRequest.getHeader(ServletRequestHelper.AUTHORISATION_HEADER_NAME);
+
+ if (basicHeader == null) {
+ throw new AuthenticationException("Authorization Required");
+ }
+
+ String[] userNamePasswordArray = basicHeader.split(" ");
+
+ if (userNamePasswordArray == null || userNamePasswordArray.length != 2) {
+ throw new AuthenticationException("Authorization Required");
+ }
+
+ String decodedString = servletRequestHelper.decode(userNamePasswordArray[1]);
+
+ String[] array = decodedString.split(":");
+
+ if (array == null || array.length != 2) {
+ throw new AuthenticationException("Authorization Required");
+ }
+
+ return array;
+
+ }
+
+ @Override
+ protected boolean doAuthentication(Object credentials) throws AuthenticationException {
+ if (this.getUserStore() == null) {
+ throw new AuthenticationException("Authenticator is not initialized. Error processing request.");
+ }
+
+ if (credentials == null)
+ return false;
+
+ HttpServletRequest httpServletRequest = (HttpServletRequest) credentials;
+
+ String[] array = getUserNamePassword(httpServletRequest);
+
+ String userName = array[0];
+ String password = array[1];
+
+ try {
+ return this.getUserStore().authenticate(userName, password);
+
+ } catch (UserStoreException e) {
+ throw new AuthenticationException("Error querying database for session information.", e);
+ }
+ }
+
+
+
+ @Override
+ public void onSuccessfulAuthentication(Object authenticationInfo) {
+
+ HttpServletRequest httpServletRequest = (HttpServletRequest) authenticationInfo;
+
+ try {
+ String[] array = getUserNamePassword(httpServletRequest);
+
+ StringBuilder stringBuilder = new StringBuilder("User : ");
+
+ if (array != null) {
+
+ servletRequestHelper.addUserToSession(array[0], httpServletRequest);
+
+ stringBuilder.append(array[0]).append(" successfully logged into system at ").append(getCurrentTime());
+ log.debug(stringBuilder.toString());
+
+ } else {
+ log.error("System error occurred while extracting user name after authentication. " +
+ "Couldn't extract user name from the request.");
+ }
+ } catch (AuthenticationException e) {
+ log.error("System error occurred while extracting user name after authentication.", e);
+ }
+
+ }
+
+ @Override
+ public void onFailedAuthentication(Object authenticationInfo) {
+
+ HttpServletRequest httpServletRequest = (HttpServletRequest) authenticationInfo;
+
+ try {
+ String[] array = getUserNamePassword(httpServletRequest);
+
+ StringBuilder stringBuilder = new StringBuilder("User : ");
+
+ if (array != null) {
+
+ stringBuilder.append(array[0]).append(" Failed login attempt to system at ").append(getCurrentTime());
+ log.warn(stringBuilder.toString());
+
+ } else {
+ stringBuilder.append("Failed login attempt to system at ").append(getCurrentTime()).append( ". User unknown.");
+ log.warn(stringBuilder.toString());
+ }
+ } catch (AuthenticationException e) {
+ log.error("System error occurred while extracting user name after authentication.", e);
+ }
+ }
+
+ @Override
+ public boolean isAuthenticated(Object credentials) {
+ HttpServletRequest httpServletRequest = (HttpServletRequest) credentials;
+
+ HttpSession httpSession = httpServletRequest.getSession();
+
+ boolean seenInSession = false;
+
+ if (httpSession != null) {
+ String user = null;
+ String gateway = null;
+ try{
+ user = (String)httpSession.getAttribute(Constants.USER_IN_SESSION);
+ gateway = (String)httpSession.getAttribute(ServerSettings.getDefaultUserGateway());
+ }
+ catch (ApplicationSettingsException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ if (user != null && gateway != null) {
+ servletRequestHelper.addToContext(user, gateway);
+ seenInSession = true;
+ }
+ }
+
+ return seenInSession;
+
+ }
+
+ @Override
+ public boolean canProcess(Object credentials) {
+
+ HttpServletRequest httpServletRequest = (HttpServletRequest) credentials;
+
+ return (httpServletRequest.getHeader(ServletRequestHelper.AUTHORISATION_HEADER_NAME) != null);
+ }
+
+
+
+ @Override
+ public void configure(Node node) throws RuntimeException {
+
+ /**
+ <specificConfigurations>
+ <database>
+ <jdbcUrl></jdbcUrl>
+ <databaseDriver></databaseDriver>
+ <userName></userName>
+ <password></password>
+ <userTableName></userTableName>
+ <userNameColumnName></userNameColumnName>
+ <passwordColumnName></passwordColumnName>
+ </database>
+ </specificConfigurations>
+ */
+
+ try {
+ this.getUserStore().configure(node);
+ } catch (UserStoreException e) {
+ throw new RuntimeException("Error while configuring authenticator user store", e);
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/58c58cf2/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/local/LocalUserStore.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/local/LocalUserStore.java b/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/local/LocalUserStore.java
new file mode 100644
index 0000000..0a2ca83
--- /dev/null
+++ b/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/local/LocalUserStore.java
@@ -0,0 +1,339 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.credentialstore.local;
+
+import java.security.NoSuchAlgorithmException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+
+import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.common.utils.SecurityUtil;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * User store to maintain internal DB database.
+ */
+public class LocalUserStore {
+
+ protected static Logger log = LoggerFactory.getLogger(LocalUserStore.class);
+
+ private DBUtil dbUtil;
+
+ private String hashMethod;
+
+ public LocalUserStore(ServletContext servletContext) throws Exception {
+ // Properties properties = WebAppUtil.getAiravataProperties(servletContext);
+
+ hashMethod = ServerSettings.getSetting("default.registry.password.hash.method");
+
+ dbUtil = new DBUtil(ServerSettings.getSetting("registry.jdbc.url"),
+ ServerSettings.getSetting("registry.jdbc.user"),
+ ServerSettings.getSetting("registry.jdbc.password"),
+ ServerSettings.getSetting("registry.jdbc.driver"));
+
+ }
+
+ public LocalUserStore(DBUtil db) {
+ dbUtil = db;
+ }
+
+ public void addUser(String userName, String password) {
+
+ String sql = "insert into Users values (?, ?)";
+
+ Connection connection = null;
+ PreparedStatement preparedStatement = null;
+
+ try {
+ connection = dbUtil.getConnection();
+ preparedStatement = connection.prepareStatement(sql);
+
+ preparedStatement.setString(1, userName);
+ preparedStatement.setString(2, SecurityUtil.digestString(password, hashMethod));
+
+ preparedStatement.executeUpdate();
+
+ connection.commit();
+
+ log.debug("User " + userName + " successfully added.");
+
+ } catch (SQLException e) {
+ StringBuilder stringBuilder = new StringBuilder("Error persisting user information.");
+ stringBuilder.append(" user - ").append(userName);
+
+ log.error(stringBuilder.toString(), e);
+
+ throw new RuntimeException(stringBuilder.toString(), e);
+ } catch (NoSuchAlgorithmException e) {
+ String stringBuilder = "Error creating hash value for password.";
+ log.error(stringBuilder, e);
+
+ throw new RuntimeException(stringBuilder, e);
+ } finally {
+
+ dbUtil.cleanup(preparedStatement, connection);
+ }
+
+ }
+
+ protected String getPassword(String userName, Connection connection) {
+
+ String sql = "select password from Users where user_name = ?";
+
+ PreparedStatement preparedStatement = null;
+ ResultSet resultSet = null;
+
+ try {
+ preparedStatement = connection.prepareStatement(sql);
+
+ preparedStatement.setString(1, userName);
+
+ resultSet = preparedStatement.executeQuery();
+
+ if (resultSet.next()) {
+ return resultSet.getString("password");
+ }
+
+ } catch (SQLException e) {
+ StringBuilder stringBuilder = new StringBuilder("Error retrieving credentials for user.");
+ stringBuilder.append("name - ").append(userName);
+
+ log.error(stringBuilder.toString(), e);
+
+ throw new RuntimeException(stringBuilder.toString(), e);
+ } finally {
+
+ if (resultSet != null) {
+ try {
+ resultSet.close();
+ } catch (SQLException e) {
+ log.error("Error closing result set", e);
+ }
+ }
+
+ if (preparedStatement != null) {
+ try {
+ preparedStatement.close();
+ } catch (SQLException e) {
+ log.error("Error closing prepared statement", e);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public void changePassword(String userName, String oldPassword, String newPassword) {
+
+ Connection connection = null;
+ PreparedStatement preparedStatement = null;
+
+ try {
+ connection = dbUtil.getConnection();
+
+ String storedPassword = getPassword(userName, connection);
+
+ String oldDigestedPassword = SecurityUtil.digestString(oldPassword, hashMethod);
+
+ if (storedPassword != null) {
+ if (!storedPassword.equals(oldDigestedPassword)) {
+ throw new RuntimeException("Previous password did not match correctly. Please specify old password"
+ + " correctly.");
+ }
+ }
+
+ String sql = "update Users set password = ? where user_name = ?";
+
+ preparedStatement = connection.prepareStatement(sql);
+
+ preparedStatement.setString(1, SecurityUtil.digestString(newPassword, hashMethod));
+ preparedStatement.setString(2, userName);
+
+ preparedStatement.executeUpdate();
+
+ connection.commit();
+
+ log.debug("Password changed for user " + userName);
+
+ } catch (SQLException e) {
+ StringBuilder stringBuilder = new StringBuilder("Error updating credentials.");
+ stringBuilder.append(" user - ").append(userName);
+
+ log.error(stringBuilder.toString(), e);
+
+ throw new RuntimeException(stringBuilder.toString(), e);
+ } catch (NoSuchAlgorithmException e) {
+ String stringBuilder = "Error creating hash value for password.";
+ log.error(stringBuilder, e);
+
+ throw new RuntimeException(stringBuilder, e);
+ } finally {
+
+ dbUtil.cleanup(preparedStatement, connection);
+ }
+
+ }
+
+ public void changePasswordByAdmin(String userName, String newPassword) {
+
+ Connection connection = null;
+ PreparedStatement preparedStatement = null;
+
+ try {
+ connection = dbUtil.getConnection();
+
+ String sql = "update Users set password = ? where user_name = ?";
+
+ preparedStatement = connection.prepareStatement(sql);
+
+ preparedStatement.setString(1, SecurityUtil.digestString(newPassword, hashMethod));
+ preparedStatement.setString(2, userName);
+
+ preparedStatement.executeUpdate();
+
+ connection.commit();
+
+ log.debug("Admin changed password of user " + userName);
+
+ } catch (SQLException e) {
+ StringBuilder stringBuilder = new StringBuilder("Error updating credentials.");
+ stringBuilder.append(" user - ").append(userName);
+
+ log.error(stringBuilder.toString(), e);
+
+ throw new RuntimeException(stringBuilder.toString(), e);
+ } catch (NoSuchAlgorithmException e) {
+ String stringBuilder = "Error creating hash value for password.";
+ log.error(stringBuilder, e);
+
+ throw new RuntimeException(stringBuilder, e);
+ } finally {
+
+ dbUtil.cleanup(preparedStatement, connection);
+ }
+
+ }
+
+ public void deleteUser(String userName) {
+
+ String sql = "delete from Users where user_name=?";
+
+ Connection connection = null;
+ PreparedStatement preparedStatement = null;
+
+ try {
+ connection = dbUtil.getConnection();
+ preparedStatement = connection.prepareStatement(sql);
+
+ preparedStatement.setString(1, userName);
+
+ preparedStatement.executeUpdate();
+
+ connection.commit();
+
+ log.debug("User " + userName + " deleted.");
+
+ } catch (SQLException e) {
+ StringBuilder stringBuilder = new StringBuilder("Error deleting user.");
+ stringBuilder.append("user - ").append(userName);
+
+ log.error(stringBuilder.toString(), e);
+
+ throw new RuntimeException(stringBuilder.toString(), e);
+ } finally {
+ dbUtil.cleanup(preparedStatement, connection);
+ }
+
+ }
+
+ public List<String> getUsers() {
+
+ List<String> userList = new ArrayList<String>();
+
+ String sql = "select user_name from Users";
+
+ PreparedStatement preparedStatement = null;
+ ResultSet resultSet = null;
+ Connection connection = null;
+
+ try {
+
+ connection = dbUtil.getConnection();
+ preparedStatement = connection.prepareStatement(sql);
+
+ resultSet = preparedStatement.executeQuery();
+
+ while (resultSet.next()) {
+ userList.add(resultSet.getString("user_name"));
+ }
+
+ } catch (SQLException e) {
+ String errorString = "Error retrieving Users.";
+ log.error(errorString, e);
+
+ throw new RuntimeException(errorString, e);
+ } finally {
+
+ if (resultSet != null) {
+ try {
+ resultSet.close();
+ } catch (SQLException e) {
+ log.error("Error closing result set", e);
+ }
+ }
+
+ if (preparedStatement != null) {
+ try {
+ preparedStatement.close();
+ } catch (SQLException e) {
+ log.error("Error closing prepared statement", e);
+ }
+ }
+
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ log.error("Error closing connection", e);
+ }
+ }
+ }
+
+ Collections.sort(userList);
+
+ return userList;
+
+ }
+
+ public static String getPasswordRegularExpression() {
+ return "'^[a-zA-Z0-9_-]{6,15}$'";
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/58c58cf2/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java
----------------------------------------------------------------------
diff --git a/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java b/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java
new file mode 100644
index 0000000..0847d54
--- /dev/null
+++ b/modules/credential-store/credential-store-webapp/src/main/java/org/apache/airavata/credentialstore/session/HttpAuthenticatorFilter.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.credentialstore.session;
+
+import org.apache.airavata.security.AuthenticationException;
+import org.apache.airavata.security.Authenticator;
+import org.apache.airavata.security.configurations.AuthenticatorConfigurationReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * A servlet filter class which intercepts the request and do authentication.
+ */
+public class HttpAuthenticatorFilter implements Filter {
+
+ private List<Authenticator> authenticatorList;
+
+ private static Logger log = LoggerFactory.getLogger(HttpAuthenticatorFilter.class);
+
+ private ServletRequestHelper servletRequestHelper = new ServletRequestHelper();
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ String authenticatorConfiguration = filterConfig.getInitParameter("authenticatorConfigurations");
+
+ //TODO make this able to read from a file as well
+
+
+ InputStream configurationFileStream = HttpAuthenticatorFilter.class.getClassLoader().
+ getResourceAsStream(authenticatorConfiguration);
+
+ if (configurationFileStream == null) {
+ String msg = "Invalid authenticator configuration. Cannot read file - ".concat(authenticatorConfiguration);
+ log.error(msg);
+ throw new ServletException(msg);
+ }
+
+ AuthenticatorConfigurationReader authenticatorConfigurationReader
+ = new AuthenticatorConfigurationReader();
+ try {
+ authenticatorConfigurationReader.init(configurationFileStream);
+ } catch (IOException e) {
+ String msg = "Error reading authenticator configurations.";
+
+ log.error(msg, e);
+ throw new ServletException(msg, e);
+ } catch (ParserConfigurationException e) {
+ String msg = "Error parsing authenticator configurations.";
+
+ log.error(msg, e);
+ throw new ServletException(msg, e);
+ } catch (SAXException e) {
+ String msg = "Error parsing authenticator configurations.";
+
+ log.error(msg, e);
+ throw new ServletException(msg, e);
+ } finally {
+ try {
+ configurationFileStream.close();
+ } catch (IOException e) {
+ log.error("Error closing authenticator file stream.", e);
+ }
+ }
+
+ this.authenticatorList = authenticatorConfigurationReader.getAuthenticatorList();
+
+ if (this.authenticatorList.isEmpty()) {
+ String msg = "No authenticators registered in the system. System cannot function without authenticators";
+ log.error(msg);
+ throw new ServletException(msg);
+ }
+
+ }
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+
+ // Firs check whether authenticators are disabled
+ if (! AuthenticatorConfigurationReader.isAuthenticationEnabled()) {
+
+ // Extract user id and gateway id
+ try {
+ servletRequestHelper.addIdentityInformationToSession((HttpServletRequest) servletRequest);
+ } catch (AuthenticationException e) {
+ log.warn("Error adding identity information to session.", e);
+ populateUnauthorisedData(servletResponse, "Error adding identity information to session.");
+
+ }
+
+ filterChain.doFilter(servletRequest, servletResponse);
+ return;
+ }
+
+ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+
+ Authenticator authenticator = getAuthenticator(httpServletRequest);
+
+ if (authenticator == null) {
+ //sendUnauthorisedError(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+ populateUnauthorisedData(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+ } else {
+ if (authenticator.isAuthenticated(httpServletRequest)) {
+ // Allow request to flow
+ filterChain.doFilter(servletRequest, servletResponse);
+ } else {
+ try {
+ if (!authenticator.authenticate(httpServletRequest)) {
+ //sendUnauthorisedError(servletResponse, "Unauthorised : Provided credentials are not valid.");
+ populateUnauthorisedData(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+ } else {
+ // Allow request to flow
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+ } catch (AuthenticationException e) {
+ String msg = "An error occurred while authenticating request.";
+ log.error(msg, e);
+ //sendUnauthorisedError(servletResponse, e.getMessage());
+ populateUnauthorisedData(servletResponse, "Invalid request. Request does not contain sufficient credentials to authenticate");
+ }
+ }
+ }
+ }
+
+ public static void sendUnauthorisedError(ServletResponse servletResponse, String message) throws IOException {
+ HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
+ httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, message);
+ }
+
+ @Override
+ public void destroy() {
+
+ this.authenticatorList = null;
+ }
+
+ private Authenticator getAuthenticator(HttpServletRequest httpServletRequest) {
+
+ for (Authenticator authenticator : authenticatorList) {
+ if (authenticator.canProcess(httpServletRequest)) {
+ return authenticator;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * This method will create a 401 unauthorized response to be sent.
+ *
+ * @param servletResponse The HTTP response.
+ */
+ public static void populateUnauthorisedData(ServletResponse servletResponse, String message) {
+
+ HttpServletResponse httpServletResponse = (HttpServletResponse)servletResponse;
+
+ httpServletResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ httpServletResponse.addHeader("Server", "Airavata Server");
+ httpServletResponse.addHeader("Description", message);
+ httpServletResponse.addDateHeader("Date", Calendar.getInstance().getTimeInMillis());
+ httpServletResponse.addHeader("WWW-Authenticate", "Basic realm=Airavata");
+ httpServletResponse.setContentType("text/html");
+
+ }
+}