summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca')
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.java30
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java32
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java32
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.java30
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.java80
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java42
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java42
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.java50
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java179
-rw-r--r--tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java66
11 files changed, 0 insertions, 620 deletions
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.java
deleted file mode 100644
index a3f1f11826..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/AService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes;
-
-/**
- * Simple Service
- */
-public interface AService {
-
- public void testMaxAge() throws InterruptedException;
- public void testMaxIdle() throws InterruptedException;
- public void testSinglePrincipal();
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java
deleted file mode 100644
index 7290c31f1a..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/B2Service.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes;
-
-import org.oasisopen.sca.annotation.Conversational;
-
-/**
- * Simple Service
- */
-@Conversational
-public interface B2Service {
-
- public void setState(String someState);
- public String getState();
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java
deleted file mode 100644
index d38ca0276c..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/BService.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes;
-
-import org.oasisopen.sca.annotation.Conversational;
-
-/**
- * Simple Service
- */
-@Conversational
-public interface BService {
-
- public void setState(String someState);
- public String getState();
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.java
deleted file mode 100644
index 5db8768398..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/CService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes;
-
-import org.oasisopen.sca.ServiceReference;
-
-/**
- * Simple Service
- */
-public interface CService {
-
- public void testSinglePricipal(ServiceReference<BService> bReference);
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.java
deleted file mode 100644
index a0a654920d..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/AServiceImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes.impl;
-
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.AService;
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.B2Service;
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService;
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.CService;
-import org.oasisopen.sca.ComponentContext;
-import org.oasisopen.sca.annotation.Context;
-import org.oasisopen.sca.annotation.Reference;
-import org.oasisopen.sca.annotation.Service;
-
-@Service(AService.class)
-public class AServiceImpl implements AService {
-
- @Reference
- protected BService b;
-
- @Reference
- protected B2Service b2;
-
- @Reference
- protected CService c;
-
- @Context
- protected ComponentContext context;
-
- private void delayForSeconds(int numSeconds) {
- try {
- Thread.sleep(numSeconds * 1000);// millisecs
- } catch (InterruptedException ex) {
- throw new Error(ex);
- }
- }
-
- public void testMaxAge() {
-
- String someState = "someState";
- b.setState(someState);
- delayForSeconds(2);
- b.setState(someState);
-
- }
-
- public void testMaxIdle() {
-
- String someState = "someState";
- b2.setState(someState);
- delayForSeconds(2);
- b2.setState(someState);
-
- }
-
- public void testSinglePrincipal() {
-
- b.setState("Some state");
- System.out.println("Calling c and passing reference to b");
- c.testSinglePricipal(context.getServiceReference(BService.class, "b"));
-
- }
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java
deleted file mode 100644
index 2f711be74d..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/B2ServiceImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes.impl;
-
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService;
-import org.oasisopen.sca.annotation.ConversationAttributes;
-import org.oasisopen.sca.annotation.Scope;
-import org.oasisopen.sca.annotation.Service;
-
-@Service(BService.class)
-@Scope("CONVERSATION")
-@ConversationAttributes(maxIdleTime="1 seconds")
-public class B2ServiceImpl implements BService {
-
- String someState;
-
- public void setState(String someState) {
- this.someState = someState;
- }
-
- public String getState() {
- return someState;
- }
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java
deleted file mode 100644
index f9aa1de8bd..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/BServiceImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes.impl;
-
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService;
-import org.oasisopen.sca.annotation.ConversationAttributes;
-import org.oasisopen.sca.annotation.Scope;
-import org.oasisopen.sca.annotation.Service;
-
-@Service(BService.class)
-@Scope("CONVERSATION")
-@ConversationAttributes(maxAge="1 seconds", singlePrincipal=true)
-public class BServiceImpl implements BService {
-
- String someState;
-
- public void setState(String someState) {
- this.someState = someState;
- }
-
- public String getState() {
- return someState;
- }
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.java
deleted file mode 100644
index cc1c0d18fd..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/impl/CServiceImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes.impl;
-
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.BService;
-import org.apache.tuscany.sca.vtest.javaapi.annotations.conversationattributes.CService;
-import org.oasisopen.sca.ServiceReference;
-import org.oasisopen.sca.annotation.Service;
-
-@Service(CService.class)
-public class CServiceImpl implements CService {
-
- public void testSinglePricipal(ServiceReference<BService> bReference) {
-
- System.out.println("In C calling set state on passed reference to B");
- bReference.getService().setState("someState");
-
- }
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.java
deleted file mode 100644
index 3820240ee2..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/ACallbackHandler.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes.security;
-
-import java.io.IOException;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ACallbackHandler implements CallbackHandler {
-
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
- NameCallback nc = (NameCallback)callbacks[i];
- nc.setName("AUser");
- } else if (callbacks[i] instanceof PasswordCallback) {
- PasswordCallback pc = (PasswordCallback)callbacks[i];
- pc.setPassword("AUserPasswd".toCharArray());
- } else {
- throw new UnsupportedCallbackException
- (callbacks[i], "Unsupported Callback!");
- }
- }
- }
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java
deleted file mode 100644
index 75573b838d..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/JaasLoginModule.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes.security;
-
-import java.security.Principal;
-import java.util.Map;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-
-
-/**
- * @version $Rev$ $Date$
- */
-public class JaasLoginModule implements LoginModule {
-
- private CallbackHandler callbackHandler;
- private Subject subject;
- private Principal userPrincipal;
- private String userId;
- private String password;
- private boolean succeeded;
- private boolean commitSucceeded;
-
- public void initialize(Subject subject,
- CallbackHandler callbackHandler,
- Map<String, ?> sharedState,
- Map<String, ?> options) {
- this.callbackHandler = callbackHandler;
- this.subject = subject;
- }
-
- public boolean login() throws LoginException {
- Callback[] callbacks = new Callback[2];
- callbacks[0] = new NameCallback("UserId:");
- callbacks[1] = new PasswordCallback("Password:", false);
-
- try {
- callbackHandler.handle(callbacks);
- userId = ((NameCallback)callbacks[0]).getName();
- password = new String(((PasswordCallback)callbacks[1]).getPassword());
-
- if (userId.equals("CalculatorUser") && password.equals("CalculatorUserPasswd")) {
- System.out.println("Successfully AUTHENTICATED!!");
- succeeded = true;
- return true;
- } else {
- System.out.println("Incorrect userId / password! AUTHENTICATION FAILED!!");
- return false;
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- /**
- * <p> This method is called if the LoginContext's
- * overall authentication succeeded
- * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules
- * succeeded).
- *
- * <p> If this LoginModule's own authentication attempt
- * succeeded (checked by retrieving the private state saved by the
- * <code>login</code> method), then this method associates a
- * <code>UserPrincipal</code>
- * with the <code>Subject</code> located in the
- * <code>LoginModule</code>. If this LoginModule's own
- * authentication attempted failed, then this method removes
- * any state that was originally saved.
- *
- * <p>
- *
- * @exception LoginException if the commit fails.
- *
- * @return true if this LoginModule's own login and commit
- * attempts succeeded, or false otherwise.
- */
- public boolean commit() throws LoginException {
- if (succeeded == false) {
- return false;
- } else {
- // add a Principal (authenticated identity) to the Subject
-
- // assume the user we authenticated is the UserPrincipal
- userPrincipal = new UserPrincipal(userId);
- if (!subject.getPrincipals().contains(userPrincipal))
- subject.getPrincipals().add(userPrincipal);
-
- // in any case, clean out state
- userId = null;
- password = null;
- commitSucceeded = true;
- return true;
- }
- }
-
- /**
- * <p> This method is called if the LoginContext's
- * overall authentication failed.
- * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules
- * did not succeed).
- *
- * <p> If this LoginModule's own authentication attempt
- * succeeded (checked by retrieving the private state saved by the
- * <code>login</code> and <code>commit</code> methods),
- * then this method cleans up any state that was originally saved.
- *
- * <p>
- *
- * @exception LoginException if the abort fails.
- *
- * @return false if this LoginModule's own login and/or commit attempts
- * failed, and true otherwise.
- */
- public boolean abort() throws LoginException {
- if (succeeded == false) {
- return false;
- } else if (succeeded == true && commitSucceeded == false) {
- // login succeeded but overall authentication failed
- succeeded = false;
- userId = null;
- password = null;
- userPrincipal = null;
- } else {
- // overall authentication succeeded and commit succeeded,
- // but someone else's commit failed
- logout();
- }
- return true;
- }
-
- /**
- * Logout the user.
- *
- * <p> This method removes the <code>SimplePrincipal</code>
- * that was added by the <code>commit</code> method.
- *
- * <p>
- *
- * @exception LoginException if the logout fails.
- *
- * @return true in all cases since this <code>LoginModule</code>
- * should not be ignored.
- */
- public boolean logout() throws LoginException {
- subject.getPrincipals().remove(userPrincipal);
- succeeded = false;
- succeeded = commitSucceeded;
- userId = null;
- if (password != null)
- password = null;
- userPrincipal = null;
- return true;
- }
-
-}
diff --git a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java b/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java
deleted file mode 100644
index 8349e775c5..0000000000
--- a/tags/java/sca/2.0-M2/vtest/java-api/annotations/conversationattributes/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/conversationattributes/security/UserPrincipal.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.tuscany.sca.vtest.javaapi.annotations.conversationattributes.security;
-
-import java.security.Principal;
-
-/**
- * @version $Rev$ $Date$
- */
-public class UserPrincipal implements Principal {
-
- private final String name;
-
- public UserPrincipal(String name) {
- if (name == null)
- throw new IllegalArgumentException("name cannot be null");
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String toString() {
- return name;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final UserPrincipal other = (UserPrincipal)obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-}