我正试图在Glassfish中使用自定义安全领域(我尝试了3.0.1 final和3.1 B33).我阅读了几乎所有关于此的教程,但它并不适用于我的系统.我收到了错误
Login failed: javax.security.auth.login.LoginException: unable to find LoginModule class: com.company.security.realm.CustomLoginModule
Run Code Online (Sandbox Code Playgroud)
在尝试登录时.
这就是我所做的:我创建了一个小Maven项目,其中包含所需的Realm类CustomRealm和相应的LoginModule,CustomLoginModule.我的pom.xml:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>security.realm</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Custom JDBCRealm</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.glassfish.security</groupId>
<artifactId>security</artifactId>
<version>3.1-b33</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<optimise>true</optimise>
<debug>true</debug>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
我的自定义领域类:
package com.company.security.realm;
import com.sun.appserv.security.AppservRealm;
import com.sun.enterprise.security.auth.realm.BadRealmException;
import com.sun.enterprise.security.auth.realm.InvalidOperationException;
import com.sun.enterprise.security.auth.realm.NoSuchRealmException;
import com.sun.enterprise.security.auth.realm.NoSuchUserException;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;
public class CustomRealm extends AppservRealm
{
Vector<String> groups …Run Code Online (Sandbox Code Playgroud) 所以我编写了一些我被问过的面试问题.我回答了一些问题并记下了我不能解答的答案.有些问题不是C特定的,而且是一般性的.每个人都可以在问题中添加输入.没有义务按照我写的答案!
Q1:2位系统和16位系统上指针的大小是多少?
答:2位和2个字节
Q2:为什么我们在C语言中需要OOP /类,我们可以实现相同的目标?
答:留给SO用户回答!
问题3:如果您被告知将程序划分为嵌入式系统的不同部分,它们会是什么?
答:IO部分和CPU部分
问题4:使用线程有哪些硬件级优势?任何给出单个CPU(单核)的单个示例A:一个线程将进行一些数字运算,另一个只是生活一个毫秒可能发出事件来读取硬盘驱动器.
Q5:如果我们有一个指针char* p = NULL,会cout<<sizeof(*p)打印什么?答:大小char不是char*.这意味着它可以指向的内存量,而不是指针本身的大小
Q6:函数指针指向虚拟表中的哪些函数?答:虚拟功能
问题7:您如何计算程序需要为单个CPU(单核)的最佳性能生成多少个线程?你会进行身体测试还是自动化你的程序?举个例子.或两者,再一个例子.
A:SO用户在这里给你答案!
Q8:如果一个虚函数(不纯)是继承,则不在派生类中实现.现在,如果我有一个指向派生类对象的基类指针,然后进行调用
baseObject->function(),会发生什么?在编译时/运行时间的任何时候都会出现问题吗?答:没有.:)
我不时会遇到奇怪的MySQL行为.假设我有索引(type,rel,created),(type),(rel).像这样的查询的最佳选择:
SELECT id FROM tbl
WHERE rel = 3 AND type = 3
ORDER BY created;
Run Code Online (Sandbox Code Playgroud)
将是使用索引(type, rel, created).但MySQL的决定交叉索引(type)和(rel),并导致更坏更流畅.这是一个例子:
mysql> EXPLAIN
-> SELECT id FROM tbl
-> WHERE rel = 3 AND type = 3
-> ORDER BY created\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: tbl
type: index_merge
possible_keys: idx_type,idx_rel,idx_rel_type_created
key: idx_type,idx_rel
key_len: 1,2
ref: NULL
rows: 4343
Extra: Using intersect(idx_type,idx_rel); Using where; Using filesort
Run Code Online (Sandbox Code Playgroud)
和相同的查询,但添加了一个提示:
mysql> EXPLAIN
-> SELECT id …Run Code Online (Sandbox Code Playgroud) mysql query-optimization sql-execution-plan database-indexes
我使用以下代码检查用户名和密码.我希望在3次无效密码尝试后阻止用户名.我应该在我的代码中添加什么
MD5CryptoServiceProvider md5hasher = new MD5CryptoServiceProvider();
Byte[] hashedDataBytes;
UTF8Encoding encoder = new UTF8Encoding();
hashedDataBytes = md5hasher.ComputeHash(encoder.GetBytes(TextBox3.Text));
StringBuilder hex = new StringBuilder(hashedDataBytes.Length * 2);
foreach (Byte b in hashedDataBytes)
{
hex.AppendFormat("{0:x2}", b);
}
string hash = hex.ToString();
SqlConnection con = new SqlConnection("Data Source=Shihab-PC;Initial Catalog=test;User ID=SOMETHING;Password=SOMETHINGELSE");
SqlDataAdapter ad = new SqlDataAdapter("select password from Users where UserId='" + TextBox4.Text + "'", con);
DataSet ds = new DataSet();
ad.Fill(ds, "Users");
SqlDataAdapter ad2 = new SqlDataAdapter("select UserId from Users ", con);
DataSet ds2 = new …Run Code Online (Sandbox Code Playgroud) 我有一些Java代码,我正在翻译成Scala.
代码由一些不可变的类组成,这些类符合case classScala中的目的.
但我不想引入错误,因此我想确保为当前实现生成的代码equals和hashCode/ 和/的行为等效.
我已经看过"Scala编程",但它只是说
第三,编译器将方法的"自然"实现添加到String,hashCode,并且等于你的类.
我已为长时间运行的进程编写了此示例代码,但Windows窗体冻结直到该过程完成.如何更改代码以使工作并行运行?
var ui = TaskScheduler.FromCurrentSynchronizationContext();
Task t = Task.Factory.StartNew(delegate
{
textBox1.Text = "Enter Thread";
for (int i = 0; i < 20; i++)
{
//My Long Running Work
}
textBox1.Text = textBox1.Text + Environment.NewLine + "After Loop";
}, CancellationToken.None, TaskCreationOptions.None, ui);
Run Code Online (Sandbox Code Playgroud) 在Eclipse中,选择一行并按Alt+ ↑/ ↓将上下移动线,这是避免复制和粘贴的快速方法.Visual Studio中是否有等价物?
如何在Windows Serve 2003启动时禁用登录窗口?
虽然没有密码需要我仍然必须按OK或每次登录时输入.
谢谢.
嗨,我正在尝试使用C语言的Windows API做一个项目.我项目中的一小部分是获取lsass.exe的进程ID.
我试过下面的程序,但它不会工作.我读过有关CreateToolhelp32Snapshot,Process32First,Process32Next函数的任何人都可以帮我解释如何在代码中使用它们.
所以请帮助我.我是Windows API的初学者,所以如果有人能建议我推荐一本好的电子书,我会很感激.